Skip to content
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,61 @@ see wiki for more information: [wiki](https://github.com/thmarx/cms/wiki)
* **MAINTENANCE** multiple dependencies updated
* **MAINTENANCE** maven wrapper added to project

### Developer experience

In this release we introduced some features to make life of developers easier.

#### Registering hooks via annotations

It is now possible to pass an object with annotated hook definitions to the HookSystem.register method.

```java
@Filter("test/annotation/filter1")
public List<String> filter (FilterContext<List<String>> context) {
context.value().remove("2");
return context.value();
}
@Action("test/annotation/action1")
public void action1 (ActionContext<?> context) {
// do something
}
```

#### HTTP-Controllers

The RoutesExtensionPoint is an extension point for defining HTTP routes.
It allows developers to provide a list of objects whose methods can be registered as routes using annotations.

```java
@Route("/test2")
public boolean handle2 (Request request, Response response, Callback callback) {
return true;
}
```

#### ShortCodes

The RegisterShortCodesExtensionPoint interface now includes a new method, shortCodeDefinitions, which returns a list of objects that contain shortcode definitions provided through annotations.

```java
@ShortCode("printHello")
public String printHello (Parameter parameter) {
return "hello " + parameter.getOrDefault("name", "");
}
```

#### TemplateComponents

A new method, componentDefinitions, has been added to the RegisterTemplateComponentExtensionPoint interface. It returns a list of objects that define template components using annotations.

```java
@TemplateComponent("tag3")
public String tag3 (Parameter parameter) {
return "<div>%s</div>".formatted(parameter.get("_content"));
}

```

## 7.8.0

* **BUG** Namespaces not set when executing content pipeline [#416](https://github.com/CondationCMS/cms-server/pull/416)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.condation.cms.api.annotations;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
* @author thorstenmarx
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Action {
String value ();
int priority () default 10;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.condation.cms.api.annotations;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
* @author thorstenmarx
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Filter {
String value ();
int priority () default 10;
}
35 changes: 35 additions & 0 deletions cms-api/src/main/java/com/condation/cms/api/annotations/Route.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.condation.cms.api.annotations;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Route {
String value();
String method() default "GET"; // Optional: GET, POST, PUT, DELETE ...
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.condation.cms.api.annotations;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
* @author thorstenmarx
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface ShortCode {
String value ();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.condation.cms.api.annotations;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
*
* @author thorstenmarx
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface TemplateComponent {
String value ();
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@
*/
public interface HttpHandler {

/**
*
* @param request
* @param response
* @param callback
* @return true if the request is handled by the HttpHandler, otherwise false
* @throws Exception
*/
boolean handle (Request request, Response response, Callback callback) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@


import com.condation.cms.api.model.Parameter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

Expand All @@ -33,5 +35,11 @@
*/
public abstract class RegisterShortCodesExtensionPoint extends AbstractExtensionPoint {

public abstract Map<String, Function<Parameter, String>> shortCodes ();
public Map<String, Function<Parameter, String>> shortCodes () {
return Collections.emptyMap();
}

public List<Object> shortCodeDefinitions () {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@


import com.condation.cms.api.model.Parameter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

Expand All @@ -33,5 +35,11 @@
*/
public abstract class RegisterTemplateComponentExtensionPoint extends AbstractExtensionPoint {

public abstract Map<String, Function<Parameter, String>> components ();
public Map<String, Function<Parameter, String>> components () {
return Collections.emptyMap();
}

public List<Object> componentDefinitions () {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.condation.cms.api.extensions.http.routes;

/*-
* #%L
* cms-api
* %%
* Copyright (C) 2023 - 2025 CondationCMS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import com.condation.cms.api.extensions.AbstractExtensionPoint;
import java.util.List;

/**
*
* @author thorstenmarx
*/
public abstract class RoutesExtensionPoint extends AbstractExtensionPoint {
abstract public List<Object> getRouteDefinitions ();
}
Loading