mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
8 Commits
release/7.
...
10.3
Author | SHA1 | Date | |
---|---|---|---|
|
22ef4441f3 | ||
|
2f77c8b304 | ||
|
e34165b72e | ||
|
f7f4f70990 | ||
|
e293976b58 | ||
|
747f2c8919 | ||
|
f445646045 | ||
|
1e02870774 |
411
.github/workflows/ci.yml
vendored
411
.github/workflows/ci.yml
vendored
@@ -1,411 +0,0 @@
|
||||
name: Alfresco Community Repo CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- release/**
|
||||
- feature/**
|
||||
- fix/**
|
||||
|
||||
push:
|
||||
branches:
|
||||
- feature/**
|
||||
- fix/**
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts
|
||||
TAS_ENVIRONMENT: ./packaging/tests/environment
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
|
||||
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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Prepare maven cache and check compilation"
|
||||
run: bash ./scripts/ci/prepare.sh
|
||||
- name: "Clean Maven cache"
|
||||
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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run tests"
|
||||
run: |
|
||||
mvn -B test -pl core,data-model -am -DfailIfNoTests=false
|
||||
mvn -B test -pl "repository" -am "-Dtest=AllUnitTestsSuite" -DfailIfNoTests=false
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_app_context_test_suites:
|
||||
name: Repository - ${{ matrix.testSuite }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
!contains(github.event.head_commit.message, '[skip repo]') &&
|
||||
!contains(github.event.head_commit.message, '[skip tests]') &&
|
||||
!contains(github.event.head_commit.message, '[force]')
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- testSuite: AppContext01TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext02TestSuite
|
||||
compose-profile: default
|
||||
- testSuite: AppContext03TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext04TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContext05TestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '"-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"'
|
||||
- testSuite: AppContext06TestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: AppContextExtraTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: MiscContextTestSuite
|
||||
compose-profile: with-transform-core-aio
|
||||
- testSuite: SearchTestSuite
|
||||
compose-profile: default
|
||||
mvn-options: '-Dindex.subsystem.name=solr6'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.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: |
|
||||
if [ -e ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh ]; then
|
||||
bash ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh
|
||||
fi
|
||||
docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
|
||||
- name: "Run tests"
|
||||
run: mvn -B test -pl repository -am -Dtest=${{ matrix.testSuite }} -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco ${{ matrix.mvn-options }}
|
||||
- name: "Clean Maven cache"
|
||||
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' || startsWith(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']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: Run MariaDB ${{ matrix.version }} database
|
||||
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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mariadb_10_5_tests:
|
||||
name: Repository - MariaDB 10.5 tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: Run MariaDB 10.5 database
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
|
||||
env:
|
||||
MARIADB_VERSION: 10.5
|
||||
- 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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mysql_5_7_28_tests:
|
||||
name: Repository - MySQL ${{ matrix.version }} tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run MySQL 5.7.28 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mysql up -d
|
||||
env:
|
||||
MYSQL_VERSION: 5.7.28
|
||||
- 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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_mysql_8_tests:
|
||||
name: Repository - MySQL 8 tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run MySQL 8 database"
|
||||
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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_tests:
|
||||
name: "Repository - PostgreSQL ${{ matrix.version }} tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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.9', '11.7', '12.4']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run PostgreSQL ${{ matrix.version }} database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: ${{ matrix.version }}
|
||||
- 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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
repository_postgresql_13_1_tests:
|
||||
name: "Repository - PostgreSQL 13.1 tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- name: "Run PostgreSQL 13.1 database"
|
||||
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
|
||||
env:
|
||||
POSTGRES_VERSION: 13.1
|
||||
- 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"
|
||||
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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- 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"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
|
||||
tas_tests:
|
||||
name: ${{ matrix.test-name }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [prepare]
|
||||
if: >
|
||||
(((github.ref_name == 'master' || startsWith(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-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: "11"
|
||||
- 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: "Run tests"
|
||||
id: tests
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: mvn -B verify -f packaging/tests/${{ matrix.pom-dir }}/pom.xml -Pall-tas-tests,${{ matrix.test-profile }} -Denvironment=default -DrunBugs=false
|
||||
- name: "Print output after success"
|
||||
if: ${{ always() && steps.tests.outcome == 'success' }}
|
||||
run: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Print output after failure"
|
||||
if: ${{ always() && steps.tests.outcome == 'failure' }}
|
||||
run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/${{ matrix.pom-dir }}"
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
79
.github/workflows/master_release.yml
vendored
79
.github/workflows/master_release.yml
vendored
@@ -1,79 +0,0 @@
|
||||
name: Master/Release branch workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- release/**
|
||||
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
|
||||
GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }}
|
||||
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }}
|
||||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
|
||||
|
||||
jobs:
|
||||
run_ci:
|
||||
uses: ./.github/workflows/ci.yml
|
||||
secrets: inherit
|
||||
push_to_nexus:
|
||||
name: "Push to Nexus"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [run_ci]
|
||||
if: >
|
||||
!(failure() || cancelled()) &&
|
||||
!contains(github.event.head_commit.message, '[no release]') &&
|
||||
github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.33.0
|
||||
with:
|
||||
username: ${{ env.GIT_USERNAME }}
|
||||
email: ${{ env.GIT_EMAIL }}
|
||||
global: true
|
||||
- name: "Release"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash scripts/ci/verify_release_tag.sh
|
||||
bash scripts/ci/maven_release.sh
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
||||
update_downstream:
|
||||
name: "Update alfresco-enterprise-repo"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [push_to_nexus]
|
||||
if: >
|
||||
!(failure() || cancelled()) &&
|
||||
!contains(github.event.head_commit.message, '[no downstream]') &&
|
||||
github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
- name: "Init"
|
||||
run: bash ./scripts/ci/init.sh
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.33.0
|
||||
with:
|
||||
username: ${{ env.GIT_USERNAME }}
|
||||
email: ${{ env.GIT_EMAIL }}
|
||||
global: true
|
||||
- name: "Update downstream"
|
||||
run: bash ./scripts/ci/update_downstream.sh
|
||||
env:
|
||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||
- name: "Clean Maven cache"
|
||||
run: bash ./scripts/ci/cleanup_cache.sh
|
@@ -25,6 +25,10 @@
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<properties>
|
||||
<!-- WhiteSource token -->
|
||||
<org.whitesource.orgToken>${env.WHITESOURCE_API_KEY}</org.whitesource.orgToken>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
300
.travis.yml
Normal file
300
.travis.yml
Normal file
@@ -0,0 +1,300 @@
|
||||
---
|
||||
dist: focal
|
||||
language: java
|
||||
jdk: openjdk11
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- ${HOME}/.m2/repository
|
||||
|
||||
# the cache can grow constantly
|
||||
before_cache: bash scripts/travis/cleanup_cache.sh
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /release\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
|
||||
env:
|
||||
global:
|
||||
- TAS_SCRIPTS=../alfresco-community-repo/packaging/tests/scripts
|
||||
- TAS_ENVIRONMENT=./packaging/tests/environment
|
||||
|
||||
stages:
|
||||
- name: test
|
||||
if: commit_message !~ /\[skip tests\]/
|
||||
- name: release
|
||||
if: fork = false AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND commit_message !~ /\[no release\]/
|
||||
- name: update_downstream
|
||||
if: fork = false AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND commit_message !~ /\[no downstream\]/
|
||||
- name: trigger_downstream
|
||||
if: fork = false AND (branch != master AND branch !~ /release\/.*/) AND type != pull_request AND commit_message !~ /\[no downstream\]/
|
||||
|
||||
before_install: travis_retry bash scripts/travis/init.sh
|
||||
install: travis_retry travis_wait 40 bash scripts/travis/build.sh
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
||||
- name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test"
|
||||
script:
|
||||
- travis_retry mvn -B test -pl core,data-model
|
||||
- travis_retry mvn -B test -pl repository -Dtest=AllUnitTestsSuite
|
||||
|
||||
- name: "Repository - AppContext01TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContext02TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContext03TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContext04TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContext05TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- mkdir -p "${HOME}/tmp"
|
||||
- cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp"
|
||||
- export HOST_IP=$(hostname -I | cut -f1 -d' ')
|
||||
- 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
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext05TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"
|
||||
|
||||
- name: "Repository - AppContext06TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - AppContextExtraTestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - MiscContextTestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - SearchTestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=SearchTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco -Dindex.subsystem.name=solr6
|
||||
|
||||
- name: "Repository - MariaDB 10.2.18 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.2.18 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -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: "Repository - MariaDB 10.4 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.4 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -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: "Repository - MariaDB 10.5 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.5 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -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: "Repository - MySQL 5.7.23 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mysql:5.7.23 --transaction-isolation='READ-COMMITTED'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - MySQL 8 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mysql:8 --transaction-isolation='READ-COMMITTED'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - PostgreSQL 10.9 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:10.9 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - PostgreSQL 11.7 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.7 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - PostgreSQL 12.4 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:12.4 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - PostgreSQL 13.1 tests"
|
||||
if: commit_message !~ /\[skip db\]/
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Remote-api - AppContext01TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Remote-api - AppContext02TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Remote-api - AppContext03TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Remote-api - AppContext04TestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Remote-api - AppContextExtraTestSuite"
|
||||
before_script:
|
||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "REST API TAS tests part1"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 60 mvn -B install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "REST API TAS tests part2"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 60 mvn -B install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "REST API TAS tests part3"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 60 mvn -B install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "CMIS TAS tests - BROWSER binding"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 40 mvn -B install -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "CMIS TAS tests - ATOM binding"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 40 mvn -B install -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "CMIS TAS tests - WEBSERVICES binding"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 40 mvn -B install -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "Email TAS tests"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 30 mvn -B install -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "WebDAV TAS tests"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 30 mvn -B install -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "Integration TAS tests"
|
||||
if: branch = master OR commit_message =~ /\[tas\]/
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script:
|
||||
- travis_wait 30 mvn -B install -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
|
||||
- name: "Push to Nexus"
|
||||
stage: release
|
||||
before_script: bash scripts/travis/verify_release_tag.sh
|
||||
script: travis_wait 40 bash scripts/travis/maven_release.sh
|
||||
|
||||
- name: "Update alfresco-enterprise-repo"
|
||||
stage: update_downstream
|
||||
install: skip
|
||||
script: bash scripts/travis/update_downstream.sh
|
||||
|
||||
- name: "Trigger alfresco-enterprise-repo build"
|
||||
stage: trigger_downstream
|
||||
before_install: skip
|
||||
install: skip
|
||||
script: bash scripts/travis/trigger_travis.sh "Alfresco" "alfresco-enterprise-repo" "${TRAVIS_BRANCH}"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# alfresco-community-repo
|
||||
|
||||
[](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml)
|
||||
[](https://travis-ci.com/Alfresco/alfresco-community-repo)
|
||||
|
||||
This project contains the bulk of the [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository) code.
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Data model classes
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 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
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Fetch image based on Tomcat 9.0, Java 11 and Centos 8
|
||||
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
||||
FROM alfresco/alfresco-base-tomcat:9.0.52-java-11-centos-7
|
||||
FROM alfresco/alfresco-base-tomcat:9.0.45-java-11-centos-8
|
||||
|
||||
# Set default docker_context.
|
||||
ARG resource_path=target
|
||||
@@ -65,12 +65,12 @@ RUN sed -i -e "s_log4j.appender.File.File\=alfresco.log_log4j.appender.File.File
|
||||
|
||||
# fontconfig is required by Activiti worflow diagram generator
|
||||
# installing pinned dependencies as well
|
||||
RUN yum install -y fontconfig-2.13.0-4.3.el7 \
|
||||
dejavu-fonts-common-2.33-6.el7 \
|
||||
fontpackages-filesystem-1.44-8.el7 \
|
||||
freetype-2.8-14.el7_9.1 \
|
||||
libpng-1.5.13-8.el7 \
|
||||
dejavu-sans-fonts-2.33-6.el7 && \
|
||||
RUN yum install -y fontconfig-2.13.1-3.el8 \
|
||||
dejavu-fonts-common-2.35-7.el8 \
|
||||
fontpackages-filesystem-1.44-22.el8 \
|
||||
freetype-2.9.1-4.el8_3.1 \
|
||||
libpng-1.6.34-5.el8 \
|
||||
dejavu-sans-fonts-2.35-7.el8 && \
|
||||
yum clean all
|
||||
|
||||
# The standard configuration is to have all Tomcat files owned by root with group GROUPNAME and whilst owner has read/write privileges,
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<profiles>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
TRANSFORMERS_TAG=2.4.0
|
||||
SOLR6_TAG=2.0.2-RC2
|
||||
TRANSFORMERS_TAG=2.5.0
|
||||
SOLR6_TAG=2.0.2
|
||||
POSTGRES_TAG=13.1
|
||||
ACTIVEMQ_TAG=5.16.1
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TAS_DIRECTORY=$1
|
||||
|
||||
cd ${TAS_DIRECTORY}
|
||||
|
||||
failures=$(grep 'status="FAIL"' target/surefire-reports/testng-results.xml | sed 's|^.*[ ]name="\([^"]*\)".*$|\1|g')
|
||||
|
||||
for failure in ${failures}
|
||||
do
|
||||
cat target/reports/alfresco-tas.log | sed '/STARTING Test: \['${failure}'\]/,/ENDING Test: \['${failure}'\]/!d;/ENDING Test: \['${failure}'\]/q'
|
||||
done
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TAS_DIRECTORY=$1
|
||||
|
||||
cd ${TAS_DIRECTORY}
|
||||
|
||||
cat target/reports/alfresco-tas.log | grep -a "*** STARTING"
|
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export DOCKER_COMPOSE_PATH=$1
|
||||
export DOCKER_COMPOSES=""
|
||||
export CLEAN_UP=""
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
if [ "$var" == "no-clean-up" ]
|
||||
then
|
||||
export CLEAN_UP="$var"
|
||||
else
|
||||
export DOCKER_COMPOSES+="--file $var "
|
||||
fi
|
||||
done
|
||||
export CLEAN_UP="$2"
|
||||
|
||||
if [ -z "$DOCKER_COMPOSE_PATH" ]
|
||||
then
|
||||
@@ -26,8 +15,8 @@ fi
|
||||
# The second parameter can be used to avoid doing a clean up if we are doing a restart test.
|
||||
if [ "$CLEAN_UP" != "no-clean-up" ]
|
||||
then
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") kill
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") rm -f
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" kill
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" rm -f
|
||||
|
||||
export GENERATED_IMAGES=$(docker images | grep '^environment_' | awk '{ print $3 }')
|
||||
if [ -n "$GENERATED_IMAGES" ]
|
||||
@@ -39,7 +28,7 @@ fi
|
||||
echo "Starting ACS stack in ${DOCKER_COMPOSE_PATH}"
|
||||
|
||||
# .env files are picked up from project directory correctly on docker-compose 1.23.0+
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -347,30 +347,13 @@ public class GetSitesTests extends RestTest
|
||||
public void checkPaginationWithSkipCountAndMaxItems() throws Exception
|
||||
{
|
||||
sites = restClient.authenticateUser(regularUser).withParams("skipCount=10&maxItems=110").withCoreAPI().getSites();
|
||||
|
||||
int expectedCount;
|
||||
if (sites.getPagination().isHasMoreItems())
|
||||
{
|
||||
expectedCount = sites.getPagination().getMaxItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sites.getPagination().getTotalItems() < sites.getPagination().getSkipCount())
|
||||
{
|
||||
expectedCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
expectedCount = sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount();
|
||||
}
|
||||
}
|
||||
|
||||
sites.getPagination().assertThat()
|
||||
.field("totalItems").isNotEmpty().and()
|
||||
.field("maxItems").is("110").and()
|
||||
.field("hasMoreItems").is((sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount() > sites.getPagination().getMaxItems())?"true":"false").and()
|
||||
.field("skipCount").is("10").and()
|
||||
.field("count").is(expectedCount);
|
||||
.field("count").is((sites.getPagination().isHasMoreItems()) ? sites.getPagination().getMaxItems()
|
||||
: sites.getPagination().getTotalItems() - sites.getPagination().getSkipCount());
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION})
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -1,25 +1,17 @@
|
||||
package org.alfresco.webdav;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.network.ServerHealth;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
@ContextConfiguration("classpath:alfresco-webdav-context.xml")
|
||||
public abstract class WebDavTest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
private static final Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@@ -44,16 +36,4 @@ public abstract class WebDavTest extends AbstractTestNGSpringContextTests
|
||||
// The webdav protocol is enabled by default.
|
||||
//webDavProtocol.assertThat().protocolIsEnabled();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void showStartTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun=true)
|
||||
public void showEndTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</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>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<properties>
|
||||
<acs.version.major>7</acs.version.major>
|
||||
<acs.version.minor>0</acs.version.minor>
|
||||
<acs.version.revision>1</acs.version.revision>
|
||||
<acs.version.revision>2</acs.version.revision>
|
||||
<acs.version.label />
|
||||
|
||||
<version.edition>Community</version.edition>
|
||||
@@ -59,7 +59,7 @@
|
||||
<dependency.jackson-databind.version>2.12.3</dependency.jackson-databind.version>
|
||||
<dependency.cxf.version>3.4.4</dependency.cxf.version>
|
||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||
<dependency.webscripts.version>8.27</dependency.webscripts.version>
|
||||
<dependency.webscripts.version>8.19</dependency.webscripts.version>
|
||||
<dependency.bouncycastle.version>1.69</dependency.bouncycastle.version>
|
||||
<dependency.mockito-core.version>3.9.0</dependency.mockito-core.version>
|
||||
<dependency.org-json.version>20210307</dependency.org-json.version>
|
||||
@@ -117,7 +117,7 @@
|
||||
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
||||
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
||||
<tag>HEAD</tag>
|
||||
<tag>10.3</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>9.42-SNAPSHOT</version>
|
||||
<version>10.3</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -245,7 +245,7 @@
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.20-alfresco-patched-20220413</version>
|
||||
<version>2.3.20-alfresco-patched-20200421</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
|
@@ -34,10 +34,7 @@ import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.jscript.ScriptAction;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.action.ParameterConstraint;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -129,10 +126,6 @@ public class ScriptActionExecuter extends ActionExecuterAbstractBase
|
||||
if (nodeService.exists(actionedUponNodeRef))
|
||||
{
|
||||
NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
|
||||
if(!isValidScriptRef(action))
|
||||
{
|
||||
throw new IllegalStateException("Invalid script ref path: " + scriptRef);
|
||||
}
|
||||
NodeRef spaceRef = this.serviceRegistry.getRuleService().getOwningNodeRef(action);
|
||||
if (spaceRef == null)
|
||||
{
|
||||
@@ -229,19 +222,4 @@ public class ScriptActionExecuter extends ActionExecuterAbstractBase
|
||||
|
||||
return companyHomeRef;
|
||||
}
|
||||
|
||||
private boolean isValidScriptRef(Action action)
|
||||
{
|
||||
NodeRef scriptRef = (NodeRef) action.getParameterValue(PARAM_SCRIPTREF);
|
||||
ActionService actionService = this.serviceRegistry.getActionService();
|
||||
ActionDefinition actDef = actionService.getActionDefinition(action.getActionDefinitionName());
|
||||
ParameterDefinition parameterDef = actDef.getParameterDefintion(PARAM_SCRIPTREF);
|
||||
String paramConstraintName = parameterDef.getParameterConstraintName();
|
||||
if (paramConstraintName != null)
|
||||
{
|
||||
ParameterConstraint paramConstraint = actionService.getParameterConstraint(paramConstraintName);
|
||||
return paramConstraint.isValidValue(scriptRef.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -30,14 +30,12 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.bulkimport.ImportableItem.ContentAndMetadata;
|
||||
import org.alfresco.repo.bulkimport.MetadataLoader;
|
||||
import org.alfresco.repo.bulkimport.impl.FileUtils;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
@@ -62,9 +60,6 @@ abstract class AbstractMapBasedMetadataLoader implements MetadataLoader
|
||||
|
||||
private final static String DEFAULT_MULTI_VALUED_SEPARATOR = ",";
|
||||
|
||||
private final List<QName> TYPES_TO_HANDLE_EMPTY_VALUE = List.of(DataTypeDefinition.DATE, DataTypeDefinition.DATETIME,
|
||||
DataTypeDefinition.FLOAT, DataTypeDefinition.DOUBLE, DataTypeDefinition.INT, DataTypeDefinition.LONG);
|
||||
|
||||
protected final NamespaceService namespaceService;
|
||||
protected final DictionaryService dictionaryService;
|
||||
protected final String multiValuedSeparator;
|
||||
@@ -169,7 +164,7 @@ abstract class AbstractMapBasedMetadataLoader implements MetadataLoader
|
||||
else
|
||||
{
|
||||
// Single value property
|
||||
metadata.addProperty(name, handleValue(propertyDefinition, metadataProperties.get(key)));
|
||||
metadata.addProperty(name, metadataProperties.get(key));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -192,17 +187,4 @@ abstract class AbstractMapBasedMetadataLoader implements MetadataLoader
|
||||
}
|
||||
}
|
||||
|
||||
private Serializable handleValue(PropertyDefinition pd, Serializable value)
|
||||
{
|
||||
if (pd != null && TYPES_TO_HANDLE_EMPTY_VALUE.contains(pd.getDataType().getName()))
|
||||
{
|
||||
if (value != null && value.toString().trim().length() == 0)
|
||||
{
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.exporter;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -39,7 +39,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.node.MLPropertyInterceptor;
|
||||
@@ -78,7 +77,6 @@ import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
@@ -101,8 +99,6 @@ public class ExporterComponent
|
||||
private DescriptorService descriptorService;
|
||||
private AuthenticationService authenticationService;
|
||||
private PermissionService permissionService;
|
||||
|
||||
private String exportChunkSize;
|
||||
|
||||
|
||||
/** Indent Size */
|
||||
@@ -182,14 +178,6 @@ public class ExporterComponent
|
||||
{
|
||||
this.exportSecondaryNodes = exportSecondaryNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exportChunkSize the exportChunkSize
|
||||
*/
|
||||
public void setExportChunkSize(String exportChunkSize)
|
||||
{
|
||||
this.exportChunkSize = exportChunkSize;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterService#exportView(java.io.OutputStream, org.alfresco.service.cmr.view.ExporterCrawlerParameters, org.alfresco.service.cmr.view.Exporter)
|
||||
@@ -955,21 +943,26 @@ public class ExporterComponent
|
||||
try
|
||||
{
|
||||
// Current strategy is to determine if node is a child of the root exported node
|
||||
if (context.getExportMap() != null)
|
||||
for (NodeRef exportRoot : context.getExportList())
|
||||
{
|
||||
for (NodeRef[] listNodeRef : context.getExportMap().values())
|
||||
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
|
||||
{
|
||||
for (NodeRef exportRoot : listNodeRef)
|
||||
{
|
||||
isWithin = checkIsWithin(nodeRef, exportRoot, parameters);
|
||||
}
|
||||
// node to export is the root export node (and root is to be exported)
|
||||
isWithin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (NodeRef exportRoot : context.getExportList())
|
||||
else
|
||||
{
|
||||
isWithin = checkIsWithin(nodeRef, exportRoot, parameters);
|
||||
// locate export root in primary parent path of node
|
||||
Path nodePath = nodeService.getPath(nodeRef);
|
||||
for (int i = nodePath.size() - 1; i >= 0; i--)
|
||||
{
|
||||
Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i);
|
||||
if (pathElement.getRef().getChildRef().equals(exportRoot))
|
||||
{
|
||||
isWithin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -986,28 +979,6 @@ public class ExporterComponent
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIsWithin(NodeRef nodeRef, NodeRef exportRoot, ExporterCrawlerParameters parameters){
|
||||
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
|
||||
{
|
||||
// node to export is the root export node (and root is to be exported)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// locate export root in primary parent path of node
|
||||
Path nodePath = nodeService.getPath(nodeRef);
|
||||
for (int i = nodePath.size() - 1; i >= 0; i--)
|
||||
{
|
||||
Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i);
|
||||
if (pathElement.getRef().getChildRef().equals(exportRoot))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exporter Context
|
||||
@@ -1015,9 +986,7 @@ public class ExporterComponent
|
||||
private class ExporterContextImpl implements ExporterContext
|
||||
{
|
||||
private NodeRef[] exportList;
|
||||
private Map<Integer,NodeRef[]> exportListMap;
|
||||
private NodeRef[] parentList;
|
||||
private Map<Integer,NodeRef[]> parentListMap;
|
||||
private String exportedBy;
|
||||
private Date exportedDate;
|
||||
private String exporterVersion;
|
||||
@@ -1026,10 +995,8 @@ public class ExporterComponent
|
||||
private Map<Integer, Set<NodeRef>> nodesWithAssociations = new HashMap<Integer, Set<NodeRef>>();
|
||||
|
||||
private int index;
|
||||
private int indexSubList;
|
||||
private int chunkSize;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
@@ -1038,17 +1005,7 @@ public class ExporterComponent
|
||||
public ExporterContextImpl(ExporterCrawlerParameters parameters)
|
||||
{
|
||||
index = 0;
|
||||
indexSubList = 0;
|
||||
|
||||
|
||||
if(!NumberUtils.isParsable(exportChunkSize)){
|
||||
chunkSize = 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
chunkSize = Integer.parseInt(exportChunkSize);
|
||||
}
|
||||
|
||||
|
||||
// get current user performing export
|
||||
String currentUserName = authenticationService.getCurrentUserName();
|
||||
exportedBy = (currentUserName == null) ? "unknown" : currentUserName;
|
||||
@@ -1065,80 +1022,24 @@ public class ExporterComponent
|
||||
NodeRef exportOf = getNodeRef(parameters.getExportFrom());
|
||||
exportList[0] = exportOf;
|
||||
}
|
||||
if(exportList.length > chunkSize)
|
||||
parentList = new NodeRef[exportList.length];
|
||||
for (int i = 0; i < exportList.length; i++)
|
||||
{
|
||||
exportListMap = splitArray(exportList);
|
||||
|
||||
parentListMap = new HashMap<>();
|
||||
for(Map.Entry<Integer, NodeRef[]> exportEntrySet : exportListMap.entrySet())
|
||||
{
|
||||
parentList= new NodeRef[exportEntrySet.getValue().length];
|
||||
for (int i = 0; i < exportEntrySet.getValue().length; i++)
|
||||
{
|
||||
parentList[i] = getParent(exportEntrySet.getValue()[i], parameters.isCrawlSelf());
|
||||
}
|
||||
parentListMap.put(exportEntrySet.getKey(), parentList);
|
||||
}
|
||||
parentList[i] = getParent(exportList[i], parameters.isCrawlSelf());
|
||||
}
|
||||
else{
|
||||
parentList = new NodeRef[exportList.length];
|
||||
for (int i = 0; i < exportList.length; i++)
|
||||
{
|
||||
parentList[i] = getParent(exportList[i], parameters.isCrawlSelf());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// get exporter version
|
||||
exporterVersion = descriptorService.getServerDescriptor().getVersion();
|
||||
}
|
||||
|
||||
public Map<Integer, NodeRef[]> splitArray(NodeRef[] arrayToSplit){
|
||||
if(chunkSize <= 0){
|
||||
return null;
|
||||
}
|
||||
int rest = arrayToSplit.length % chunkSize;
|
||||
int chunks = arrayToSplit.length / chunkSize + (rest > 0 ? 1 : 0);
|
||||
Map<Integer, NodeRef[]> arrays = new HashMap<>() ;
|
||||
for(Integer i = 0; i < (rest > 0 ? chunks - 1 : chunks); i++){
|
||||
arrays.put(i, Arrays.copyOfRange(arrayToSplit, i * chunkSize, i * chunkSize + chunkSize));
|
||||
}
|
||||
if(rest > 0){
|
||||
arrays.put(chunks - 1, Arrays.copyOfRange(arrayToSplit, (chunks - 1) * chunkSize, (chunks - 1) * chunkSize + rest));
|
||||
}
|
||||
return arrays;
|
||||
}
|
||||
|
||||
public boolean canRetrieve()
|
||||
{
|
||||
if(exportListMap != null)
|
||||
{
|
||||
if (exportListMap.containsKey(indexSubList))
|
||||
{
|
||||
return index < exportListMap.get(indexSubList).length;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return index < exportList.length;
|
||||
}
|
||||
return index < exportList.length;
|
||||
}
|
||||
|
||||
public int setNextValue()
|
||||
{
|
||||
if(exportListMap != null && (index == exportListMap.get(indexSubList).length-1)){
|
||||
resetContext();
|
||||
if(indexSubList <= exportListMap.size())
|
||||
{
|
||||
++indexSubList;
|
||||
}
|
||||
}
|
||||
else{
|
||||
++index;
|
||||
}
|
||||
return index;
|
||||
return ++index;
|
||||
}
|
||||
|
||||
public void resetContext()
|
||||
@@ -1177,13 +1078,7 @@ public class ExporterComponent
|
||||
{
|
||||
if (canRetrieve())
|
||||
{
|
||||
if(exportListMap!=null)
|
||||
{
|
||||
return exportListMap.get(indexSubList)[index];
|
||||
}
|
||||
else {
|
||||
return exportList[index];
|
||||
}
|
||||
return exportList[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1196,13 +1091,7 @@ public class ExporterComponent
|
||||
{
|
||||
if (canRetrieve())
|
||||
{
|
||||
if(parentListMap!=null)
|
||||
{
|
||||
return parentListMap.get(indexSubList)[index];
|
||||
}
|
||||
else {
|
||||
return parentList[index];
|
||||
}
|
||||
return parentList[index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1216,11 +1105,6 @@ public class ExporterComponent
|
||||
return exportList;
|
||||
}
|
||||
|
||||
public Map<Integer, NodeRef[]> getExportMap()
|
||||
{
|
||||
return exportListMap;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ExporterContext#getExportParentList()
|
||||
|
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.jscript;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mozilla.javascript.Callable;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.ContextFactory;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
/**
|
||||
* Custom factory that allows to apply configured limits during script executions
|
||||
*
|
||||
* @see ContextFactory
|
||||
*/
|
||||
public class AlfrescoContextFactory extends ContextFactory
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(AlfrescoContextFactory.class);
|
||||
|
||||
private int optimizationLevel = -1;
|
||||
private int maxScriptExecutionSeconds = -1;
|
||||
private int maxStackDepth = -1;
|
||||
private long maxMemoryUsedInBytes = -1L;
|
||||
private int observeInstructionCount = -1;
|
||||
|
||||
private AlfrescoScriptThreadMxBeanWrapper threadMxBeanWrapper;
|
||||
|
||||
private final int INTERPRETIVE_MODE = -1;
|
||||
|
||||
@Override
|
||||
protected Context makeContext()
|
||||
{
|
||||
AlfrescoScriptContext context = new AlfrescoScriptContext();
|
||||
|
||||
context.setOptimizationLevel(optimizationLevel);
|
||||
|
||||
// Needed for both time and memory measurement
|
||||
if (maxScriptExecutionSeconds > 0 || maxMemoryUsedInBytes > 0L)
|
||||
{
|
||||
if (observeInstructionCount > 0)
|
||||
{
|
||||
LOGGER.info("Enabling observer count...");
|
||||
context.setGenerateObserverCount(true);
|
||||
context.setInstructionObserverThreshold(observeInstructionCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info("Disabling observer count...");
|
||||
context.setGenerateObserverCount(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Memory limit
|
||||
if (maxMemoryUsedInBytes > 0)
|
||||
{
|
||||
context.setThreadId(Thread.currentThread().getId());
|
||||
}
|
||||
|
||||
// Max stack depth
|
||||
if (maxStackDepth > 0)
|
||||
{
|
||||
if (optimizationLevel != INTERPRETIVE_MODE)
|
||||
{
|
||||
LOGGER.warn("Changing optimization level from " + optimizationLevel + " to " + INTERPRETIVE_MODE);
|
||||
}
|
||||
// stack depth can only be set when no optimizations are applied
|
||||
context.setOptimizationLevel(INTERPRETIVE_MODE);
|
||||
context.setMaximumInterpreterStackDepth(maxStackDepth);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void observeInstructionCount(Context cx, int instructionCount)
|
||||
{
|
||||
AlfrescoScriptContext acx = (AlfrescoScriptContext) cx;
|
||||
|
||||
if (acx.isLimitsEnabled())
|
||||
{
|
||||
// Time limit
|
||||
if (maxScriptExecutionSeconds > 0)
|
||||
{
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (currentTime - acx.getStartTime() > maxScriptExecutionSeconds * 1000)
|
||||
{
|
||||
throw new Error("Maximum script time of " + maxScriptExecutionSeconds + " seconds exceeded");
|
||||
}
|
||||
}
|
||||
|
||||
// Memory
|
||||
if (maxMemoryUsedInBytes > 0 && threadMxBeanWrapper != null && threadMxBeanWrapper.isThreadAllocatedMemorySupported())
|
||||
{
|
||||
|
||||
if (acx.getStartMemory() <= 0)
|
||||
{
|
||||
acx.setStartMemory(threadMxBeanWrapper.getThreadAllocatedBytes(acx.getThreadId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
long currentAllocatedBytes = threadMxBeanWrapper.getThreadAllocatedBytes(acx.getThreadId());
|
||||
if (currentAllocatedBytes - acx.getStartMemory() >= maxMemoryUsedInBytes)
|
||||
{
|
||||
throw new Error("Memory limit of " + maxMemoryUsedInBytes + " bytes reached");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
|
||||
{
|
||||
AlfrescoScriptContext acx = (AlfrescoScriptContext) cx;
|
||||
acx.setStartTime(System.currentTimeMillis());
|
||||
return super.doTopCall(callable, cx, scope, thisObj, args);
|
||||
}
|
||||
|
||||
public int getOptimizationLevel()
|
||||
{
|
||||
return optimizationLevel;
|
||||
}
|
||||
|
||||
public void setOptimizationLevel(int optimizationLevel)
|
||||
{
|
||||
this.optimizationLevel = optimizationLevel;
|
||||
}
|
||||
|
||||
public int getMaxScriptExecutionSeconds()
|
||||
{
|
||||
return maxScriptExecutionSeconds;
|
||||
}
|
||||
|
||||
public void setMaxScriptExecutionSeconds(int maxScriptExecutionSeconds)
|
||||
{
|
||||
this.maxScriptExecutionSeconds = maxScriptExecutionSeconds;
|
||||
}
|
||||
|
||||
public int getMaxStackDepth()
|
||||
{
|
||||
return maxStackDepth;
|
||||
}
|
||||
|
||||
public void setMaxStackDepth(int maxStackDepth)
|
||||
{
|
||||
this.maxStackDepth = maxStackDepth;
|
||||
}
|
||||
|
||||
public long getMaxMemoryUsedInBytes()
|
||||
{
|
||||
return maxMemoryUsedInBytes;
|
||||
}
|
||||
|
||||
public void setMaxMemoryUsedInBytes(long maxMemoryUsedInBytes)
|
||||
{
|
||||
this.maxMemoryUsedInBytes = maxMemoryUsedInBytes;
|
||||
if (maxMemoryUsedInBytes > 0)
|
||||
{
|
||||
this.threadMxBeanWrapper = new AlfrescoScriptThreadMxBeanWrapper();
|
||||
if (!threadMxBeanWrapper.isThreadAllocatedMemorySupported())
|
||||
{
|
||||
LOGGER.warn("com.sun.management.ThreadMXBean was not found on the classpath. "
|
||||
+ "This means that the limiting the memory usage for a script will NOT work.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getObserveInstructionCount()
|
||||
{
|
||||
return observeInstructionCount;
|
||||
}
|
||||
|
||||
public void setObserveInstructionCount(int observeInstructionCount)
|
||||
{
|
||||
this.observeInstructionCount = observeInstructionCount;
|
||||
}
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.jscript;
|
||||
|
||||
import org.mozilla.javascript.Context;
|
||||
|
||||
/**
|
||||
* Custom Rhino context that holds data as start time and memory
|
||||
*
|
||||
* @see Context
|
||||
*/
|
||||
public class AlfrescoScriptContext extends Context
|
||||
{
|
||||
private long startTime;
|
||||
private long threadId;
|
||||
private long startMemory;
|
||||
private boolean limitsEnabled = false;
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getThreadId()
|
||||
{
|
||||
return threadId;
|
||||
}
|
||||
|
||||
public void setThreadId(long threadId)
|
||||
{
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
public long getStartMemory()
|
||||
{
|
||||
return startMemory;
|
||||
}
|
||||
|
||||
public void setStartMemory(long startMemory)
|
||||
{
|
||||
this.startMemory = startMemory;
|
||||
}
|
||||
|
||||
public boolean isLimitsEnabled()
|
||||
{
|
||||
return limitsEnabled;
|
||||
}
|
||||
|
||||
public void setLimitsEnabled(boolean limitsEnabled)
|
||||
{
|
||||
this.limitsEnabled = limitsEnabled;
|
||||
}
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.jscript;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
|
||||
/**
|
||||
* Allows to monitor memory usage
|
||||
*/
|
||||
public class AlfrescoScriptThreadMxBeanWrapper
|
||||
{
|
||||
|
||||
private ThreadMXBean threadMXBean = null;
|
||||
private boolean threadAllocatedMemorySupported = false;
|
||||
|
||||
private final String THREAD_MX_BEAN_SUN = "com.sun.management.ThreadMXBean";
|
||||
|
||||
public AlfrescoScriptThreadMxBeanWrapper()
|
||||
{
|
||||
checkThreadAllocatedMemory();
|
||||
}
|
||||
|
||||
public long getThreadAllocatedBytes(long threadId)
|
||||
{
|
||||
if (threadMXBean != null && threadAllocatedMemorySupported)
|
||||
{
|
||||
return ((com.sun.management.ThreadMXBean) threadMXBean).getThreadAllocatedBytes(threadId);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void checkThreadAllocatedMemory()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = Class.forName(THREAD_MX_BEAN_SUN);
|
||||
if (clazz != null)
|
||||
{
|
||||
this.threadAllocatedMemorySupported = true;
|
||||
this.threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.threadAllocatedMemorySupported = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isThreadAllocatedMemorySupported()
|
||||
{
|
||||
return threadAllocatedMemorySupported;
|
||||
}
|
||||
}
|
@@ -57,12 +57,10 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.ContextFactory;
|
||||
import org.mozilla.javascript.ImporterTopLevel;
|
||||
import org.mozilla.javascript.Script;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.Undefined;
|
||||
import org.mozilla.javascript.WrapFactory;
|
||||
import org.mozilla.javascript.WrappedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -110,23 +108,6 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
/** Cache of runtime compiled script instances */
|
||||
private final Map<String, Script> scriptCache = new ConcurrentHashMap<String, Script>(256);
|
||||
|
||||
/** Rhino optimization level */
|
||||
private int optimizationLevel = -1;
|
||||
|
||||
/** Maximum seconds a script is allowed to run */
|
||||
private int maxScriptExecutionSeconds = -1;
|
||||
|
||||
/** Maximum of call stack depth (in terms of number of call frames) */
|
||||
private int maxStackDepth = -1;
|
||||
|
||||
/** Maximum memory (bytes) a script can use */
|
||||
private long maxMemoryUsedInBytes = -1L;
|
||||
|
||||
/** Number of (bytecode) instructions that will trigger the observer */
|
||||
private int observerInstructionCount = 100;
|
||||
|
||||
/** Custom context factory */
|
||||
public static AlfrescoContextFactory contextFactory;
|
||||
|
||||
/**
|
||||
* Set the default store reference
|
||||
@@ -163,51 +144,6 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
this.shareSealedScopes = shareSealedScopes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param optimizationLevel
|
||||
* -1 interpretive mode, 0 no optimizations, 1-9 optimizations performed
|
||||
*/
|
||||
public void setOptimizationLevel(int optimizationLevel)
|
||||
{
|
||||
this.optimizationLevel = optimizationLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxScriptExecutionSeconds
|
||||
* the number of seconds a script is allowed to run
|
||||
*/
|
||||
public void setMaxScriptExecutionSeconds(int maxScriptExecutionSeconds)
|
||||
{
|
||||
this.maxScriptExecutionSeconds = maxScriptExecutionSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxStackDepth
|
||||
* the number of call stack depth allowed
|
||||
*/
|
||||
public void setMaxStackDepth(int maxStackDepth)
|
||||
{
|
||||
this.maxStackDepth = maxStackDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxMemoryUsedInBytes
|
||||
* the number of memory a script can use
|
||||
*/
|
||||
public void setMaxMemoryUsedInBytes(long maxMemoryUsedInBytes)
|
||||
{
|
||||
this.maxMemoryUsedInBytes = maxMemoryUsedInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param observerInstructionCount
|
||||
* the number of instructions that will trigger {@link ContextFactory#observeInstructionCount}
|
||||
*/
|
||||
public void setObserverInstructionCount(int observerInstructionCount)
|
||||
{
|
||||
this.observerInstructionCount = observerInstructionCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.repository.ScriptProcessor#reset()
|
||||
*/
|
||||
@@ -505,8 +441,6 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
private Object executeScriptImpl(Script script, Map<String, Object> model, boolean secure, String debugScriptName)
|
||||
throws AlfrescoRuntimeException
|
||||
{
|
||||
Scriptable scope = null;
|
||||
|
||||
long startTime = 0;
|
||||
if (callLogger.isDebugEnabled())
|
||||
{
|
||||
@@ -523,16 +457,14 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
// Create a thread-specific scope from one of the shared scopes.
|
||||
// See http://www.mozilla.org/rhino/scopes.html
|
||||
cx.setWrapFactory(secure ? wrapFactory : sandboxFactory);
|
||||
|
||||
// Enables or disables execution limits based on secure flag
|
||||
enableLimits(cx, secure);
|
||||
|
||||
Scriptable scope;
|
||||
if (this.shareSealedScopes)
|
||||
{
|
||||
Scriptable sharedScope = secure ? this.nonSecureScope : this.secureScope;
|
||||
scope = cx.newObject(sharedScope);
|
||||
scope.setPrototype(sharedScope);
|
||||
scope.setParentScope(null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -606,7 +538,6 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
}
|
||||
finally
|
||||
{
|
||||
unsetScope(model, scope);
|
||||
Context.exit();
|
||||
|
||||
if (callLogger.isDebugEnabled())
|
||||
@@ -699,9 +630,6 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// Initialize context factory
|
||||
initContextFactory();
|
||||
|
||||
// Initialize the secure scope
|
||||
Context cx = Context.enter();
|
||||
try
|
||||
@@ -759,129 +687,4 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean supplied scope and unset it from any model instance where it has been injected before
|
||||
*
|
||||
* @param model
|
||||
* Data model containing objects from where scope will be unset
|
||||
* @param scope
|
||||
* The scope to clean
|
||||
*/
|
||||
private void unsetScope(Map<String, Object> model, Scriptable scope)
|
||||
{
|
||||
if (scope != null)
|
||||
{
|
||||
Object[] ids = scope.getIds();
|
||||
if (ids != null)
|
||||
{
|
||||
for (Object id : ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
deleteProperty(scope, id.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("Unable to delete id: " + id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
for (String key : model.keySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
deleteProperty(scope, key);
|
||||
|
||||
Object obj = model.get(key);
|
||||
if (obj instanceof Scopeable)
|
||||
{
|
||||
((Scopeable) obj).setScope(null);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("Unable to unset model object " + key + " : ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a property from the supplied scope, if property is not removable, then is set to null
|
||||
*
|
||||
* @param scope
|
||||
* the scope object from where property will be removed
|
||||
* @param name
|
||||
* the property name to delete
|
||||
*/
|
||||
private void deleteProperty(Scriptable scope, String name)
|
||||
{
|
||||
if (scope != null && name != null)
|
||||
{
|
||||
if (!ScriptableObject.deleteProperty(scope, name))
|
||||
{
|
||||
ScriptableObject.putProperty(scope, name, null);
|
||||
}
|
||||
scope.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the context factory with limits configuration
|
||||
*/
|
||||
private synchronized void initContextFactory()
|
||||
{
|
||||
if (contextFactory == null)
|
||||
{
|
||||
contextFactory = new AlfrescoContextFactory();
|
||||
contextFactory.setOptimizationLevel(optimizationLevel);
|
||||
|
||||
if (maxScriptExecutionSeconds > 0)
|
||||
{
|
||||
contextFactory.setMaxScriptExecutionSeconds(maxScriptExecutionSeconds);
|
||||
}
|
||||
|
||||
if (maxMemoryUsedInBytes > 0L)
|
||||
{
|
||||
contextFactory.setMaxMemoryUsedInBytes(maxMemoryUsedInBytes);
|
||||
}
|
||||
|
||||
if (maxStackDepth > 0)
|
||||
{
|
||||
contextFactory.setMaxStackDepth(maxStackDepth);
|
||||
}
|
||||
|
||||
if (maxScriptExecutionSeconds > 0 || maxMemoryUsedInBytes > 0L)
|
||||
{
|
||||
contextFactory.setObserveInstructionCount(observerInstructionCount);
|
||||
}
|
||||
|
||||
ContextFactory.initGlobal(contextFactory);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If script is considered secure no limits will be applied, otherwise, the limits are enabled and the script can be
|
||||
* interrupted in case a limit has been reached.
|
||||
*
|
||||
* @param cx
|
||||
* the Rhino scope
|
||||
* @param secure
|
||||
* true if script execution is considered secure (e.g, deployed at classpath level)
|
||||
*/
|
||||
private void enableLimits(Context cx, boolean secure)
|
||||
{
|
||||
if (cx != null)
|
||||
{
|
||||
if (cx instanceof AlfrescoScriptContext)
|
||||
{
|
||||
((AlfrescoScriptContext) cx).setLimitsEnabled(!secure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.search.impl.querymodel.impl.db;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -74,10 +74,6 @@ public class DBQuery extends BaseQuery implements DBQueryBuilderComponent
|
||||
|
||||
Set<String> selectorGroup;
|
||||
|
||||
private int limit = 0;
|
||||
|
||||
private int offset = 0;
|
||||
|
||||
/**
|
||||
* @param source Source
|
||||
* @param constraint Constraint
|
||||
@@ -137,22 +133,6 @@ public class DBQuery extends BaseQuery implements DBQueryBuilderComponent
|
||||
this.sinceTxId = sinceTxId;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public List<DBQueryBuilderJoinCommand> getJoins()
|
||||
{
|
||||
HashMap<QName, DBQueryBuilderJoinCommand> singleJoins = new HashMap<QName, DBQueryBuilderJoinCommand>();
|
||||
|
@@ -76,10 +76,8 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.ibatis.executor.result.DefaultResultContext;
|
||||
import org.apache.ibatis.session.ResultContext;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.apache.ibatis.session.RowBounds;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
@@ -91,11 +89,7 @@ public class DBQueryEngine implements QueryEngine
|
||||
protected static final Log logger = LogFactory.getLog(DBQueryEngine.class);
|
||||
|
||||
protected static final String SELECT_BY_DYNAMIC_QUERY = "alfresco.metadata.query.select_byDynamicQuery";
|
||||
|
||||
private static final int DEFAULT_MIN_PAGING_BATCH_SIZE = 2500;
|
||||
|
||||
private static final int DEFAULT_MAX_PAGING_BATCH_SIZE = 10000;
|
||||
|
||||
|
||||
protected SqlSessionTemplate template;
|
||||
|
||||
protected QNameDAO qnameDAO;
|
||||
@@ -120,12 +114,6 @@ public class DBQueryEngine implements QueryEngine
|
||||
|
||||
private boolean maxPermissionCheckEnabled;
|
||||
|
||||
private boolean usePagingQuery = false;
|
||||
|
||||
private int minPagingBatchSize = DEFAULT_MIN_PAGING_BATCH_SIZE;
|
||||
|
||||
private int maxPagingBatchSize = DEFAULT_MAX_PAGING_BATCH_SIZE;
|
||||
|
||||
protected EntityLookupCache<Long, Node, NodeRef> nodesCache;
|
||||
|
||||
private List<Pair<Long, StoreRef>> stores;
|
||||
@@ -161,31 +149,7 @@ public class DBQueryEngine implements QueryEngine
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public boolean isUsePagingQuery() {
|
||||
return usePagingQuery;
|
||||
}
|
||||
|
||||
public void setUsePagingQuery(boolean usePagingQuery) {
|
||||
this.usePagingQuery = usePagingQuery;
|
||||
}
|
||||
|
||||
public int getMinPagingBatchSize() {
|
||||
return minPagingBatchSize;
|
||||
}
|
||||
|
||||
public void setMinPagingBatchSize(int minPagingBatchSize) {
|
||||
this.minPagingBatchSize = minPagingBatchSize;
|
||||
}
|
||||
|
||||
public int getMaxPagingBatchSize() {
|
||||
return maxPagingBatchSize;
|
||||
}
|
||||
|
||||
public void setMaxPagingBatchSize(int maxPagingBatchSize) {
|
||||
this.maxPagingBatchSize = maxPagingBatchSize;
|
||||
}
|
||||
|
||||
|
||||
public void setMetadataIndexCheck2(OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2)
|
||||
{
|
||||
this.metadataIndexCheck2 = metadataIndexCheck2;
|
||||
@@ -367,7 +331,7 @@ public class DBQueryEngine implements QueryEngine
|
||||
int requiredNodes = computeRequiredNodesCount(options);
|
||||
|
||||
logger.debug("- query sent to the database");
|
||||
performTmdqSelect(pickQueryTemplate(options, dbQuery), dbQuery, requiredNodes, new ResultHandler<Node>()
|
||||
template.select(pickQueryTemplate(options, dbQuery), dbQuery, new ResultHandler<Node>()
|
||||
{
|
||||
@Override
|
||||
public void handleResult(ResultContext<? extends Node> context)
|
||||
@@ -435,54 +399,6 @@ public class DBQueryEngine implements QueryEngine
|
||||
return frs;
|
||||
}
|
||||
|
||||
private void performTmdqSelect(String statement, DBQuery dbQuery, int requiredNodes, ResultHandler<Node> handler)
|
||||
{
|
||||
if (usePagingQuery)
|
||||
{
|
||||
performTmdqSelectPaging(statement, dbQuery, requiredNodes, handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
performTmdqSelectStreaming(statement, dbQuery, handler);
|
||||
}
|
||||
}
|
||||
|
||||
private void performTmdqSelectStreaming(String statement, DBQuery dbQuery, ResultHandler<Node> handler)
|
||||
{
|
||||
template.select(statement, dbQuery, handler);
|
||||
}
|
||||
|
||||
private void performTmdqSelectPaging(String statement, DBQuery dbQuery, int requiredNodes, ResultHandler<Node> handler)
|
||||
{
|
||||
int batchStart = 0;
|
||||
int batchSize = requiredNodes * 2;
|
||||
batchSize = Math.min(Math.max(batchSize, minPagingBatchSize), maxPagingBatchSize);
|
||||
DefaultResultContext<Node> resultCtx = new DefaultResultContext<>();
|
||||
while (!resultCtx.isStopped())
|
||||
{
|
||||
dbQuery.setOffset(batchStart);
|
||||
dbQuery.setLimit(batchSize);
|
||||
List<Node> batch = template.selectList(statement, dbQuery);
|
||||
for (Node node : batch)
|
||||
{
|
||||
resultCtx.nextResultObject(node);
|
||||
handler.handleResult(resultCtx);
|
||||
if (resultCtx.isStopped())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (batch.size() < batchSize)
|
||||
{
|
||||
resultCtx.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
batchStart += batchSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DBResultSet createResultSet(QueryOptions options, List<Node> nodes, int numberFound)
|
||||
{
|
||||
DBResultSet dbResultSet = new DBResultSet(options.getAsSearchParmeters(), nodes, nodeDAO, nodeService, tenantService, Integer.MAX_VALUE);
|
||||
|
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.urlshortening;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.urlshortening.UrlShortener;
|
||||
import org.apache.commons.httpclient.HostConfiguration;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.httpclient.protocol.Protocol;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* @deprecated as it is no longer used in the core repository code.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BitlyUrlShortenerImpl implements UrlShortener
|
||||
{
|
||||
private static final Log log = LogFactory.getLog(BitlyUrlShortenerImpl.class);
|
||||
|
||||
private int urlLength = 20;
|
||||
private String username;
|
||||
private String apiKey = "R_ca15c6c89e9b25ccd170bafd209a0d4f";
|
||||
private HttpClient httpClient;
|
||||
|
||||
public BitlyUrlShortenerImpl()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
httpClient.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
|
||||
HostConfiguration hostConfiguration = new HostConfiguration();
|
||||
hostConfiguration.setHost("api-ssl.bitly.com", 443, Protocol.getProtocol("https"));
|
||||
httpClient.setHostConfiguration(hostConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortenUrl(String longUrl)
|
||||
{
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Shortening URL: " + longUrl);
|
||||
}
|
||||
String shortUrl = longUrl;
|
||||
if (longUrl.length() > urlLength)
|
||||
{
|
||||
GetMethod getMethod = new GetMethod();
|
||||
getMethod.setPath("/v3/shorten");
|
||||
|
||||
List<NameValuePair> args = new ArrayList<NameValuePair>();
|
||||
args.add(new NameValuePair("login", username));
|
||||
args.add(new NameValuePair("apiKey", apiKey));
|
||||
args.add(new NameValuePair("longUrl", longUrl));
|
||||
args.add(new NameValuePair("format", "txt"));
|
||||
getMethod.setQueryString(args.toArray(new NameValuePair[args.size()]));
|
||||
|
||||
try
|
||||
{
|
||||
int resultCode = httpClient.executeMethod(getMethod);
|
||||
if (resultCode == 200)
|
||||
{
|
||||
shortUrl = getMethod.getResponseBodyAsString();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn("Failed to shorten URL " + longUrl + " - response code == " + resultCode);
|
||||
log.warn(getMethod.getResponseBodyAsString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.error("Failed to shorten URL " + longUrl, ex);
|
||||
}
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("URL " + longUrl + " has been shortened to " + shortUrl);
|
||||
}
|
||||
}
|
||||
return shortUrl.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getUrlLength()
|
||||
{
|
||||
return urlLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param urlLength the urlLength to set
|
||||
*/
|
||||
public void setUrlLength(int urlLength)
|
||||
{
|
||||
this.urlLength = urlLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param apiKey the apiKey to set
|
||||
*/
|
||||
public void setApiKey(String apiKey)
|
||||
{
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
}
|
@@ -84,7 +84,6 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
private static Log logger = LogFactory.getLog(Version2ServiceImpl.class);
|
||||
|
||||
private PermissionService permissionService;
|
||||
private boolean useVersionAssocIndex = false;
|
||||
|
||||
private ExtendedTrait<VersionServiceTrait> versionServiceTrait;
|
||||
|
||||
@@ -97,23 +96,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to use child association index on versions. This helps ordering versions when sequential IDs are not
|
||||
* guaranteed by the DBMS.
|
||||
*
|
||||
* @param useVersionAssocIndex
|
||||
*/
|
||||
public void setUseVersionAssocIndex(boolean useVersionAssocIndex)
|
||||
{
|
||||
this.useVersionAssocIndex = useVersionAssocIndex;
|
||||
}
|
||||
|
||||
public boolean isUseVersionAssocIndex()
|
||||
{
|
||||
return useVersionAssocIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise method
|
||||
*/
|
||||
@@ -523,12 +506,9 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.CHILD_VERSIONS+"-"+versionNumber), // TODO - testing - note: all children (of a versioned node) will have the same version number, maybe replace with a version sequence of some sort 001-...00n
|
||||
sourceTypeRef,
|
||||
nodeDetails.getProperties());
|
||||
if (isUseVersionAssocIndex())
|
||||
{
|
||||
nodeService.setChildAssociationIndex(childAssocRef, getAllVersions(versionHistoryRef).size());
|
||||
}
|
||||
versionNodeRef = childAssocRef.getChildRef();
|
||||
|
||||
versionNodeRef = childAssocRef.getChildRef();
|
||||
|
||||
// NOTE: special ML case - see also MultilingualContentServiceImpl.makeMLContainer
|
||||
if (sourceTypeRef.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
|
||||
{
|
||||
|
@@ -1,32 +1,31 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.service.cmr.view;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
@@ -74,8 +73,6 @@ public interface ExporterContext
|
||||
* @return NodeRef[]
|
||||
*/
|
||||
public NodeRef[] getExportList();
|
||||
|
||||
public Map<Integer, NodeRef[]> getExportMap();
|
||||
|
||||
/**
|
||||
* Gets list of parents for exporting nodes
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.service.cmr.view;
|
||||
|
||||
import java.io.OutputStream;
|
||||
@@ -75,6 +75,5 @@ public interface ExporterService
|
||||
*/
|
||||
@Auditable(parameters = {"exporter", "parameters", "progress"})
|
||||
public void exportView(Exporter exporter, ExporterCrawlerParameters parameters, Exporter progress);
|
||||
|
||||
public void setExportChunkSize(String exportChunkSize);
|
||||
|
||||
}
|
||||
|
@@ -488,9 +488,6 @@
|
||||
<property name="versionComparatorClass">
|
||||
<value>${version.store.versionComparatorClass}</value>
|
||||
</property>
|
||||
<property name="useVersionAssocIndex">
|
||||
<value>${version.store.useVersionAssocIndex}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="versionNodeService" class="org.alfresco.repo.version.Node2ServiceImpl">
|
||||
|
@@ -180,8 +180,7 @@
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
<if test="limit != 0">limit #{offset}, #{limit}</if>
|
||||
</sql>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@@ -130,9 +130,6 @@
|
||||
<property name="permissionService">
|
||||
<ref bean="PermissionService" />
|
||||
</property>
|
||||
<property name="exportChunkSize">
|
||||
<value>${rm.export.chunk.size}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="repositoryExporterComponent" class="org.alfresco.repo.exporter.RepositoryExporterComponent">
|
||||
|
@@ -3,7 +3,7 @@
|
||||
repository.name=Main Repository
|
||||
|
||||
# Schema number
|
||||
version.schema=14100
|
||||
version.schema=14200
|
||||
|
||||
# Directory configuration
|
||||
|
||||
@@ -378,14 +378,6 @@ version.store.version2Store=workspace://version2Store
|
||||
# if upgrading from a version that used unordered sequences in a cluster.
|
||||
version.store.versionComparatorClass=
|
||||
|
||||
# Optional to set the child association index when creating a new version.
|
||||
# This helps ordering versions when sequential IDs are not guaranteed by the DBMS.
|
||||
# Not compatible with AGS < 7.1.1
|
||||
# Once enabled, it should not be disabled again or new versions will go back
|
||||
# to have index -1 and you will get the wrong order in version history.
|
||||
# Please, see MNT-22715 for details.
|
||||
version.store.useVersionAssocIndex=false
|
||||
|
||||
# Folders for storing people
|
||||
system.system_container.childname=sys:system
|
||||
system.people_container.childname=sys:people
|
||||
@@ -1245,19 +1237,4 @@ system.new-node-transaction-indexes.ignored=true
|
||||
|
||||
# Allows the configuration of maximum limits of the temp files to be deleted or the maximum time allowed to run for the job
|
||||
system.tempFileCleaner.maxFilesToDelete=
|
||||
system.tempFileCleaner.maxTimeToRun=
|
||||
|
||||
# Rhino optimization level
|
||||
scripts.execution.optimizationLevel=0
|
||||
|
||||
# Max seconds a script is allowed to run
|
||||
scripts.execution.maxScriptExecutionSeconds=-1
|
||||
|
||||
# Max call stack depth
|
||||
scripts.execution.maxStackDepth=-1
|
||||
|
||||
# Max memory (bytes) a script can use
|
||||
scripts.execution.maxMemoryUsedInBytes=-1
|
||||
|
||||
# Number of instructions that will trigger the observer
|
||||
scripts.execution.observerInstructionCount=-1
|
||||
system.tempFileCleaner.maxTimeToRun=
|
@@ -45,21 +45,6 @@
|
||||
<property name="storePath">
|
||||
<value>${spaces.company_home.childname}</value>
|
||||
</property>
|
||||
<property name="optimizationLevel">
|
||||
<value>${scripts.execution.optimizationLevel}</value>
|
||||
</property>
|
||||
<property name="maxScriptExecutionSeconds">
|
||||
<value>${scripts.execution.maxScriptExecutionSeconds}</value>
|
||||
</property>
|
||||
<property name="maxStackDepth">
|
||||
<value>${scripts.execution.maxStackDepth}</value>
|
||||
</property>
|
||||
<property name="maxMemoryUsedInBytes">
|
||||
<value>${scripts.execution.maxMemoryUsedInBytes}</value>
|
||||
</property>
|
||||
<property name="observerInstructionCount">
|
||||
<value>${scripts.execution.observerInstructionCount}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- base config implementation that script extension beans extend from - for auto registration
|
||||
|
@@ -105,35 +105,8 @@
|
||||
<ref bean="metadataQueryIndexesCheck2" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="search.dbQueryEngineImpl" class="org.alfresco.util.bean.HierarchicalBeanLoader">
|
||||
<property name="targetBeanName">
|
||||
<value>search.dbQueryEngineImpl.#bean.dialect#</value>
|
||||
</property>
|
||||
<property name="targetClass">
|
||||
<value>org.alfresco.repo.search.impl.querymodel.QueryEngine</value>
|
||||
</property>
|
||||
<property name="dialectBaseClass">
|
||||
<value>org.alfresco.repo.domain.dialect.Dialect</value>
|
||||
</property>
|
||||
<property name="dialectClass">
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
|
||||
<property name="targetBeanName" value="dialect" />
|
||||
<property name="propertyPath" value="class.name" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="search.dbQueryEngineImpl.org.alfresco.repo.domain.dialect.Dialect"
|
||||
parent="search.baseDbQueryEngineImpl">
|
||||
<property name="usePagingQuery" value="false"/>
|
||||
</bean>
|
||||
<bean id="search.dbQueryEngineImpl.org.alfresco.repo.domain.dialect.MySQLInnoDBDialect"
|
||||
parent="search.baseDbQueryEngineImpl">
|
||||
<property name="usePagingQuery" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean id="search.baseDbQueryEngineImpl" class="org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryEngine" abstract="true">
|
||||
|
||||
<bean id="search.dbQueryEngineImpl" class="org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryEngine" >
|
||||
<property name="permissionService" ref="permissionService"/>
|
||||
<property name="dictionaryService" ref="dictionaryService" />
|
||||
<property name="namespaceService" ref="namespaceService" />
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -77,10 +77,7 @@ import org.junit.runners.Suite;
|
||||
// From MiscContextTestSuite
|
||||
org.alfresco.repo.domain.query.CannedQueryDAOTest.class,
|
||||
|
||||
// ACS-1907
|
||||
org.alfresco.repo.search.impl.querymodel.impl.db.ACS1907Test.class,
|
||||
|
||||
// REPO-2963 : Tests causing a cascade of failures in AllDBTestsTestSuite on PostgreSQL/MySQL
|
||||
// REPO-2963 : Tests causing a cascade of failures in AllDBTestsTestSuite on PostgreSQL/MySQL
|
||||
// Moved at the bottom of the suite because DbNodeServiceImplTest.testNodeCleanupRegistry() takes a long time on a clean DB.
|
||||
org.alfresco.repo.node.db.DbNodeServiceImplTest.class,
|
||||
|
||||
|
@@ -75,6 +75,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class,
|
||||
org.alfresco.repo.transfer.manifest.TransferManifestTest.class,
|
||||
org.alfresco.repo.transfer.TransferVersionCheckerImplTest.class,
|
||||
org.alfresco.repo.urlshortening.BitlyUrlShortenerTest.class,
|
||||
org.alfresco.service.cmr.calendar.CalendarRecurrenceHelperTest.class,
|
||||
org.alfresco.service.cmr.calendar.CalendarTimezoneHelperTest.class,
|
||||
org.alfresco.tools.RenameUserTest.class,
|
||||
@@ -109,7 +110,6 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.util.schemacomp.validator.NameValidatorTest.class,
|
||||
org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class,
|
||||
org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class,
|
||||
org.alfresco.util.test.junitrules.RetryAtMostRuleTest.class,
|
||||
org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class,
|
||||
org.alfresco.repo.search.impl.solr.AbstractSolrQueryHTTPClientTest.class,
|
||||
org.alfresco.repo.search.impl.solr.SpellCheckDecisionManagerTest.class,
|
||||
|
@@ -26,8 +26,8 @@
|
||||
|
||||
package org.alfresco.repo.action;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
||||
import org.alfresco.repo.action.executer.CounterIncrementActionExecuter;
|
||||
import org.alfresco.repo.action.executer.ScriptActionExecuter;
|
||||
@@ -260,7 +259,7 @@ public class ActionServiceImpl2Test
|
||||
public void testExecuteScript() throws Exception
|
||||
{
|
||||
final NodeRef scriptToBeExecuted = addTempScript("changeFileNameTest.js",
|
||||
"document.properties.name = \"Changed_\" + document.properties.name;\ndocument.save();");
|
||||
"document.properties.name = \"Changed\" + \"_\" + document.properties.name;\ndocument.save();");
|
||||
assertNotNull("Failed to add the test script.", scriptToBeExecuted);
|
||||
|
||||
// add a test file to the Site in order to change its name
|
||||
@@ -311,73 +310,6 @@ public class ActionServiceImpl2Test
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
//Execute script not in Data Dictionary > Scripts
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(testSiteAndMemberInfo.siteManager);
|
||||
NodeRef companyHomeRef = wellKnownNodes.getCompanyHome();
|
||||
NodeRef sharedFolderRef = nodeService.getChildByName(companyHomeRef, ContentModel.ASSOC_CONTAINS,
|
||||
"Shared");
|
||||
final NodeRef invalidScriptRef = addTempScript("changeFileNameTest.js",
|
||||
"document.properties.name = \"Invalid_Change.pdf\";\ndocument.save();",sharedFolderRef);
|
||||
assertNotNull("Failed to add the test script.", scriptToBeExecuted);
|
||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
// Create the action
|
||||
Action action = actionService.createAction(ScriptActionExecuter.NAME);
|
||||
action.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, invalidScriptRef);
|
||||
|
||||
try
|
||||
{
|
||||
// Execute the action
|
||||
actionService.executeAction(action, testNode);
|
||||
}
|
||||
catch (Throwable th)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
assertFalse("Scripts outside of Data Dictionary Scripts folder should not be executed",
|
||||
("Invalid_Change.pdf".equals(nodeService.getProperty(testNode, ContentModel.PROP_NAME))));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testActionResult() throws Exception
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create the script node reference
|
||||
NodeRef script = addTempScript("test-action-result-script.js", "\"VALUE\";");
|
||||
|
||||
// Create the action
|
||||
Action action = actionService.createAction(ScriptActionExecuter.NAME);
|
||||
action.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, script);
|
||||
|
||||
// Execute the action
|
||||
actionService.executeAction(action, testNode);
|
||||
|
||||
// Get the result
|
||||
String result = (String) action.getParameterValue(ActionExecuter.PARAM_RESULT);
|
||||
assertNotNull(result);
|
||||
assertEquals("VALUE", result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -437,32 +369,6 @@ public class ActionServiceImpl2Test
|
||||
});
|
||||
}
|
||||
|
||||
private NodeRef addTempScript(final String scriptFileName, final String javaScript, final NodeRef parentRef)
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
return transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
|
||||
// Create the script node reference
|
||||
NodeRef script = nodeService.createNode(parentRef, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, scriptFileName),
|
||||
ContentModel.TYPE_CONTENT).getChildRef();
|
||||
|
||||
nodeService.setProperty(script, ContentModel.PROP_NAME, scriptFileName);
|
||||
|
||||
ContentWriter contentWriter = contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_JAVASCRIPT);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.putContent(javaScript);
|
||||
|
||||
tempNodes.addNodeRef(script);
|
||||
return script;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private NodeRef addTempScript(final String scriptFileName, final String javaScript)
|
||||
{
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
@@ -480,7 +386,20 @@ public class ActionServiceImpl2Test
|
||||
NodeRef scriptsRef = nodeService.getChildByName(dataDictionaryRef, ContentModel.ASSOC_CONTAINS,
|
||||
"Scripts");
|
||||
|
||||
return addTempScript(scriptFileName, javaScript, scriptsRef);
|
||||
// Create the script node reference
|
||||
NodeRef script = nodeService.createNode(scriptsRef, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, scriptFileName),
|
||||
ContentModel.TYPE_CONTENT).getChildRef();
|
||||
|
||||
nodeService.setProperty(script, ContentModel.PROP_NAME, scriptFileName);
|
||||
|
||||
ContentWriter contentWriter = contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_JAVASCRIPT);
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.putContent(javaScript);
|
||||
|
||||
tempNodes.addNodeRef(script);
|
||||
return script;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -805,6 +805,46 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
||||
assertEquals(action4, savedAction2.getAction(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the action result parameter
|
||||
*/
|
||||
@Test
|
||||
public void testActionResult()
|
||||
{
|
||||
// We need to run this test as Administrator. The ScriptAction has to run as a full user (instead of as System)
|
||||
// so that we can setup the Person object in the ScriptNode
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
try
|
||||
{
|
||||
// Create the script node reference
|
||||
NodeRef script = this.nodeService.createNode(
|
||||
this.folder,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testScript.js"),
|
||||
ContentModel.TYPE_CONTENT).getChildRef();
|
||||
this.nodeService.setProperty(script, ContentModel.PROP_NAME, "testScript.js");
|
||||
ContentWriter contentWriter = this.contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
||||
contentWriter.setMimetype("text/plain");
|
||||
contentWriter.setEncoding("UTF-8");
|
||||
contentWriter.putContent("\"VALUE\";");
|
||||
|
||||
// Create the action
|
||||
Action action1 = this.actionService.createAction(ScriptActionExecuter.NAME);
|
||||
action1.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, script);
|
||||
|
||||
// Execute the action
|
||||
this.actionService.executeAction(action1, this.nodeRef);
|
||||
|
||||
// Get the result
|
||||
String result = (String)action1.getParameterValue(ActionExecuter.PARAM_RESULT);
|
||||
assertNotNull(result);
|
||||
assertEquals("VALUE", result);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
/** ===================================================================================
|
||||
* Test asynchronous actions
|
||||
|
@@ -25,11 +25,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.domain.permissions;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -66,15 +61,12 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.test.junitrules.RetryAtMostRule;
|
||||
import org.alfresco.util.test.junitrules.RetryAtMostRule.RetryAtMost;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test class for {@link FixedAclUpdater}
|
||||
*
|
||||
@@ -83,7 +75,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
||||
* @since 4.2.7
|
||||
*
|
||||
*/
|
||||
public class FixedAclUpdaterTest
|
||||
public class FixedAclUpdaterTest extends TestCase
|
||||
{
|
||||
private ApplicationContext ctx;
|
||||
private RetryingTransactionHelper txnHelper;
|
||||
@@ -107,10 +99,7 @@ public class FixedAclUpdaterTest
|
||||
private static String TEST_GROUP_NAME_FULL = PermissionService.GROUP_PREFIX + TEST_GROUP_NAME;
|
||||
private static String DEFAULT_PERMISSION = PermissionService.CONTRIBUTOR;
|
||||
|
||||
@Rule
|
||||
public RetryAtMostRule retryAtMostRule = new RetryAtMostRule();
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
ctx = ApplicationContextHelper.getApplicationContext();
|
||||
@@ -133,7 +122,7 @@ public class FixedAclUpdaterTest
|
||||
setFixedAclMaxTransactionTime(permissionsDaoComponent, homeFolderNodeRef, maxTransactionTime);
|
||||
}
|
||||
|
||||
@After
|
||||
@Override
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
@@ -209,7 +198,6 @@ public class FixedAclUpdaterTest
|
||||
* Test setting permissions explicitly as async
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsync()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncFolder");
|
||||
@@ -256,7 +244,6 @@ public class FixedAclUpdaterTest
|
||||
* MNT-21847 - Create a new content in folder that has the aspect applied
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeCreation()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeCreationFolder");
|
||||
@@ -287,7 +274,6 @@ public class FixedAclUpdaterTest
|
||||
* MNT-22009 - Delete node that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeDeletion()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeDeletionFolder");
|
||||
@@ -378,7 +364,6 @@ public class FixedAclUpdaterTest
|
||||
* MNT-22040 - Copy node that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeCopy()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeCopyOriginFolder");
|
||||
@@ -458,7 +443,6 @@ public class FixedAclUpdaterTest
|
||||
* Copy node that has the aspect to another folder that also has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeCopyToPendingFolder()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeCopyOriginFolder");
|
||||
@@ -550,7 +534,6 @@ public class FixedAclUpdaterTest
|
||||
* runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeCopyParentToChildPendingFolder()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeCopyOriginFolder");
|
||||
@@ -662,7 +645,6 @@ public class FixedAclUpdaterTest
|
||||
* runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeMoveChildToChildPendingFolder()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeMoveChildToChildPendingFolderOrigin");
|
||||
@@ -748,7 +730,6 @@ public class FixedAclUpdaterTest
|
||||
* ACL
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithErrorsForceSharedACL()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithErrorsForceSharedACL");
|
||||
@@ -807,7 +788,6 @@ public class FixedAclUpdaterTest
|
||||
* MNT-22040 - Move node that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeMove()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeMoveOriginFolder");
|
||||
@@ -884,7 +864,6 @@ public class FixedAclUpdaterTest
|
||||
* Move node that has the aspect to another folder that also has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeMoveToPendingFolder()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeMoveOriginFolder");
|
||||
@@ -973,7 +952,6 @@ public class FixedAclUpdaterTest
|
||||
* Lock node that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeLock()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFileTests("testAsyncWithNodeLockFolder");
|
||||
@@ -1003,7 +981,6 @@ public class FixedAclUpdaterTest
|
||||
* Checkout a node for editing that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeCheckout()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFileTests("testAsyncWithNodeCheckoutFolder");
|
||||
@@ -1034,7 +1011,6 @@ public class FixedAclUpdaterTest
|
||||
* Update the permissions of a node that has the aspect applied (new permissions: fixed)
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeUpdatePermissionsFixed()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeUpdatePermissionsFixedFolder");
|
||||
@@ -1076,7 +1052,6 @@ public class FixedAclUpdaterTest
|
||||
* Update the permissions of a node that has the aspect applied (new permissions: shared)
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeUpdatePermissionsShared()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithNodeUpdatePermissionsSharedFolder");
|
||||
@@ -1115,7 +1090,6 @@ public class FixedAclUpdaterTest
|
||||
* Update the permissions of the parent of a node that has the aspect applied (new permissions: fixed)
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithParentUpdatePermissionsFixed()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithParentUpdatePermissionsFixedFolder");
|
||||
@@ -1157,7 +1131,6 @@ public class FixedAclUpdaterTest
|
||||
* Update the permissions of the parent of a node that has the aspect applied (new permissions: shared)
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithParentUpdatePermissionsShared()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncWithParentUpdatePermissionsSharedFolder");
|
||||
@@ -1196,7 +1169,6 @@ public class FixedAclUpdaterTest
|
||||
}
|
||||
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncCascadeUpdatePermissions()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncCascadeUpdatePermissionsFolder");
|
||||
@@ -1249,7 +1221,6 @@ public class FixedAclUpdaterTest
|
||||
* Update the content of a node that has the aspect applied before job runs
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncWithNodeContentUpdate()
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFileTests("testAsyncWithNodeContentUpdateFolder");
|
||||
@@ -1282,7 +1253,6 @@ public class FixedAclUpdaterTest
|
||||
* Test setting permissions concurrently to actually cause the expected concurrency exception
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncConcurrentPermissionsUpdate() throws Throwable
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncConcurrentPermissionsUpdateFolder");
|
||||
@@ -1354,7 +1324,6 @@ public class FixedAclUpdaterTest
|
||||
* exception but the job should be able to recover
|
||||
*/
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testAsyncConcurrentUpdateAndJob() throws Throwable
|
||||
{
|
||||
NodeRef folderRef = createFolderHierarchyInRootForFolderTests("testAsyncConcurrentUpdateAndJobFolder");
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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
|
||||
@@ -33,10 +33,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -44,8 +41,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.importer.ACPImportPackageHandler;
|
||||
@@ -55,7 +50,12 @@ import org.alfresco.repo.security.permissions.PermissionServiceSPI;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.*;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.MLText;
|
||||
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.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
@@ -68,7 +68,6 @@ import org.alfresco.service.cmr.view.ExporterService;
|
||||
import org.alfresco.service.cmr.view.ImportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
@@ -83,7 +82,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.extensions.surf.util.InputStreamContent;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
|
||||
@@ -97,7 +95,6 @@ public class ExporterComponentTest extends BaseSpringTest
|
||||
private FileFolderService fileFolderService;
|
||||
private CategoryService categoryService;
|
||||
private TransactionService transactionService;
|
||||
private ContentService contentService;
|
||||
private StoreRef storeRef;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private PermissionServiceSPI permissionService;
|
||||
@@ -115,7 +112,6 @@ public class ExporterComponentTest extends BaseSpringTest
|
||||
categoryService = (CategoryService) applicationContext.getBean("categoryService");
|
||||
transactionService = (TransactionService) applicationContext.getBean("transactionService");
|
||||
permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService");
|
||||
contentService = (ContentService) applicationContext.getBean("contentService");
|
||||
|
||||
this.authenticationService = (MutableAuthenticationService) applicationContext.getBean("AuthenticationService");
|
||||
this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
|
||||
@@ -155,7 +151,9 @@ public class ExporterComponentTest extends BaseSpringTest
|
||||
OutputStream output = new FileOutputStream(tempFile);
|
||||
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
|
||||
parameters.setExportFrom(location);
|
||||
|
||||
// parameters.setExcludeAspects(new QName[] { ContentModel.ASPECT_AUDITABLE });
|
||||
// parameters.setExcludeChildAssocs(new QName[] { ContentModel.ASSOC_CONTAINS });
|
||||
|
||||
File acpFile = TempFileProvider.createTempFile("alf", ACPExportPackageHandler.ACP_EXTENSION);
|
||||
File dataFile = new File("test");
|
||||
File contentDir = new File("test");
|
||||
@@ -164,81 +162,6 @@ public class ExporterComponentTest extends BaseSpringTest
|
||||
acpHandler.setExportAsFolders(true);
|
||||
exporterService.exportView(acpHandler, parameters, testProgress);
|
||||
output.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExportWithChunkedList()
|
||||
throws Exception
|
||||
{
|
||||
TestProgress testProgress = new TestProgress();
|
||||
Location location = new Location(storeRef);
|
||||
|
||||
String testFile = "_testFile";
|
||||
int numberOfNodesToExport = 20;
|
||||
// now export
|
||||
location.setPath("/system");
|
||||
File tempFile = TempFileProvider.createTempFile("xmlexporttest", ".xml");
|
||||
OutputStream output = new FileOutputStream(tempFile);
|
||||
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
|
||||
parameters.setExportFrom(location);
|
||||
|
||||
File acpFile = TempFileProvider.createTempFile("alf", ACPExportPackageHandler.ACP_EXTENSION);
|
||||
File dataFile = new File("test");
|
||||
File contentDir = new File("test");
|
||||
ACPExportPackageHandler acpHandler = new ACPExportPackageHandler(new FileOutputStream(acpFile), dataFile, contentDir, null);
|
||||
acpHandler.setNodeService(nodeService);
|
||||
acpHandler.setExportAsFolders(true);
|
||||
NodeRef nodeRef = (location == null) ? null : location.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
// If a specific node has not been provided, default to the root
|
||||
nodeRef = nodeService.getRootNode(location.getStoreRef());
|
||||
}
|
||||
NodeRef[] childRefs = new NodeRef[numberOfNodesToExport];
|
||||
|
||||
for (int i = 0; i < numberOfNodesToExport; i++)
|
||||
{
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
props.put(ContentModel.PROP_NAME, this.getClass() + testFile + i);
|
||||
childRefs[i] = nodeService.createNode(nodeRef, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_CONTENT, props).getChildRef();
|
||||
}
|
||||
parameters.getExportFrom().setNodeRefs(childRefs);
|
||||
parameters.setCrawlSelf(true);
|
||||
exporterService.setExportChunkSize("3");
|
||||
exporterService.exportView(acpHandler, parameters, testProgress);
|
||||
output.close();
|
||||
ZipFile zipFile = new ZipFile(acpFile.getAbsolutePath());
|
||||
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
int numberOfExportedNodes = 0;
|
||||
while(entries.hasMoreElements()){
|
||||
ZipEntry entry = entries.nextElement();
|
||||
InputStream stream = zipFile.getInputStream(entry);
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
stream, StandardCharsets.UTF_8));) {
|
||||
|
||||
String line;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
||||
if(line.contains(testFile)){
|
||||
numberOfExportedNodes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
stream.close();
|
||||
}
|
||||
zipFile.close();
|
||||
|
||||
assertEquals(numberOfNodesToExport, numberOfExportedNodes);
|
||||
|
||||
parameters.getExportFrom().setNodeRefs(null);
|
||||
for (int i = 0; i < numberOfNodesToExport; i++)
|
||||
{
|
||||
nodeService.deleteNode(childRefs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,48 +1,48 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.jscript;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.dictionary.DictionaryComponent;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.M2Model;
|
||||
import org.alfresco.repo.node.BaseNodeServiceTest;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.node.BaseNodeServiceTest;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -54,16 +54,13 @@ import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.ImporterTopLevel;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.Undefined;
|
||||
import org.mozilla.javascript.UniqueTag;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
|
||||
/**
|
||||
@@ -367,173 +364,77 @@ public class RhinoScriptTest extends TestCase
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// MNT-21009
|
||||
public void testUnsecureScriptAddedOnRepoNode()
|
||||
{
|
||||
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
|
||||
NodeRef root = nodeService.getRootNode(store);
|
||||
BaseNodeServiceTest.buildNodeGraph(nodeService, root);
|
||||
|
||||
try
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("out", System.out);
|
||||
|
||||
// create an Alfresco scriptable Node object
|
||||
// the Node object is a wrapper similar to the TemplateNode
|
||||
// concept
|
||||
ScriptNode rootNode = new ScriptNode(root, serviceRegistry, null);
|
||||
model.put("root", rootNode);
|
||||
|
||||
// test executing a script embedded inside Node content
|
||||
ChildAssociationRef childRef = nodeService.createNode(root, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName(BaseNodeServiceTest.NAMESPACE, "script_content"), BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT, null);
|
||||
NodeRef contentNodeRef = childRef.getChildRef();
|
||||
ContentWriter writer = contentService.getWriter(contentNodeRef, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, true);
|
||||
writer.setMimetype("application/x-javascript");
|
||||
writer.putContent(BASIC_JAVA);
|
||||
|
||||
try
|
||||
{
|
||||
scriptService.executeScript(contentNodeRef, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, model);
|
||||
fail("execution of nonsecure script on nodeRef is not allowed.");
|
||||
}
|
||||
catch (AlfrescoRuntimeException ex)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
ChildAssociationRef childRef1 = nodeService.createNode(root, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName(BaseNodeServiceTest.NAMESPACE, "script_content"), BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT, null);
|
||||
NodeRef contentNodeRef1 = childRef1.getChildRef();
|
||||
ContentWriter writer1 = contentService.getWriter(contentNodeRef1, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, true);
|
||||
writer1.setMimetype("application/x-javascript");
|
||||
writer1.putContent(REFLECTION_GET_CLASS);
|
||||
|
||||
try
|
||||
{
|
||||
scriptService.executeScript(contentNodeRef1, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, model);
|
||||
fail("execution of nonsecure script on nodeRef is not allowed.");
|
||||
}
|
||||
catch (AlfrescoRuntimeException ex)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// MNT-21009
|
||||
public void testUnsecureScriptAddedOnRepoNode()
|
||||
{
|
||||
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
|
||||
NodeRef root = nodeService.getRootNode(store);
|
||||
BaseNodeServiceTest.buildNodeGraph(nodeService, root);
|
||||
|
||||
try
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("out", System.out);
|
||||
|
||||
// create an Alfresco scriptable Node object
|
||||
// the Node object is a wrapper similar to the TemplateNode
|
||||
// concept
|
||||
ScriptNode rootNode = new ScriptNode(root, serviceRegistry, null);
|
||||
model.put("root", rootNode);
|
||||
|
||||
// test executing a script embedded inside Node content
|
||||
ChildAssociationRef childRef = nodeService.createNode(root, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName(BaseNodeServiceTest.NAMESPACE, "script_content"), BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT, null);
|
||||
NodeRef contentNodeRef = childRef.getChildRef();
|
||||
ContentWriter writer = contentService.getWriter(contentNodeRef, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, true);
|
||||
writer.setMimetype("application/x-javascript");
|
||||
writer.putContent(BASIC_JAVA);
|
||||
|
||||
try
|
||||
{
|
||||
scriptService.executeScript(contentNodeRef, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, model);
|
||||
fail("execution of nonsecure script on nodeRef is not allowed.");
|
||||
}
|
||||
catch (AlfrescoRuntimeException ex)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
ChildAssociationRef childRef1 = nodeService.createNode(root, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN,
|
||||
QName.createQName(BaseNodeServiceTest.NAMESPACE, "script_content"), BaseNodeServiceTest.TYPE_QNAME_TEST_CONTENT, null);
|
||||
NodeRef contentNodeRef1 = childRef1.getChildRef();
|
||||
ContentWriter writer1 = contentService.getWriter(contentNodeRef1, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, true);
|
||||
writer1.setMimetype("application/x-javascript");
|
||||
writer1.putContent(REFLECTION_GET_CLASS);
|
||||
|
||||
try
|
||||
{
|
||||
scriptService.executeScript(contentNodeRef1, BaseNodeServiceTest.PROP_QNAME_TEST_CONTENT, model);
|
||||
fail("execution of nonsecure script on nodeRef is not allowed.");
|
||||
}
|
||||
catch (AlfrescoRuntimeException ex)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// MNT-23158
|
||||
public void testScopeData()
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
Context cx = Context.enter();
|
||||
try
|
||||
{
|
||||
Scriptable sharedScope = new ImporterTopLevel(cx, true);
|
||||
Scriptable scope = cx.newObject(sharedScope);
|
||||
scope.setPrototype(sharedScope);
|
||||
scope.setParentScope(null);
|
||||
|
||||
// Executes a first script
|
||||
Object result = cx.evaluateString(scope, "var a = 10; var b = 20; var sum = a+b;", "TestJS1", 1, null);
|
||||
assertTrue(Undefined.isUndefined(result));
|
||||
|
||||
// Test sum value
|
||||
Object sum = scope.get("sum", scope);
|
||||
assertEquals(30.0, Context.toNumber(sum));
|
||||
|
||||
// No 'sum' property should be found in the shared scope
|
||||
sum = sharedScope.get("sum", sharedScope);
|
||||
assertEquals(sum, UniqueTag.NOT_FOUND);
|
||||
|
||||
// No 'b' property should be found in the shared scope
|
||||
Object b = ScriptableObject.getProperty(sharedScope, "b");
|
||||
assertEquals(b, UniqueTag.NOT_FOUND);
|
||||
|
||||
// Cleans scope
|
||||
unsetScope(scope);
|
||||
|
||||
// Executes a second script using the same scope
|
||||
result = cx.evaluateString(scope, "var test = 'test';", "TestJS2", 1, null);
|
||||
|
||||
// 'sum' property should be null
|
||||
sum = scope.get("sum", scope);
|
||||
assertNull(sum);
|
||||
|
||||
// New scope initialization
|
||||
scope = cx.newObject(sharedScope);
|
||||
scope.setPrototype(sharedScope);
|
||||
scope.setParentScope(null);
|
||||
|
||||
// check 'test' property
|
||||
Object test = scope.get("test", scope);
|
||||
assertEquals(test, UniqueTag.NOT_FOUND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Context.exit();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void unsetScope(Scriptable scope)
|
||||
{
|
||||
if (scope != null)
|
||||
{
|
||||
Object[] ids = scope.getIds();
|
||||
|
||||
if (ids != null)
|
||||
{
|
||||
for (Object id : ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
deleteProperty(scope, id.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteProperty(Scriptable scope, String name)
|
||||
{
|
||||
if (scope != null && name != null)
|
||||
{
|
||||
if (!ScriptableObject.deleteProperty(scope, name))
|
||||
{
|
||||
ScriptableObject.putProperty(scope, name, null);
|
||||
}
|
||||
scope.delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TESTSCRIPT_CLASSPATH1 = "org/alfresco/repo/jscript/test_script1.js";
|
||||
private static final String TESTSCRIPT_CLASSPATH2 = "org/alfresco/repo/jscript/test_script2.js";
|
||||
private static final String TESTSCRIPT_CLASSPATH3 = "org/alfresco/repo/jscript/test_script3.js";
|
||||
@@ -551,14 +452,14 @@ public class RhinoScriptTest extends TestCase
|
||||
"var childByNameNode = root.childByNamePath(\"/\" + childList[0].name);\r\n" +
|
||||
"logger.log(\"child by name path: \" + childByNameNode.name);\r\n" +
|
||||
"var xpathResults = root.childrenByXPath(\"/*\");\r\n" +
|
||||
"logger.log(\"children of root from xpath: \" + xpathResults.length);\r\n";
|
||||
|
||||
private static final String BASIC_JAVA =
|
||||
"var list = com.google.common.collect.Lists.newArrayList();\n" +
|
||||
"root.nodeRef.getClass().forName(\"java.lang.ProcessBuilder\")";
|
||||
|
||||
private static final String REFLECTION_GET_CLASS =
|
||||
"root.nodeRef.getClass().forName(\"java.lang.ProcessBuilder\")";
|
||||
|
||||
"logger.log(\"children of root from xpath: \" + xpathResults.length);\r\n";
|
||||
|
||||
private static final String BASIC_JAVA =
|
||||
"var list = com.google.common.collect.Lists.newArrayList();\n" +
|
||||
"root.nodeRef.getClass().forName(\"java.lang.ProcessBuilder\")";
|
||||
|
||||
private static final String REFLECTION_GET_CLASS =
|
||||
"root.nodeRef.getClass().forName(\"java.lang.ProcessBuilder\")";
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,260 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 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.repo.search.impl.querymodel.impl.db;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cache.TransactionalCache;
|
||||
import org.alfresco.repo.management.subsystems.SwitchableApplicationContextFactory;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.repo.security.permissions.AccessControlList;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
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.*;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.DBTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
@Category({OwnJVMTestsCategory.class, DBTests.class})
|
||||
public class ACS1907Test extends TestCase
|
||||
{
|
||||
|
||||
private ApplicationContext ctx;
|
||||
|
||||
private NodeService nodeService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private MutableAuthenticationDao authenticationDAO;
|
||||
private SearchService pubSearchService;
|
||||
private PermissionService pubPermissionService;
|
||||
private TransactionService transactionService;
|
||||
private RetryingTransactionHelper txnHelper;
|
||||
private DBQueryEngine queryEngine;
|
||||
|
||||
private TransactionalCache<Serializable, AccessControlList> aclCache;
|
||||
private TransactionalCache<Serializable, Object> aclEntityCache;
|
||||
private TransactionalCache<Serializable, Object> permissionEntityCache;
|
||||
|
||||
private NodeRef rootNodeRef;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
setupServices();
|
||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||
rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
setupTestUsers();
|
||||
setupTestContent();
|
||||
dropCaches();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
|
||||
private void setupServices()
|
||||
{
|
||||
ctx = ApplicationContextHelper.getApplicationContext();
|
||||
nodeService = (NodeService) ctx.getBean("dbNodeService");
|
||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
|
||||
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
|
||||
pubSearchService = (SearchService) ctx.getBean("SearchService");
|
||||
pubPermissionService = (PermissionService) ctx.getBean("PermissionService");
|
||||
transactionService = (TransactionService) ctx.getBean("TransactionService");
|
||||
aclCache = (TransactionalCache) ctx.getBean("aclCache");
|
||||
aclEntityCache = (TransactionalCache) ctx.getBean("aclEntityCache");
|
||||
permissionEntityCache = (TransactionalCache) ctx.getBean("permissionEntityCache");
|
||||
SwitchableApplicationContextFactory searchContextFactory = (SwitchableApplicationContextFactory) ctx.getBean("Search");
|
||||
ApplicationContext searchCtx = searchContextFactory.getApplicationContext();
|
||||
queryEngine = (DBQueryEngine) searchCtx.getBean("search.dbQueryEngineImpl");
|
||||
txnHelper = new RetryingTransactionHelper();
|
||||
txnHelper.setTransactionService(transactionService);
|
||||
txnHelper.setReadOnly(false);
|
||||
txnHelper.setMaxRetries(1);
|
||||
txnHelper.setMinRetryWaitMs(1);
|
||||
txnHelper.setMaxRetryWaitMs(10);
|
||||
txnHelper.setRetryWaitIncrementMs(1);
|
||||
}
|
||||
|
||||
private void setupTestUser(String userName)
|
||||
{
|
||||
if (!authenticationDAO.userExists(userName))
|
||||
{
|
||||
authenticationService.createAuthentication(userName, userName.toCharArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupTestUsers()
|
||||
{
|
||||
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object execute() throws Throwable {
|
||||
setupTestUser("userA");
|
||||
setupTestUser("userB");
|
||||
setupTestUser(AuthenticationUtil.getAdminUserName());
|
||||
return null;
|
||||
}
|
||||
}, false, false);
|
||||
}
|
||||
|
||||
private void setupTestContent()
|
||||
{
|
||||
for(int f = 0; f < 5; f++)
|
||||
{
|
||||
final int ff = f;
|
||||
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object execute() throws Throwable {
|
||||
Map<QName, Serializable> testFolderProps = new HashMap<>();
|
||||
testFolderProps.put(ContentModel.PROP_NAME, "folder"+ff);
|
||||
NodeRef testFolder = nodeService.createNode(
|
||||
rootNodeRef,
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("https://example.com/test", "folder"+ff),
|
||||
ContentModel.TYPE_FOLDER,
|
||||
testFolderProps
|
||||
).getChildRef();
|
||||
for(int c = 0; c < 5; c++)
|
||||
{
|
||||
Map<QName, Serializable> testContentProps = new HashMap<>();
|
||||
testContentProps.put(ContentModel.PROP_NAME, "content"+c);
|
||||
NodeRef testContent = nodeService.createNode(
|
||||
testFolder,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName("https://example.com/test", "content"+c),
|
||||
ContentModel.TYPE_CONTENT,
|
||||
testContentProps
|
||||
).getChildRef();
|
||||
String user = c % 2 == 0 ? "userA" : "userB";
|
||||
pubPermissionService.setPermission(testContent, user, "Read", true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropCaches()
|
||||
{
|
||||
aclCache.clear();
|
||||
aclEntityCache.clear();
|
||||
permissionEntityCache.clear();
|
||||
}
|
||||
|
||||
public void testACS1907()
|
||||
{
|
||||
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
|
||||
@Override
|
||||
public Object execute() throws Throwable {
|
||||
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() {
|
||||
@Override
|
||||
public Object doWork() throws Exception {
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
|
||||
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
|
||||
sp.setQuery("TYPE:\"cm:content\"");
|
||||
ResultSet rs = pubSearchService.query(sp);
|
||||
int cnt = 0;
|
||||
for (ResultSetRow row : rs)
|
||||
{
|
||||
assertNotNull(row.getValue(ContentModel.PROP_NAME));
|
||||
cnt++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, "userA");
|
||||
return null;
|
||||
}
|
||||
}, false, false);
|
||||
}
|
||||
|
||||
public void testPaging()
|
||||
{
|
||||
HashSet<NodeRef> resultPageSize2 = queryNodes(2);
|
||||
HashSet<NodeRef> resultPageSize5 = queryNodes(5);
|
||||
HashSet<NodeRef> resultPageSize10 = queryNodes(10);
|
||||
HashSet<NodeRef> resultPageSizeAll = queryNodes(10000);
|
||||
// all result sets must be equal, independent of page size used to retrieve them
|
||||
assertTrue(resultPageSize2.size() >= 25);
|
||||
assertTrue(resultPageSize5.size() >= 25);
|
||||
assertTrue(resultPageSize10.size() >= 25);
|
||||
assertTrue(resultPageSizeAll.size() >= 25);
|
||||
assertTrue(resultPageSize2.containsAll(resultPageSize5));
|
||||
assertTrue(resultPageSize2.containsAll(resultPageSize10));
|
||||
assertTrue(resultPageSize2.containsAll(resultPageSizeAll));
|
||||
assertTrue(resultPageSize5.containsAll(resultPageSize2));
|
||||
assertTrue(resultPageSize5.containsAll(resultPageSize10));
|
||||
assertTrue(resultPageSize5.containsAll(resultPageSizeAll));
|
||||
assertTrue(resultPageSize10.containsAll(resultPageSize2));
|
||||
assertTrue(resultPageSize10.containsAll(resultPageSize5));
|
||||
assertTrue(resultPageSize10.containsAll(resultPageSizeAll));
|
||||
assertTrue(resultPageSizeAll.containsAll(resultPageSize2));
|
||||
assertTrue(resultPageSizeAll.containsAll(resultPageSize5));
|
||||
assertTrue(resultPageSizeAll.containsAll(resultPageSize10));
|
||||
// reset
|
||||
queryEngine.setMinPagingBatchSize(2500);
|
||||
queryEngine.setMaxPagingBatchSize(10000);
|
||||
}
|
||||
|
||||
HashSet<NodeRef> queryNodes(int pageSize)
|
||||
{
|
||||
queryEngine.setMinPagingBatchSize(pageSize);
|
||||
queryEngine.setMaxPagingBatchSize(pageSize);
|
||||
HashSet<NodeRef> result = new HashSet<>();
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
|
||||
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
|
||||
sp.setQuery("TYPE:\"cm:content\"");
|
||||
ResultSet rs = pubSearchService.query(sp);
|
||||
int cnt = 0;
|
||||
for (ResultSetRow row : rs)
|
||||
{
|
||||
result.add(row.getNodeRef());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -99,7 +99,7 @@ public class SecurityTestSuite extends TestSuite
|
||||
|
||||
suite.addTest(new JUnit4TestAdapter(HomeFolderProviderSynchronizerTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(AlfrescoSSLSocketFactoryTest.class));
|
||||
suite.addTest(new JUnit4TestAdapter(FixedAclUpdaterTest.class));
|
||||
suite.addTestSuite(FixedAclUpdaterTest.class);
|
||||
|
||||
suite.addTestSuite(DefaultRemoteUserMapperTest.class);
|
||||
suite.addTestSuite(IdentityServiceRemoteUserMapperTest.class);
|
||||
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.urlshortening;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @deprecated as BitlyUrlShortenerImpl is no longer used in the core repository code.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BitlyUrlShortenerTest extends TestCase
|
||||
{
|
||||
private BitlyUrlShortenerImpl shortener;
|
||||
|
||||
public void testShorten()
|
||||
{
|
||||
String url = "http://www.alfresco.com/";
|
||||
String shortUrl = shortener.shortenUrl(url);
|
||||
assertNotNull(shortUrl);
|
||||
assertFalse(shortUrl.isEmpty());
|
||||
assertFalse(url.equals(shortUrl));
|
||||
assertTrue(shortUrl.length() < url.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
this.shortener = new BitlyUrlShortenerImpl();;
|
||||
shortener.setApiKey("R_ca15c6c89e9b25ccd170bafd209a0d4f");
|
||||
shortener.setUrlLength(20);
|
||||
shortener.setUsername("brianalfresco");
|
||||
}
|
||||
}
|
@@ -39,6 +39,7 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -93,8 +94,6 @@ import org.springframework.test.annotation.Commit;
|
||||
import org.springframework.test.context.transaction.TestTransaction;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* versionService test class.
|
||||
*
|
||||
@@ -576,86 +575,6 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When IDs are out of order the comparator only fixes the order we retrieve versions. Any operation fails due to
|
||||
* the head version not being the latest. (MNT-22715)
|
||||
*/
|
||||
@Test
|
||||
public void testVersionIndex()
|
||||
{
|
||||
setUseVersionAssocIndex(true);
|
||||
NodeRef versionableNode = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}MyVersionableNodeTestIndex"), ContentModel.TYPE_CONTENT, null).getChildRef();
|
||||
nodeService.addAspect(versionableNode, ContentModel.ASPECT_VERSIONABLE, new HashMap<QName, Serializable>());
|
||||
Version version1 = createVersion(versionableNode);
|
||||
Version version2 = createVersion(versionableNode);
|
||||
Version version3 = createVersion(versionableNode);
|
||||
|
||||
VersionHistory vh = versionService.getVersionHistory(versionableNode);
|
||||
assertEquals("Version History does not contain 3 versions", 3, vh.getAllVersions().size());
|
||||
|
||||
NodeRef root = nodeService.getPrimaryParent(vh.getRootVersion().getFrozenStateNodeRef()).getParentRef();
|
||||
NodeRef versionHistoryNode = dbNodeService.getChildByName(root, Version2Model.CHILD_QNAME_VERSION_HISTORIES,
|
||||
versionableNode.getId());
|
||||
|
||||
// getChildAssocs orders by assoc_index first and then by ID. Version History relies on this.
|
||||
List<ChildAssociationRef> vhChildAssocs = nodeService.getChildAssocs(versionHistoryNode);
|
||||
int index = 0;
|
||||
for (ChildAssociationRef vhChildAssoc : vhChildAssocs)
|
||||
{
|
||||
// Unset indexes are -1
|
||||
assertFalse("Index is not set", vhChildAssoc.getNthSibling() < 0);
|
||||
assertTrue("Index is not increasing as expected", vhChildAssoc.getNthSibling() > index);
|
||||
index = vhChildAssoc.getNthSibling();
|
||||
}
|
||||
|
||||
assertEquals("1st version is not 1st assoc", version1.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(0).getChildRef().getId());
|
||||
assertEquals("2nd version is not 2nd assoc", version2.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(1).getChildRef().getId());
|
||||
assertEquals("3rd version is not 3rd assoc", version3.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(2).getChildRef().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test version assoc index use disabled
|
||||
*/
|
||||
@Test
|
||||
public void testVersionIndexDisabled()
|
||||
{
|
||||
setUseVersionAssocIndex(false);
|
||||
NodeRef versionableNode = nodeService
|
||||
.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
|
||||
QName.createQName("{test}MyVersionableNodeTestWithoutIndex"), ContentModel.TYPE_CONTENT, null)
|
||||
.getChildRef();
|
||||
nodeService.addAspect(versionableNode, ContentModel.ASPECT_VERSIONABLE, new HashMap<QName, Serializable>());
|
||||
Version version1 = createVersion(versionableNode);
|
||||
Version version2 = createVersion(versionableNode);
|
||||
Version version3 = createVersion(versionableNode);
|
||||
|
||||
VersionHistory vh = versionService.getVersionHistory(versionableNode);
|
||||
assertEquals("Version History does not contain 3 versions", 3, vh.getAllVersions().size());
|
||||
|
||||
NodeRef root = nodeService.getPrimaryParent(vh.getRootVersion().getFrozenStateNodeRef()).getParentRef();
|
||||
NodeRef versionHistoryNode = dbNodeService.getChildByName(root, Version2Model.CHILD_QNAME_VERSION_HISTORIES,
|
||||
versionableNode.getId());
|
||||
|
||||
// getChildAssocs orders by assoc_index first and then by ID. Version History relies on this.
|
||||
List<ChildAssociationRef> vhChildAssocs = nodeService.getChildAssocs(versionHistoryNode);
|
||||
for (ChildAssociationRef vhChildAssoc : vhChildAssocs)
|
||||
{
|
||||
// Unset indexes are -1
|
||||
assertTrue("Index is not set", vhChildAssoc.getNthSibling() < 0);
|
||||
}
|
||||
|
||||
assertEquals("1st version is not 1st assoc", version1.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(0).getChildRef().getId());
|
||||
assertEquals("2nd version is not 2nd assoc", version2.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(1).getChildRef().getId());
|
||||
assertEquals("3rd version is not 3rd assoc", version3.getFrozenStateNodeRef().getId(),
|
||||
vhChildAssocs.get(2).getChildRef().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the versionService to be one that has is db ids out of order
|
||||
* so would normally have versions displayed in the wrong order.
|
||||
@@ -693,25 +612,6 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
|
||||
setVersionService(versionService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the versionService to use the version assoc Index
|
||||
* @param useVersionAssocIndex
|
||||
*/
|
||||
private void setUseVersionAssocIndex(boolean useVersionAssocIndex)
|
||||
{
|
||||
Version2ServiceImpl versionService = new Version2ServiceImpl();
|
||||
versionService.setNodeService(nodeService);
|
||||
versionService.setDbNodeService(dbNodeService); // mtAwareNodeService
|
||||
versionService.setSearcher(versionSearchService);
|
||||
versionService.setDictionaryService(dictionaryService);
|
||||
versionService.setPolicyComponent(policyComponent);
|
||||
versionService.setPolicyBehaviourFilter(policyBehaviourFilter);
|
||||
versionService.setPermissionService(permissionService);
|
||||
versionService.setUseVersionAssocIndex(useVersionAssocIndex);
|
||||
versionService.initialise();
|
||||
setVersionService(versionService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds another version to the version history then checks that getVersionHistory is returning
|
||||
* the correct data.
|
||||
|
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.util.test.junitrules;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
/**
|
||||
* This JUnit rule can be used to turn existing test code into retryable tests.
|
||||
* The test methods marked with the {@link RetryAtMost} annotation will be attempted at most the specified
|
||||
* amount of times, stopping at the first successful execution.
|
||||
*
|
||||
* @author Domenico Sibilio
|
||||
*/
|
||||
public class RetryAtMostRule implements TestRule
|
||||
{
|
||||
private static final Log LOG = LogFactory.getLog(RetryAtMostRule.class);
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement statement, final Description description)
|
||||
{
|
||||
RetryAtMost retryAtMost = description.getAnnotation(RetryAtMost.class);
|
||||
|
||||
if (retryAtMost != null)
|
||||
{
|
||||
return new RetryAtMostTestStatement(statement, description, retryAtMost.value());
|
||||
}
|
||||
|
||||
return statement;
|
||||
}
|
||||
|
||||
private static class RetryAtMostTestStatement extends Statement
|
||||
{
|
||||
private final Statement statement;
|
||||
private final Description description;
|
||||
private final int retryCount;
|
||||
|
||||
private RetryAtMostTestStatement(Statement statement, Description description, int retryCount)
|
||||
{
|
||||
this.statement = statement;
|
||||
this.description = description;
|
||||
this.retryCount = retryCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable
|
||||
{
|
||||
validate();
|
||||
for (int i = 0; i < retryCount; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
LOG.debug(
|
||||
"Retryable testing configured for method: " + description.getMethodName()
|
||||
+ " // Attempt #" + (i + 1));
|
||||
statement.evaluate();
|
||||
break; // stop at the first successful execution
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// ignore failed test runs unless it's the last possible execution
|
||||
if (isLastExecution(i))
|
||||
{
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validate()
|
||||
{
|
||||
if (retryCount < 1)
|
||||
{
|
||||
String methodName = description.getMethodName();
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid value for @RetryAtMost on method " + methodName + ": " + retryCount + " is less than 1.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLastExecution(int i)
|
||||
{
|
||||
return i == retryCount - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This annotation is a marker used to identify a JUnit @{@link Test} method as a retryable test.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RetryAtMost
|
||||
{
|
||||
/**
|
||||
* @return The amount of times a test will be attempted, at most.
|
||||
*/
|
||||
int value() default 1;
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.util.test.junitrules;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.alfresco.util.test.junitrules.RetryAtMostRule.RetryAtMost;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.model.Statement;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
/**
|
||||
* Test class for {@link RetryAtMostRule}.
|
||||
*
|
||||
* @author Domenico Sibilio
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class RetryAtMostRuleTest
|
||||
{
|
||||
|
||||
private static final String ANNOTATION_WITH_NEGATIVE_VALUE = "annotationRetryAtMostNegativeTimes";
|
||||
private static final String ANNOTATION_RETRY_AT_MOST_THRICE = "annotationRetryAtMostThrice";
|
||||
private static final AtomicInteger EXECUTION_COUNT = new AtomicInteger(0);
|
||||
@Rule
|
||||
public RetryAtMostRule retryAtMostRule = new RetryAtMostRule();
|
||||
@Rule
|
||||
public TestName testNameRule = new TestName();
|
||||
@Mock
|
||||
private Statement statementMock;
|
||||
|
||||
@Test
|
||||
public void testSucceedOnFirstAttempt() throws Throwable
|
||||
{
|
||||
Description description = Description.createTestDescription(RetryAtMostRuleTest.class.getSimpleName(),
|
||||
testNameRule.getMethodName(), getAnnotationByMethodName(ANNOTATION_RETRY_AT_MOST_THRICE));
|
||||
|
||||
Statement statement = retryAtMostRule.apply(statementMock, description);
|
||||
statement.evaluate();
|
||||
verify(statementMock, times(1)).evaluate();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSucceedOnSecondAttempt() throws Throwable
|
||||
{
|
||||
doThrow(new AssertionError("First execution should fail")).doNothing().when(statementMock).evaluate();
|
||||
|
||||
Description description = Description.createTestDescription(RetryAtMostRuleTest.class.getSimpleName(),
|
||||
testNameRule.getMethodName(), getAnnotationByMethodName(ANNOTATION_RETRY_AT_MOST_THRICE));
|
||||
|
||||
Statement statement = retryAtMostRule.apply(statementMock, description);
|
||||
statement.evaluate();
|
||||
verify(statementMock, times(2)).evaluate();
|
||||
}
|
||||
|
||||
@Test
|
||||
@RetryAtMost(3)
|
||||
public void testSucceedOnThirdAttempt()
|
||||
{
|
||||
int currentExecution = EXECUTION_COUNT.incrementAndGet();
|
||||
assertSame("This test should be executed 3 times", 3, currentExecution);
|
||||
}
|
||||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void testFailAfterMaxAttempts() throws Throwable
|
||||
{
|
||||
doThrow(new AssertionError("All executions should fail")).when(statementMock).evaluate();
|
||||
|
||||
Description description = Description.createTestDescription(RetryAtMostRuleTest.class.getSimpleName(),
|
||||
testNameRule.getMethodName(), getAnnotationByMethodName(ANNOTATION_RETRY_AT_MOST_THRICE));
|
||||
|
||||
Statement statement = retryAtMostRule.apply(statementMock, description);
|
||||
statement.evaluate();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidRetryAtMostTimes() throws Throwable
|
||||
{
|
||||
Description description = Description.createTestDescription(RetryAtMostRuleTest.class.getSimpleName(),
|
||||
testNameRule.getMethodName(), getAnnotationByMethodName(ANNOTATION_WITH_NEGATIVE_VALUE));
|
||||
|
||||
Statement statement = retryAtMostRule.apply(statementMock, description);
|
||||
statement.evaluate();
|
||||
verifyNoInteractions(statementMock);
|
||||
}
|
||||
|
||||
private Annotation getAnnotationByMethodName(String methodName) throws NoSuchMethodException
|
||||
{
|
||||
return this.getClass().getMethod(methodName).getAnnotation(RetryAtMost.class);
|
||||
}
|
||||
|
||||
@RetryAtMost(-1)
|
||||
public void annotationRetryAtMostNegativeTimes()
|
||||
{
|
||||
// intentionally empty
|
||||
}
|
||||
|
||||
@RetryAtMost(3)
|
||||
public void annotationRetryAtMostThrice()
|
||||
{
|
||||
// intentionally empty
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT" | xargs -r -l rm -rf
|
@@ -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:2.4.0
|
||||
environment:
|
||||
JAVA_OPTS: " -Xms256m -Xmx256m"
|
||||
ports:
|
||||
- "8090:8090"
|
||||
postgres:
|
||||
image: postgres:13.1
|
||||
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.16.1
|
||||
ports:
|
||||
- "5672:5672" # AMQP
|
||||
- "61616:61616" # OpenWire
|
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
M2_REPO_DIR="$HOME/.m2/repository"
|
||||
M2_REPO_TTL_MINUTES=10080
|
||||
M2_REPO_EXPIRED="$(find $M2_REPO_DIR -type f -mmin +$M2_REPO_TTL_MINUTES 2>/dev/null | head -n 1 | wc -l)"
|
||||
M2_REPO_FILE_COUNT="$(find $M2_REPO_DIR -type f 2>/dev/null | wc -l)"
|
||||
|
||||
ORG_ALFRESCO_M2_REPO_DIR="$M2_REPO_DIR/org/alfresco"
|
||||
ORG_ALFRESCO_M2_REPO_TTL_MINUTES=1440
|
||||
ORG_ALFRESCO_M2_REPO_EXPIRED="$(find $ORG_ALFRESCO_M2_REPO_DIR -type f -mmin +$ORG_ALFRESCO_M2_REPO_TTL_MINUTES 2>/dev/null | head -n 1 | wc -l)"
|
||||
|
||||
echo "Files in the maven repo: $M2_REPO_FILE_COUNT"
|
||||
|
||||
if [ $ORG_ALFRESCO_M2_REPO_EXPIRED -eq 1 ];then
|
||||
echo "Invalidating org/alfresco maven local cache."
|
||||
rm -rf "$ORG_ALFRESCO_M2_REPO_DIR"
|
||||
fi
|
||||
|
||||
if [ $M2_REPO_EXPIRED -eq 1 ];then
|
||||
echo "Invalidating maven local cache."
|
||||
rm -rf "$M2_REPO_DIR"
|
||||
fi
|
||||
|
||||
echo "Verifying compilation and ensuring maven cache populated."
|
||||
export BUILD_PROFILES="-Pall-tas-tests"
|
||||
export BUILD_OPTIONS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dmaven.artifact.threads=8"
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/build.sh"
|
@@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "=========================== Starting AppContext05TestSuite setup ==========================="
|
||||
PS4="\[\e[35m\]+ \[\e[m\]"
|
||||
set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
|
||||
|
||||
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
|
||||
|
||||
popd
|
||||
set +vex
|
||||
echo "=========================== Finishing AppContext05TestSuite setup =========================="
|
@@ -6,21 +6,18 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh"
|
||||
|
||||
if [[ -n ${BUILD_PROFILES} ]]; then
|
||||
PROFILES="${BUILD_PROFILES}"
|
||||
elif [[ "${REQUIRES_LOCAL_IMAGES}" == "true" ]]; then
|
||||
if isBranchBuild && [ "${TRAVIS_BRANCH}" = "master" ] && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] ; then
|
||||
# update ":latest" image tags on remote repositories by using the maven *internal* profile
|
||||
PROFILES="-Pinternal"
|
||||
else
|
||||
# build the ":latest" image tags locally with the maven *communityDocker* profile
|
||||
PROFILES="-PcommunityDocker"
|
||||
fi
|
||||
|
||||
if [[ "${REQUIRES_INSTALLED_ARTIFACTS}" == "true" ]]; then
|
||||
PHASE="install"
|
||||
else
|
||||
PHASE="package"
|
||||
fi
|
||||
mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true "${PROFILES}"
|
||||
|
||||
mvn -B -V $PHASE -DskipTests -Dmaven.javadoc.skip=true $PROFILES $BUILD_OPTIONS
|
||||
|
||||
popd
|
||||
set +vex
|
||||
echo "=========================== Finishing Build Script =========================="
|
||||
echo "=========================== Finishing Build Script =========================="
|
||||
|
@@ -2,18 +2,18 @@
|
||||
set +vx
|
||||
|
||||
function isPullRequestBuild() {
|
||||
test "${PULL_REQUEST}" != "false"
|
||||
test "${TRAVIS_PULL_REQUEST}" != "false"
|
||||
}
|
||||
|
||||
function isBranchBuild() {
|
||||
test "${PULL_REQUEST}" = "false"
|
||||
test "${TRAVIS_PULL_REQUEST}" = "false"
|
||||
}
|
||||
|
||||
function cloneRepo() {
|
||||
local REPO="${1}"
|
||||
local TAG_OR_BRANCH="${2}"
|
||||
|
||||
printf "Cloning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
|
||||
printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
|
||||
|
||||
# clone the repository branch/tag
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
|
||||
@@ -82,9 +82,15 @@ function remoteBranchExists() {
|
||||
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}" "${BRANCH_NAME}" ; then
|
||||
echo "${BRANCH_NAME}"
|
||||
if remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}" ; then
|
||||
echo "${TRAVIS_BRANCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
19
scripts/travis/cleanup_cache.sh
Normal file
19
scripts/travis/cleanup_cache.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/acs-community-packaging"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo-*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-core"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-data-model"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-remote-api"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repo-*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repository"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-remote-api"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-repository"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services*"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/content-services-community"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-community-repo-*-test"
|
||||
rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-enterprise-repo-*-test"
|
||||
|
@@ -5,11 +5,17 @@ set -vex
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
# Maven Setup
|
||||
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
|
||||
echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin
|
||||
echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
|
||||
echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin
|
||||
echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io
|
||||
fi
|
||||
|
||||
# not helpful in this script
|
||||
# export HOST_IP=$(hostname -I | cut -f1 -d' ')
|
||||
|
||||
popd
|
||||
set +vex
|
@@ -6,14 +6,14 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
|
||||
# Use full history for release
|
||||
git checkout -B "${BRANCH_NAME}"
|
||||
git checkout -B "${TRAVIS_BRANCH}"
|
||||
# Add email to link commits to user
|
||||
git config user.email "${GIT_EMAIL}"
|
||||
|
||||
# Run the release plugin - with "[skip ci]" in the release commit message
|
||||
mvn -B \
|
||||
-PfullBuild,all-tas-tests \
|
||||
"-Darguments=-PfullBuild,all-tas-tests -DskipTests -Dbuild-number=${BUILD_NUMBER}" \
|
||||
"-Darguments=-PfullBuild,all-tas-tests -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
|
||||
release:clean release:prepare release:perform \
|
||||
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \
|
||||
-Dusername="${GIT_USERNAME}" \
|
48
scripts/travis/trigger_travis.sh
Executable file
48
scripts/travis/trigger_travis.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ev
|
||||
|
||||
USER=${1}
|
||||
REPO=${2}
|
||||
BRANCH=${3}
|
||||
|
||||
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
|
||||
echo "Downstream projects shouldn't be triggered from PR builds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/${USER}/${REPO}.git" "${BRANCH}" ; then
|
||||
echo "Branch \"${BRANCH}\" not found on the downstream repository ${USER}/${REPO}. Exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
URL="https://api.travis-ci.com/repo/${USER}%2F${REPO}/requests"
|
||||
BODY="{
|
||||
\"request\": {
|
||||
\"branch\":\"${BRANCH}\"
|
||||
}}"
|
||||
|
||||
printf "Travis API call:\n URL: %s\n Body: %s\n\n" "${URL}" "${BODY}"
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Travis-API-Version: 3" \
|
||||
-H "Authorization: token ${TRAVIS_ACCESS_TOKEN}" \
|
||||
-d "${BODY}" \
|
||||
"${URL}" \
|
||||
| tee /tmp/travis-request-output.txt
|
||||
|
||||
cat /tmp/travis-request-output.txt
|
||||
|
||||
if grep -q '"@type": "error"' /tmp/travis-request-output.txt; then
|
||||
echo "Error when triggering build..."
|
||||
exit 2
|
||||
fi
|
||||
if grep -q 'access denied' /tmp/travis-request-output.txt; then
|
||||
echo "Access denied when triggering build..."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@@ -6,9 +6,9 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh"
|
||||
|
||||
#Fetch the latest changes, as GHA will only checkout the PR commit
|
||||
git fetch origin "${BRANCH_NAME}"
|
||||
git checkout "${BRANCH_NAME}"
|
||||
#Fetch the latest changes, as Travis will only checkout the PR commit
|
||||
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,11 +33,7 @@ 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")
|
||||
git commit --allow-empty -m "${FORCE_TOKEN} Update upstream version to ${VERSION}"
|
||||
git push
|
||||
elif git status --untracked-files=no --porcelain | grep -q '^' ; then
|
||||
if git status --untracked-files=no --porcelain | grep -q '^' ; then
|
||||
git commit -m "Update upstream version to ${VERSION}"
|
||||
git push
|
||||
else
|
Reference in New Issue
Block a user