From 899c2e131eaf2ab5be1ea68231da1569f415f74b Mon Sep 17 00:00:00 2001 From: hechmi-dammak-xenit <107396375+hechmi-dammak-xenit@users.noreply.github.com> Date: Thu, 21 Dec 2023 12:55:42 +0100 Subject: [PATCH] XENOPS-1128 add check for content store fetching file to health check (#22) * XENOPS-1128 add check for content stora fetching file to health check * XENOPS-1128 add check for content stora fetching file to health check * XENOPS-1128 add check for content stora fetching file to health check * XENOPS-1128 add more testing for details * XENOPS-1128 change the way to access the noderef for content store to a constant --- .github/workflows/ci.yml | 61 ++++++------- README.md | 47 +++++++--- alfresco-actuators/build.gradle | 54 ++---------- .../alfresco-global.properties | 0 .../bootstrap/AlfrescoActuatorsACP.acp | Bin 0 -> 2363 bytes .../bootstrap/bootstrap.xml | 28 ++++++ .../context/services-context.xml | 8 +- .../context/webscripts-context.xml | 6 +- .../alfresco-actuators/log4j.properties | 0 .../alfresco-actuators/module-context.xml | 1 + .../actuators/webscripts/health.get.desc.xml | 0 .../actuators/webscripts/health.get.json.ftl} | 0 .../webscripts/healthdetails.get.desc.xml | 0 .../webscripts/healthdetails.get.json.ftl | 1 + .../main/java/eu/xenit/actuators/Health.java | 25 ------ .../xenit/actuators/HealthDetailsError.java | 15 ---- .../eu/xenit/actuators/HealthIndicator.java | 21 ++++- .../java/eu/xenit/actuators/HealthStatus.java | 6 -- .../services/AlfrescoInfoService.java | 50 +++-------- .../services/ContentInfoService.java | 43 +++++++++ .../services/LicenseInfoService.java | 42 +++------ .../actuators/services/StatusInfoService.java | 31 +------ .../actuators/services/SystemInfoService.java | 35 ++------ .../classical/AbstractHealthWebScript.java | 65 ++++++++++++++ .../classical/HealthDetailsWebScript.java | 20 +++++ .../webscripts/classical/HealthWebScript.java | 43 ++++----- .../classical/HealthdetailsWebScript.java | 52 ----------- .../alfresco-actuators/module.properties | 4 - .../actuators/webscripts/health.get.json.ftl | 3 - build.gradle | 25 ++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../alfresco-community-61/overload.gradle | 2 +- .../alfresco-community-62/overload.gradle | 2 +- .../alfresco-community-70/overload.gradle | 2 +- .../alfresco-community-71/overload.gradle | 2 +- .../alfresco-community-72/overload.gradle | 4 +- .../alfresco-community-73/overload.gradle | 2 +- .../alfresco-community-74/overload.gradle | 8 ++ .../alfresco-enterprise-61/overload.gradle | 2 +- .../alfresco-enterprise-62/overload.gradle | 4 +- .../alfresco-enterprise-70/overload.gradle | 4 +- .../alfresco-enterprise-71/overload.gradle | 4 +- .../alfresco-enterprise-72/overload.gradle | 4 +- .../alfresco-enterprise-73/overload.gradle | 4 +- .../alfresco-enterprise-74/overload.gradle | 8 ++ integration-tests/build.gradle | 32 ++++--- .../ActuatorsEndpointSmokeTest.java | 65 +++++++++++++- .../test/resources/compose/docker-compose.yml | 11 ++- publish.gradle | 77 ++++++++-------- settings.gradle | 5 +- .../resources => specifications}/swagger.yaml | 82 ++++++++++++++---- swaggerCodeGen.gradle | 34 ++++++++ 52 files changed, 583 insertions(+), 463 deletions(-) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/module/alfresco-actuators/alfresco-global.properties (100%) create mode 100644 alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/AlfrescoActuatorsACP.acp create mode 100644 alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/bootstrap.xml rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/module/alfresco-actuators/context/services-context.xml (66%) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/module/alfresco-actuators/context/webscripts-context.xml (72%) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/module/alfresco-actuators/log4j.properties (100%) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/module/alfresco-actuators/module-context.xml (72%) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.desc.xml (100%) rename alfresco-actuators/src/main/{resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl => amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl} (100%) rename alfresco-actuators/src/main/{resources => amp/config}/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.desc.xml (100%) create mode 100644 alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl delete mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/Health.java delete mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/HealthDetailsError.java delete mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/HealthStatus.java create mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/services/ContentInfoService.java create mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/AbstractHealthWebScript.java create mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthDetailsWebScript.java delete mode 100644 alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthdetailsWebScript.java delete mode 100644 alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module.properties delete mode 100644 alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl create mode 100644 integration-tests/alfresco-community-74/overload.gradle create mode 100644 integration-tests/alfresco-enterprise-74/overload.gradle rename {alfresco-actuators/src/main/resources => specifications}/swagger.yaml (69%) create mode 100644 swaggerCodeGen.gradle diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53daf4e..7da746a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,58 +1,59 @@ name: CI on: push: - branches: - - master - tags: - - v* - pull_request: + workflow_dispatch: env: - GRADLE_OPTS: "-Dorg.gradle.project.org.alfresco.artifacts.username=${{ secrets.ALFRESCO_NEXUS_USERNAME }} -Dorg.gradle.project.org.alfresco.artifacts.password=${{ secrets.ALFRESCO_NEXUS_PASSWORD }}" + GRADLE_OPTS: >- + -Dorg.gradle.project.org.alfresco.maven.nexus.username=${{ secrets.ALFRESCO_NEXUS_USERNAME }} + -Dorg.gradle.project.org.alfresco.maven.nexus.password=${{ secrets.ALFRESCO_NEXUS_PASSWORD }} jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: flavour: [ "community", "enterprise" ] version: [ "61", "62", "70", "71", "72", "73" ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + - name: Set up JDK 11 + uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3 with: - fetch-depth: 0 - - uses: actions/setup-java@v1 + distribution: 'temurin' + java-version: '11' + - name: Login to Docker + run: echo "${{ secrets.CLOUDSMITH_APIKEY }}" | docker login private.docker.xenit.eu --username "${{ secrets.CLOUDSMITH_USER }}" --password-stdin + - name: Integration Test + uses: gradle/gradle-build-action@v2 with: - java-version: 11 - - name: Login to CloudSmith docker registry - env: - DOCKER_USER: ${{ secrets.CLOUDSMITH_USER }} - DOCKER_PASSWORD: ${{ secrets.CLOUDSMITH_APIKEY }} - run: echo "$DOCKER_PASSWORD" | docker login docker.xenit.eu --username "$DOCKER_USER" --password-stdin - - name: Integration test - run: ./gradlew :integration-tests:alfresco-${{ matrix.flavour }}-${{ matrix.version }}:integrationTest --parallel - - name: 'Upload Artifact' + cache-read-only: false + arguments: :integration-tests:alfresco-${{ matrix.flavour }}-${{ matrix.version }}:integrationTest --parallel + - name: 'Upload Test Reports' if: success() || failure() uses: actions/upload-artifact@v3 with: name: test-result-${{ matrix.flavour }}-${{ matrix.version }} - path: /home/runner/work/**/build/reports - retention-days: 2 + path: /home/runner/**/build/reports + retention-days: 14 publish: needs: [ test ] runs-on: ubuntu-latest - if: ${{ startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/tags/') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') }} steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-java@v1 + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + - name: Set up JDK 11 + uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3 with: - java-version: 11 + distribution: 'temurin' + java-version: '11' + - name: Add TAG_VERSION env property + run: echo "TAG_VERSION=`echo ${GITHUB_REF#refs/tags/}`" >> $GITHUB_ENV - name: Publish env: - ORG_GRADLE_PROJECT_publish_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - ORG_GRADLE_PROJECT_publish_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - SIGNING_PRIVATE_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }} - SIGNING_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }} + ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.SONATYPE_S01_USERNAME }} + ORG_GRADLE_PROJECT_sonatype_password: ${{ secrets.SONATYPE_S01_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }} run: ./gradlew publish --info diff --git a/README.md b/README.md index 73b37af..7c80862 100644 --- a/README.md +++ b/README.md @@ -4,38 +4,59 @@ Health endpoint, unauthenticated, to be used as docker and load balancer health The webscript is available at: +``` alfresco/s/xenit/actuators/health + alfresco/s/xenit/actuators/health/details +``` + +with both having request parameter disabled with values : + +* `SystemInfoService` +* `AlfrescoInfoService` +* `ContentInfoService` +* `LicenseInfoService` +* `StatusInfoService` + +example: + +* `alfresco/s/xenit/actuators/health?disabled=SystemInfoService,LicenseInfoService` +* `alfresco/s/xenit/actuators/health/details?disabled=SystemInfoService` ## Usage Status code is to be used for the health check. -The output of the check is: +The output of the health check is: ``` + {"status":"UP"} + ``` or ``` -{"status":"DOWN"} + +{"status":"DOWN" , "message":"error message"} + ``` Currently the check looks at: * system - * os - * java - * cpu + * os + * java + * cpu * alfresco - * id - * version - * edition - * license - * warManifest - * modules - * status + * id + * version + * edition + * license + * warManifest + * modules + * status + * content store # Development @@ -46,5 +67,7 @@ See [TODO.md](TODO.md) ## How to run integration tests ``` + ./gradlew integrationTest + ``` diff --git a/alfresco-actuators/build.gradle b/alfresco-actuators/build.gradle index 8b7b3d0..65e501a 100644 --- a/alfresco-actuators/build.gradle +++ b/alfresco-actuators/build.gradle @@ -2,7 +2,6 @@ plugins { id 'java' id 'maven-publish' id 'eu.xenit.amp' - id 'org.hidetake.swagger.generator' version '2.19.2' id "com.github.johnrengelman.shadow" version "7.1.2" } @@ -10,13 +9,10 @@ description = "Xenit webscripts to retrieve health of the application" // compile against alfresco 5.2 ext { - alfrescoVersion = '5.2.7' + alfrescoVersion = '6.1.1.11' servletApiVersion = '2.5' } -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} java { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -25,57 +21,19 @@ java { } dependencies { - alfrescoProvided("org.alfresco:alfresco-repository:$alfrescoVersion") - alfrescoProvided("org.alfresco:alfresco-enterprise-repository:$alfrescoVersion") - alfrescoProvided("javax.servlet:servlet-api:$servletApiVersion") + alfrescoProvided platform("org.alfresco:acs-packaging:${alfrescoVersion}") + alfrescoProvided("org.alfresco:alfresco-repository") + alfrescoProvided("org.alfresco:alfresco-enterprise-repository") - // Add dependency for Swagger Codegen CLI - swaggerCodegen 'io.swagger:swagger-codegen-cli:2.2.3' + alfrescoProvided("javax.servlet:servlet-api:$servletApiVersion") compileOnly 'io.swagger:swagger-annotations:1.5.6' compileOnly 'javax.validation:validation-api:1.1.0.Final' compileOnly 'com.fasterxml.jackson.core:jackson-annotations:2.9.0' } -swaggerSources { - - model { - inputFile = file("src/main/resources/swagger.yaml") - code { - language = 'spring' - additionalProperties = [ - "modelPackage" : "eu.xenit.actuators.model.gen", - "serializableModel": "true" - ] - // Only generate model: - components = ['models'] - } - } - -} - -processResources { - filesMatching("**/module.properties") { - expand project.properties - } -} - -sourceSets { - main { - java { - srcDirs = ["src/main/java", "$generateSwaggerCodeModel.outputDir/src/main/java"] - } - resources { - srcDirs = ['src/main/resources'] - } - amp { - module("src/main/resources/alfresco/module/alfresco-actuators/module.properties") - } - } -} - +apply from: "${rootProject.projectDir}/swaggerCodeGen.gradle" -compileJava.dependsOn generateSwaggerCodeModel publishing { publications { diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/alfresco-global.properties b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/alfresco-global.properties similarity index 100% rename from alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/alfresco-global.properties rename to alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/alfresco-global.properties diff --git a/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/AlfrescoActuatorsACP.acp b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/AlfrescoActuatorsACP.acp new file mode 100644 index 0000000000000000000000000000000000000000..76fc722fa5e452e0bd3b0b11cd82cf0f64158dac GIT binary patch literal 2363 zcma)-c{~*8AIHb!7!^_~BO!$dxs8d{j3Eq~s9dq+m_j>K1~Z04D4~oq3~Ss5U9NQ& z61gYjYG)c(jHBFStX~$d?YFP?wfp_&^IV_j`Fx*$-YDcQP6Yr61OnW_#aIHq)y8%m z1N;PldAQzk@pQt#oN!)_ILs|im>%l16XqA3%P%-3MI0W-0ob?c`M>hQN&`4z7hF95 z)qSuDwi_S;;(YaVsyAIe#Jp*GqvwV&Rm!Hj=ylj9u_LjWt7rK>eRlQ;G*0Z^gF^Cv zl7vD-6t`bf-d5B$;DHhbo>1THAWP8jqL*Y-@LxrcWOAB?uXV`TfE6kyEl^9ec=v{79I-#%ezo*j&Wh?g zHBp}7FijC+MoS|Nr+<4r1nZuvhFAqa0Gr_fLPPJ=>$4=Ed*av3qAJ{?4q!%bhr4b zj*MMkh!qy@GP*ulo5sHjsX05VbRq~fg9-KvEALy8_jgJ9ngz5^$2VNX~>x@dm~*#O>(@4kYwKSni(ux(WB@}KXjETYwHEAJ{NiGbn4gcn+L3+9v3n5Y!Q4fY0=g34#6*xQfs<~pXS$|d zrxx_Ai;!#Ldf>za3t~7Oo6Sr1x%68*^u`l%Wm{aeZYcS=J~^B7?Gl2Gzf^o#HL@&B zb;T+(DSH6JqHXwX;MaN+h%JGMU3+uS4yE~@re1+gmUSvCKb^t%`tdKy=JAGYixn&}8>H|{VIn`?F4@J}No4}*tl4*a)wnm~?Dg&*uUV$lY zkt14xlV{`eQi@Kvy-|gQbxoR{NAX5ih_n{K#ulD|a|6tv^Sae~z?g^*7LOB=b%sDM zg4&xs#x7OC-y-zcDT$Oi#FYYJypI&ITBVsx*ej=zpIVpa-F8ey;4t((dn{FaF#nEG z-(s=dy0}e|GxM_{2;HJCmloKk!|XPpyPwGUowM27Ja5Kl&DJq!3Ai_e*4HekM?BJ=bzsWEzVyM> zLcx{7Dup5S;Sqt@J6(~3WBSAn(Z`yWnJN!TsED3vbJaFk-ly!De!Q*F3j@KNIQViA zjpGnkS$*(X3lsN-n%3?ypsV*1raXJSav+z%xL!?Ytshg+7QwLcK#J%wx})={uS|Ml z5bc^)iU2cvqfq-oM)7BoLFeuAk5BJ^DxM>hyI>)vJZ%qI%Y{b+7$`@u$iaBjf$8Po z4fMvH@}&=O4TiOH0xPh}q?eIyf*RX?B zekb_^_)N%p)v3dZjKutS|E9b6>w#PX;kz$_zgW5ie7+&x)C|^ky%;LMWuhZ=^?=8< z1v8{%-|AHjb$*KnzWqjeNk8f8XdmHqYY;Rpvq|^7d5V?4sDgb#jtHHf7*7r>?h4S& zNS?a{EPA0ckjQ`Kp_R;J=En#DH`RK^!u%MO|ptmrKnk5>+_l5OYM+3!JpG9Yk3-jQR2|c$VCB7aGQ$s{Z zEd&!c>bSmPG&dO}I`ipC%ycIV=QD*)+5dWwI8qnkQ^~{5l0*)g};br@mBxE}6 z&i9jQG$s=98D?;WdHdM~L3x)3pG2{1=Wn+jcofCMOh{(T)FeGQndQF(K>+W~QR2Lc zKg>O9V`jN}#q8DXhBo~AMR${Ws|t@LJh``Umj>Qa6p{m|0Qd{tn`Hb8-NxH&+?37L z9|7%eAQuJf0Cfkj-`xTD?@<4Hu+8v0!Gr;@?=JnPU|V<=1?;rC(|Y}PUN7vwpc;kb w=9b?!Z2r?u0k;P`D#5X}P|mZZ-+X_L`axUs&21Et>(Ac@0)T+c^IK>C2iB()a{vGU literal 0 HcmV?d00001 diff --git a/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/bootstrap.xml b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/bootstrap.xml new file mode 100644 index 0000000..7998d4d --- /dev/null +++ b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/bootstrap/bootstrap.xml @@ -0,0 +1,28 @@ + + + + + + eu.xenit.alfresco-actuators.alfresco-actuators.filesLoader + + + + 0 + + + ${version.schema} + + + 99999 + + + + + UPDATE_EXISTING + /${spaces.company_home.childname}/${spaces.dictionary.childname} + alfresco/module/alfresco-actuators/bootstrap/AlfrescoActuatorsACP.acp + + + + diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/services-context.xml b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/services-context.xml similarity index 66% rename from alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/services-context.xml rename to alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/services-context.xml index a361644..0f92791 100644 --- a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/services-context.xml +++ b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/services-context.xml @@ -9,12 +9,14 @@ - + + + class="eu.xenit.actuators.services.LicenseInfoService"> + class="eu.xenit.actuators.services.StatusInfoService"> \ No newline at end of file diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/webscripts-context.xml b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/webscripts-context.xml similarity index 72% rename from alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/webscripts-context.xml rename to alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/webscripts-context.xml index 185cd0a..48e2992 100644 --- a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/context/webscripts-context.xml +++ b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/context/webscripts-context.xml @@ -4,9 +4,9 @@ + parent="webscript"/> + class="eu.xenit.actuators.webscripts.classical.HealthDetailsWebScript" + parent="webscript"/> \ No newline at end of file diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/log4j.properties b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/log4j.properties similarity index 100% rename from alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/log4j.properties rename to alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/log4j.properties diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module-context.xml b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/module-context.xml similarity index 72% rename from alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module-context.xml rename to alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/module-context.xml index d79f960..72c1ae2 100644 --- a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module-context.xml +++ b/alfresco-actuators/src/main/amp/config/alfresco/module/alfresco-actuators/module-context.xml @@ -2,4 +2,5 @@ + diff --git a/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.desc.xml b/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.desc.xml similarity index 100% rename from alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.desc.xml rename to alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.desc.xml diff --git a/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl b/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl similarity index 100% rename from alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl rename to alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl diff --git a/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.desc.xml b/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.desc.xml similarity index 100% rename from alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.desc.xml rename to alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.desc.xml diff --git a/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl b/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl new file mode 100644 index 0000000..7227312 --- /dev/null +++ b/alfresco-actuators/src/main/amp/config/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/healthdetails.get.json.ftl @@ -0,0 +1 @@ +${json} \ No newline at end of file diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/Health.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/Health.java deleted file mode 100644 index 477f019..0000000 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/Health.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.xenit.actuators; - -public class Health { - - private HealthStatus status; - private Object details; - - public Object getDetails() { - return details; - } - - public void setDetails(Object details) { - this.details = details; - } - - - public HealthStatus getStatus() { - return status; - } - - public void setStatus(HealthStatus status) { - this.status = status; - } - -} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthDetailsError.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthDetailsError.java deleted file mode 100644 index d668f13..0000000 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthDetailsError.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.xenit.actuators; - -public class HealthDetailsError { - - private final String error; - - public HealthDetailsError(String error) { - this.error = error; - } - - public String getError() { - return this.error; - } - -} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthIndicator.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthIndicator.java index 76167cd..94a7e6b 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthIndicator.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthIndicator.java @@ -1,5 +1,22 @@ package eu.xenit.actuators; -public interface HealthIndicator { - Health isHealthy(); +import eu.xenit.actuators.model.gen.HealthInfo; +import eu.xenit.actuators.model.gen.StatusEnum; + + +public abstract class HealthIndicator { + public HealthInfo isHealthy() { + HealthInfo health = new HealthInfo(); + health.setName(this.getClass().getSimpleName()); + try { + health.setDetails(getHealthDetails()); + health.setStatus(StatusEnum.UP); + } catch (Exception exception) { + health.setStatus(StatusEnum.DOWN); + health.setError(exception.getMessage()); + } + return health; + } + + protected abstract Object getHealthDetails() throws Exception; } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthStatus.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthStatus.java deleted file mode 100644 index 194746e..0000000 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/HealthStatus.java +++ /dev/null @@ -1,6 +0,0 @@ -package eu.xenit.actuators; - -public enum HealthStatus { - UP, - DOWN -} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/AlfrescoInfoService.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/AlfrescoInfoService.java index 6b70385..1eba600 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/AlfrescoInfoService.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/AlfrescoInfoService.java @@ -1,19 +1,8 @@ package eu.xenit.actuators.services; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthDetailsError; import eu.xenit.actuators.HealthIndicator; -import eu.xenit.actuators.HealthStatus; import eu.xenit.actuators.model.gen.AlfrescoInfo; import eu.xenit.actuators.model.gen.ModuleInfo; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.stream.Collectors; - import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.service.cmr.module.ModuleService; import org.alfresco.service.descriptor.Descriptor; @@ -24,9 +13,17 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.stream.Collectors; + @Service -public class AlfrescoInfoService implements HealthIndicator { +public class AlfrescoInfoService extends HealthIndicator { private static final Logger logger = LoggerFactory.getLogger(AlfrescoInfoService.class); @@ -39,7 +36,8 @@ public class AlfrescoInfoService implements HealthIndicator { @Qualifier("global-properties") private Properties globalProperties; - AlfrescoInfo getAlfrescoInfo() { + @Override + protected AlfrescoInfo getHealthDetails() { ManifestInfo manifestInfo = ManifestInfo.getInstance(); Descriptor serverDescriptor = descriptorService.getServerDescriptor(); @@ -58,20 +56,6 @@ AlfrescoInfo getAlfrescoInfo() { } - String getVersion() { - Descriptor serverDescriptor = descriptorService.getServerDescriptor(); - return serverDescriptor.getVersion(); - } - - String getEdition() { - Descriptor serverDescriptor = descriptorService.getServerDescriptor(); - return serverDescriptor.getEdition(); - } - - Map getManifestProperties() { - return ManifestInfo.getInstance().getManifestProperties(); - } - private Map retrieveFilteredProperties() { final String PROP_FILTERED_PREFIX = "prefix.properties.filtered"; @@ -107,16 +91,4 @@ private static ModuleInfo toAlfrescoModule(ModuleDetails moduleDetails) { .version(moduleDetails.getProperties().getProperty(ModuleDetails.PROP_VERSION)); } - @Override - public Health isHealthy() { - Health health = new Health(); - try { - health.setDetails(getAlfrescoInfo()); - health.setStatus(HealthStatus.UP); - } catch (Exception exception) { - health.setStatus(HealthStatus.DOWN); - health.setDetails(new HealthDetailsError(exception.getMessage())); - } - return health; - } } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/ContentInfoService.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/ContentInfoService.java new file mode 100644 index 0000000..4cf579e --- /dev/null +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/ContentInfoService.java @@ -0,0 +1,43 @@ +package eu.xenit.actuators.services; + +import eu.xenit.actuators.HealthIndicator; +import eu.xenit.actuators.model.gen.ContentStoreInfo; +import org.alfresco.model.ContentModel; +import org.alfresco.service.cmr.repository.ContentData; +import org.alfresco.service.cmr.repository.ContentReader; +import org.alfresco.service.cmr.repository.ContentService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.io.InputStream; + + +@Service +public class ContentInfoService extends HealthIndicator { + + @Autowired + private NodeService nodeService; + @Autowired + private ContentService contentService; + + @Override + protected ContentStoreInfo getHealthDetails() throws IOException { + long start = System.currentTimeMillis(); + //it is fixed node ref for a file uploaded using acp + //under path /app:company_home/app:dictionary/cm:Alfresco_x0020_Actuators/cm:alfresco-actuators.txt + NodeRef node = new NodeRef("workspace://SpacesStore/b9da637d-c86b-4ecc-b676-ea1cd60e61b0"); + AccessContentForNode(node); + return new ContentStoreInfo().accessTime(System.currentTimeMillis() - start); + } + + private boolean AccessContentForNode(NodeRef node) throws IOException { + final ContentData contentData = (ContentData) nodeService.getProperty(node, ContentModel.PROP_CONTENT); + ContentReader contentReader = contentService.getRawReader(contentData.getContentUrl()); + try (InputStream ignored = contentReader.getContentInputStream()) { + return true; + } + } +} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/LicenseInfoService.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/LicenseInfoService.java index 63deb22..445e4f4 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/LicenseInfoService.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/LicenseInfoService.java @@ -1,24 +1,17 @@ package eu.xenit.actuators.services; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthDetailsError; import eu.xenit.actuators.HealthIndicator; -import eu.xenit.actuators.HealthStatus; import eu.xenit.actuators.model.gen.LicenseInfo; import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.license.LicenseDescriptor; import org.alfresco.service.license.LicenseService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; @Service -public class LicenseInfoService implements HealthIndicator { - - private static final Logger logger = LoggerFactory.getLogger(LicenseInfoService.class); +public class LicenseInfoService extends HealthIndicator { @Autowired(required = false) private LicenseService licenseService; @@ -28,7 +21,18 @@ public class LicenseInfoService implements HealthIndicator { @Qualifier("DescriptorService") private DescriptorService descriptorService; - public LicenseInfo retrieveLicenseInfo() { + @Override + protected Object getHealthDetails() { + LicenseInfo licenseInfo = retrieveLicenseInfo(); + //community + if (licenseInfo != null) { + return licenseInfo; + } else { + return "No license required for community"; + } + } + + private LicenseInfo retrieveLicenseInfo() { if (licenseService == null) { licenseService = appContext.getBeansOfType(LicenseService.class).get("licenseService"); } @@ -50,23 +54,5 @@ public LicenseInfo retrieveLicenseInfo() { .heartbeatDisabled(licenseDescriptor.isHeartBeatDisabled()); } - @Override - public Health isHealthy() { - Health health = new Health(); - try { - LicenseInfo licenseInfo = retrieveLicenseInfo(); - //community - if (licenseInfo != null) { - health.setDetails(licenseInfo); - } else { - health.setDetails(new HealthDetailsError("No license required for community")); - } - health.setStatus(HealthStatus.UP); - } catch (Exception exception) { - logger.error("Problem retrieving license info",exception); - health.setStatus(HealthStatus.DOWN); - health.setDetails(new HealthDetailsError(exception.getMessage())); - } - return health; - } + } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/StatusInfoService.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/StatusInfoService.java index b7b6ea4..7644e43 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/StatusInfoService.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/StatusInfoService.java @@ -1,26 +1,18 @@ package eu.xenit.actuators.services; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthDetailsError; import eu.xenit.actuators.HealthIndicator; -import eu.xenit.actuators.HealthStatus; import eu.xenit.actuators.model.gen.StatusInfo; -import java.util.Properties; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.service.cmr.admin.RepoAdminService; import org.alfresco.service.cmr.audit.AuditService; import org.alfresco.service.cmr.thumbnail.ThumbnailService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @Service -public class StatusInfoService implements HealthIndicator { +public class StatusInfoService extends HealthIndicator { - private static final Logger logger = LoggerFactory.getLogger(StatusInfoService.class); @Autowired private RepoAdminService repoAdminService; @@ -30,12 +22,11 @@ public class StatusInfoService implements HealthIndicator { private ThumbnailService thumbnailService; @Autowired private RetryingTransactionHelper retryingTransactionHelper; - @Autowired - @Qualifier("global-properties") - private Properties globalProperties; + // needs authentication - protected StatusInfo retrieveStatusInfo() { + @Override + protected StatusInfo getHealthDetails() { final StatusInfo statusInfo = new StatusInfo(); retryingTransactionHelper.doInTransaction(() -> { AuthenticationUtil.runAs(() -> { @@ -50,18 +41,4 @@ protected StatusInfo retrieveStatusInfo() { return statusInfo; } - @Override - public Health isHealthy() { - Health health = new Health(); - try { - StatusInfo statusInfo = retrieveStatusInfo(); - health.setDetails(statusInfo); - health.setStatus(HealthStatus.UP); - } catch (Exception exception) { - logger.error("Problem retrieving Status info", exception); - health.setStatus(HealthStatus.DOWN); - health.setDetails(new HealthDetailsError(exception.getMessage())); - } - return health; - } } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/SystemInfoService.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/SystemInfoService.java index 4f5d8f8..44248fb 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/services/SystemInfoService.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/services/SystemInfoService.java @@ -1,13 +1,12 @@ package eu.xenit.actuators.services; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthDetailsError; import eu.xenit.actuators.HealthIndicator; -import eu.xenit.actuators.HealthStatus; import eu.xenit.actuators.model.gen.CpuInfo; import eu.xenit.actuators.model.gen.JavaInfo; import eu.xenit.actuators.model.gen.OperatingSystemInfo; import eu.xenit.actuators.model.gen.SystemInfo; +import org.springframework.stereotype.Service; + import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.lang.management.OperatingSystemMXBean; @@ -16,17 +15,14 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; @Service -public class SystemInfoService implements HealthIndicator { +public class SystemInfoService extends HealthIndicator { - private static final Logger logger = LoggerFactory.getLogger(SystemInfoService.class); - private SystemInfo getSystemInfo() { + @Override + protected SystemInfo getHealthDetails() { return new SystemInfo() .os(osInfo()) .java(javaInfo()) @@ -34,9 +30,8 @@ private SystemInfo getSystemInfo() { } - private static OperatingSystemInfo osInfo() { + private OperatingSystemInfo osInfo() { OperatingSystemMXBean osMXBean = ManagementFactory.getOperatingSystemMXBean(); - return new OperatingSystemInfo() .name(osMXBean.getName()) .version(osMXBean.getVersion()) @@ -44,7 +39,7 @@ private static OperatingSystemInfo osInfo() { } - private static JavaInfo javaInfo() { + private JavaInfo javaInfo() { List gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans(); @@ -69,24 +64,10 @@ private static JavaInfo javaInfo() { .systemProperties(javaProperties); } - private static CpuInfo cpuInfo() { + private CpuInfo cpuInfo() { OperatingSystemMXBean osMXBean = ManagementFactory.getOperatingSystemMXBean(); return new CpuInfo() .processors(osMXBean.getAvailableProcessors()); } - @Override - public Health isHealthy() { - Health health = new Health(); - try { - SystemInfo systemInfo = getSystemInfo(); - health.setStatus(HealthStatus.UP); - health.setDetails(systemInfo); - } catch (Exception e) { - logger.error("Problem retrieving system info", e); - health.setStatus(HealthStatus.DOWN); - health.setDetails(new HealthDetailsError(e.getMessage())); - } - return health; - } } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/AbstractHealthWebScript.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/AbstractHealthWebScript.java new file mode 100644 index 0000000..9a25857 --- /dev/null +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/AbstractHealthWebScript.java @@ -0,0 +1,65 @@ +package eu.xenit.actuators.webscripts.classical; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import eu.xenit.actuators.HealthIndicator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +import java.util.HashMap; +import java.util.Map; + +public abstract class AbstractHealthWebScript extends DeclarativeWebScript implements ManifestSettingWebScript { + private static final Logger logger = LoggerFactory.getLogger(AbstractHealthWebScript.class); + + @Autowired + protected ApplicationContext applicationContext; + protected final ObjectMapper objectMapper = new ObjectMapper(); + + AbstractHealthWebScript() { + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + + protected Map getHealthIndicators() { + return applicationContext.getBeansOfType(HealthIndicator.class); + } + + protected Map fillModel(Status status, Object object) { + final Map model = new HashMap<>(); + try { + model.put("json", objectMapper.writeValueAsString(object)); + } catch (JsonProcessingException e) { + String message = "Exception writing health to json"; + logger.error(message, e); + status.setCode(Status.STATUS_INTERNAL_SERVER_ERROR, "Exception writing health to json"); + } + return model; + } + + @Override + protected Map executeImpl(WebScriptRequest request, Status status, Cache cache) { + setManifestProperties(request); + Map indicators = getHealthIndicators(); + String disableParam = request.getParameter("disabled"); + if (disableParam != null && !disableParam.isEmpty()) { + for (String indicatorName : disableParam.split(",")) { + if (indicators.containsKey(indicatorName)) { + logger.debug("disabling indicator with name {}", indicatorName); + indicators.remove(indicatorName); + } else { + logger.info("indicator with name {} was not found nothing will be removed", indicatorName); + } + } + } + return fillModel(status, executeHealth(indicators, status)); + } + + protected abstract Object executeHealth(Map indicators, Status status); +} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthDetailsWebScript.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthDetailsWebScript.java new file mode 100644 index 0000000..a162015 --- /dev/null +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthDetailsWebScript.java @@ -0,0 +1,20 @@ +package eu.xenit.actuators.webscripts.classical; + +import eu.xenit.actuators.HealthIndicator; +import eu.xenit.actuators.model.gen.HealthInfo; +import org.springframework.extensions.webscripts.Status; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class HealthDetailsWebScript extends AbstractHealthWebScript { + @Override + protected List executeHealth(Map indicators, Status status) { + return indicators + .values() + .stream() + .map(HealthIndicator::isHealthy) + .collect(Collectors.toList()); + } +} diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthWebScript.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthWebScript.java index e7df04f..9cef4ae 100644 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthWebScript.java +++ b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthWebScript.java @@ -1,42 +1,31 @@ package eu.xenit.actuators.webscripts.classical; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthDetailsError; import eu.xenit.actuators.HealthIndicator; -import eu.xenit.actuators.HealthStatus; -import java.util.HashMap; -import java.util.Map; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; +import eu.xenit.actuators.model.gen.HealthInfo; +import eu.xenit.actuators.model.gen.HealthStatus; +import eu.xenit.actuators.model.gen.StatusEnum; import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; -public class HealthWebScript extends DeclarativeWebScript implements ManifestSettingWebScript { +import java.util.Map; - @Autowired - private ApplicationContext applicationContext; +public class HealthWebScript extends AbstractHealthWebScript { - @Override - protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - setManifestProperties(req); - final Map model = new HashMap<>(); - model.put("health", "UP"); - String message = ""; - Map indicators = applicationContext.getBeansOfType(HealthIndicator.class); + @Override + protected HealthStatus executeHealth(Map indicators, Status status) { + HealthStatus healthStatus = new HealthStatus(); + healthStatus.setStatus(StatusEnum.UP); for (HealthIndicator indicator : indicators.values()) { - Health health = indicator.isHealthy(); - if (health.getStatus().equals(HealthStatus.DOWN)) { - model.put("health", health.getStatus()); + HealthInfo health = indicator.isHealthy(); + if (StatusEnum.DOWN.equals(health.getStatus())) { + healthStatus.setStatus(health.getStatus()); status.setCode(Status.STATUS_INTERNAL_SERVER_ERROR); - status.setMessage(((HealthDetailsError) health.getDetails()).getError()); + healthStatus.setMessage(health.getName() + " failed with error: " + health.getError()); + status.setMessage(health.getError()); break; } } - model.put("message", message); - - return model; + return healthStatus; } + } diff --git a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthdetailsWebScript.java b/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthdetailsWebScript.java deleted file mode 100644 index 31de195..0000000 --- a/alfresco-actuators/src/main/java/eu/xenit/actuators/webscripts/classical/HealthdetailsWebScript.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.xenit.actuators.webscripts.classical; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.xenit.actuators.Health; -import eu.xenit.actuators.HealthIndicator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptRequest; - -public class HealthdetailsWebScript extends DeclarativeWebScript implements ManifestSettingWebScript { - - private static final Logger logger = LoggerFactory.getLogger(HealthdetailsWebScript.class); - - private final ApplicationContext applicationContext; - private final ObjectMapper objectMapper = new ObjectMapper(); - - @Autowired - public HealthdetailsWebScript(ApplicationContext applicationContext) { - this.applicationContext = applicationContext; - } - - @Override - protected Map executeImpl(WebScriptRequest request, Status status, Cache cache) { - setManifestProperties(request); - final Map model = new HashMap<>(); - Map indicators = applicationContext.getBeansOfType(HealthIndicator.class); - List> healthList = indicators.values().stream() - .map(it -> { - Map healthMap = new HashMap<>(); - healthMap.put(it.getClass().getName(), it.isHealthy()); - return healthMap; - }).collect(Collectors.toList()); - try { - model.put("json", objectMapper.writeValueAsString(healthList)); - } catch (JsonProcessingException e) { - String message = "Exception writing health to json"; - logger.error(message, e); - status.setCode(Status.STATUS_INTERNAL_SERVER_ERROR, "Exception writing health to json"); - } - return model; - } -} diff --git a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module.properties b/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module.properties deleted file mode 100644 index 67aad3f..0000000 --- a/alfresco-actuators/src/main/resources/alfresco/module/alfresco-actuators/module.properties +++ /dev/null @@ -1,4 +0,0 @@ -module.id=${project.name} -module.title=${project.name} -module.description=${project.description} -module.version=${project.version} diff --git a/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl b/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl deleted file mode 100644 index 69bc795..0000000 --- a/alfresco-actuators/src/main/resources/alfresco/templates/webscripts/eu/xenit/actuators/webscripts/health.get.json.ftl +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status":"${health}" -} diff --git a/build.gradle b/build.gradle index e47bcfa..ee8c403 100644 --- a/build.gradle +++ b/build.gradle @@ -1,24 +1,33 @@ + plugins { id 'eu.xenit.docker-compose' version '5.3.2' apply false + id 'org.hidetake.swagger.generator' version '2.19.2' apply false id 'eu.xenit.alfresco' version "1.1.0" id 'be.vbgn.ci-detect' version '0.5.0' - id 'org.ajoberstar.reckon' version '0.16.1' } -reckon { - snapshots() - calcStageFromProp() -} subprojects { group = 'eu.xenit.alfresco-actuators' apply plugin: 'eu.xenit.alfresco' - + version = '1.0.0' + boolean isRelease = ci.branch?.startsWith("release") + if (!isRelease) { + version += "-SNAPSHOT" + } repositories { mavenCentral() - alfrescoPublic() - alfrescoEnterprise() + maven { + url 'https://artifacts.alfresco.com/nexus/content/repositories/public/' + } + maven { + url 'https://artifacts.alfresco.com/nexus/content/groups/private' + credentials { + username project.property('org.alfresco.maven.nexus.username') + password project.property('org.alfresco.maven.nexus.password') + } + } } apply from: "${rootProject.projectDir}/publish.gradle" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..f42e62f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/integration-tests/alfresco-community-61/overload.gradle b/integration-tests/alfresco-community-61/overload.gradle index c7c3534..27f53a8 100644 --- a/integration-tests/alfresco-community-61/overload.gradle +++ b/integration-tests/alfresco-community-61/overload.gradle @@ -1,6 +1,6 @@ ext { alfrescoBaseWar = 'org.alfresco:content-services-community:6.1.2-ga@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:6.1.2-ga' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:6.1' postgresImage = 'postgres:10.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-62/overload.gradle b/integration-tests/alfresco-community-62/overload.gradle index 2e8a1e7..ece83cb 100644 --- a/integration-tests/alfresco-community-62/overload.gradle +++ b/integration-tests/alfresco-community-62/overload.gradle @@ -1,6 +1,6 @@ ext { alfrescoBaseWar = 'org.alfresco:content-services-community:6.2.0-ga@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:6.2.0-ga' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:6.2' postgresImage = 'postgres:10.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-70/overload.gradle b/integration-tests/alfresco-community-70/overload.gradle index befd8a7..d96bcc7 100644 --- a/integration-tests/alfresco-community-70/overload.gradle +++ b/integration-tests/alfresco-community-70/overload.gradle @@ -2,7 +2,7 @@ ext { alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.0.0' alfrescoBaseWar = 'org.alfresco:content-services-community@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:7.0.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.0' postgresImage = 'postgres:13.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-71/overload.gradle b/integration-tests/alfresco-community-71/overload.gradle index 09e6a12..6354880 100644 --- a/integration-tests/alfresco-community-71/overload.gradle +++ b/integration-tests/alfresco-community-71/overload.gradle @@ -2,7 +2,7 @@ ext { alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.1.1' alfrescoBaseWar = 'org.alfresco:content-services-community@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:7.1.1' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.1' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-72/overload.gradle b/integration-tests/alfresco-community-72/overload.gradle index af137ac..cdd951f 100644 --- a/integration-tests/alfresco-community-72/overload.gradle +++ b/integration-tests/alfresco-community-72/overload.gradle @@ -1,8 +1,8 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.2.0' + alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.2.1' alfrescoBaseWar = 'org.alfresco:content-services-community@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:7.2.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.2' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-73/overload.gradle b/integration-tests/alfresco-community-73/overload.gradle index 9312432..d427c48 100644 --- a/integration-tests/alfresco-community-73/overload.gradle +++ b/integration-tests/alfresco-community-73/overload.gradle @@ -2,7 +2,7 @@ ext { alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.3.0' alfrescoBaseWar = 'org.alfresco:content-services-community@war' - alfrescoBaseImage = 'xenit/alfresco-repository-community:7.3.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.3' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-community-74/overload.gradle b/integration-tests/alfresco-community-74/overload.gradle new file mode 100644 index 0000000..091c45f --- /dev/null +++ b/integration-tests/alfresco-community-74/overload.gradle @@ -0,0 +1,8 @@ +ext { + alfrescoBaseWarBom = 'org.alfresco:acs-community-packaging:7.4.0.1' + alfrescoBaseWar = 'org.alfresco:content-services-community@war' + + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.4' + + postgresImage = 'postgres:13' +} \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-61/overload.gradle b/integration-tests/alfresco-enterprise-61/overload.gradle index 226f06b..9e0c454 100644 --- a/integration-tests/alfresco-enterprise-61/overload.gradle +++ b/integration-tests/alfresco-enterprise-61/overload.gradle @@ -1,7 +1,7 @@ ext { alfrescoBaseWarBom = 'org.alfresco:acs-packaging:6.1.1.11' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:6.1.1' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:6.1' postgresImage = 'postgres:10.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-62/overload.gradle b/integration-tests/alfresco-enterprise-62/overload.gradle index 6f199ee..dbcfa1b 100644 --- a/integration-tests/alfresco-enterprise-62/overload.gradle +++ b/integration-tests/alfresco-enterprise-62/overload.gradle @@ -1,7 +1,7 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-packaging:6.2.2.19' + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:6.2.2.25' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:6.2.2.19' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:6.2' postgresImage = 'postgres:10.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-70/overload.gradle b/integration-tests/alfresco-enterprise-70/overload.gradle index 13e9135..18ccef9 100644 --- a/integration-tests/alfresco-enterprise-70/overload.gradle +++ b/integration-tests/alfresco-enterprise-70/overload.gradle @@ -1,8 +1,8 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.0.1.3' + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.0.1.9' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:7.0.1.3' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.0' postgresImage = 'postgres:13.1' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-71/overload.gradle b/integration-tests/alfresco-enterprise-71/overload.gradle index a469e65..3c60fee 100644 --- a/integration-tests/alfresco-enterprise-71/overload.gradle +++ b/integration-tests/alfresco-enterprise-71/overload.gradle @@ -1,8 +1,8 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.1.0' + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.1.0.6' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:7.1.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.1' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-72/overload.gradle b/integration-tests/alfresco-enterprise-72/overload.gradle index be45534..5b5fffd 100644 --- a/integration-tests/alfresco-enterprise-72/overload.gradle +++ b/integration-tests/alfresco-enterprise-72/overload.gradle @@ -1,8 +1,8 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.2.0' + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.2.1.13' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:7.2.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.2' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-73/overload.gradle b/integration-tests/alfresco-enterprise-73/overload.gradle index 7f9843c..de6fb64 100644 --- a/integration-tests/alfresco-enterprise-73/overload.gradle +++ b/integration-tests/alfresco-enterprise-73/overload.gradle @@ -1,8 +1,8 @@ ext { - alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.3.0' + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.3.1.2' alfrescoBaseWar = 'org.alfresco:content-services@war' - alfrescoBaseImage = 'docker.xenit.eu/private/alfresco-enterprise/alfresco-repository-enterprise:7.3.0' + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.3' postgresImage = 'postgres:13' } \ No newline at end of file diff --git a/integration-tests/alfresco-enterprise-74/overload.gradle b/integration-tests/alfresco-enterprise-74/overload.gradle new file mode 100644 index 0000000..2e46bdc --- /dev/null +++ b/integration-tests/alfresco-enterprise-74/overload.gradle @@ -0,0 +1,8 @@ +ext { + alfrescoBaseWarBom = 'org.alfresco:acs-packaging:7.4.1.3' + alfrescoBaseWar = 'org.alfresco:content-services@war' + + alfrescoBaseImage = 'xenit/alfresco-repository-skeleton:7.4' + + postgresImage = 'postgres:13' +} \ No newline at end of file diff --git a/integration-tests/build.gradle b/integration-tests/build.gradle index a6a1be1..262f630 100644 --- a/integration-tests/build.gradle +++ b/integration-tests/build.gradle @@ -15,6 +15,7 @@ java { sourceCompatibility = JavaVersion.VERSION_11 } + dependencies { testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junitJupiterVersion}" @@ -25,8 +26,14 @@ dependencies { testImplementation group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}" testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: "${slf4jVersion}" -} + implementation 'javax.annotation:javax.annotation-api:1.3.2' + implementation 'io.swagger:swagger-annotations:1.5.6' + implementation 'javax.validation:validation-api:1.1.0.Final' + implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.5' +} +apply from: "${rootProject.projectDir}/swaggerCodeGen.gradle" test { // By default tests should only run in the subprojects. To manually run tests in your IDEA, uncomment: enabled = false @@ -38,6 +45,8 @@ test { subprojects { apply plugin: 'java' + apply plugin: 'eu.xenit.docker-alfresco' + apply plugin: 'eu.xenit.docker-compose.auto' def alfrescoVersion = project.name[-2..-1] apply from: "${project.projectDir}/overload.gradle" @@ -60,34 +69,23 @@ subprojects { maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 } - apply plugin: 'eu.xenit.docker-alfresco' - apply plugin: 'eu.xenit.docker-compose.auto' - - configurations { - sharedLib - } - dependencies { if (project.hasProperty("alfrescoBaseWarBom")) { baseAlfrescoWar platform("${alfrescoBaseWarBom}") + alfrescoAmp platform("${alfrescoBaseWarBom}") + alfrescoAmp "org.alfresco:alfresco-share-services@amp" } baseAlfrescoWar "${alfrescoBaseWar}" alfrescoAmp project(path: ":alfresco-actuators", configuration: "amp") - - if (alfrescoBaseImage.contains("alfresco-repository-skeleton")) { - sharedLib 'org.postgresql:postgresql:42.2.6' - } + alfrescoSM 'org.postgresql:postgresql:42.2.6' + alfrescoSM "org.orderofthebee.support-tools:support-tools-repo:1.2.0.0" } dockerAlfresco { baseImage = "${alfrescoBaseImage}" - leanImage = !alfrescoBaseImage.contains("alfresco-repository-skeleton") - } - - createDockerFile { - smartCopy(configurations.sharedLib, '${CATALINA_HOME}/shared/lib/') + leanImage = false } dockerCompose { diff --git a/integration-tests/src/test/java/eu/xenit/actuators/integrationtesting/ActuatorsEndpointSmokeTest.java b/integration-tests/src/test/java/eu/xenit/actuators/integrationtesting/ActuatorsEndpointSmokeTest.java index 6d78d99..5b07192 100644 --- a/integration-tests/src/test/java/eu/xenit/actuators/integrationtesting/ActuatorsEndpointSmokeTest.java +++ b/integration-tests/src/test/java/eu/xenit/actuators/integrationtesting/ActuatorsEndpointSmokeTest.java @@ -1,23 +1,80 @@ package eu.xenit.actuators.integrationtesting; +import eu.xenit.actuators.model.gen.HealthInfo; +import eu.xenit.actuators.model.gen.StatusEnum; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.Set; +import java.util.stream.Collectors; + import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.containsString; class ActuatorsEndpointSmokeTest extends RestAssuredTest { @Test void testClassicalEndpoint() { - final String healthInfo = given() + final HealthInfo healthInfo = given() .log().ifValidationFails() .when() .get("/s/xenit/actuators/health") .then() .log().ifValidationFails() .statusCode(200) - .body(containsString("\"status\":\"UP\"")) - .toString(); + .extract().body().as(HealthInfo.class); + Assertions.assertEquals(StatusEnum.UP, healthInfo.getStatus()); + } + + @Test + void testDetailsEndpoint() { + final ArrayList healthInfos = given() + .log().ifValidationFails() + .auth().preemptive().basic("admin", "admin") + .when() + .get("/s/xenit/actuators/health/details") + .then() + .log().ifValidationFails() + .statusCode(200) + .extract().body().as(HealthInfoList.class); + Assertions.assertTrue(healthInfos + .stream() + .map(HealthInfo::getName) + .collect(Collectors.toSet()) + .containsAll( + Set.of("SystemInfoService", + "AlfrescoInfoService", + "ContentInfoService", + "LicenseInfoService", + "StatusInfoService"))); + } + + @Test + void testDisabledDetailsEndpoint() { + final ArrayList healthInfos = given() + .log().ifValidationFails() + .auth().preemptive().basic("admin", "admin") + .when() + .get("/s/xenit/actuators/health/details?disabled=ContentInfoService,AlfrescoInfoService") + .then() + .log().ifValidationFails() + .statusCode(200) + .extract().body().as(HealthInfoList.class); + Set names = healthInfos + .stream() + .map(HealthInfo::getName) + .collect(Collectors.toSet()); + Assertions.assertTrue(names + .containsAll( + Set.of("SystemInfoService", + "LicenseInfoService", + "StatusInfoService"))); + Assertions.assertFalse(names.contains("AlfrescoInfoService")); + Assertions.assertFalse(names.contains("ContentInfoService")); + } + public static class HealthInfoList extends ArrayList { + + } } diff --git a/integration-tests/src/test/resources/compose/docker-compose.yml b/integration-tests/src/test/resources/compose/docker-compose.yml index 89d1e30..a8b58fb 100644 --- a/integration-tests/src/test/resources/compose/docker-compose.yml +++ b/integration-tests/src/test/resources/compose/docker-compose.yml @@ -4,16 +4,21 @@ services: alfresco: image: ${DOCKER_IMAGE} ports: - - target: 8080 - mode: host + - "8080:8080" + - "8000:8000" environment: - GLOBAL_local.transform.service.enabled=false - GLOBAL_legacy.transform.service.enabled=false - GLOBAL_index.subsystem.name=noindex - GLOBAL_ooo.enabled=false + - DEBUG=true +# - JAVA_OPTS_DEBUGH="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:8000" - GLOBAL_jodconverter.enabled=false - JAVA_OPTS=-Xmx312M # results in about ~670MB memory in use - + share: + image: private.docker.xenit.eu/customer/xenit/alfresco-alf1/share:latest + ports: + - "8081:8080" postgresql: image: ${POSTGRES_IMAGE} environment: diff --git a/publish.gradle b/publish.gradle index 4b39281..da2f501 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,50 +1,49 @@ -pluginManager.withPlugin('maven-publish') { - apply plugin: 'signing' - publishing { - repositories { - if ("${project.version}".endsWith('-SNAPSHOT')) { - sonatypeSnapshots { - credentials { - username = project.findProperty('publish_username') - password = project.findProperty('publish_password') - } - } - } else { - sonatypeMavenCentral { - credentials { - username = project.findProperty('publish_username') - password = project.findProperty('publish_password') - } - } +apply plugin: 'maven-publish' +apply plugin: 'signing' +publishing { + repositories { + maven { + def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + url = version.toString().endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + + credentials { + username = project.findProperty('sonatype_username') + password = project.findProperty('sonatype_password') } } - publications { - all { - pom { - url = 'https://github.com/xenit-eu/alfresco-actuators' - name = "alfresco-actuators" - description = project.description + } + publications { + all { + pom { + url = 'https://github.com/xenit-eu/alfresco-actuators' + name = "alfresco-actuators" + description = project.description - scm { - connection = 'scm:git:git@github.com:xenit-eu/alfresco-actuators.git' - developerConnection = 'scm:git:git@github.com:xenit-eu/alfresco-actuators.git' - url = 'https://github.com/xenit-eu/alfresco-actuators.git' - } - developers { - developer { - id = "xenit" - name = "Xenit Solutions NV" - } + scm { + connection = 'scm:git:git@github.com:xenit-eu/alfresco-actuators.git' + developerConnection = 'scm:git:git@github.com:xenit-eu/alfresco-actuators.git' + url = 'https://github.com/xenit-eu/alfresco-actuators.git' + } + developers { + developer { + id = "xenit" + name = "Xenit Solutions NV" } + } - licenses { - license { - name = 'GNU Lesser General Public License v3.0' - url = 'https://www.gnu.org/licenses/lgpl-3.0.txt' - } + licenses { + license { + name = 'GNU Lesser General Public License v3.0' + url = 'https://www.gnu.org/licenses/lgpl-3.0.txt' } } } } } } +signing { + required { !version.toString().endsWith("SNAPSHOT") } + useInMemoryPgpKeys(findProperty("signingKeyId"), findProperty("signingKey"), findProperty("signingPassword")) + sign publishing.publications +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 5e6cbfa..f1abb90 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,13 +1,10 @@ -plugins { - id 'eu.xenit.enterprise-conventions.oss' version '0.2.0' -} rootProject.name = 'alfresco-actuators' // Alfresco Actuators implementation include ':alfresco-actuators' include ':integration-tests' -["61", "62", "70", "71", "72", "73"].each { version -> +["61", "62", "70", "71", "72", "73", "74"].each { version -> include ":integration-tests:alfresco-community-${version}" include ":integration-tests:alfresco-enterprise-${version}" } diff --git a/alfresco-actuators/src/main/resources/swagger.yaml b/specifications/swagger.yaml similarity index 69% rename from alfresco-actuators/src/main/resources/swagger.yaml rename to specifications/swagger.yaml index 7672286..8acf6be 100644 --- a/alfresco-actuators/src/main/resources/swagger.yaml +++ b/specifications/swagger.yaml @@ -5,47 +5,81 @@ info: title: "Xenit System Information Module" contact: email: "engineering@xenit.eu" -basePath: "/alfresco/s/xenit/api/v1/health" +basePath: "/alfresco/s/xenit/actuators/health" tags: -- name: "System" - description: "System information API" + - name: "System" + description: "System information API" schemes: -- "http" + - "http" ########################################################################## # PATHS # ########################################################################## paths: - "/information": + "/": get: tags: - - "Health" - summary: "Retrieve health information of the system" + - "Health" + summary: "Retrieve health of the system" description: "Multiple status values can be provided with comma separated strings" operationId: "getHealthInfo" produces: - - "application/json" + - "application/json" responses: 200: description: "successful operation" schema: - $ref: "#/definitions/HealthInfo" - 400: + $ref: "#/definitions/HealthStatus" + 500: description: "Invalid status value" + schema: + $ref: "#/definitions/HealthStatus" + "/details": + get: + tags: + - "Health" + summary: "Retrieve health information of the system" + description: "Multiple status values can be provided with comma separated strings" + operationId: "getHealthInfo" + produces: + - "application/json" + responses: + 200: + description: "successful operation" + schema: + type: array + items: + $ref: "#/definitions/HealthInfo" + 500: + description: "Failed to write Object" ########################################################################## # DEFINITIONS # ########################################################################## definitions: -# ROOT + + # ROOT + HealthStatus: + type: object + properties: + status: + $ref: '#/definitions/StatusEnum' + message: + type: string + HealthInfo: type: object properties: - system: - $ref: '#/definitions/SystemInfo' - alfresco: - $ref: '#/definitions/AlfrescoInfo' -# SYSTEM + name: + type: string + status: + $ref: '#/definitions/StatusEnum' + error: + type: string + details: + type: object + additionalProperties: { } + # SYSTEM SystemInfo: type: object properties: @@ -88,7 +122,14 @@ definitions: type: integer format: int32 example: 4 -# ALFRESCO + ContentStoreInfo: + type: object + properties: + access-time: + type: integer + format: int64 + example: 4 + # ALFRESCO AlfrescoInfo: type: object properties: @@ -152,4 +193,9 @@ definitions: auditEnabled: type: boolean thumbnailGeneration: - type: boolean \ No newline at end of file + type: boolean + StatusEnum: + type: string + enum: + - UP + - DOWN \ No newline at end of file diff --git a/swaggerCodeGen.gradle b/swaggerCodeGen.gradle new file mode 100644 index 0000000..caa1331 --- /dev/null +++ b/swaggerCodeGen.gradle @@ -0,0 +1,34 @@ +apply plugin: 'org.hidetake.swagger.generator' +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + + +dependencies { + // Add dependency for Swagger Codegen CLI + swaggerCodegen 'io.swagger:swagger-codegen-cli:2.2.3' + +} +swaggerSources { + model { + inputFile = file("${rootProject.projectDir}/specifications/swagger.yaml") + code { + language = 'spring' + additionalProperties = [ + "modelPackage" : "eu.xenit.actuators.model.gen", + "serializableModel": "true" + ] + // Only generate model: + components = ['models'] + } + } + +} +compileJava.dependsOn generateSwaggerCodeModel +sourceSets { + main { + java { + srcDirs = ["src/main/java", "$generateSwaggerCodeModel.outputDir/src/main/java"] + } + } +}