mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
182 Commits
rm-7187-ev
...
20.45-DEV
Author | SHA1 | Date | |
---|---|---|---|
|
646211fea0 | ||
|
6520228db4 | ||
|
6c0c6d4872 | ||
|
bf89b6f154 | ||
|
3fd00f1d40 | ||
|
a490a23f9a | ||
|
547bcb4759 | ||
|
583467904a | ||
|
cc8dcc51e1 | ||
|
c59f0c9c4d | ||
|
c3b01aa89e | ||
|
60a04b0402 | ||
|
c50c10ef2b | ||
|
cdbe3292e0 | ||
|
2c860b827f | ||
|
54843fa336 | ||
|
c66bb48258 | ||
|
fdc8c0ade1 | ||
|
077752ad86 | ||
|
004ea6e049 | ||
|
d77fa7dead | ||
|
256398a15d | ||
|
1749b2d74b | ||
|
eea23b0d2a | ||
|
88b6a8e5b3 | ||
|
c8abb9d3fc | ||
|
d07a47d088 | ||
|
94cb9de79b | ||
|
28114338c8 | ||
|
78e1d5863c | ||
|
0aae95b255 | ||
|
841735491d | ||
|
42e29d95de | ||
|
5749a1a67a | ||
|
9dce05cb5b | ||
|
c1198a0145 | ||
|
6bd50fda1a | ||
|
ace6eca99b | ||
|
0f8349dc4c | ||
|
eb7bcbfbfb | ||
|
d9bbc9c628 | ||
|
5c434f7898 | ||
|
06a25a48da | ||
|
f511436823 | ||
|
f96b3012c4 | ||
|
415aa2ca33 | ||
|
b701f9a994 | ||
|
d04043b015 | ||
|
e3241fe178 | ||
|
ea8ed0eec3 | ||
|
f06f2edaa1 | ||
|
24e685b70e | ||
|
e603f7882f | ||
|
683e73e687 | ||
|
15fe18ca9f | ||
|
ce47b25fd8 | ||
|
cc3d965414 | ||
|
9ee412df04 | ||
|
e9a0a31c84 | ||
|
7dd8aef46c | ||
|
4e14c2cbd7 | ||
|
b618ea7e06 | ||
|
f67a08c7e3 | ||
|
1a3d59dfa1 | ||
|
1b6d8af497 | ||
|
c4c910b13e | ||
|
e9af1baa86 | ||
|
7927c7a119 | ||
|
3a5c47babb | ||
|
7f6c503434 | ||
|
18acbf65dc | ||
|
50b7d83495 | ||
|
c9f64210e4 | ||
|
4bbf264cdc | ||
|
7c21ec298d | ||
|
85d7fccf11 | ||
|
e51457d535 | ||
|
f5bbdd7ead | ||
|
8885e91a58 | ||
|
d652244292 | ||
|
f04ca4b77f | ||
|
ad2b107afd | ||
|
75f68c612e | ||
|
d3ff57bffc | ||
|
82efc2e564 | ||
|
af3e6f6009 | ||
|
457bb5b469 | ||
|
0f70ac9eba | ||
|
2bff9eeb00 | ||
|
46b3021541 | ||
|
614884a4f6 | ||
|
615759f148 | ||
|
d323e7e3aa | ||
|
fee2a75049 | ||
|
35b2d64876 | ||
|
115260470c | ||
|
16727dce57 | ||
|
670ff0de10 | ||
|
e93ea3bcce | ||
|
f70743ed33 | ||
|
95ba57d06f | ||
|
cb165c67b1 | ||
|
ca276a9e82 | ||
|
c7f6e876dd | ||
|
b6131b3dd3 | ||
|
54b96280fc | ||
|
48fa7748f1 | ||
|
5f6795eff0 | ||
|
e9c87493d0 | ||
|
440582d176 | ||
|
9353865c25 | ||
|
f58ca49b06 | ||
|
f6382f28d3 | ||
|
50652a4fab | ||
|
93adf7515a | ||
|
d6fb3814ab | ||
|
93c1ee9cbf | ||
|
5c82775afb | ||
|
3535801e5c | ||
|
9d537e6158 | ||
|
f783d4bbc1 | ||
|
ff18fba533 | ||
|
a093a10484 | ||
|
f9ca64bb51 | ||
|
08cbc94ee7 | ||
|
22b9179961 | ||
|
eec1596872 | ||
|
ffe31c2a6a | ||
|
da4bd743e1 | ||
|
b1f4b5fa93 | ||
|
f166fef906 | ||
|
29470674ce | ||
|
9eefea8904 | ||
|
01a4b7886b | ||
|
79445d40fc | ||
|
448687294d | ||
|
56d374a915 | ||
|
94b33bf7a9 | ||
|
c53d71fc75 | ||
|
eff1ab0744 | ||
|
196e37e8d9 | ||
|
9886d4afe3 | ||
|
9105056738 | ||
|
a8484b3644 | ||
|
e53377947e | ||
|
77d67d4ed9 | ||
|
b5bd2be96e | ||
|
770acdba38 | ||
|
1f3b024a28 | ||
|
bf72cbf0b0 | ||
|
5c1ec44387 | ||
|
c536f53293 | ||
|
b056e166cc | ||
|
87bfcdbadd | ||
|
62e09bd1ac | ||
|
c9e7d798e5 | ||
|
8762148a68 | ||
|
04af833ba6 | ||
|
5b6f56a2ef | ||
|
ea60259b36 | ||
|
a050488d8e | ||
|
0dde0315f1 | ||
|
42da3ee691 | ||
|
8d15375874 | ||
|
18a39ac0fd | ||
|
ad9bce3812 | ||
|
0401246d96 | ||
|
bdce8a0329 | ||
|
a4417a0ebf | ||
|
905b34e64b | ||
|
a05c8c6634 | ||
|
8781d82216 | ||
|
9be2a90f81 | ||
|
d56e53c0ef | ||
|
4ccb22acbb | ||
|
f3c45a13dd | ||
|
5f24b4c3cd | ||
|
f7c07c30f5 | ||
|
a0ae0dd4ec | ||
|
bbd7c46ddd | ||
|
87c0fa228e | ||
|
72182f4ef5 |
564
.github/workflows/ci.yml
vendored
Normal file
564
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,564 @@
|
||||
name: Alfresco Community Repo CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- feature/**
|
||||
- fix/**
|
||||
push:
|
||||
branches:
|
||||
# - feature/**
|
||||
- fix/**
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
LOG_WARN: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
TAS_ENVIRONMENT: ./packaging/tests/environment
|
||||
TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: "Prepare"
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
# - name: "Prepare environment"
|
||||
# run: bash ./scripts/ci/prepare.sh
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
veracode:
|
||||
name: "Source Clear Scan (SCA)"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
((github.ref_name == 'master' || contains(github.ref_name, 'release/')) && github.event_name != 'pull_request') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- name: Cache local Maven repository
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/veracode@master
|
||||
with:
|
||||
srcclr-api-token: ${{ secrets.SRCCLR_API_TOKEN }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
all_unit_tests_suite:
|
||||
name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run tests"
|
||||
run: |
|
||||
mvn -B test -pl core,data-model -am -DfailIfNoTests=false
|
||||
mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
remote_api_app_context_test_suites:
|
||||
name: Remote-api - ${{ matrix.testSuite }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- testSuite: AppContext01TestSuite
|
||||
compose-profile: default
|
||||
- testSuite: AppContext02TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext03TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext04TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContextExtraTestSuite
|
||||
compose-profile: default
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set transformers tag"
|
||||
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl remote-api -Dtest=${{ matrix.testSuite }} -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mariadb_tests:
|
||||
name: Repository - MariaDB ${{ matrix.version }} tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/')) &&
|
||||
github.event_name != 'pull_request' &&
|
||||
! contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: ['10.2.18', '10.4', '10.5']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
|
||||
env:
|
||||
MARIADB_VERSION: ${{ matrix.version }}
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mariadb_10_6_tests:
|
||||
name: "Repository - MariaDB 10.6 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
|
||||
! contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
|
||||
env:
|
||||
MARIADB_VERSION: 10.6
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mysql_tests:
|
||||
name: Repository - MySQL 8 tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
|
||||
! contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mysql up -d
|
||||
env:
|
||||
MYSQL_VERSION: 8
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_13_7_tests:
|
||||
name: "Repository - PostgreSQL 13.7 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/')) && github.event_name != 'pull_request' &&
|
||||
! contains(github.event.head_commit.message, '[skip db]')) ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: 10.6
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_14_4_tests:
|
||||
name: "Repository - PostgreSQL 14.4 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(!contains(github.event.head_commit.message, '[skip db]') ||
|
||||
contains(github.event.head_commit.message, '[latest db]') ||
|
||||
contains(github.event.head_commit.message, '[db]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: 14.4
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_messaging_tests:
|
||||
name: Repository - Messaging tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile activemq up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_app_context_test_suites:
|
||||
name: Repository - ${{ matrix.testSuite }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- testSuite: AppContext01TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext02TestSuite
|
||||
compose-profile: default
|
||||
- testSuite: AppContext03TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext04TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext05TestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '"-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"'
|
||||
- testSuite: AppContext06TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContextExtraTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: MiscContextTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: SearchTestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '-Dindex.subsystem.name=solr6'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up IDS"
|
||||
run: |
|
||||
if [ "${{ matrix.testSuite }}" == 'AppContext05TestSuite' ];
|
||||
then
|
||||
mkdir -p "${HOME}/tmp"
|
||||
cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp"
|
||||
echo "HOST_IP=$(hostname -I | cut -f1 -d' ')" >> $GITHUB_ENV
|
||||
docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2
|
||||
fi
|
||||
- name: "Set transformers tag"
|
||||
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=${{ matrix.testSuite }} -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco ${{ matrix.mvn-options }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
tas-tests:
|
||||
name: ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
! contains(github.event.head_commit.message, '[skip tas]')) ||
|
||||
contains(github.event.head_commit.message, '[tas]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- test-name: "REST API TAS tests part1"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part1
|
||||
- test-name: "REST API TAS tests part2"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part2
|
||||
- test-name: "REST API TAS tests part3"
|
||||
pom-dir: tas-restapi
|
||||
test-profile: run-restapi-part3
|
||||
- test-name: "CMIS TAS tests - BROWSER binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-browser
|
||||
- test-name: "CMIS TAS tests - ATOM binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-atom
|
||||
- test-name: "CMIS TAS tests - WEBSERVICES binding"
|
||||
pom-dir: tas-cmis
|
||||
test-profile: run-cmis-webservices
|
||||
- test-name: "Email TAS tests"
|
||||
pom-dir: tas-email
|
||||
- test-name: "WebDAV TAS tests"
|
||||
pom-dir: tas-webdav
|
||||
- test-name: "Integration TAS tests"
|
||||
pom-dir: tas-integration
|
||||
env:
|
||||
REQUIRES_LOCAL_IMAGES: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set up the environment"
|
||||
run: |
|
||||
${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-minimal+transforms.yml
|
||||
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
- name: "Set up the environment for integration tests"
|
||||
run: |
|
||||
if [ "${{ matrix.test-name }}" == 'Integration TAS tests' ];
|
||||
then
|
||||
mvn install -pl :alfresco-community-repo-integration-test -am -DskipTests -Pall-tas-tests
|
||||
fi
|
||||
- name: "Run tests"
|
||||
id: tests
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn -B verify -f packaging/tests/${{ matrix.pom-dir }}/pom.xml -Pall-tas-tests,${{ matrix.test-profile }} -Denvironment=default -DrunBugs=false
|
||||
- name: "Print output after success"
|
||||
if: ${{ always() }} && outcome.tests.outcome == 'success'
|
||||
run: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Print output after failure"
|
||||
if: ${{ always() }} && outcome.tests.outcome == 'failure'
|
||||
run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
share_services_share_services_test_suite:
|
||||
name: Share Services - ShareServicesTestSuite
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
! contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Set up the environment"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile postgres up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_tests_postgressql:
|
||||
name: AGS Integration Tests 0${{ matrix.part }} (PostgreSQL) ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
! contains(github.event.head_commit.message, '[skip ags]')) ||
|
||||
contains(github.event.head_commit.message, '[ags]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Verify"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_tests_mysql:
|
||||
name: AGS Integration Tests 0${{ matrix.part }} (MySQL) ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
! contains(github.event.head_commit.message, '[skip ags]')) ||
|
||||
contains(github.event.head_commit.message, '[ags on MySQL]')) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
part: [1, 2, 3, 4]
|
||||
env:
|
||||
REQUIRES_INSTALLED_ARTIFACTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Verify"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
ags_community_rest_api_tests:
|
||||
name: "AGS Community Rest API Tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
|
||||
! contains(github.event.head_commit.message, '[skip ags]') && ! contains(github.event.head_commit.message, '[skip tas]')) ||
|
||||
(contains(github.event.head_commit.message, '[ags]') && contains(github.event.head_commit.message, '[tas]'))) &&
|
||||
! contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
! contains(github.event.head_commit.message, '[force]')
|
||||
env:
|
||||
REQUIRES_LOCAL_IMAGES: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set up the environment"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
${{ env.TAS_SCRIPTS }}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml
|
||||
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco"
|
||||
mvn -B install -pl :alfresco-governance-services-automation-community-rest-api -am -Pags -Pall-tas-tests -DskipTests
|
||||
- name: "Test"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests
|
||||
- name: "Get logs and move to deploy_dir"
|
||||
shell: bash
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
bash amps/ags/ci/scripts/getLogs.sh
|
||||
mkdir -p deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests
|
||||
mv "alfresco.log" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
|
||||
mv "solr.log" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
|
||||
mv "./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
|
||||
- name: "Configure AWS credentials"
|
||||
if: ${{ always() }}
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AGS_AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AGS_AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: "Upload artifacts to Amazon S3 bucket"
|
||||
if: ${{ always() }}
|
||||
run: aws s3 cp --recursive ./deploy_dir s3://ags-travis-artifacts
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
71
.github/workflows/master_release.yml
vendored
Normal file
71
.github/workflows/master_release.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
name: Master/Release branch workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release/**
|
||||
- feature/ACS-3841_test_migration
|
||||
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }}
|
||||
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
|
||||
jobs:
|
||||
run_ci:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
secrets: inherit
|
||||
push_to_nexus:
|
||||
name: "Push to Nexus"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run_ci]
|
||||
if: >
|
||||
always() &&
|
||||
(needs.run_ci.result == 'skipped' || needs.run_ci.result == 'success') &&
|
||||
(! contains(github.event.head_commit.message, '[no release]')) &&
|
||||
(github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.ref_name == 'feature/ACS-3841_test_migration') &&
|
||||
(github.event_name != 'pull_request')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Release"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash scripts/ci/verify_release_tag.sh
|
||||
bash scripts/ci/maven_release.sh
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
update_downstream:
|
||||
name: "Update alfresco-enterprise-repo"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run_ci, push_to_nexus]
|
||||
if: >
|
||||
always() &&
|
||||
(needs.run_ci.result == 'skipped' || needs.run_ci.result == 'success') &&
|
||||
(! contains(github.event.head_commit.message, '[no downstream]')) &&
|
||||
((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.ref_name == 'feature/ACS-3841_test_migration') && github.event_name != 'pull_request')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Update downstream"
|
||||
run: bash ./scripts/ci/update_downstream.sh
|
||||
env:
|
||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
@@ -19,10 +19,7 @@ before_cache: bash scripts/travis/cleanup_cache.sh
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /release\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- none
|
||||
|
||||
env:
|
||||
global:
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -1,39 +1,46 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.utils;
|
||||
|
||||
package org.alfresco.rest.framework.core.exceptions;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The addressed Relationship Resource was not found
|
||||
*/
|
||||
public class EventAlreadyExistsException extends ApiException {
|
||||
import org.testng.IMethodInstance;
|
||||
import org.testng.IMethodInterceptor;
|
||||
import org.testng.ITestContext;
|
||||
|
||||
private static final long serialVersionUID = -3675294374348951929L;
|
||||
|
||||
public EventAlreadyExistsException(String msgId, Object[] msgParams) {
|
||||
super(msgId, msgParams);
|
||||
public class AlphabeticallyPriorityInterceptor implements IMethodInterceptor
|
||||
{
|
||||
@Override
|
||||
public List<IMethodInstance> intercept(List<IMethodInstance> methods,
|
||||
ITestContext context)
|
||||
{
|
||||
return methods.stream().sorted(Comparator.comparing(el -> el.getMethod().getTestClass().toString()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,10 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000">
|
||||
<test name="restapi">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.rest.rm.community.utils.AlphabeticallyPriorityInterceptor" />
|
||||
</listeners>
|
||||
<test name="restapi" preserve-order="false">
|
||||
<packages>
|
||||
<package name="org.alfresco.rest.rm.community.*"/>
|
||||
</packages>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.6-A4
|
||||
SOLR6_TAG=2.0.6
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -175,14 +175,6 @@
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.events.EventEntityResource">
|
||||
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.events.EventTypeEntityResource">
|
||||
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
|
||||
</bean>
|
||||
|
||||
<!-- extended sites bean definition -->
|
||||
<bean id="rm.sites" class="org.alfresco.rm.rest.api.impl.RMSitesImpl" parent="sites">
|
||||
<property name="siteSurfConfig" ref="rm.siteSurfConfig" />
|
||||
@@ -217,8 +209,6 @@
|
||||
<entry key="org.alfresco.service.cmr.attributes.DuplicateAttributeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
|
||||
<entry key="org.alfresco.module.org_alfresco_module_rm.record.RecordCreationException" value="422" />
|
||||
<entry key="org.alfresco.service.cmr.model.FileExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="404" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -1,222 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.EventBody;
|
||||
import org.alfresco.rm.rest.api.model.EventInfo;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
/**
|
||||
* Event entity resource
|
||||
*/
|
||||
@EntityResource(name = "events", title = "Events")
|
||||
public class EventEntityResource implements EntityResourceAction.Read<EventInfo>,
|
||||
EntityResourceAction.ReadById<EventInfo>,
|
||||
EntityResourceAction.Update<EventBody>,
|
||||
EntityResourceAction.Create<EventBody> {
|
||||
|
||||
private RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
/**
|
||||
* Set the records management event service
|
||||
*
|
||||
* @param rmEventService
|
||||
*/
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
|
||||
{
|
||||
this.recordsManagementEventService = rmEventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a single event identified by 'eventId'")
|
||||
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
|
||||
public EventInfo readById(String eventId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
mandatory("eventId", eventId);
|
||||
|
||||
RecordsManagementEvent event = null;
|
||||
if (eventExists(eventId))
|
||||
{
|
||||
// Get the event
|
||||
event = recordsManagementEventService.getEvent(eventId);
|
||||
}
|
||||
|
||||
return EventInfo.fromRecordsManagementEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a list of events")
|
||||
public CollectionWithPagingInfo<EventInfo> readAll(Parameters params)
|
||||
{
|
||||
Paging paging = params.getPaging();
|
||||
|
||||
List<EventInfo> eventInfoList = recordsManagementEventService.getEvents().stream()
|
||||
.map(EventInfo::fromRecordsManagementEvent)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int totalCount = eventInfoList.size();
|
||||
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
|
||||
return CollectionWithPagingInfo.asPaged(paging, eventInfoList.stream()
|
||||
.skip(paging.getSkipCount())
|
||||
.limit(paging.getMaxItems())
|
||||
.collect(Collectors.toList()), hasMoreItems, totalCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Create a new event")
|
||||
public List<EventBody> create(List<EventBody> eventBodyList, Parameters parameters)
|
||||
{
|
||||
//TODO: 403 User not allowed to update event error still needs to be implemented
|
||||
mandatory("eventBodyList", eventBodyList);
|
||||
for (EventBody eventBody : eventBodyList) {
|
||||
mandatory("eventName", eventBody.getName());
|
||||
mandatory("eventType", eventBody.getType());
|
||||
}
|
||||
|
||||
List<EventBody> responseEventBodyList = new ArrayList<>();
|
||||
for (EventBody eventBody : eventBodyList) {
|
||||
String eventId = GUID.generate();
|
||||
String eventName = eventBody.getName();
|
||||
String eventType = eventBody.getType();
|
||||
|
||||
if(canCreateEvent(eventId, eventName)) {
|
||||
RecordsManagementEvent event = recordsManagementEventService.addEvent(eventType, eventId, eventName);
|
||||
responseEventBodyList.add(EventBody.fromRecordsManagementEvent(event));
|
||||
}
|
||||
}
|
||||
return responseEventBodyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update a single event identified by 'eventId'")
|
||||
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
|
||||
public EventBody update(String eventId, EventBody eventBody, Parameters parameters)
|
||||
{
|
||||
//TODO: 403 User not allowed to update event error still needs to be implemented
|
||||
mandatory("eventId", eventId);
|
||||
mandatory("eventName", eventBody.getName());
|
||||
mandatory("eventType", eventBody.getType());
|
||||
|
||||
RecordsManagementEvent event = null;
|
||||
if (canEditEvent(eventBody.getName(), eventId, eventBody.getType()))
|
||||
{
|
||||
// Create event
|
||||
event = recordsManagementEventService.addEvent(eventBody.getType(), eventId, eventBody.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get event
|
||||
event = recordsManagementEventService.getEvent(eventId);
|
||||
}
|
||||
|
||||
return EventBody.fromRecordsManagementEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event exists or not. Throws an
|
||||
* error if the event does not exist.
|
||||
*
|
||||
* @param eventId The id of the event
|
||||
*/
|
||||
private boolean eventExists(String eventId)
|
||||
{
|
||||
boolean eventExists = true;
|
||||
|
||||
// Check the event exists
|
||||
if (!recordsManagementEventService.existsEvent(eventId))
|
||||
{
|
||||
throw new EntityNotFoundException(eventId);
|
||||
}
|
||||
|
||||
return eventExists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event can be created or not. Throws an
|
||||
* error if the event already exists.
|
||||
*
|
||||
* @param eventId The id of the event
|
||||
* @param eventName The name of the event
|
||||
*/
|
||||
private boolean canCreateEvent(String eventId, String eventName)
|
||||
{
|
||||
boolean canCreateEvent = true;
|
||||
|
||||
if (!recordsManagementEventService.canCreateEvent(eventName, eventId))
|
||||
{
|
||||
throw new EventAlreadyExistsException("framework.exception.CreateEventAlreadyExists", new Object[] {eventName});
|
||||
}
|
||||
|
||||
return canCreateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event can be edited or not. Throws an
|
||||
* error if an event with the same display label already exists.
|
||||
*
|
||||
* @param eventName The name of the event
|
||||
* @param eventId The id of the event
|
||||
* @param eventType The type of the event
|
||||
* @return true if the event can be edited, false otherwise
|
||||
*/
|
||||
private boolean canEditEvent(String eventName, String eventId, String eventType)
|
||||
{
|
||||
boolean canEditEvent = false;
|
||||
if (eventExists(eventId)) {
|
||||
try
|
||||
{
|
||||
canEditEvent = recordsManagementEventService.canEditEvent(eventName, eventId, eventType);
|
||||
}
|
||||
catch (AlfrescoRuntimeException are)
|
||||
{
|
||||
throw new EventAlreadyExistsException("framework.exception.UpdateEventAlreadyExists", new Object[] {eventName});
|
||||
}
|
||||
}
|
||||
return canEditEvent;
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.EventTypeInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Event Type entity resource
|
||||
*/
|
||||
@EntityResource(name = "event-types", title = "Event Types")
|
||||
public class EventTypeEntityResource implements EntityResourceAction.Read<EventTypeInfo> {
|
||||
private RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
/**
|
||||
* Set the records management event service
|
||||
* @param rmEventService
|
||||
*/
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
|
||||
{
|
||||
this.recordsManagementEventService = rmEventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a list of different event types")
|
||||
public CollectionWithPagingInfo<EventTypeInfo> readAll(Parameters params)
|
||||
{
|
||||
// TODO: AssociationName and ActionOnAssociatedNode properties still need to be assigned.
|
||||
Paging paging = params.getPaging();
|
||||
|
||||
List<EventTypeInfo> eventTypeInfoList = recordsManagementEventService.getEventTypes().stream()
|
||||
.map(EventTypeInfo::fromRecordsManagementEventType)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int totalCount = eventTypeInfoList.size();
|
||||
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
|
||||
return CollectionWithPagingInfo.asPaged(paging, eventTypeInfoList.stream()
|
||||
.skip(paging.getSkipCount())
|
||||
.limit(paging.getMaxItems())
|
||||
.collect(Collectors.toList()), hasMoreItems, totalCount);
|
||||
}
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
|
||||
/**
|
||||
* The EventBody model to be exposed through REST API.
|
||||
*/
|
||||
public class EventBody {
|
||||
private String name;
|
||||
private String type;
|
||||
|
||||
public static EventBody fromRecordsManagementEvent(RecordsManagementEvent event)
|
||||
{
|
||||
EventBody eventBody = new EventBody();
|
||||
if(event != null) {
|
||||
eventBody.setName(event.getDisplayLabel());
|
||||
eventBody.setType(event.getType());
|
||||
}
|
||||
return eventBody;
|
||||
}
|
||||
|
||||
public EventBody() {}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
|
||||
/**
|
||||
* The EventInfo model to be exposed through REST API.
|
||||
*/
|
||||
public class EventInfo {
|
||||
private String id;
|
||||
private String name;
|
||||
private String type;
|
||||
|
||||
public static EventInfo fromRecordsManagementEvent(RecordsManagementEvent event)
|
||||
{
|
||||
EventInfo eventInfo = new EventInfo();
|
||||
if (event != null) {
|
||||
eventInfo.setName(event.getDisplayLabel());
|
||||
eventInfo.setId(event.getName());
|
||||
eventInfo.setType(event.getType());
|
||||
}
|
||||
return eventInfo;
|
||||
}
|
||||
|
||||
public EventInfo() {}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
|
||||
/**
|
||||
* The EventTypeInfo model to be exposed through REST API.
|
||||
*/
|
||||
public class EventTypeInfo {
|
||||
private String id;
|
||||
private String name;
|
||||
private boolean isAutomatic;
|
||||
private String associationName;
|
||||
private String actionOnAssociatedNode;
|
||||
|
||||
public static EventTypeInfo fromRecordsManagementEventType(RecordsManagementEventType eventType)
|
||||
{
|
||||
EventTypeInfo eventTypeInfo = new EventTypeInfo();
|
||||
if (eventType != null) {
|
||||
eventTypeInfo.setName(eventType.getDisplayLabel());
|
||||
eventTypeInfo.setId(eventType.getName());
|
||||
eventTypeInfo.setAutomatic(eventType.isAutomaticEvent());
|
||||
}
|
||||
return eventTypeInfo;
|
||||
}
|
||||
|
||||
public EventTypeInfo() {}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isAutomatic()
|
||||
{
|
||||
return isAutomatic;
|
||||
}
|
||||
|
||||
public void setAutomatic(boolean automatic)
|
||||
{
|
||||
isAutomatic = automatic;
|
||||
}
|
||||
|
||||
public String getAssociationName()
|
||||
{
|
||||
return associationName;
|
||||
}
|
||||
|
||||
public void setAssociationName(String associationName)
|
||||
{
|
||||
this.associationName = associationName;
|
||||
}
|
||||
|
||||
public String getActionOnAssociatedNode()
|
||||
{
|
||||
return actionOnAssociatedNode;
|
||||
}
|
||||
|
||||
public void setActionOnAssociatedNode(String actionOnAssociatedNode)
|
||||
{
|
||||
this.actionOnAssociatedNode = actionOnAssociatedNode;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.6-A4
|
||||
SOLR6_TAG=2.0.6
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -4,4 +4,4 @@ TAS_DIRECTORY=$1
|
||||
|
||||
cd ${TAS_DIRECTORY}
|
||||
|
||||
cat target/reports/alfresco-tas.log | grep "*** STARTING"
|
||||
cat target/reports/alfresco-tas.log | grep -a "*** STARTING"
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
@@ -47,8 +49,7 @@ This must be unique within the parent category.
|
||||
private boolean hasChildren;
|
||||
/**
|
||||
The number of nodes that are assigned to this category.
|
||||
*/
|
||||
|
||||
*/
|
||||
private long count;
|
||||
|
||||
public String getId()
|
||||
@@ -99,6 +100,33 @@ This must be unique within the parent category.
|
||||
public void setCount(long count)
|
||||
{
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RestCategoryModel that = (RestCategoryModel) o;
|
||||
return Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "RestCategoryModel{" +
|
||||
"id='" + id + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", parentId='" + parentId + '\'' +
|
||||
", hasChildren=" + hasChildren +
|
||||
", count=" + count +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,34 +1,35 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
/**
|
||||
* Package info that defines the Information Governance Events REST API
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestCategoryModelsCollection extends RestModels<RestCategoryModel, RestCandidateModelsCollection>
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -25,9 +25,14 @@
|
||||
*/
|
||||
package org.alfresco.rest.requests;
|
||||
|
||||
import static org.alfresco.rest.core.JsonBodyGenerator.arrayToJson;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.RestRequest;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
import org.alfresco.rest.model.RestCategoryModelsCollection;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
public class Categories extends ModelRequest<Categories>
|
||||
@@ -41,9 +46,9 @@ public class Categories extends ModelRequest<Categories>
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a category with ID using GET call on using GET call on "/tags/{tagId}"
|
||||
* Retrieves a category with ID using GET call on "/categories/{categoryId}"
|
||||
*
|
||||
* @return
|
||||
* @return RestCategoryModel
|
||||
*/
|
||||
public RestCategoryModel getCategory()
|
||||
{
|
||||
@@ -52,4 +57,51 @@ public class Categories extends ModelRequest<Categories>
|
||||
return restWrapper.processModel(RestCategoryModel.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create several categories in one request.
|
||||
*
|
||||
* @param restCategoryModels The list of categories to create.
|
||||
* @return The list of created categories with additional data populated by the repository.
|
||||
*/
|
||||
public RestCategoryModelsCollection createCategoriesList(List<RestCategoryModel> restCategoryModels) {
|
||||
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, arrayToJson(restCategoryModels), "categories/{categoryId}/subcategories", category.getId());
|
||||
return restWrapper.processModels(RestCategoryModelsCollection.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create single category.
|
||||
*
|
||||
* @param restCategoryModel The categories to create.
|
||||
* @return Created category with additional data populated by the repository.
|
||||
*/
|
||||
public RestCategoryModel createSingleCategory(RestCategoryModel restCategoryModel)
|
||||
{
|
||||
RestRequest request = RestRequest
|
||||
.requestWithBody(HttpMethod.POST, restCategoryModel.toJson(), "categories/{categoryId}/subcategories", category.getId());
|
||||
return restWrapper.processModel(RestCategoryModel.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent category children.
|
||||
*
|
||||
* @return The list of child categories.
|
||||
*/
|
||||
public RestCategoryModelsCollection getCategoryChildren()
|
||||
{
|
||||
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "categories/{categoryId}/subcategories", category.getId());
|
||||
return restWrapper.processModels(RestCategoryModelsCollection.class, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete category.
|
||||
*
|
||||
* - DELETE /categories/{categoryId}
|
||||
*/
|
||||
public void deleteCategory()
|
||||
{
|
||||
RestRequest request = RestRequest.
|
||||
simpleRequest(HttpMethod.DELETE, "/categories/{categoryId}", category.getId());
|
||||
restWrapper.processEmptyModel(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.categories;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
import org.alfresco.rest.model.RestCategoryModelsCollection;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class CreateCategoriesTests extends RestTest
|
||||
{
|
||||
private static final String FIELD_NAME = "name";
|
||||
private static final String FIELD_PARENT_ID = "parentId";
|
||||
private static final String FIELD_HAS_CHILDREN = "hasChildren";
|
||||
private static final String FIELD_ID = "id";
|
||||
private UserModel user;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
STEP("Create a user");
|
||||
user = dataUser.createRandomTestUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can create a category as direct child of root category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateCategoryUnderRoot()
|
||||
{
|
||||
STEP("Create a category under root category (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName());
|
||||
createdCategory.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId());
|
||||
createdCategory.assertThat().field(FIELD_HAS_CHILDREN).is(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get 400 error when attempting to create a category with empty name
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateCategoryWithoutName_andFail()
|
||||
{
|
||||
STEP("Create a category under root category (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(StringUtils.EMPTY);
|
||||
restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Category name must not be null or empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can create several categories as children of a created category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateSeveralSubCategories()
|
||||
{
|
||||
STEP("Create a category under root category (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName())
|
||||
.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId())
|
||||
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
|
||||
.assertThat().field(FIELD_ID).isNotEmpty();
|
||||
|
||||
STEP("Create two categories under the previously created (as admin)");
|
||||
final int categoriesNumber = 2;
|
||||
final List<RestCategoryModel> categoriesToCreate = getCategoriesToCreate(categoriesNumber);
|
||||
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(createdCategory)
|
||||
.createCategoriesList(categoriesToCreate);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdSubCategories.assertThat()
|
||||
.entriesListCountIs(categoriesToCreate.size());
|
||||
IntStream.range(0, categoriesNumber)
|
||||
.forEach(i -> createdSubCategories.getEntries().get(i).onModel()
|
||||
.assertThat().field(FIELD_NAME).is(categoriesToCreate.get(i).getName())
|
||||
.assertThat().field(FIELD_PARENT_ID).is(createdCategory.getId())
|
||||
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
|
||||
.assertThat().field(FIELD_ID).isNotEmpty()
|
||||
);
|
||||
|
||||
STEP("Get the parent category and check if it now has children (as regular user)");
|
||||
final RestCategoryModel parentCategoryFromGet = restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(createdCategory)
|
||||
.getCategory();
|
||||
|
||||
parentCategoryFromGet.assertThat().field(FIELD_HAS_CHILDREN).is(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can create over 100 categories as children of a created category and pagination information is proper.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateOver100SubCategories()
|
||||
{
|
||||
STEP("Create a category under root category (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName())
|
||||
.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId())
|
||||
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
|
||||
.assertThat().field(FIELD_ID).isNotEmpty();
|
||||
|
||||
STEP("Create more than a hundred categories under the previously created (as admin)");
|
||||
final int categoriesNumber = 120;
|
||||
final List<RestCategoryModel> categoriesToCreate = getCategoriesToCreate(categoriesNumber);
|
||||
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(createdCategory)
|
||||
.createCategoriesList(categoriesToCreate);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdSubCategories.assertThat()
|
||||
.entriesListCountIs(categoriesToCreate.size());
|
||||
IntStream.range(0, categoriesNumber)
|
||||
.forEach(i -> createdSubCategories.getEntries().get(i).onModel()
|
||||
.assertThat().field(FIELD_NAME).is(categoriesToCreate.get(i).getName())
|
||||
.assertThat().field(FIELD_PARENT_ID).is(createdCategory.getId())
|
||||
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
|
||||
.assertThat().field(FIELD_ID).isNotEmpty()
|
||||
);
|
||||
createdSubCategories.getPagination().assertThat().field("count").is(categoriesNumber)
|
||||
.assertThat().field("totalItems").is(categoriesNumber)
|
||||
.assertThat().field("maxItems").is(categoriesNumber)
|
||||
.assertThat().field("skipCount").is(0)
|
||||
.assertThat().field("hasMoreItems").is(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we cannot create a category as direct child of root category as non-admin user
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateCategoryUnderRootAsRegularUser_andFail()
|
||||
{
|
||||
STEP("Create a category under root category (as user)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(FORBIDDEN).assertLastError().containsSummary("Current user does not have permission to create a category");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we cannot create a category under non existing parent node
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateCategoryUnderNonExistingParent_andFail()
|
||||
{
|
||||
STEP("Create a category under non existing category node (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
final String id = "non-existing-node-id";
|
||||
rootCategory.setId(id);
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary("The entity with id: " + id + " was not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we cannot create a category under a node which is not a category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testCreateCategoryUnderFolderNode_andFail()
|
||||
{
|
||||
STEP("Create a site and a folder inside it");
|
||||
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Create a category under folder node (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId(folder.getNodeRef());
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
|
||||
}
|
||||
|
||||
static List<RestCategoryModel> getCategoriesToCreate(final int count)
|
||||
{
|
||||
return IntStream.range(0, count)
|
||||
.mapToObj(i -> {
|
||||
final RestCategoryModel aSubCategory = new RestCategoryModel();
|
||||
aSubCategory.setName((RandomData.getRandomName("SubCategory")));
|
||||
return aSubCategory;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.categories;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
||||
|
||||
public class DeleteCategoriesTests extends RestTest {
|
||||
|
||||
private UserModel user;
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
STEP("Create a user");
|
||||
user = dataUser.createRandomTestUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can delete a category.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testDeleteCategory()
|
||||
{
|
||||
STEP("Create a category and send a request to delete it.");
|
||||
RestCategoryModel aCategory = createCategory();
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(aCategory).deleteCategory();
|
||||
restClient.assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
STEP("Ensure that the category has been deleted by sending a GET request and receiving 404.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(aCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when trying to delete a category as a non-admin user.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testDeleteCategoryAsRegularUser_andFail()
|
||||
{
|
||||
RestCategoryModel aCategory = createCategory();
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(aCategory).deleteCategory();
|
||||
restClient.assertStatusCodeIs(FORBIDDEN).assertLastError().containsSummary("Current user does not have permission to delete a category");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we receive 404 error when trying to delete a category with a non-existent node id.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testDeleteNonExistentCategory()
|
||||
{
|
||||
STEP("Get category with non-existent id");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
final String id = "non-existing-dummy-id";
|
||||
rootCategory.setId(id);
|
||||
|
||||
STEP("Attempt to delete category with non-existent id and receive 404");
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(rootCategory).deleteCategory();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to delete a category when providing a node id that doesn't belong to a category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testDeleteCategory_givenNonCategoryNodeId()
|
||||
{
|
||||
STEP("Create a site and a folder inside it");
|
||||
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
String id = folder.getNodeRef();
|
||||
|
||||
STEP("Create a category, set its id to the folder id and attempt to delete it");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setId(id);
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(aCategory).deleteCategory();
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
|
||||
}
|
||||
|
||||
public RestCategoryModel createCategory()
|
||||
{
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
return createdCategory;
|
||||
}
|
||||
}
|
@@ -28,10 +28,20 @@ package org.alfresco.rest.categories;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
import org.alfresco.rest.model.RestCategoryModelsCollection;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
@@ -41,6 +51,10 @@ import org.testng.annotations.Test;
|
||||
|
||||
public class GetCategoriesTests extends RestTest
|
||||
{
|
||||
private static final List<String> DEFAULT_ROOT_CATEGORIES = List.of("Software Document Classification", "Languages", "Regions", "Tags");
|
||||
private static final String ROOT = "-root-";
|
||||
private static final String NON_EXISTING_CATEGORY_ID = "non-existing-category-id";
|
||||
|
||||
private UserModel user;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@@ -50,21 +64,52 @@ public class GetCategoriesTests extends RestTest
|
||||
user = dataUser.createRandomTestUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can get a category which we just created in as direct child of root category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryById()
|
||||
{
|
||||
STEP("Create a category under root category (as admin)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId(ROOT);
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName(RandomData.getRandomName("Category"));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
createdCategory.assertThat()
|
||||
.field("name").is(aCategory.getName());
|
||||
createdCategory.assertThat()
|
||||
.field("parentId").is(rootCategory.getId());
|
||||
createdCategory.assertThat()
|
||||
.field("hasChildren").is(false);
|
||||
|
||||
STEP("Get the created category (as regular user)");
|
||||
final RestCategoryModel categoryFromGet =
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(createdCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
categoryFromGet.assertThat().isEqualTo(createdCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing -root- as category id
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryByIdProvidingRootAsId()
|
||||
{
|
||||
STEP("Get category with -root- as id (which does not exist)");
|
||||
STEP("Get category with -root- as id");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
rootCategory.setId(ROOT);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing as category id
|
||||
* Check we get an error when passing folder node id as category id
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryByIdProvidingFolderAsId()
|
||||
@@ -77,7 +122,101 @@ public class GetCategoriesTests extends RestTest
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId(folder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing non existing as category id
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryByIdProvidingNonExistingId()
|
||||
{
|
||||
STEP("Get category with id which does not exist");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
final String id = NON_EXISTING_CATEGORY_ID;
|
||||
rootCategory.setId(id);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can get children category of a root category
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryChildren()
|
||||
{
|
||||
STEP("Get category children with -root- as parent id");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId(ROOT);
|
||||
RestCategoryModelsCollection childCategoriesList =
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
|
||||
childCategoriesList.assertThat().entriesListIsNotEmpty();
|
||||
assertTrue(childCategoriesList.getEntries().stream()
|
||||
.map(RestCategoryModel::onModel)
|
||||
.map(RestCategoryModel::getName)
|
||||
.collect(Collectors.toList())
|
||||
.containsAll(DEFAULT_ROOT_CATEGORIES));
|
||||
STEP("Create a new category under root and make sure it is returned as one of root's children");
|
||||
final RestCategoryModel aCategory = new RestCategoryModel();
|
||||
aCategory.setName((RandomData.getRandomName("newCategoryUnderRoot")));
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
childCategoriesList = restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
assertTrue(childCategoriesList.getEntries().stream()
|
||||
.map(RestCategoryModel::onModel)
|
||||
.map(RestCategoryModel::getId)
|
||||
.collect(Collectors.toList())
|
||||
.contains(createdCategory.getId()));
|
||||
|
||||
STEP("Create 2 more categories under newCategoryUnderRoot and make sure they are returned as children");
|
||||
final int categoriesCount = 2;
|
||||
final List<RestCategoryModel> categoriesToCreate = CreateCategoriesTests.getCategoriesToCreate(categoriesCount);
|
||||
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(createdCategory)
|
||||
.createCategoriesList(categoriesToCreate);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
childCategoriesList = restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
childCategoriesList.getEntries().containsAll(createdSubCategories.getEntries());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing folder node id as parent category id when getting children.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryChildrenProvidingFolderAsId()
|
||||
{
|
||||
STEP("Create a site and a folder inside it");
|
||||
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Get category children with folder id passed as parent id");
|
||||
final RestCategoryModel parentCategory = new RestCategoryModel();
|
||||
parentCategory.setId(folder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(parentCategory).getCategoryChildren();
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing a non-existent node id as parent category id when getting children.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API})
|
||||
public void testGetCategoryChildrenProvidingNonExistingParent()
|
||||
{
|
||||
|
||||
STEP("Get category with folder id passed as id");
|
||||
final RestCategoryModel parentCategory = new RestCategoryModel();
|
||||
final String parentId = NON_EXISTING_CATEGORY_ID;
|
||||
parentCategory.setId(parentId);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(parentCategory).getCategoryChildren();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary(parentId);
|
||||
}
|
||||
}
|
||||
|
@@ -56,6 +56,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
@@ -63,6 +64,7 @@ import javax.json.JsonObject;
|
||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||
import org.alfresco.rest.model.RestActionConstraintModel;
|
||||
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -267,6 +269,38 @@ public class CreateRulesTests extends RulesRestTest
|
||||
.assertThat().field("name").is(ruleNames.get(i)));
|
||||
}
|
||||
|
||||
/** Check we can create over 100 rules and get them all back in response. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createOver100Rules()
|
||||
{
|
||||
STEP("Create a list of 120 rules in one POST request");
|
||||
final int ruleCount = 120;
|
||||
final String ruleNamePrefix = "multiRule";
|
||||
final List<RestRuleModel> ruleModels = IntStream.rangeClosed(1, ruleCount)
|
||||
.mapToObj(i -> rulesUtils.createRuleModel(ruleNamePrefix + i))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
final FolderModel aFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(aFolder).usingDefaultRuleSet()
|
||||
.createListOfRules(ruleModels);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
assertEquals("Unexpected number of rules received in response.", ruleCount, rules.getEntries().size());
|
||||
IntStream.range(0, ruleModels.size()).forEach(i ->
|
||||
rules.getEntries().get(i).onModel()
|
||||
.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("name").is(ruleNamePrefix + (i + 1)));
|
||||
|
||||
rules.getPagination()
|
||||
.assertThat().field("count").is(ruleCount)
|
||||
.assertThat().field("totalItems").is(ruleCount)
|
||||
.assertThat().field("maxItems").is(ruleCount)
|
||||
.assertThat().field("skipCount").is(0)
|
||||
.assertThat().field("hasMoreItems").is(false);
|
||||
|
||||
}
|
||||
|
||||
/** Try to create several rules with an error in one of them. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createRulesWithOneError()
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -1,17 +1,25 @@
|
||||
package org.alfresco.webdav;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.network.ServerHealth;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.slf4j.Logger;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
@ContextConfiguration("classpath:alfresco-webdav-context.xml")
|
||||
public abstract class WebDavTest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
private static final Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@@ -36,4 +44,16 @@ public abstract class WebDavTest extends AbstractTestNGSpringContextTests
|
||||
// The webdav protocol is enabled by default.
|
||||
//webDavProtocol.assertThat().protocolIsEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void showStartTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun=true)
|
||||
public void showEndTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
8
pom.xml
8
pom.xml
@@ -2,7 +2,7 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -109,8 +109,8 @@
|
||||
<dependency.jakarta-json-path.version>2.7.0</dependency.jakarta-json-path.version>
|
||||
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
|
||||
|
||||
<alfresco.googledrive.version>3.3.1-DEV-LOG4J2</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.5.0-DEV-LOG4J2</alfresco.aos-module.version>
|
||||
<alfresco.googledrive.version>3.4.0-A1</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.6.0-A1</alfresco.aos-module.version>
|
||||
<alfresco.api-explorer.version>7.3.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
|
||||
|
||||
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
|
||||
@@ -148,7 +148,7 @@
|
||||
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
||||
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
||||
<tag>HEAD</tag>
|
||||
<tag>20.45-DEV</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -26,13 +26,22 @@
|
||||
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
@Experimental
|
||||
public interface Categories
|
||||
{
|
||||
Category getCategoryById(String id, Parameters params);
|
||||
|
||||
List<Category> createSubcategories(String parentCategoryId, List<Category> categories, Parameters parameters);
|
||||
|
||||
CollectionWithPagingInfo<Category> getCategoryChildren(String parentCategoryId, Parameters params);
|
||||
|
||||
void deleteCategoryById(String id, Parameters params);
|
||||
|
||||
}
|
||||
|
@@ -41,7 +41,8 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
* @author mpichura
|
||||
*/
|
||||
@EntityResource(name = "categories", title = "Categories")
|
||||
public class CategoriesEntityResource implements EntityResourceAction.ReadById<Category>
|
||||
public class CategoriesEntityResource implements EntityResourceAction.ReadById<Category>,
|
||||
EntityResourceAction.Delete
|
||||
{
|
||||
private final Categories categories;
|
||||
|
||||
@@ -58,4 +59,12 @@ public class CategoriesEntityResource implements EntityResourceAction.ReadById<C
|
||||
{
|
||||
return categories.getCategoryById(id, parameters);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Delete category",
|
||||
description = "Delete a category given its node id",
|
||||
successStatus = HttpServletResponse.SC_NO_CONTENT)
|
||||
@Override
|
||||
public void delete(String id, Parameters parameters) {
|
||||
categories.deleteCategoryById(id, parameters);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.categories;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.Categories;
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
|
||||
@RelationshipResource(name = "subcategories", entityResource = CategoriesEntityResource.class, title = "Subcategories")
|
||||
public class SubcategoriesRelation implements RelationshipResourceAction.Create<Category>, RelationshipResourceAction.Read<Category>
|
||||
{
|
||||
|
||||
private final Categories categories;
|
||||
|
||||
public SubcategoriesRelation(Categories categories)
|
||||
{
|
||||
this.categories = categories;
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "Create a category",
|
||||
description = "Creates one or more categories under a parent category",
|
||||
successStatus = HttpServletResponse.SC_CREATED)
|
||||
@Override
|
||||
public List<Category> create(String parentCategoryId, List<Category> categoryList, Parameters parameters)
|
||||
{
|
||||
return categories.createSubcategories(parentCategoryId, categoryList, parameters);
|
||||
}
|
||||
|
||||
@WebApiDescription(title = "List category direct children",
|
||||
description = "Lists direct children of a parent category",
|
||||
successStatus = HttpServletResponse.SC_OK)
|
||||
@Override
|
||||
public CollectionWithPagingInfo<Category> readAll(String parentCategoryId, Parameters params)
|
||||
{
|
||||
return categories.getCategoryChildren(parentCategoryId, params);
|
||||
}
|
||||
}
|
@@ -29,31 +29,47 @@ package org.alfresco.rest.api.impl;
|
||||
import static org.alfresco.rest.api.Nodes.PATH_ROOT;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.rest.api.Categories;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.ListPage;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Experimental
|
||||
public class CategoriesImpl implements Categories
|
||||
{
|
||||
static final String NOT_A_VALID_CATEGORY = "Node id does not refer to a valid category";
|
||||
static final String NO_PERMISSION_TO_CREATE_A_CATEGORY = "Current user does not have permission to create a category";
|
||||
static final String NO_PERMISSION_TO_DELETE_A_CATEGORY = "Current user does not have permission to delete a category";
|
||||
private static final String NOT_NULL_OR_EMPTY = "Category name must not be null or empty";
|
||||
|
||||
private final AuthorityService authorityService;
|
||||
private final CategoryService categoryService;
|
||||
private final Nodes nodes;
|
||||
private final NodeService nodeService;
|
||||
|
||||
public CategoriesImpl(Nodes nodes, NodeService nodeService)
|
||||
public CategoriesImpl(AuthorityService authorityService, CategoryService categoryService, Nodes nodes, NodeService nodeService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
this.categoryService = categoryService;
|
||||
this.nodes = nodes;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
@@ -61,28 +77,121 @@ public class CategoriesImpl implements Categories
|
||||
@Override
|
||||
public Category getCategoryById(final String id, final Parameters params)
|
||||
{
|
||||
final NodeRef nodeRef = nodes.validateNode(id);
|
||||
final boolean isCategory = nodes.isSubClass(nodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
if (!isCategory || isRootCategory(nodeRef))
|
||||
final NodeRef nodeRef = getCategoryNodeRef(id);
|
||||
if (isRootCategory(nodeRef))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{id});
|
||||
}
|
||||
|
||||
return mapToCategory(nodeRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Category> createSubcategories(String parentCategoryId, List<Category> categories, Parameters parameters)
|
||||
{
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
{
|
||||
throw new PermissionDeniedException(NO_PERMISSION_TO_CREATE_A_CATEGORY);
|
||||
}
|
||||
final NodeRef parentNodeRef = getCategoryNodeRef(parentCategoryId);
|
||||
final List<NodeRef> categoryNodeRefs = categories.stream()
|
||||
.map(c -> createCategoryNodeRef(parentNodeRef, c))
|
||||
.collect(Collectors.toList());
|
||||
return categoryNodeRefs.stream()
|
||||
.map(this::mapToCategory)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionWithPagingInfo<Category> getCategoryChildren(String parentCategoryId, Parameters params)
|
||||
{
|
||||
final NodeRef parentNodeRef = getCategoryNodeRef(parentCategoryId);
|
||||
final List<ChildAssociationRef> childCategoriesAssocs = nodeService.getChildAssocs(parentNodeRef).stream()
|
||||
.filter(ca -> ContentModel.ASSOC_SUBCATEGORIES.equals(ca.getTypeQName()))
|
||||
.collect(Collectors.toList());
|
||||
final List<Category> categories = childCategoriesAssocs.stream()
|
||||
.map(c -> mapToCategory(c.getChildRef()))
|
||||
.collect(Collectors.toList());
|
||||
return ListPage.of(categories, params.getPaging());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCategoryById(String id, Parameters params)
|
||||
{
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
{
|
||||
throw new PermissionDeniedException(NO_PERMISSION_TO_DELETE_A_CATEGORY);
|
||||
}
|
||||
|
||||
final NodeRef nodeRef = nodes.validateNode(id);
|
||||
if (isNotACategory(nodeRef) || isRootCategory(nodeRef))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{id});
|
||||
}
|
||||
|
||||
nodeService.deleteNode(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets category NodeRef for a given category id.
|
||||
* If '-root-' is passed as category id, then it's retrieved as a call to {@link org.alfresco.service.cmr.search.CategoryService#getRootCategoryNodeRef}
|
||||
* In all other cases it's retrieved as a node of a category type {@link #validateCategoryNode(String)}
|
||||
* @param nodeId category node id
|
||||
* @return NodRef of category node
|
||||
*/
|
||||
private NodeRef getCategoryNodeRef(String nodeId)
|
||||
{
|
||||
return PATH_ROOT.equals(nodeId) ?
|
||||
categoryService.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE)
|
||||
.orElseThrow(() -> new EntityNotFoundException(nodeId)) :
|
||||
validateCategoryNode(nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if the node exists and is a category.
|
||||
* @param nodeId (presumably) category node id
|
||||
* @return category NodeRef
|
||||
*/
|
||||
private NodeRef validateCategoryNode(String nodeId)
|
||||
{
|
||||
final NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
if (isNotACategory(nodeRef))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{nodeId});
|
||||
}
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
private NodeRef createCategoryNodeRef(NodeRef parentNodeRef, Category c)
|
||||
{
|
||||
if (StringUtils.isEmpty(c.getName())) {
|
||||
throw new InvalidArgumentException(NOT_NULL_OR_EMPTY);
|
||||
}
|
||||
return categoryService.createCategory(parentNodeRef, c.getName());
|
||||
}
|
||||
|
||||
private boolean isNotACategory(NodeRef nodeRef)
|
||||
{
|
||||
return !nodes.isSubClass(nodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
}
|
||||
|
||||
private Category mapToCategory(NodeRef nodeRef)
|
||||
{
|
||||
final Node categoryNode = nodes.getNode(nodeRef.getId());
|
||||
final Category category = new Category();
|
||||
category.setId(nodeRef.getId());
|
||||
category.setName(categoryNode.getName());
|
||||
category.setParentId(getParentId(nodeRef));
|
||||
final boolean hasChildren = CollectionUtils
|
||||
.isNotEmpty(nodeService.getChildAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false));
|
||||
category.setHasChildren(hasChildren);
|
||||
|
||||
return category;
|
||||
return Category.builder()
|
||||
.id(nodeRef.getId())
|
||||
.name(categoryNode.getName())
|
||||
.parentId(getParentId(nodeRef))
|
||||
.hasChildren(hasChildren)
|
||||
.create();
|
||||
}
|
||||
|
||||
private boolean isRootCategory(final NodeRef nodeRef)
|
||||
{
|
||||
final List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
|
||||
return parentAssocs.stream().anyMatch(pa -> pa.getQName().equals(ContentModel.ASPECT_GEN_CLASSIFIABLE));
|
||||
return parentAssocs.stream().anyMatch(pa -> ContentModel.ASPECT_GEN_CLASSIFIABLE.equals(pa.getQName()));
|
||||
}
|
||||
|
||||
private String getParentId(final NodeRef nodeRef)
|
||||
|
@@ -26,6 +26,8 @@
|
||||
|
||||
package org.alfresco.rest.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Category
|
||||
{
|
||||
private String id;
|
||||
@@ -72,4 +74,68 @@ public class Category
|
||||
{
|
||||
this.hasChildren = hasChildren;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Category category = (Category) o;
|
||||
return hasChildren == category.hasChildren && Objects.equals(id, category.id) && name.equals(category.name) &&
|
||||
Objects.equals(parentId, category.parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(id, name, parentId, hasChildren);
|
||||
}
|
||||
|
||||
public static Builder builder()
|
||||
{
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
private String id;
|
||||
private String name;
|
||||
private String parentId;
|
||||
private boolean hasChildren;
|
||||
|
||||
public Builder id(String id)
|
||||
{
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name)
|
||||
{
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder parentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder hasChildren(boolean hasChildren)
|
||||
{
|
||||
this.hasChildren = hasChildren;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Category create()
|
||||
{
|
||||
final Category category = new Category();
|
||||
category.setId(id);
|
||||
category.setName(name);
|
||||
category.setParentId(parentId);
|
||||
category.setHasChildren(hasChildren);
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,6 +44,7 @@ import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResource
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
||||
import org.alfresco.rest.framework.tools.RecognizedParamsExtractor;
|
||||
@@ -377,7 +378,8 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
{
|
||||
if (created !=null && created.size() > 1)
|
||||
{
|
||||
return CollectionWithPagingInfo.asPagedCollection(created.toArray());
|
||||
final Paging pagingAll = Paging.valueOf(0, created.size());
|
||||
return CollectionWithPagingInfo.asPaged(pagingAll, created);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -7,8 +7,6 @@ framework.exception.InvalidQuery=An invalid WHERE query was received. {0}
|
||||
framework.exception.InvalidSelect=An invalid {1} query was received. {0}
|
||||
framework.exception.NotFound={0} was not found
|
||||
framework.exception.EntityNotFound=The entity with id: {0} was not found
|
||||
framework.exception.CreateEventAlreadyExists=Cannot create event. An event with name: {0} already exists
|
||||
framework.exception.UpdateEventAlreadyExists=Cannot update event. An event with name: {0} already exists
|
||||
framework.exception.RelationshipNotFound=The relationship resource was not found for the entity with id: {0} and a relationship id of {1}
|
||||
framework.exception.PermissionDenied=Permission was denied
|
||||
framework.exception.StaleEntity=Attempt to update a stale entity
|
||||
|
@@ -830,6 +830,8 @@
|
||||
</bean>
|
||||
|
||||
<bean id="categories" class="org.alfresco.rest.api.impl.CategoriesImpl">
|
||||
<constructor-arg name="authorityService" ref="AuthorityService"/>
|
||||
<constructor-arg name="categoryService" ref="CategoryService"/>
|
||||
<constructor-arg name="nodes" ref="nodes"/>
|
||||
<constructor-arg name="nodeService" ref="NodeService"/>
|
||||
</bean>
|
||||
@@ -1099,10 +1101,14 @@
|
||||
<constructor-arg name="categories" ref="Categories"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.categories.SubcategoriesRelation">
|
||||
<constructor-arg name="categories" ref="Categories"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.tags.TagsEntityResource">
|
||||
<property name="tags" ref="Tags" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean class="org.alfresco.rest.api.people.PersonSitesRelation">
|
||||
<property name="sites" ref="Sites" />
|
||||
</bean>
|
||||
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.categories;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.rest.api.Categories;
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SubcategoriesRelationTest
|
||||
{
|
||||
private static final String PARENT_CATEGORY_ID = "parent-category-node-id";
|
||||
private static final String CATEGORY_ID = "category-node-id";
|
||||
private static final String CATEGORY_NAME = "categoryName";
|
||||
private static final String SUBCATEGORY_NAME_PREFIX = "childCategoryName";
|
||||
|
||||
@Mock
|
||||
private Categories categoriesMock;
|
||||
@Mock
|
||||
private Parameters parametersMock;
|
||||
|
||||
@InjectMocks
|
||||
private SubcategoriesRelation objectUnderTest;
|
||||
|
||||
@Test
|
||||
public void testCreateSubcategory()
|
||||
{
|
||||
final Category categoryToCreate = Category.builder().name(CATEGORY_NAME).create();
|
||||
final Category category = Category.builder().name(CATEGORY_NAME).parentId(PARENT_CATEGORY_ID).hasChildren(false).id(CATEGORY_ID).create();
|
||||
final List<Category> categoriesToCreate = List.of(categoryToCreate);
|
||||
given(categoriesMock.createSubcategories(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock)).willReturn(List.of(category));
|
||||
|
||||
//when
|
||||
List<Category> categories = objectUnderTest.create(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock);
|
||||
|
||||
then(categoriesMock).should().createSubcategories(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock);
|
||||
then(categoriesMock).shouldHaveNoMoreInteractions();
|
||||
assertEquals(List.of(category), categories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren() {
|
||||
final CollectionWithPagingInfo<Category> categoryChildren = getCategories(3);
|
||||
given(categoriesMock.getCategoryChildren(PARENT_CATEGORY_ID, parametersMock)).willReturn(categoryChildren);
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Category> returnedChildren = objectUnderTest.readAll(PARENT_CATEGORY_ID, parametersMock);
|
||||
|
||||
then(categoriesMock).should().getCategoryChildren(PARENT_CATEGORY_ID, parametersMock);
|
||||
then(categoriesMock).shouldHaveNoMoreInteractions();
|
||||
assertEquals(categoryChildren, returnedChildren);
|
||||
}
|
||||
|
||||
private CollectionWithPagingInfo<Category> getCategories(final int count)
|
||||
{
|
||||
return CollectionWithPagingInfo.asPaged(Paging.DEFAULT,
|
||||
IntStream.range(0, count)
|
||||
.mapToObj(i -> Category.builder().name(SUBCATEGORY_NAME_PREFIX + "-" + i)
|
||||
.parentId(PARENT_CATEGORY_ID)
|
||||
.hasChildren(false)
|
||||
.id(CATEGORY_ID + "-" + i)
|
||||
.create())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
@@ -26,15 +26,20 @@
|
||||
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import static org.alfresco.rest.api.Nodes.PATH_ROOT;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
@@ -42,11 +47,15 @@ import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -69,6 +78,10 @@ public class CategoriesImplTest
|
||||
@Mock
|
||||
private Parameters parametersMock;
|
||||
@Mock
|
||||
private AuthorityService authorityServiceMock;
|
||||
@Mock
|
||||
private CategoryService categoryServiceMock;
|
||||
@Mock
|
||||
private ChildAssociationRef dummyChildAssociationRefMock;
|
||||
@Mock
|
||||
private ChildAssociationRef categoryChildAssociationRefMock;
|
||||
@@ -93,6 +106,8 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryRootNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,10 +141,16 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
assertEquals(categoryNode.getName(), category.getName());
|
||||
assertEquals(CATEGORY_ID, category.getId());
|
||||
assertEquals(PARENT_ID, category.getParentId());
|
||||
assertTrue(category.getHasChildren());
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
|
||||
final Category expectedCategory = Category.builder()
|
||||
.id(CATEGORY_ID)
|
||||
.name(categoryNode.getName())
|
||||
.hasChildren(true)
|
||||
.parentId(PARENT_ID)
|
||||
.create();
|
||||
assertEquals(expectedCategory, category);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,10 +183,16 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
assertEquals(categoryNode.getName(), category.getName());
|
||||
assertEquals(CATEGORY_ID, category.getId());
|
||||
assertEquals(PARENT_ID, category.getParentId());
|
||||
assertFalse(category.getHasChildren());
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
|
||||
final Category expectedCategory = Category.builder()
|
||||
.id(CATEGORY_ID)
|
||||
.name(categoryNode.getName())
|
||||
.hasChildren(false)
|
||||
.parentId(PARENT_ID)
|
||||
.create();
|
||||
assertEquals(expectedCategory, category);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,6 +210,8 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,5 +226,430 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCategoryById_asAdmin()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef categoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
|
||||
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(categoryNodeRef);
|
||||
given(nodesMock.isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
final Node categoryNode = new Node();
|
||||
categoryNode.setName(CATEGORY_NAME);
|
||||
categoryNode.setNodeId(CATEGORY_ID);
|
||||
final NodeRef parentNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
categoryNode.setParentId(parentNodeRef);
|
||||
|
||||
//when
|
||||
objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock);
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should().validateNode(CATEGORY_ID);
|
||||
|
||||
then(nodesMock).should().isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryNodeRef);
|
||||
then(nodeServiceMock).should().deleteNode(categoryNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCategoryById_asNonAdminUser()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(false);
|
||||
|
||||
//when
|
||||
assertThrows(PermissionDeniedException.class, () -> objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodesMock).shouldHaveNoInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCategoryById_nonCategoryId()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef categoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
|
||||
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(categoryNodeRef);
|
||||
given(nodesMock.isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
|
||||
|
||||
//when
|
||||
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodesMock).should().validateNode(CATEGORY_ID);
|
||||
then(nodesMock).should().isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCategoryById_rootCategory()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef categoryRootNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CAT_ROOT_NODE_ID);
|
||||
given(nodesMock.validateNode(CAT_ROOT_NODE_ID)).willReturn(categoryRootNodeRef);
|
||||
given(nodesMock.isSubClass(categoryRootNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
given(categoryChildAssociationRefMock.getQName()).willReturn(ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
||||
given(nodeServiceMock.getParentAssocs(categoryRootNodeRef)).willReturn(List.of(categoryChildAssociationRefMock));
|
||||
|
||||
//when
|
||||
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.deleteCategoryById(CAT_ROOT_NODE_ID, parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodesMock).should().validateNode(CAT_ROOT_NODE_ID);
|
||||
then(nodesMock).should().isSubClass(categoryRootNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryRootNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategoryUnderRoot()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PATH_ROOT);
|
||||
given(categoryServiceMock.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE))
|
||||
.willReturn(Optional.of(parentCategoryNodeRef));
|
||||
final NodeRef categoryNodeRef = prepareCategoryNodeRef();
|
||||
given(categoryServiceMock.createCategory(parentCategoryNodeRef, CATEGORY_NAME)).willReturn(categoryNodeRef);
|
||||
given(nodesMock.getNode(CATEGORY_ID)).willReturn(prepareCategoryNode());
|
||||
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentCategoryNodeRef, null, categoryNodeRef);
|
||||
given(nodeServiceMock.getPrimaryParent(categoryNodeRef)).willReturn(parentAssoc);
|
||||
given(nodeServiceMock.getParentAssocs(parentCategoryNodeRef)).willReturn(List.of(parentAssoc));
|
||||
given(nodeServiceMock.getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false))
|
||||
.willReturn(Collections.emptyList());
|
||||
|
||||
//when
|
||||
final List<Category> createdCategories = objectUnderTest.createSubcategories(PATH_ROOT, prepareCategories(), parametersMock);
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should().getNode(CATEGORY_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getPrimaryParent(categoryNodeRef);
|
||||
then(nodeServiceMock).should().getParentAssocs(parentCategoryNodeRef);
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(categoryServiceMock).should().getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
then(categoryServiceMock).should().createCategory(parentCategoryNodeRef, CATEGORY_NAME);
|
||||
then(categoryServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
assertEquals(1, createdCategories.size());
|
||||
final Category expectedCategory = Category.builder()
|
||||
.id(CATEGORY_ID)
|
||||
.name(CATEGORY_NAME)
|
||||
.hasChildren(false)
|
||||
.parentId(PATH_ROOT)
|
||||
.create();
|
||||
final Category createdCategory = createdCategories.iterator().next();
|
||||
assertEquals(expectedCategory, createdCategory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategory()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
final NodeRef categoryNodeRef = prepareCategoryNodeRef();
|
||||
given(categoryServiceMock.createCategory(parentCategoryNodeRef, CATEGORY_NAME)).willReturn(categoryNodeRef);
|
||||
given(nodesMock.getNode(CATEGORY_ID)).willReturn(prepareCategoryNode());
|
||||
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentCategoryNodeRef, null, categoryNodeRef);
|
||||
given(nodeServiceMock.getPrimaryParent(categoryNodeRef)).willReturn(parentAssoc);
|
||||
given(nodeServiceMock.getParentAssocs(parentCategoryNodeRef)).willReturn(List.of(parentAssoc));
|
||||
given(nodeServiceMock.getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false))
|
||||
.willReturn(Collections.emptyList());
|
||||
|
||||
//when
|
||||
final List<Category> createdCategories = objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock);
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).should().getNode(CATEGORY_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getPrimaryParent(categoryNodeRef);
|
||||
then(nodeServiceMock).should().getParentAssocs(parentCategoryNodeRef);
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(categoryServiceMock).should().createCategory(parentCategoryNodeRef, CATEGORY_NAME);
|
||||
then(categoryServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
assertEquals(1, createdCategories.size());
|
||||
final Category expectedCategory = Category.builder()
|
||||
.id(CATEGORY_ID)
|
||||
.name(CATEGORY_NAME)
|
||||
.hasChildren(false)
|
||||
.parentId(PARENT_ID)
|
||||
.create();
|
||||
final Category createdCategory = createdCategories.iterator().next();
|
||||
assertEquals(expectedCategory, createdCategory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategories_noPermissions()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(false);
|
||||
|
||||
//when
|
||||
assertThrows(PermissionDeniedException.class,
|
||||
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).shouldHaveNoInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategories_wrongParentNodeType()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
|
||||
|
||||
//when
|
||||
assertThrows(InvalidArgumentException.class,
|
||||
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategories_nonExistingParentNode()
|
||||
{
|
||||
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willThrow(EntityNotFoundException.class);
|
||||
|
||||
//when
|
||||
assertThrows(EntityNotFoundException.class,
|
||||
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRootCategoryChildren()
|
||||
{
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PATH_ROOT);
|
||||
given(categoryServiceMock.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE))
|
||||
.willReturn(Optional.of(parentCategoryNodeRef));
|
||||
final int childrenCount = 3;
|
||||
final List<ChildAssociationRef> childAssociationRefMocks = prepareChildAssocMocks(childrenCount, parentCategoryNodeRef);
|
||||
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(childAssociationRefMocks);
|
||||
childAssociationRefMocks.forEach(this::prepareCategoryNodeMocks);
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PATH_ROOT, parametersMock);
|
||||
|
||||
then(categoryServiceMock).should().getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
then(categoryServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
|
||||
childAssociationRefMocks.forEach(ca -> {
|
||||
then(nodesMock).should().getNode(ca.getChildRef().getId());
|
||||
then(nodeServiceMock).should()
|
||||
.getChildAssocs(ca.getChildRef(), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).should().getPrimaryParent(ca.getChildRef());
|
||||
});
|
||||
then(nodeServiceMock).should(times(childrenCount)).getParentAssocs(parentCategoryNodeRef);
|
||||
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
|
||||
assertEquals(childAssociationRefMocks.size(), categoryChildren.getTotalItems().intValue());
|
||||
final List<Category> categoryChildrenList = new ArrayList<>(categoryChildren.getCollection());
|
||||
assertEquals(childAssociationRefMocks.size(), categoryChildrenList.size());
|
||||
IntStream.range(0, childrenCount).forEach(i -> doCategoryAssertions(categoryChildrenList.get(i), i, PATH_ROOT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren()
|
||||
{
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
final int childrenCount = 3;
|
||||
final List<ChildAssociationRef> childAssociationRefMocks = prepareChildAssocMocks(childrenCount, parentCategoryNodeRef);
|
||||
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(childAssociationRefMocks);
|
||||
childAssociationRefMocks.forEach(this::prepareCategoryNodeMocks);
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock);
|
||||
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
|
||||
childAssociationRefMocks.forEach(ca -> {
|
||||
then(nodesMock).should().getNode(ca.getChildRef().getId());
|
||||
then(nodeServiceMock).should()
|
||||
.getChildAssocs(ca.getChildRef(), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).should().getPrimaryParent(ca.getChildRef());
|
||||
});
|
||||
then(nodeServiceMock).should(times(childrenCount)).getParentAssocs(parentCategoryNodeRef);
|
||||
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
|
||||
assertEquals(childAssociationRefMocks.size(), categoryChildren.getTotalItems().intValue());
|
||||
final List<Category> categoryChildrenList = new ArrayList<>(categoryChildren.getCollection());
|
||||
assertEquals(childAssociationRefMocks.size(), categoryChildrenList.size());
|
||||
IntStream.range(0, childrenCount).forEach(i -> doCategoryAssertions(categoryChildrenList.get(i), i, PARENT_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren_noChildren()
|
||||
{
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
|
||||
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(Collections.emptyList());
|
||||
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock);
|
||||
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
|
||||
assertEquals(0, categoryChildren.getTotalItems().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren_wrongParentNodeType()
|
||||
{
|
||||
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
|
||||
|
||||
//when
|
||||
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock));
|
||||
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren_nonExistingParentNode()
|
||||
{
|
||||
given(nodesMock.validateNode(PARENT_ID)).willThrow(EntityNotFoundException.class);
|
||||
|
||||
//when
|
||||
assertThrows(EntityNotFoundException.class, () -> objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock));
|
||||
|
||||
|
||||
then(nodesMock).should().validateNode(PARENT_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
private Node prepareCategoryNode()
|
||||
{
|
||||
final NodeRef parentNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
|
||||
return prepareCategoryNode(CATEGORY_NAME, CATEGORY_ID, parentNodeRef);
|
||||
}
|
||||
|
||||
private Node prepareCategoryNode(final String name, final String id, final NodeRef parentNodeRef)
|
||||
{
|
||||
final Node categoryNode = new Node();
|
||||
categoryNode.setName(name);
|
||||
categoryNode.setNodeId(id);
|
||||
categoryNode.setParentId(parentNodeRef);
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
private NodeRef prepareCategoryNodeRef()
|
||||
{
|
||||
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
|
||||
}
|
||||
|
||||
private List<Category> prepareCategories()
|
||||
{
|
||||
return List.of(Category.builder()
|
||||
.name(CATEGORY_NAME)
|
||||
.create());
|
||||
}
|
||||
|
||||
private List<ChildAssociationRef> prepareChildAssocMocks(final int count, NodeRef parentCategoryNodeRef)
|
||||
{
|
||||
return IntStream.range(0, count).mapToObj(i -> {
|
||||
ChildAssociationRef dummyChildAssocMock = mock(ChildAssociationRef.class);
|
||||
given(dummyChildAssocMock.getTypeQName()).willReturn(ContentModel.ASSOC_SUBCATEGORIES);
|
||||
given(dummyChildAssocMock.getChildRef())
|
||||
.willReturn(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID + "-" + i));
|
||||
given(dummyChildAssocMock.getParentRef()).willReturn(parentCategoryNodeRef);
|
||||
return dummyChildAssocMock;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void prepareCategoryNodeMocks(ChildAssociationRef childAssociationRef)
|
||||
{
|
||||
final NodeRef childRef = childAssociationRef.getChildRef();
|
||||
final String id = childRef.getId();
|
||||
final String name = id.replace(CATEGORY_ID, CATEGORY_NAME);
|
||||
final NodeRef parentRef = childAssociationRef.getParentRef();
|
||||
given(nodesMock.getNode(id)).willReturn(prepareCategoryNode(name, id, parentRef));
|
||||
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentRef, null, childRef);
|
||||
given(nodeServiceMock.getPrimaryParent(childRef)).willReturn(parentAssoc);
|
||||
given(nodeServiceMock.getParentAssocs(parentRef)).willReturn(List.of(parentAssoc));
|
||||
}
|
||||
|
||||
private void doCategoryAssertions(final Category category, final int index, final String parentId)
|
||||
{
|
||||
final Category expectedCategory = Category.builder()
|
||||
.id(CATEGORY_ID + "-" + index)
|
||||
.name(CATEGORY_NAME + "-" + index)
|
||||
.parentId(parentId)
|
||||
.hasChildren(false)
|
||||
.create();
|
||||
assertEquals(expectedCategory, category);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
<version>20.45-DEV</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -573,6 +573,7 @@
|
||||
org.alfresco.service.cmr.search.CategoryService.deleteClassification=ACL_ALLOW
|
||||
org.alfresco.service.cmr.search.CategoryService.deleteCategory=ACL_ALLOW
|
||||
org.alfresco.service.cmr.search.CategoryService.getTopCategories=ACL_ALLOW
|
||||
org.alfresco.service.cmr.search.CategoryService.getRootCategoryNodeRef=ACL_ALLOW
|
||||
org.alfresco.service.cmr.search.CategoryService.*=ACL_DENY
|
||||
</value>
|
||||
</property>
|
||||
|
20
scripts/ci/build_functions.sh
Normal file
20
scripts/ci/build_functions.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set +vx
|
||||
|
||||
function cloneRepo() {
|
||||
local REPO="${1}"
|
||||
local TAG_OR_BRANCH="${2}"
|
||||
|
||||
printf "Cloning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
|
||||
|
||||
# clone the repository branch/tag
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
|
||||
|
||||
rm -rf "$(basename "${REPO%.git}")"
|
||||
|
||||
git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}"
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
set -vx
|
40
scripts/ci/docker-compose/docker-compose-db.yaml
Normal file
40
scripts/ci/docker-compose/docker-compose-db.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
profiles: ["postgres"]
|
||||
image: postgres:${POSTGRES_VERSION}
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=alfresco
|
||||
- POSTGRES_USER=alfresco
|
||||
- POSTGRES_DB=alfresco
|
||||
command: postgres -c max_connections=300
|
||||
ports:
|
||||
- "5433:5432"
|
||||
mariadb:
|
||||
profiles: ["mariadb"]
|
||||
image: mariadb:${MARIADB_VERSION}
|
||||
command: --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=alfresco
|
||||
- MYSQL_USER=alfresco
|
||||
- MYSQL_DATABASE=alfresco
|
||||
- MYSQL_PASSWORD=alfresco
|
||||
ports:
|
||||
- "3307:3306"
|
||||
mysql:
|
||||
profiles: ["mysql"]
|
||||
image: mysql:${MYSQL_VERSION}
|
||||
command: --transaction-isolation='READ-COMMITTED'
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=alfresco
|
||||
- MYSQL_USER=alfresco
|
||||
- MYSQL_DATABASE=alfresco
|
||||
- MYSQL_PASSWORD=alfresco
|
||||
ports:
|
||||
- "3307:3306"
|
||||
activemq:
|
||||
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
|
||||
ports:
|
||||
- "5672:5672" # AMQP
|
||||
- "61616:61616" # OpenWire
|
26
scripts/ci/docker-compose/docker-compose.yaml
Normal file
26
scripts/ci/docker-compose/docker-compose.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
transform-core-aio:
|
||||
profiles: ["with-transform-core-aio"]
|
||||
image: alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG}
|
||||
environment:
|
||||
JAVA_OPTS: " -Xms256m -Xmx256m"
|
||||
ports:
|
||||
- "8090:8090"
|
||||
postgres:
|
||||
image: postgres:14.4
|
||||
profiles: ["default", "with-transform-core-aio", "postgres"]
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=alfresco
|
||||
- POSTGRES_USER=alfresco
|
||||
- POSTGRES_DB=alfresco
|
||||
command: postgres -c max_connections=300
|
||||
ports:
|
||||
- "5433:5432"
|
||||
activemq:
|
||||
profiles: ["default", "with-transform-core-aio", "activemq"]
|
||||
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
|
||||
ports:
|
||||
- "5672:5672" # AMQP
|
||||
- "61616:61616" # OpenWire
|
@@ -5,7 +5,7 @@ set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
# Maven Setup
|
||||
mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml"
|
||||
mkdir -p "${HOME}/.m2" && cp -f .github/.ci.settings.xml "${HOME}/.m2/settings.xml"
|
||||
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf
|
||||
|
||||
# Docker Logins
|
@@ -4,23 +4,22 @@ PS4="\[\e[35m\]+ \[\e[m\]"
|
||||
set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
|
||||
# Use full history for release
|
||||
git checkout -B "${TRAVIS_BRANCH}"
|
||||
# Add email to link commits to user
|
||||
git checkout -B "${BRANCH_NAME}"
|
||||
# Define git identity for commits
|
||||
git config user.email "${GIT_EMAIL}"
|
||||
git config user.name "${GIT_USERNAME}"
|
||||
|
||||
# Run the release plugin - with "[skip ci]" in the release commit message
|
||||
mvn -B \
|
||||
-Pall-tas-tests \
|
||||
-Pags \
|
||||
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
|
||||
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${BUILD_NUMBER}" \
|
||||
release:clean release:prepare release:perform \
|
||||
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \
|
||||
-Dusername="${GIT_USERNAME}" \
|
||||
-Dpassword="${GIT_PASSWORD}"
|
||||
|
||||
|
||||
popd
|
||||
set +vex
|
||||
echo "=========================== Finishing Release Script =========================="
|
@@ -7,8 +7,8 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh"
|
||||
|
||||
#Fetch the latest changes, as Travis will only checkout the PR commit
|
||||
git fetch origin "${TRAVIS_BRANCH}"
|
||||
git checkout "${TRAVIS_BRANCH}"
|
||||
git fetch origin "${BRANCH_NAME}"
|
||||
git checkout "${BRANCH_NAME}"
|
||||
git pull
|
||||
|
||||
# Retrieve the current Community version - latest tag on the current branch
|
||||
@@ -16,7 +16,7 @@ VERSION="$(git describe --abbrev=0 --tags)"
|
||||
|
||||
DOWNSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-repo.git"
|
||||
|
||||
cloneRepo "${DOWNSTREAM_REPO}" "${TRAVIS_BRANCH}"
|
||||
cloneRepo "${DOWNSTREAM_REPO}" "${BRANCH_NAME}"
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${DOWNSTREAM_REPO%.git}")"
|
||||
|
||||
@@ -33,8 +33,8 @@ git status
|
||||
git --no-pager diff pom.xml
|
||||
git add pom.xml
|
||||
|
||||
if [[ "${TRAVIS_COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
|
||||
FORCE_TOKEN=$(echo "${TRAVIS_COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
|
||||
if [[ "${COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
|
||||
FORCE_TOKEN=$(echo "${COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
|
||||
git commit --allow-empty -m "${FORCE_TOKEN} Update upstream version to ${VERSION}"
|
||||
git push
|
||||
elif git status --untracked-files=no --porcelain | grep -q '^' ; then
|
@@ -1,193 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set +vx
|
||||
|
||||
function isPullRequestBuild() {
|
||||
test "${TRAVIS_PULL_REQUEST}" != "false"
|
||||
}
|
||||
|
||||
function isBranchBuild() {
|
||||
test "${TRAVIS_PULL_REQUEST}" = "false"
|
||||
}
|
||||
|
||||
function cloneRepo() {
|
||||
local REPO="${1}"
|
||||
local TAG_OR_BRANCH="${2}"
|
||||
|
||||
printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
|
||||
|
||||
# clone the repository branch/tag
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
|
||||
|
||||
rm -rf "$(basename "${REPO%.git}")"
|
||||
|
||||
git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}"
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function retrievePomParentVersion() {
|
||||
local REPO="${1}"
|
||||
|
||||
if [ -z "${REPO}" ]; then
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
|
||||
else
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null
|
||||
fi
|
||||
|
||||
sed -n '/<parent>/,/<\/parent>/p' pom.xml \
|
||||
| sed -n '/<version>/,/<\/version>/p' \
|
||||
| tr -d '\n' \
|
||||
| grep -oP '(?<=<version>).*(?=</version>)' \
|
||||
| xargs
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function retrievePomProperty() {
|
||||
local KEY="${1}"
|
||||
local REPO="${2}"
|
||||
|
||||
if [ -z "${REPO}" ]; then
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
|
||||
else
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null
|
||||
fi
|
||||
|
||||
sed -n '/<properties>/,/<\/properties>/p' pom.xml \
|
||||
| sed -n "/<${KEY}>/,/<\/${KEY}>/p" \
|
||||
| tr -d '\n' \
|
||||
| grep -oP "(?<=<${KEY}>).*(?=</${KEY}>)" \
|
||||
| xargs
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function evaluatePomProperty() {
|
||||
local KEY="${1}"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
|
||||
|
||||
mvn -B -q help:evaluate -Dexpression="${KEY}" -DforceStdout
|
||||
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function remoteBranchExists() {
|
||||
local REMOTE_REPO="${1}"
|
||||
local BRANCH="${2}"
|
||||
|
||||
git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH}" &>/dev/null
|
||||
}
|
||||
|
||||
function identifyUpstreamSourceBranch() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
|
||||
# if it's a pull request, use the source branch name (if it exists)
|
||||
if isPullRequestBuild && remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_PULL_REQUEST_BRANCH}" ; then
|
||||
echo "${TRAVIS_PULL_REQUEST_BRANCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# otherwise use the current branch name (or in case of PRs, the target branch name)
|
||||
if remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}" ; then
|
||||
echo "${TRAVIS_BRANCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# if none of the previous exists, use the "master" branch
|
||||
echo "master"
|
||||
}
|
||||
|
||||
function pullUpstreamTag() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
local TAG="${2}"
|
||||
|
||||
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
|
||||
}
|
||||
|
||||
function pullSameBranch() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
|
||||
local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")"
|
||||
|
||||
cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"
|
||||
}
|
||||
|
||||
function buildUpstreamTag() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
local TAG="${2}"
|
||||
local EXTRA_BUILD_ARGUMENTS="${3}"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
|
||||
|
||||
cd "$(basename "${UPSTREAM_REPO%.git}")"
|
||||
|
||||
mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS}
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function buildSameBranchOnUpstream() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
local EXTRA_BUILD_ARGUMENTS="${2}"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
|
||||
|
||||
cd "$(basename "${UPSTREAM_REPO%.git}")"
|
||||
|
||||
mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS}
|
||||
mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function pullUpstreamTagAndBuildDockerImage() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
local TAG="${2}"
|
||||
local EXTRA_BUILD_ARGUMENTS="${3}"
|
||||
|
||||
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
|
||||
|
||||
cd "$(basename "${UPSTREAM_REPO%.git}")"
|
||||
|
||||
mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS}
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function pullAndBuildSameBranchOnUpstream() {
|
||||
local UPSTREAM_REPO="${1}"
|
||||
local EXTRA_BUILD_ARGUMENTS="${2}"
|
||||
|
||||
local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")"
|
||||
|
||||
cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
|
||||
|
||||
cd "$(basename "${UPSTREAM_REPO%.git}")"
|
||||
|
||||
mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS}
|
||||
mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
function retieveLatestTag() {
|
||||
local REPO="${1}"
|
||||
local BRANCH="${2}"
|
||||
|
||||
local LOCAL_PATH="/tmp/$(basename "${REPO%.git}")"
|
||||
|
||||
git clone -q -b "${BRANCH}" "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" "${LOCAL_PATH}"
|
||||
|
||||
pushd "${LOCAL_PATH}" >/dev/null
|
||||
git describe --abbrev=0 --tags
|
||||
popd >/dev/null
|
||||
|
||||
rm -rf "${LOCAL_PATH}"
|
||||
}
|
||||
|
||||
set -vx
|
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "=========================== Starting SourceClear Script ==========================="
|
||||
PS4="\[\e[35m\]+ \[\e[m\]"
|
||||
set +e -v -x
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
mvn -B -q clean install \
|
||||
-DskipTests \
|
||||
-Dmaven.javadoc.skip=true \
|
||||
com.srcclr:srcclr-maven-plugin:scan \
|
||||
-Dcom.srcclr.apiToken=${SRCCLR_API_TOKEN} > scan.log
|
||||
|
||||
SUCCESS=$? # this will read exit code of the previous command
|
||||
|
||||
if [ -z "$VERACODE_FAILS_BUILD" ] || [ "$VERACODE_FAILS_BUILD" = false ] ; then
|
||||
SUCCESS=0
|
||||
fi
|
||||
|
||||
cat scan.log | grep -e 'Full Report Details' -e 'Failed'
|
||||
|
||||
popd
|
||||
set +vex
|
||||
echo "=========================== Finishing SourceClear Script =========================="
|
||||
|
||||
exit ${SUCCESS}
|
Reference in New Issue
Block a user