Skip to content

Commit

Permalink
Support ACS 7.4+ by bridging Log4j versions
Browse files Browse the repository at this point in the history
  • Loading branch information
AFaust committed Oct 20, 2023
1 parent f503719 commit 5c6f598
Show file tree
Hide file tree
Showing 76 changed files with 4,598 additions and 1,258 deletions.
51 changes: 49 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.orderofthebee.support-tools</groupId>
<artifactId>support-tools-parent</artifactId>
<version>1.2.0.0</version>
<version>1.2.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>OOTBee Support Tools - Parent</name>
Expand Down Expand Up @@ -101,9 +101,19 @@
<alfresco.bomDependencyArtifactId>acs-community-packaging</alfresco.bomDependencyArtifactId>
<alfresco.platform.version>6.1.2-ga</alfresco.platform.version>
<alfresco.share.version>6.1.0</alfresco.share.version>

<alfresco.search.version>1.2.0</alfresco.search.version>

<!-- baseline versions -->
<alfresco.slf4j.version>1.7.25</alfresco.slf4j.version>
<alfresco74.log4j2.version>2.19.0</alfresco74.log4j2.version>

<alfresco.docker.platform.version>${alfresco.platform.version}</alfresco.docker.platform.version>
<alfresco.docker.share.version>${alfresco.share.version}</alfresco.docker.share.version>
<docker.acs.image>alfresco/alfresco-content-repository-community</docker.acs.image>
<docker.acs.dockerfile>Dockerfile</docker.acs.dockerfile>
<docker.acs.opts></docker.acs.opts>
<docker.share.image>alfresco/alfresco-share</docker.share.image>
<docker.search.opts></docker.search.opts>

