mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
1 Commits
20.41-DEV
...
rm-7187-ev
Author | SHA1 | Date | |
---|---|---|---|
|
3875f0b170 |
557
.github/workflows/ci.yml
vendored
557
.github/workflows/ci.yml
vendored
@@ -1,557 +0,0 @@
|
||||
name: Alfresco Community Repo CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- 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-
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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: >
|
||||
(((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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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
|
||||
parameters: '"-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
|
||||
parameters: '-Dindex.subsystem.name=solr6'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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.parameters }}
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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: "After success"
|
||||
if: ${{ always() }} && outcome.tests.outcome == 'success'
|
||||
run: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
continue-on-error: true
|
||||
- name: "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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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 Unit & 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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 Unit & 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 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- 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
|
||||
- run: bash amps/ags/ci/scripts/getLogs.sh
|
||||
if: ${{ always() }}
|
||||
- shell: bash
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
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
|
63
.github/workflows/master_release.yml
vendored
63
.github/workflows/master_release.yml
vendored
@@ -1,63 +0,0 @@
|
||||
name: Master/Release branch workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
# - master
|
||||
# - release/**
|
||||
- feature/ACS-3841_test_gha
|
||||
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')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.12.0
|
||||
with:
|
||||
username: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
email: ${{ secrets.BOT_GITHUB_EMAIL }}
|
||||
- name: "Verify release tag"
|
||||
run: bash ./scripts/ci/verify_release_tag.sh
|
||||
- name: "Release"
|
||||
run: bash ./scripts/ci/maven_release.sh
|
||||
env:
|
||||
BUILD_NUMBER: ${{ github.run_number }}
|
||||
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_PASSWORD }}
|
||||
GIT_EMAIL: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
- 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') &&
|
||||
(needs.push_to_nexus.result == 'success') &&
|
||||
(! contains(github.event.head_commit.message, '[no downstream]'))
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@v1.23.0
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
|
||||
- uses: Alfresco/acs-community-packaging/.github/actions/setup-build-tools@feature/ACS-3844_migrate-to-GHA
|
||||
- run: bash ./scripts/ci/update_downstream.sh
|
||||
env:
|
||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_PASSWORD }}
|
||||
GIT_EMAIL: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
- name: "Clean Maven cache"
|
||||
if: ${{ always() }}
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
@@ -19,7 +19,10 @@ before_cache: bash scripts/travis/cleanup_cache.sh
|
||||
|
||||
branches:
|
||||
only:
|
||||
- none
|
||||
- master
|
||||
- /release\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
|
||||
env:
|
||||
global:
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -1,10 +1,7 @@
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.rest.rm.community.utils.AlphabeticallyPriorityInterceptor" />
|
||||
</listeners>
|
||||
<test name="restapi" preserve-order="false">
|
||||
<test name="restapi">
|
||||
<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.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -175,6 +175,14 @@
|
||||
<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" />
|
||||
@@ -209,6 +217,8 @@
|
||||
<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.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* #%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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* #%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,35 +1,34 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2016 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 org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestCategoryModelsCollection extends RestModels<RestCategoryModel, RestCandidateModelsCollection>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* #%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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* #%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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* #%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.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -49,7 +47,8 @@ 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()
|
||||
@@ -100,33 +99,6 @@ 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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,15 +25,9 @@
|
||||
*/
|
||||
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.alfresco.rest.model.RestRuleModelsCollection;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
public class Categories extends ModelRequest<Categories>
|
||||
@@ -47,9 +41,9 @@ public class Categories extends ModelRequest<Categories>
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a category with ID using GET call on "/categories/{categoryId}"
|
||||
* Retrieves a category with ID using GET call on using GET call on "/tags/{tagId}"
|
||||
*
|
||||
* @return RestCategoryModel
|
||||
* @return
|
||||
*/
|
||||
public RestCategoryModel getCategory()
|
||||
{
|
||||
@@ -58,26 +52,4 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* #%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");
|
||||
}
|
||||
|
||||
private 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());
|
||||
}
|
||||
}
|
@@ -29,7 +29,6 @@ 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.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
@@ -51,19 +50,6 @@ 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("Get category with -root- as id (which does not exist)");
|
||||
final RestCategoryModel rootCategory = new RestCategoryModel();
|
||||
rootCategory.setId("-root-");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get an error when passing -root- as category id
|
||||
*/
|
||||
|
@@ -56,7 +56,6 @@ 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;
|
||||
@@ -64,7 +63,6 @@ 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;
|
||||
@@ -269,38 +267,6 @@ 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.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</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.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</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.4.0-A1</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.6.0-A1</alfresco.aos-module.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.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>20.41-DEV</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -26,8 +26,6 @@
|
||||
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.Experimental;
|
||||
@@ -37,6 +35,4 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
public interface Categories
|
||||
{
|
||||
Category getCategoryById(String id, Parameters params);
|
||||
|
||||
List<Category> createSubcategories(String parentCategoryId, List<Category> categories, Parameters parameters);
|
||||
}
|
||||
|
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* #%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.Parameters;
|
||||
|
||||
@RelationshipResource(name = "subcategories", entityResource = CategoriesEntityResource.class, title = "Subcategories")
|
||||
public class SubcategoriesRelation implements RelationshipResourceAction.Create<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);
|
||||
}
|
||||
}
|
@@ -29,44 +29,31 @@ 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.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";
|
||||
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(AuthorityService authorityService, CategoryService categoryService, Nodes nodes, NodeService nodeService)
|
||||
public CategoriesImpl(Nodes nodes, NodeService nodeService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
this.categoryService = categoryService;
|
||||
this.nodes = nodes;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
@@ -75,67 +62,27 @@ public class CategoriesImpl implements Categories
|
||||
public Category getCategoryById(final String id, final Parameters params)
|
||||
{
|
||||
final NodeRef nodeRef = nodes.validateNode(id);
|
||||
if (isNotACategory(nodeRef) || isRootCategory(nodeRef))
|
||||
final boolean isCategory = nodes.isSubClass(nodeRef, ContentModel.TYPE_CATEGORY, false);
|
||||
if (!isCategory || 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 = PATH_ROOT.equals(parentCategoryId) ?
|
||||
categoryService.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE)
|
||||
.orElseThrow(() -> new EntityNotFoundException(parentCategoryId)) :
|
||||
nodes.validateNode(parentCategoryId);
|
||||
if (isNotACategory(parentNodeRef))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{parentCategoryId});
|
||||
}
|
||||
final List<NodeRef> categoryNodeRefs = categories.stream()
|
||||
.map(c -> createCategoryNodeRef(parentNodeRef, c))
|
||||
.collect(Collectors.toList());
|
||||
return categoryNodeRefs.stream()
|
||||
.map(this::mapToCategory)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
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));
|
||||
return Category.builder()
|
||||
.id(nodeRef.getId())
|
||||
.name(categoryNode.getName())
|
||||
.parentId(getParentId(nodeRef))
|
||||
.hasChildren(hasChildren)
|
||||
.create();
|
||||
category.setHasChildren(hasChildren);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
private boolean isRootCategory(final NodeRef nodeRef)
|
||||
{
|
||||
final List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
|
||||
return parentAssocs.stream().anyMatch(pa -> ContentModel.ASPECT_GEN_CLASSIFIABLE.equals(pa.getQName()));
|
||||
return parentAssocs.stream().anyMatch(pa -> pa.getQName().equals(ContentModel.ASPECT_GEN_CLASSIFIABLE));
|
||||
}
|
||||
|
||||
private String getParentId(final NodeRef nodeRef)
|
||||
|
@@ -26,8 +26,6 @@
|
||||
|
||||
package org.alfresco.rest.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Category
|
||||
{
|
||||
private String id;
|
||||
@@ -74,68 +72,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,46 +1,39 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2016 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;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
package org.alfresco.rest.framework.core.exceptions;
|
||||
|
||||
import org.testng.IMethodInstance;
|
||||
import org.testng.IMethodInterceptor;
|
||||
import org.testng.ITestContext;
|
||||
/**
|
||||
* The addressed Relationship Resource was not found
|
||||
*/
|
||||
public class EventAlreadyExistsException extends ApiException {
|
||||
|
||||
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());
|
||||
private static final long serialVersionUID = -3675294374348951929L;
|
||||
|
||||
public EventAlreadyExistsException(String msgId, Object[] msgParams) {
|
||||
super(msgId, msgParams);
|
||||
}
|
||||
}
|
||||
}
|
@@ -44,7 +44,6 @@ 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;
|
||||
@@ -378,8 +377,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
{
|
||||
if (created !=null && created.size() > 1)
|
||||
{
|
||||
final Paging pagingAll = Paging.valueOf(0, created.size());
|
||||
return CollectionWithPagingInfo.asPaged(pagingAll, created);
|
||||
return CollectionWithPagingInfo.asPagedCollection(created.toArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -7,6 +7,8 @@ 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,8 +830,6 @@
|
||||
</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>
|
||||
@@ -1101,14 +1099,10 @@
|
||||
<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>
|
||||
|
@@ -26,15 +26,15 @@
|
||||
|
||||
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 java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
@@ -42,14 +42,11 @@ 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.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;
|
||||
@@ -72,10 +69,6 @@ public class CategoriesImplTest
|
||||
@Mock
|
||||
private Parameters parametersMock;
|
||||
@Mock
|
||||
private AuthorityService authorityServiceMock;
|
||||
@Mock
|
||||
private CategoryService categoryServiceMock;
|
||||
@Mock
|
||||
private ChildAssociationRef dummyChildAssociationRefMock;
|
||||
@Mock
|
||||
private ChildAssociationRef categoryChildAssociationRefMock;
|
||||
@@ -100,8 +93,6 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryRootNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,16 +126,10 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
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);
|
||||
assertEquals(categoryNode.getName(), category.getName());
|
||||
assertEquals(CATEGORY_ID, category.getId());
|
||||
assertEquals(PARENT_ID, category.getParentId());
|
||||
assertTrue(category.getHasChildren());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,16 +162,10 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
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);
|
||||
assertEquals(categoryNode.getName(), category.getName());
|
||||
assertEquals(CATEGORY_ID, category.getId());
|
||||
assertEquals(PARENT_ID, category.getParentId());
|
||||
assertFalse(category.getHasChildren());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -204,8 +183,6 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,171 +197,5 @@ public class CategoriesImplTest
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(categoryServiceMock).shouldHaveNoInteractions();
|
||||
then(authorityServiceMock).shouldHaveNoInteractions();
|
||||
}
|
||||
|
||||
@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));
|
||||
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(PATH_ROOT, prepareCategories(), parametersMock);
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
then(authorityServiceMock).shouldHaveNoMoreInteractions();
|
||||
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().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();
|
||||
}
|
||||
|
||||
private Node prepareCategoryNode()
|
||||
{
|
||||
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);
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.41-DEV</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -573,7 +573,6 @@
|
||||
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>
|
||||
|
@@ -1,20 +0,0 @@
|
||||
#!/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
|
@@ -1,40 +0,0 @@
|
||||
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
|
@@ -1,26 +0,0 @@
|
||||
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
|
193
scripts/travis/build_functions.sh
Normal file
193
scripts/travis/build_functions.sh
Normal file
@@ -0,0 +1,193 @@
|
||||
#!/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
|
@@ -5,7 +5,7 @@ set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
# Maven Setup
|
||||
mkdir -p "${HOME}/.m2" && cp -f .github/.ci.settings.xml "${HOME}/.m2/settings.xml"
|
||||
mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml"
|
||||
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf
|
||||
|
||||
# Docker Logins
|
@@ -4,22 +4,23 @@ PS4="\[\e[35m\]+ \[\e[m\]"
|
||||
set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
|
||||
# Use full history for release
|
||||
git checkout -B "${BRANCH_NAME}"
|
||||
# Define git identity for commits
|
||||
git checkout -B "${TRAVIS_BRANCH}"
|
||||
# Add email to link commits to user
|
||||
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=${BUILD_NUMBER}" \
|
||||
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${TRAVIS_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 "${BRANCH_NAME}"
|
||||
git checkout "${BRANCH_NAME}"
|
||||
git fetch origin "${TRAVIS_BRANCH}"
|
||||
git checkout "${TRAVIS_BRANCH}"
|
||||
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}" "${BRANCH_NAME}"
|
||||
cloneRepo "${DOWNSTREAM_REPO}" "${TRAVIS_BRANCH}"
|
||||
|
||||
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 [[ "${COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
|
||||
FORCE_TOKEN=$(echo "${COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
|
||||
if [[ "${TRAVIS_COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
|
||||
FORCE_TOKEN=$(echo "${TRAVIS_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
|
Reference in New Issue
Block a user