Skip to content

Commit

Permalink
Fix request context issues (#392)
Browse files Browse the repository at this point in the history
* load config from db, demo project

* fix request context usage

* remove modules temp data

---------
  • Loading branch information
thmarx authored Feb 4, 2025
1 parent 6f165d9 commit d560eaf
Show file tree
Hide file tree
Showing 32 changed files with 52 additions and 61 deletions.
2 changes: 1 addition & 1 deletion cms-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-api</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,39 @@
* @author t.marx
*/
@RequiredArgsConstructor
public class CMSRequestContext extends FeatureContainer implements ModuleRequestContext {
public class CMSRequestContext extends RequestContext implements ModuleRequestContext {

private final RequestContext requestContext;
private final RequestContext delegate;

@Override
public void close() throws Exception {
if (requestContext == null) {
return;
if (delegate != null) {
delegate.close();
}
requestContext.close();
}

@Override
public <T extends Feature> T get(Class<T> featureClass) {
if (requestContext == null) {
if (delegate == null) {
return null;
}
return requestContext.get(featureClass);
return delegate.get(featureClass);
}

@Override
public <T extends Feature> void add(Class<T> featureClass, T feature) {
if (requestContext == null) {
if (delegate == null) {
return;
}
requestContext.add(featureClass, feature);
delegate.add(featureClass, feature);
}

@Override
public boolean has(Class<? extends Feature> featureClass) {
if (requestContext == null) {
if (delegate == null) {
return false;
}
return requestContext.has(featureClass);
return delegate.has(featureClass);
}


Expand Down
2 changes: 1 addition & 1 deletion cms-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-auth</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-content</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public String execute (String name, Map<String, Object> parameters, RequestConte
try {
Parameter params;
if (parameters != null) {
params = new Parameter(parameters);
params = new Parameter(parameters, requestContext);
} else {
params = new Parameter();
params = new Parameter(requestContext);
}
return tagMap.get(name).apply(params);
} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion cms-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-core</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-extensions</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-filesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-filesystem</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-git/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-git</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion cms-media/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-media</artifactId>
<packaging>jar</packaging>
Expand Down
24 changes: 6 additions & 18 deletions cms-server/nbactions-dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<properties>
<exec.vmArgs></exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.appArgs>server start -Dcms.home=../test-server/</exec.appArgs>
<exec.appArgs>server start</exec.appArgs>
<exec.mainClass>com.condation.cms.cli.CMSCli</exec.mainClass>
<exec.executable>java</exec.executable>
<exec.workingdir>C:\entwicklung\workspaces\tma\cms\cms-server\test-server</exec.workingdir>
</properties>
</action>
<action>
Expand All @@ -29,10 +30,11 @@
<properties>
<exec.vmArgs>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.appArgs>server start -Dcms.home=../test-server/</exec.appArgs>
<exec.appArgs>server start</exec.appArgs>
<exec.mainClass>com.condation.cms.cli.CMSCli</exec.mainClass>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
<exec.workingdir>C:\entwicklung\workspaces\tma\cms\cms-server\test-server</exec.workingdir>
</properties>
</action>
<action>
Expand All @@ -49,22 +51,8 @@
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.mainClass>com.condation.cms.cli.CMSCli</exec.mainClass>
<exec.executable>java</exec.executable>
<exec.appArgs>server start -Dcms.home=../test-server/</exec.appArgs>
</properties>
</action>
<action>
<actionName>CUSTOM-Stop project</actionName>
<displayName>Stop project</displayName>
<goals>
<goal>process-classes</goal>
<goal>org.codehaus.mojo:exec-maven-plugin:3.1.0:exec</goal>
</goals>
<properties>
<exec.vmArgs></exec.vmArgs>
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
<exec.appArgs>stop</exec.appArgs>
<exec.mainClass>com.condation.cms.cli.CMSCli</exec.mainClass>
<exec.executable>java</exec.executable>
<exec.appArgs>server start</exec.appArgs>
<exec.workingdir>C:\entwicklung\workspaces\tma\cms\cms-server\test-server</exec.workingdir>
</properties>
</action>
</actions>
2 changes: 1 addition & 1 deletion cms-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-server</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.server.Handler;
Expand Down
2 changes: 1 addition & 1 deletion cms-templates/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>

<artifactId>cms-templates</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* #L%
*/
import com.condation.cms.api.request.RequestContext;
import com.condation.cms.content.shortcodes.ShortCodes;
import com.condation.cms.templates.components.TemplateComponents;
import com.condation.cms.templates.tags.component.EndComponentTag;
import com.condation.cms.templates.tags.component.ComponentTag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

import com.condation.cms.templates.renderer.Renderer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -36,6 +34,7 @@
* @author t.marx
*/
public class ParameterUtil {

public static Map<String, Object> parseAndEvaluate(String input, JexlContext jexlContext, JexlEngine engine) {
Map<String, Object> resultMap = new HashMap<>();

Expand All @@ -48,22 +47,29 @@ public static Map<String, Object> parseAndEvaluate(String input, JexlContext jex
String key = token.substring(0, equalsIndex).trim(); // Schlüssel extrahieren
String value = token.substring(equalsIndex + 1).trim(); // Wert extrahieren

boolean isVariable = true;
// Anführungszeichen entfernen, falls vorhanden
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
isVariable = false;
}

// Wert mit JEXL evaluieren
Object evaluatedValue;
try {
JexlExpression expression = engine.createExpression(value);
evaluatedValue = expression.evaluate(jexlContext);
} catch (Exception e) {
// Falls der Wert keine JEXL-Expression ist, einfach als String speichern
evaluatedValue = value;
if (isVariable) {
// Wert mit JEXL evaluieren
Object evaluatedValue;
try {
JexlExpression expression = engine.createExpression(value);
evaluatedValue = expression.evaluate(jexlContext);
} catch (Exception e) {
// Falls der Wert keine JEXL-Expression ist, einfach als String speichern
evaluatedValue = value;
}

resultMap.put(key, evaluatedValue);
} else {
resultMap.put(key, value);
}

resultMap.put(key, evaluatedValue);
}
}

Expand Down
2 changes: 1 addition & 1 deletion cms-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-test</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion distribution/build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="distribution" default="distribution" basedir=".">
<property name="cms.version">7.6.3</property>
<property name="cms.version">7.6.4</property>

<target name="copy-server" description="--> copy server">
<unzip src="../cms-server/target/cms-server-${cms.version}.zip" dest="temp/" />
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>integration-tests</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules/example-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>example-module</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<groupId>com.condation.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/system-modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.condation.cms.modules</groupId>
<artifactId>cms-modules</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
</parent>
<artifactId>cms-system-modules</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.condation.cms</groupId>
<artifactId>cms-parent</artifactId>
<version>7.6.3</version>
<version>7.6.4</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit d560eaf

Please sign in to comment.