<acs.port>8080</acs.port>
<acs.debug.port>8888</acs.debug.port>
Expand Down Expand Up @@ -201,6 +211,20 @@
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${alfresco.slf4j.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${alfresco74.log4j2.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -655,5 +679,28 @@
</plugins>
</build>
</profile>
<profile>
<id>acs-docker-7.4</id>

<properties>
<alfresco.docker.platform.version>7.4.1</alfresco.docker.platform.version>
<alfresco.docker.share.version>7.4.1</alfresco.docker.share.version>
<docker.acs.dockerfile>DockerfileWithBuildUser</docker.acs.dockerfile>
<docker.acs.opts>-Dencryption.keystore.type=JCEKS -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding -Dencryption.keyAlgorithm=DESede -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore -Dmetadata-keystore.password=mp6yc0UD9e -Dmetadata-keystore.aliases=metadata -Dmetadata-keystore.metadata.password=oKIWzVdEdA -Dmetadata-keystore.metadata.algorithm=DESede -Dsolr.secureComms=secret -Dsolr.sharedSecret=secret -Dalfresco.restApi.basicAuthScheme=true</docker.acs.opts>
<alfresco.search.version>2.0.7</alfresco.search.version>
<docker.search.opts>-Dalfresco.secureComms=secret -Dalfresco.secureComms.secret=secret</docker.search.opts>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.17.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
</project>
24 changes: 22 additions & 2 deletions repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.orderofthebee.support-tools</groupId>
<artifactId>support-tools-parent</artifactId>
<version>1.2.0.0</version>
<version>1.2.1.0-SNAPSHOT</version>
</parent>

<artifactId>support-tools-repo</artifactId>
Expand Down Expand Up @@ -104,7 +104,13 @@
<groupId>net.time4j</groupId>
<artifactId>time4j-i18n</artifactId>
<version>3.50</version>
</dependency>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -184,4 +190,18 @@
</plugins>
</build>

<profiles>
<profile>
<id>acs-docker-7.4</id>

<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.17.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
4 changes: 2 additions & 2 deletions repository/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ${docker.acs.image}:${alfresco.platform.version}
FROM ${docker.acs.image}:${alfresco.docker.platform.version}

ARG TOMCAT_DIR=/usr/local/tomcat

Expand All @@ -11,4 +11,4 @@ RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
$TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force

COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties
COPY dev-log4j.properties $TOMCAT_DIR/shared/classes/alfresco/extension
COPY dev-log4j*.properties $TOMCAT_DIR/shared/classes/alfresco/extension
20 changes: 20 additions & 0 deletions repository/src/main/docker/DockerfileWithBuildUser
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ${docker.acs.image}:${alfresco.docker.platform.version}

ARG TOMCAT_DIR=/usr/local/tomcat
ARG USERNAME=alfresco
ARG GROUPNAME=Alfresco

USER root

# Copy Dockerfile to avoid an error if no JARs exist
COPY Dockerfile extensions/*.jar $TOMCAT_DIR/webapps/alfresco/WEB-INF/lib/

# Copy Dockerfile to avoid an error if no AMPs exist
COPY Dockerfile extensions/*.amp $TOMCAT_DIR/amps/
RUN java -jar $TOMCAT_DIR/alfresco-mmt/alfresco-mmt*.jar install \
$TOMCAT_DIR/amps $TOMCAT_DIR/webapps/alfresco -directory -nobackup -force

COPY alfresco-global.properties $TOMCAT_DIR/shared/classes/alfresco-global.properties
COPY dev-log4j.properties $TOMCAT_DIR/shared/classes/alfresco/extension

USER ${USERNAME}
2 changes: 2 additions & 0 deletions repository/src/main/docker/dev-log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logger.ootbee-support-tools.name=${basePackage}
logger.ootbee-support-tools.level=DEBUG
6 changes: 4 additions & 2 deletions repository/src/main/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ services:
support-tools-repo-acs:
image: alfresco-content-services-support-tools-repo:development
build:
dockerfile: ./Dockerfile
dockerfile: ./${docker.acs.dockerfile}
context: .
environment:
CATALINA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8888"
JAVA_TOOL_OPTIONS: "${docker.acs.opts}"
ports:
- ${acs.port}:8080
- ${acs.debug.port}:8888
Expand Down Expand Up @@ -36,13 +37,14 @@ services:
- support-tools-repo-db-volume:/var/lib/postgresql/data

support-tools-repo-ass:
image: alfresco/alfresco-search-services:1.2.0
image: alfresco/alfresco-search-services:${alfresco.search.version}
environment:
SOLR_ALFRESCO_HOST: acs
SOLR_ALFRESCO_PORT: 8080
SOLR_SOLR_HOST: ass
SOLR_SOLR_PORT: 8983
SOLR_CREATE_ALFRESCO_DEFAULTS: alfresco,archive
JAVA_TOOL_OPTIONS: "${docker.search.opts}"
ports:
- 8983:8983
networks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2016 - 2022 Order of the Bee
* Copyright (C) 2016 - 2023 Order of the Bee
*
* This file is part of OOTBee Support Tools
*
Expand All @@ -18,8 +18,8 @@
* <http://www.gnu.org/licenses/>.
*
* Linked to Alfresco
* Copyright (C) 2005 - 2022 Alfresco Software Limited.
*
* Copyright (C) 2005 - 2023 Alfresco Software Limited.
*
* This file is part of code forked from the JavaScript Console project
* which was licensed under the Apache License, Version 2.0 at the time.
* In accordance with that license, the modifications / derivative work
Expand All @@ -29,7 +29,7 @@
package org.orderofthebee.addons.support.tools.repo.jsconsole;

import org.alfresco.repo.jscript.ScriptLogger;
import org.apache.log4j.Level;
import org.orderofthebee.addons.support.tools.repo.log.Log4jCompatibilityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.extensions.webscripts.annotation.ScriptClass;
Expand All @@ -41,10 +41,11 @@
* This class is based upon {@link ScriptLogger the default Repository-tier script logger} and its
* {@link org.springframework.extensions.webscripts.ScriptLogger web-scripts clone} and has been modified to allow printing of messages to
* the JavaScript Console result.
*
*
* @author Kevin Roast
* @author davidc
* @author Florian Maul (fme AG)
* @author Axel Faust
*/
@ScriptClass(help = "Provides functions to aid debugging of scripts.", code = "logger.log(\"Command Processor: isEmailed=\" + isEmailed);", types = {
ScriptClassType.JavaScriptRootObject })
Expand All @@ -58,7 +59,7 @@ public final class JavascriptConsoleScriptLogger

private final JavascriptConsoleScriptObject jsConsole;

public JavascriptConsoleScriptLogger(JavascriptConsoleScriptObject jsConsole)
public JavascriptConsoleScriptLogger(final JavascriptConsoleScriptObject jsConsole)
{
this.jsConsole = jsConsole;
}
Expand All @@ -70,10 +71,10 @@ public boolean isLoggingEnabled()
}

@ScriptMethod(help = "Logs a message")
public void log(@ScriptParameter(help = "Message to log") String str)
public void log(@ScriptParameter(help = "Message to log") final String str)
{
logger.debug(str);
jsConsole.print("DEBUG - " + str);
this.jsConsole.print("DEBUG - " + str);
}

@ScriptMethod(help = "Returns true if debug logging is enabled.", code = "var loggerStatus = logger.isDebugEnabled();", output = "true if debug logging is enabled")
Expand All @@ -83,10 +84,10 @@ public boolean isDebugLoggingEnabled()
}

