diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffd9a0b3..d8229a4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: strategy: fail-fast: false matrix: - version: [ "community-6.1.2-ga","community-6.2.0-ga","community-7.0.0", "community-7.1.1", "community-7.2.0", "community-7.3.0", "community-7.4.0", "enterprise-6.1.1","enterprise-6.2.2","enterprise-7.0.1", "enterprise-7.1.0", "enterprise-7.2.0", "enterprise-7.3.0", "enterprise-7.4.0" ] + version: [ "community-7.0.0", "community-7.1.1", "community-7.2.0", "community-7.3.0", "community-7.4.0", "community-23.1.0", "community-23.2.0", "enterprise-7.0.1", "enterprise-7.1.0", "enterprise-7.2.0", "enterprise-7.3.0", "enterprise-7.4.0", "enterprise-23.1.0", "enterprise-23.2.0" ] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 - name: Set up JDK 17 @@ -114,4 +114,4 @@ jobs: uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2 with: cache-read-only: false - arguments: :tomcat-base:tomcat-embedded-8.5:publish :tomcat-base:tomcat-embedded-9:publish --info -PsigningKeyId=CDE3528F \ No newline at end of file + arguments: :tomcat-base:tomcat-embedded-9:publish :tomcat-base:tomcat-embedded-10:publish --info -PsigningKeyId=CDE3528F \ No newline at end of file diff --git a/1alfresco-skeleton/23.1/overload.gradle b/1alfresco-skeleton/23.1/overload.gradle new file mode 100644 index 00000000..c2773d2a --- /dev/null +++ b/1alfresco-skeleton/23.1/overload.gradle @@ -0,0 +1,11 @@ +ext { + alfresco = [ + version: [ + major: 23, + minor: 1, + rev: 0 + ], + flavor: 'skeleton' + ] +} + diff --git a/1alfresco-skeleton/23.2/overload.gradle b/1alfresco-skeleton/23.2/overload.gradle new file mode 100644 index 00000000..4b265a43 --- /dev/null +++ b/1alfresco-skeleton/23.2/overload.gradle @@ -0,0 +1,11 @@ +ext { + alfresco = [ + version: [ + major: 23, + minor: 2, + rev: 0 + ], + flavor: 'skeleton' + ] +} + diff --git a/1alfresco-skeleton/6.1/overload.gradle b/1alfresco-skeleton/6.1/overload.gradle deleted file mode 100644 index c0aa5589..00000000 --- a/1alfresco-skeleton/6.1/overload.gradle +++ /dev/null @@ -1,11 +0,0 @@ -ext { - alfresco = [ - version: [ - major: 6, - minor: 1, - rev: 1 - ], - flavor: 'skeleton' - ] -} - diff --git a/1alfresco-skeleton/6.2/overload.gradle b/1alfresco-skeleton/6.2/overload.gradle deleted file mode 100644 index 4e23a40b..00000000 --- a/1alfresco-skeleton/6.2/overload.gradle +++ /dev/null @@ -1,11 +0,0 @@ -ext { - alfresco = [ - version: [ - major: 6, - minor: 2, - rev: 0 - ], - flavor: 'skeleton' - ] -} - diff --git a/1share-skeleton/6.1/local/share-config-custom.xml b/1share-skeleton/23.1/local/share-config-custom.xml similarity index 100% rename from 1share-skeleton/6.1/local/share-config-custom.xml rename to 1share-skeleton/23.1/local/share-config-custom.xml diff --git a/1share-skeleton/23.1/overload.gradle b/1share-skeleton/23.1/overload.gradle new file mode 100644 index 00000000..00b73fe2 --- /dev/null +++ b/1share-skeleton/23.1/overload.gradle @@ -0,0 +1,10 @@ +ext { + share = [ + version: [ + major: 23, + minor: 1, + rev: 0 + ], + flavor: 'skeleton' + ] +} \ No newline at end of file diff --git a/1share-skeleton/6.2/local/share-config-custom.xml b/1share-skeleton/23.2/local/share-config-custom.xml similarity index 100% rename from 1share-skeleton/6.2/local/share-config-custom.xml rename to 1share-skeleton/23.2/local/share-config-custom.xml diff --git a/1share-skeleton/23.2/overload.gradle b/1share-skeleton/23.2/overload.gradle new file mode 100644 index 00000000..7f8e04a6 --- /dev/null +++ b/1share-skeleton/23.2/overload.gradle @@ -0,0 +1,10 @@ +ext { + share = [ + version: [ + major: 23, + minor: 2, + rev: 0 + ], + flavor: 'skeleton' + ] +} \ No newline at end of file diff --git a/1share-skeleton/6.1/overload.gradle b/1share-skeleton/6.1/overload.gradle deleted file mode 100644 index 994d7674..00000000 --- a/1share-skeleton/6.1/overload.gradle +++ /dev/null @@ -1,10 +0,0 @@ -ext { - share = [ - version: [ - major: 6, - minor: 1, - rev: 0 - ], - flavor: 'skeleton' - ] -} \ No newline at end of file diff --git a/1share-skeleton/6.2/overload.gradle b/1share-skeleton/6.2/overload.gradle deleted file mode 100644 index 085e7f6c..00000000 --- a/1share-skeleton/6.2/overload.gradle +++ /dev/null @@ -1,10 +0,0 @@ -ext { - share = [ - version: [ - major: 6, - minor: 2, - rev: 0 - ], - flavor: 'skeleton' - ] -} \ No newline at end of file diff --git a/2repository/23.1/community-23.1.0/overload.gradle b/2repository/23.1/community-23.1.0/overload.gradle new file mode 100644 index 00000000..00383301 --- /dev/null +++ b/2repository/23.1/community-23.1.0/overload.gradle @@ -0,0 +1,23 @@ +ext { + alfresco = [ + version: [ + major: 23, + minor: 1, + rev : 0, + label: 1 + ], + flavor : 'community' + ] + solrimage = 'docker.io/xenit/alfresco-solr6:2.0.8.2' + shareimage = 'docker.io/xenit/alfresco-share-community:23.1.0' + psqlimage = 'postgres:15' + tests = true + alfrescoBomVersion='23.1.0' +} + +dependencies { + alfrescoAmp platform("org.alfresco:acs-community-packaging:$alfrescoBomVersion") + alfrescoAmp 'org.alfresco:alfresco-share-services@amp' + baseAlfrescoWar platform("org.alfresco:acs-community-packaging:$alfrescoBomVersion") + baseAlfrescoWar 'org.alfresco:content-services-community@war' +} diff --git a/2repository/6.1/enterprise-6.1.1/overload.gradle b/2repository/23.1/enterprise-23.1.0/overload.gradle similarity index 59% rename from 2repository/6.1/enterprise-6.1.1/overload.gradle rename to 2repository/23.1/enterprise-23.1.0/overload.gradle index 90d5d6e0..30ef53af 100644 --- a/2repository/6.1/enterprise-6.1.1/overload.gradle +++ b/2repository/23.1/enterprise-23.1.0/overload.gradle @@ -1,18 +1,18 @@ ext { alfresco = [ version: [ - major: 6, + major: 23, minor: 1, - rev : 1, - label: 11 + rev : 0, + label: 1 ], flavor : 'enterprise' ] - solrimage = 'docker.io/xenit/alfresco-solr6:1.3.0.1' - shareimage = 'docker.io/xenit/alfresco-share-community:6.1.0.2' - psqlimage = 'docker.io/xenit/postgres:11' + solrimage = 'docker.io/xenit/alfresco-solr6:2.0.8.2' + shareimage = 'docker.io/xenit/alfresco-share-community:23.1.0' + psqlimage = 'postgres:15' tests = true - alfrescoBomVersion = '6.1.1.11' + alfrescoBomVersion = '23.1.0' } dependencies { @@ -21,4 +21,3 @@ dependencies { baseAlfrescoWar platform("org.alfresco:acs-packaging:$alfrescoBomVersion") baseAlfrescoWar 'org.alfresco:content-services@war' } - diff --git a/2repository/23.2/community-23.2.0/overload.gradle b/2repository/23.2/community-23.2.0/overload.gradle new file mode 100644 index 00000000..fc6c4a0e --- /dev/null +++ b/2repository/23.2/community-23.2.0/overload.gradle @@ -0,0 +1,23 @@ +ext { + alfresco = [ + version: [ + major: 23, + minor: 2, + rev : 0, + label: 1 + ], + flavor : 'community' + ] + solrimage = 'docker.io/xenit/alfresco-solr6:2.0.8.2' + shareimage = 'docker.io/xenit/alfresco-share-community:23.2.0' + psqlimage = 'postgres:15' + tests = true + alfrescoBomVersion='23.2.0' +} + +dependencies { + alfrescoAmp platform("org.alfresco:acs-community-packaging:$alfrescoBomVersion") + alfrescoAmp 'org.alfresco:alfresco-share-services@amp' + baseAlfrescoWar platform("org.alfresco:acs-community-packaging:$alfrescoBomVersion") + baseAlfrescoWar 'org.alfresco:content-services-community@war' +} diff --git a/2repository/6.2/enterprise-6.2.2/overload.gradle b/2repository/23.2/enterprise-23.2.0/overload.gradle similarity index 59% rename from 2repository/6.2/enterprise-6.2.2/overload.gradle rename to 2repository/23.2/enterprise-23.2.0/overload.gradle index d02553c0..a9da5edd 100644 --- a/2repository/6.2/enterprise-6.2.2/overload.gradle +++ b/2repository/23.2/enterprise-23.2.0/overload.gradle @@ -1,18 +1,18 @@ ext { alfresco = [ version: [ - major: 6, + major: 23, minor: 2, - rev : 2, - label: 25 + rev : 0, + label: 1 ], flavor : 'enterprise' ] - solrimage = 'docker.io/xenit/alfresco-solr6:2.0.1' - shareimage = 'docker.io/xenit/alfresco-share-community:6.2.0' - psqlimage = 'docker.io/xenit/postgres:11.7' + solrimage = 'docker.io/xenit/alfresco-solr6:2.0.8.2' + shareimage = 'docker.io/xenit/alfresco-share-community:23.2.0' + psqlimage = 'postgres:15' tests = true - alfrescoBomVersion = '6.2.2.25' + alfrescoBomVersion = '23.2.0' } dependencies { @@ -20,4 +20,4 @@ dependencies { alfrescoAmp 'org.alfresco:alfresco-share-services@amp' baseAlfrescoWar platform("org.alfresco:acs-packaging:$alfrescoBomVersion") baseAlfrescoWar 'org.alfresco:content-services@war' -} \ No newline at end of file +} diff --git a/2repository/6.1/community-6.1.2-ga/overload.gradle b/2repository/6.1/community-6.1.2-ga/overload.gradle deleted file mode 100644 index 7010133c..00000000 --- a/2repository/6.1/community-6.1.2-ga/overload.gradle +++ /dev/null @@ -1,19 +0,0 @@ -ext { - alfresco = [ - version: [ - major: 6, - minor: 1, - rev : '2-ga' - ], - flavor : 'community' - ] - solrimage = 'docker.io/xenit/alfresco-solr6:1.3.0.1' - shareimage = 'docker.io/xenit/alfresco-share-community:6.1.0.2' - psqlimage = 'docker.io/xenit/postgres:11' - tests = true -} - -dependencies { - alfrescoAmp 'org.alfresco:alfresco-share-services:6.1.1.4@amp' - baseAlfrescoWar 'org.alfresco:content-services-community:6.1.2-ga@war' -} diff --git a/2repository/6.2/community-6.2.0-ga/overload.gradle b/2repository/6.2/community-6.2.0-ga/overload.gradle deleted file mode 100644 index a88d0b8c..00000000 --- a/2repository/6.2/community-6.2.0-ga/overload.gradle +++ /dev/null @@ -1,19 +0,0 @@ -ext { - alfresco = [ - version: [ - major: 6, - minor: 2, - rev : '0-ga' - ], - flavor : 'community' - ] - solrimage = 'docker.io/xenit/alfresco-solr6:1.4.0' - shareimage = 'docker.io/xenit/alfresco-share-community:6.2.0' - psqlimage = 'docker.io/xenit/postgres:11.7' - tests = true -} - -dependencies { - alfrescoAmp 'org.alfresco:alfresco-share-services:6.2.2.7@amp' - baseAlfrescoWar 'org.alfresco:content-services-community:6.2.0-ga@war' -} diff --git a/2share/6.1/community-6.1.0/overload.gradle b/2share/23.1/community-23.1.0/overload.gradle similarity index 51% rename from 2share/6.1/community-6.1.0/overload.gradle rename to 2share/23.1/community-23.1.0/overload.gradle index 4a7a4489..191c83de 100644 --- a/2share/6.1/community-6.1.0/overload.gradle +++ b/2share/23.1/community-23.1.0/overload.gradle @@ -1,16 +1,16 @@ ext { share = [ version: [ - major: 6, + major: 23, minor: 1, - rev: '1', - label: '4' + rev: 0, + label: 1 ], flavor: 'community' ] } dependencies { - baseShareWar 'org.alfresco:share:6.1.1.4@war' + baseShareWar 'org.alfresco:share:23.1.1.2@war' } diff --git a/2share/6.2/community-6.2.2/overload.gradle b/2share/23.2/community-23.2.0/overload.gradle similarity index 51% rename from 2share/6.2/community-6.2.2/overload.gradle rename to 2share/23.2/community-23.2.0/overload.gradle index 6154b77a..7e78ef01 100644 --- a/2share/6.2/community-6.2.2/overload.gradle +++ b/2share/23.2/community-23.2.0/overload.gradle @@ -1,16 +1,16 @@ ext { share = [ version: [ - major: 6, + major: 23, minor: 2, - rev: '2', - label: '7' + rev: 0, + label: 1 ], flavor: 'community' ] } dependencies { - baseShareWar 'org.alfresco:share:6.2.2.7@war' + baseShareWar 'org.alfresco:share:23.2.0.72@war' } diff --git a/Changelog.md b/Changelog.md index 0c0828a1..ef36eed9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,7 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). * [PR #110](https://github.com/xenit-eu/docker-alfresco/pull/110) XM2C-81 fix alfresco environment and default system properties ### Added - +* [PR #208](https://xenitsupport.jira.com/browse/DOCKER-450) DOCKER-450 Add Alfresco V23.1 & V23.2 support * [PR #98](https://github.com/xenit-eu/docker-alfresco/pull/98) XM2C-43 Merge docker-share into docker-alfresco * [PR #88](https://github.com/xenit-eu/docker-alfresco/pull/88) DOCKER-415 Add a healthcheck for Alfresco * [PR #86](https://github.com/xenit-eu/docker-alfresco/pull/86) DOCKER-414 Fix alf_data content store permissions diff --git a/build.gradle b/build.gradle index bf2e457c..957c4c5d 100644 --- a/build.gradle +++ b/build.gradle @@ -55,16 +55,17 @@ def calcRepository(flavor, isAlfresco) { String getTomcatProject(majorVersion) { println "major version used : ${majorVersion}" - if (majorVersion == 6) { - println 'tomcat-embedded-8.5' - return ":tomcat-base:tomcat-embedded-8.5" - } if (majorVersion == 7) { println 'tomcat-embedded-9' return ":tomcat-base:tomcat-embedded-9" } + if (majorVersion == 23) { + println 'tomcat-embedded-10' + return ":tomcat-base:tomcat-embedded-10" + } + return null } @@ -100,3 +101,15 @@ subprojects { } } } + +// Remove when Alfresco V7.X support is dropped. +project(":tomcat-base:tomcat-embedded-9") { + sonarqube { + skipProject = true + } +} +project(":tomcat-base:tomcat-embedded-10") { + sonarqube { + skipProject = true + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 17a20bf2..9ab473b0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,62 +1,66 @@ rootProject.name = 'docker-alfresco' - include ':tomcat-base' -include ':tomcat-base:tomcat-embedded-8.5' include ':tomcat-base:tomcat-embedded-9' +include ':tomcat-base:tomcat-embedded-10' include ':1alfresco-skeleton' -include ':1alfresco-skeleton:6.1' -include ':1alfresco-skeleton:6.2' include ':1alfresco-skeleton:7.0' include ':1alfresco-skeleton:7.1' include ':1alfresco-skeleton:7.2' include ':1alfresco-skeleton:7.3' include ':1alfresco-skeleton:7.4' +include ':1alfresco-skeleton:23.1' +include ':1alfresco-skeleton:23.2' include ':2repository' include ':1share-skeleton' -include ':1share-skeleton:6.1' -include ':1share-skeleton:6.2' include ':1share-skeleton:7.0' include ':1share-skeleton:7.1' include ':1share-skeleton:7.2' include ':1share-skeleton:7.3' include ':1share-skeleton:7.4' +include ':1share-skeleton:23.1' +include ':1share-skeleton:23.2' include ':2share' def includeRepoProject(String flavor, String version) { def projectName = ":2repository:${flavor}-$version" include projectName - project(projectName).projectDir = file("2repository/${version.substring(0,3)}/${flavor}-$version") + project(projectName).projectDir = file("2repository/${version.substring(0,getSecondDotPosition(version))}/${flavor}-$version") } def includeShareProject(String flavor, String version) { def projectName = ":2share:${flavor}-$version" include projectName - project(projectName).projectDir = file("2share/${version.substring(0,3)}/${flavor}-$version") + project(projectName).projectDir = file("2share/${version.substring(0,getSecondDotPosition(version))}/${flavor}-$version") +} + +def getSecondDotPosition(String version) { + return version.split(/\./)[0].length() + 1 + version.split(/\./)[1].length() } + if (includeCommunity == 'true') { - includeRepoProject('community', '6.1.2-ga') - includeRepoProject('community', '6.2.0-ga') includeRepoProject('community', '7.0.0') includeRepoProject('community', '7.1.1') includeRepoProject('community', '7.2.0') includeRepoProject('community', '7.3.0') includeRepoProject('community', '7.4.0') + includeRepoProject('community', '23.1.0') + includeRepoProject('community', '23.2.0') - includeShareProject('community', '6.1.0') - includeShareProject('community', '6.2.2') includeShareProject('community', '7.0.1') includeShareProject('community', '7.1.0') includeShareProject('community', '7.2.1') includeShareProject('community', '7.3.0') includeShareProject('community', '7.4.0') + includeShareProject('community', '23.1.0') + includeShareProject('community', '23.2.0') } if (includeEnterprise == 'true') { - includeRepoProject('enterprise', '6.1.1') - includeRepoProject('enterprise', '6.2.2') includeRepoProject('enterprise', '7.0.1') includeRepoProject('enterprise', '7.1.0') includeRepoProject('enterprise', '7.2.0') includeRepoProject('enterprise', '7.3.0') includeRepoProject('enterprise', '7.4.0') + includeRepoProject('enterprise', '23.1.0') + includeRepoProject('enterprise', '23.2.0') } diff --git a/tomcat-base/build.gradle b/tomcat-base/build.gradle index 3a503111..9098059f 100644 --- a/tomcat-base/build.gradle +++ b/tomcat-base/build.gradle @@ -5,7 +5,6 @@ subprojects { apply plugin: 'eu.xenit.docker' apply plugin: 'java' apply plugin: "maven-publish" - apply from: "${rootProject.projectDir}/jacoco.gradle" if (new File("${project.projectDir}/overload.gradle").exists()) { @@ -17,28 +16,37 @@ subprojects { configurations { sharedLibs } + // This can be deleted when support for Alfresco V7.X is dropped. + if (!tomcatVersion.contains("10")) { + java { + withJavadocJar() + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + + } + }else{ + java { + withJavadocJar() + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 - java { - withJavadocJar() - withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + } } ext { - jsonLoggingVersion = '0.0.7' + jsonLoggingVersion = '0.0.8' } dependencies { - compileOnly "org.projectlombok:lombok:1.18.28" - annotationProcessor "org.projectlombok:lombok:1.18.28" - + compileOnly "org.projectlombok:lombok:1.18.32" + annotationProcessor "org.projectlombok:lombok:1.18.32" implementation "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}" implementation "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}" implementation "org.apache.tomcat:tomcat-jasper:${tomcatVersion}" implementation "org.apache.tomcat:tomcat-jasper-el:${tomcatVersion}" implementation "org.apache.tomcat:tomcat-jsp-api:${tomcatVersion}" implementation "eu.xenit.logging:json-logging:${jsonLoggingVersion}" - implementation "com.fasterxml.jackson.core:jackson-databind:2.15.3" testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.0" testImplementation("org.junit-pioneer:junit-pioneer:2.1.0") testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.0" @@ -62,6 +70,7 @@ subprojects { main { java { srcDir file("$project.parent.projectDir/src/shared/main/java") + srcDir file("$project.projectDir/src/main/java") } } test { @@ -84,7 +93,12 @@ subprojects { } createDockerFile { - from 'docker.io/eclipse-temurin:11' + if (!tomcatVersion.contains("10")) { + from 'docker.io/eclipse-temurin:11' + } + else{ + from 'docker.io/eclipse-temurin:17-jre' + } smartCopy configurations.sharedLibs, '/usr/local/tomcat/shared/lib/' smartCopy "${project.parent.projectDir}/src/shared/main/resources/keystore", '/keystore' smartCopy configurations.runtimeClasspath, '/app/tomcat-embedded/lib' diff --git a/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/alfresco/tomcat/AlfrescoTomcatFactoryHelper.java b/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/alfresco/tomcat/AlfrescoTomcatFactoryHelper.java index 5ea55ca2..77d7aa23 100644 --- a/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/alfresco/tomcat/AlfrescoTomcatFactoryHelper.java +++ b/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/alfresco/tomcat/AlfrescoTomcatFactoryHelper.java @@ -14,6 +14,7 @@ import java.nio.file.Paths; import java.util.Properties; import java.util.logging.Logger; +import org.apache.tomcat.util.net.SSLHostConfigCertificate; public class AlfrescoTomcatFactoryHelper { @@ -66,9 +67,12 @@ public static void createSSLConnector(Tomcat tomcat, AlfrescoConfiguration alfre ); SSLHostConfig sslHostConfig = new SSLHostConfig(); - sslHostConfig.setCertificateKeystoreFile(alfrescoConfiguration.getTomcatSSLKeystore()); - sslHostConfig.setCertificateKeystorePassword(alfrescoConfiguration.getTomcatSSLKeystorePassword()); - sslHostConfig.setCertificateKeystoreType("JCEKS"); + SSLHostConfigCertificate sslHostConfigCertificate = new SSLHostConfigCertificate(sslHostConfig, SSLHostConfigCertificate.Type.UNDEFINED); + sslHostConfigCertificate.setCertificateKeystoreFile(alfrescoConfiguration.getTomcatSSLKeystore()); + sslHostConfigCertificate.setCertificateKeystorePassword(alfrescoConfiguration.getTomcatSSLKeystorePassword()); + sslHostConfigCertificate.setCertificateKeystoreType("JCEKS"); + + sslHostConfig.addCertificate(sslHostConfigCertificate); sslHostConfig.setTruststoreFile(alfrescoConfiguration.getTomcatSSLTruststore()); sslHostConfig.setTruststorePassword(alfrescoConfiguration.getTomcatSSLTruststorePassword()); sslHostConfig.setTruststoreType("JCEKS"); diff --git a/tomcat-base/tomcat-embedded-10/overload.gradle b/tomcat-base/tomcat-embedded-10/overload.gradle new file mode 100644 index 00000000..85b9c9d9 --- /dev/null +++ b/tomcat-base/tomcat-embedded-10/overload.gradle @@ -0,0 +1,5 @@ +ext { + tomcat = [ + version: '10.1.23' + ] +} \ No newline at end of file diff --git a/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java b/tomcat-base/tomcat-embedded-10/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java similarity index 98% rename from tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java rename to tomcat-base/tomcat-embedded-10/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java index b1ce96f0..21e3b6e4 100644 --- a/tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java +++ b/tomcat-base/tomcat-embedded-10/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java @@ -1,7 +1,7 @@ package eu.xenit.alfresco.tomcat.embedded.tomcat; import eu.xenit.alfresco.tomcat.embedded.config.TomcatConfiguration; -import eu.xenit.logging.json.valve.JsonAccessLogValve; +import eu.xenit.logging.json.valve.JsonAccessLogValve10; import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleListener; import org.apache.catalina.Service; @@ -108,7 +108,7 @@ private void addWebapp(Tomcat tomcat, Path path) { ctx.addLifecycleListener(lifecycleListener); if (getConfiguration().isAccessLogging()) { - JsonAccessLogValve valve = new JsonAccessLogValve(); + JsonAccessLogValve10 valve = new JsonAccessLogValve10(); ctx.addValve(valve); ctx.getAccessLog(); } diff --git a/tomcat-base/tomcat-embedded-8.5/overload.gradle b/tomcat-base/tomcat-embedded-8.5/overload.gradle deleted file mode 100644 index 75219e70..00000000 --- a/tomcat-base/tomcat-embedded-8.5/overload.gradle +++ /dev/null @@ -1,5 +0,0 @@ -ext { - tomcat = [ - version: '8.5.78' - ] -} diff --git a/tomcat-base/tomcat-embedded-9/overload.gradle b/tomcat-base/tomcat-embedded-9/overload.gradle index 7e93e153..7ff2f22c 100644 --- a/tomcat-base/tomcat-embedded-9/overload.gradle +++ b/tomcat-base/tomcat-embedded-9/overload.gradle @@ -2,10 +2,4 @@ ext { tomcat = [ version: '9.0.59' ] -} - -sonarqube { - properties { - property 'sonar.projectBaseDir', "$project.parent.projectDir/src/shared/" - } } \ No newline at end of file diff --git a/tomcat-base/tomcat-embedded-9/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java b/tomcat-base/tomcat-embedded-9/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java new file mode 100644 index 00000000..16817d77 --- /dev/null +++ b/tomcat-base/tomcat-embedded-9/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java @@ -0,0 +1,153 @@ +package eu.xenit.alfresco.tomcat.embedded.tomcat; + +import eu.xenit.alfresco.tomcat.embedded.config.TomcatConfiguration; +import eu.xenit.logging.json.valve.JsonAccessLogValve85; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.Service; +import org.apache.catalina.WebResourceRoot; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.webresources.DirResourceSet; +import org.apache.catalina.webresources.StandardRoot; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Stream; + +import static eu.xenit.alfresco.tomcat.embedded.utils.Utils.redirectLog4j; + +public class TomcatFactory { + + private final TomcatConfiguration configuration; + + public TomcatFactory(TomcatConfiguration configuration) { + this.configuration = configuration; + } + + public static Connector getConnector(Tomcat tomcat, String protocol, int port, boolean sslEnabled, String scheme, int maxThreads, int maxHttpHeaderSize, String relaxedPathChars, String relaxedQueryChars) { + Connector connector = new Connector(protocol); + connector.setPort(port); + connector.setProperty("connectionTimeout", "240000"); + connector.setURIEncoding(StandardCharsets.UTF_8.name()); + connector.setProperty("SSLEnabled", String.valueOf(sslEnabled)); + connector.setProperty("maxThreads", String.valueOf(maxThreads)); + connector.setProperty("maxHttpHeaderSize", String.valueOf(maxHttpHeaderSize)); + connector.setProperty("relaxedPathChars", relaxedPathChars); + connector.setProperty("relaxedQueryChars", relaxedQueryChars); + connector.setScheme(scheme); + Service service = tomcat.getService(); + service.setContainer(tomcat.getEngine()); + connector.setService(service); + return connector; + } + + private TomcatConfiguration getConfiguration() { + return configuration; + } + + public Tomcat getTomcat() throws IOException { + Tomcat tomcat = new Tomcat(); + tomcat.setBaseDir(getConfiguration().getTomcatBaseDir()); + tomcat.setPort(getConfiguration().getTomcatPort()); + tomcat.getServer().setPort(getConfiguration().getTomcatServerPort()); + createDefaultConnector(tomcat); + addUserWithRole(tomcat, "CN=Alfresco Repository Client, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB", null, "repoclient"); + addUserWithRole(tomcat, "CN=Alfresco Repository, OU=Unknown, O=Alfresco Software Ltd., L=Maidenhead, ST=UK, C=GB", null, "repository"); + Path webapps = Paths.get(getConfiguration().getWebappsPath()); + if (Files.exists(webapps)) { + try (var directoryStream = Files.newDirectoryStream(webapps)) { + directoryStream.forEach(path -> addWebapp(tomcat, path)); + } + } + return tomcat; + } + + protected boolean isEmptyDir(Path path) { + if (Files.isDirectory(path)) { + try (Stream entries = Files.list(path)) { + return entries.findFirst().isEmpty(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + return false; + } + + private void addWebapp(Tomcat tomcat, Path path) { + if (isEmptyDir(path)) { + // Our gradle plugin adds a share directory, even when baseShareWar is not configured + return; + } + if (Files.isDirectory(path)) { + String contextPath = "/" + path.getFileName().toString(); + String absolutePath = path.toAbsolutePath().toString(); + StandardContext ctx = (StandardContext) tomcat.addWebapp(contextPath, absolutePath); + ctx.setParentClassLoader(Thread.currentThread().getContextClassLoader()); + LifecycleListener lifecycleListener = event -> { + if (event.getType().equals("before_start")) { + WebResourceRoot resources = new StandardRoot(ctx); + resources.setCacheMaxSize(getConfiguration().getTomcatCacheMaxSize()); + resources.addPostResources(new DirResourceSet(resources, "/WEB-INF/classes", getConfiguration().getSharedClasspathDir(), "/")); + resources.addPostResources(new DirResourceSet(resources, "/WEB-INF/classes", getConfiguration().getGeneratedClasspathDir(), "/")); + resources.addJarResources(new DirResourceSet(resources, "/WEB-INF/lib", getConfiguration().getSharedLibDir(), "/")); + if (getConfiguration().isJsonLogging()) { + redirectLog4j(path, Paths.get(configuration.getGeneratedClasspathDir())); + } + ctx.setResources(resources); + } + if (getConfiguration().isExitOnFailure() && event.getType().equals("after_stop")) { + stopTomcat(tomcat); + } + }; + ctx.addLifecycleListener(lifecycleListener); + + if (getConfiguration().isAccessLogging()) { + JsonAccessLogValve85 valve = new JsonAccessLogValve85(); + ctx.addValve(valve); + ctx.getAccessLog(); + } + } + } + + private void createDefaultConnector(Tomcat tomcat) { + Connector connector = getConnector(tomcat, + "HTTP/1.1", + getConfiguration().getTomcatPort(), + false, + "http", + getConfiguration().getTomcatMaxThreads(), + getConfiguration().getTomcatMaxHttpHeaderSize(), + getConfiguration().getTomcatRelaxedPathChars(), + getConfiguration().getTomcatRelaxedQueryChars() + ); + connector.setRedirectPort(getConfiguration().getTomcatSslPort()); + tomcat.setConnector(connector); + } + + private void addUserWithRole(Tomcat tomcat, String username, String password, String role) { + tomcat.addUser(username, password); + tomcat.addRole(username, role); + } + + + private void stopTomcat(Tomcat tomcat) { + Thread thread = new Thread(() -> { + try { + tomcat.stop(); + tomcat.destroy(); + } catch (LifecycleException e) { + e.printStackTrace(); + } + }); + thread.start(); + + } + + +} \ No newline at end of file