@ScriptMethod(help = "Logs a debug message")
public void debug(@ScriptParameter(help = "Message to log") String str)
public void debug(@ScriptParameter(help = "Message to log") final String str)
{
logger.debug(str);
jsConsole.print("DEBUG - " + str);
this.jsConsole.print("DEBUG - " + str);
}

@ScriptMethod(help = "Returns true if info logging is enabled.", code = "var loggerStatus = logger.isInfoEnabled();", output = "true if info logging is enabled")
Expand All @@ -96,10 +97,10 @@ public boolean isInfoLoggingEnabled()
}

@ScriptMethod(help = "Logs an info message")
public void info(@ScriptParameter(help = "Message to log") String str)
public void info(@ScriptParameter(help = "Message to log") final String str)
{
logger.info(str);
jsConsole.print(str);
this.jsConsole.print(str);
}

@ScriptMethod(help = "Returns true if warn logging is enabled.", code = "var loggerStatus = logger.isWarnLoggingEnabled();", output = "true if warn logging is enabled")
Expand All @@ -109,10 +110,10 @@ public boolean isWarnLoggingEnabled()
}

@ScriptMethod(help = "Logs a warning message")
public void warn(@ScriptParameter(help = "Message to log") String str)
public void warn(@ScriptParameter(help = "Message to log") final String str)
{
logger.warn(str);
jsConsole.print("WARN - " + str);
this.jsConsole.print("WARN - " + str);
}

@ScriptMethod(help = "Returns true if error logging is enabled.", code = "var loggerStatus = logger.isErrorLoggingEnabled();", output = "true if error logging is enabled")
Expand All @@ -122,36 +123,34 @@ public boolean isErrorLoggingEnabled()
}

@ScriptMethod(help = "Logs an error message")
public void error(@ScriptParameter(help = "Message to log") String str)
public void error(@ScriptParameter(help = "Message to log") final String str)
{
logger.error(str);
jsConsole.print("ERROR - " + str);
this.jsConsole.print("ERROR - " + str);
}

public SystemOut getSystem()
{
return systemOut;
return this.systemOut;
}

public class SystemOut
{

public void out(String str)
public void out(final String str)
{
System.out.println(str);
jsConsole.print(str);
JavascriptConsoleScriptLogger.this.jsConsole.print(str);
}
}

public void setLevel(String loggerName, String level)
public void setLevel(final String loggerName, final String level)
{
org.apache.log4j.Logger underlyingLogger = org.apache.log4j.Logger.getLogger(loggerName);
Level logLevel = Level.toLevel(level);
underlyingLogger.setLevel(logLevel);
Log4jCompatibilityUtils.LOG4J_HELPER.setLevel(loggerName, level);
}

public String getLevel(String loggerName)
public String getLevel(final String loggerName)
{
return org.apache.log4j.Logger.getLogger(loggerName).getLevel().toString();
return Log4jCompatibilityUtils.LOG4J_HELPER.getLevel(loggerName);
}
}
Loading

0 comments on commit 5c6f598

Please sign in to comment.