mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	Compare commits
	
		
			258 Commits
		
	
	
		
			17.9
			...
			fix/admin-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 53ecbaa74f | ||
|  | bc5aabbf37 | ||
|  | 501d9204a9 | ||
|  | 924005e94e | ||
|  | 3a34c42d2f | ||
|  | 332af85227 | ||
|  | 556c13eba0 | ||
|  | 3caf6bf9f3 | ||
|  | b5fcc5370a | ||
|  | 29007871e8 | ||
|  | 12df503cc2 | ||
|  | e3a9e9c034 | ||
|  | d116cf397b | ||
|  | 271c123a00 | ||
|  | 5bae1ca9b6 | ||
|  | f84c82c6a2 | ||
|  | c639eec1df | ||
|  | d2e561dc95 | ||
|  | 54347fbbee | ||
|  | ab0d482179 | ||
|  | 5fed5292d9 | ||
|  | 1e8944a310 | ||
|  | b97b6751cc | ||
|  | af97aca661 | ||
|  | 368acf4724 | ||
|  | 2341f0290e | ||
|  | 2e4f5d5726 | ||
|  | be118c25ba | ||
|  | 601b743388 | ||
|  | 3c3c3b2666 | ||
|  | b671e17f03 | ||
|  | a08b134ec2 | ||
|  | 9795349f9b | ||
|  | f120ba3a87 | ||
|  | 2285dc1ecb | ||
|  | cbded8f967 | ||
|  | 5e3ee41fce | ||
|  | 6c9163ce65 | ||
|  | 8a79d3bed1 | ||
|  | f1c588f1da | ||
|  | f38902ede9 | ||
|  | 5f1cf5ef60 | ||
|  | 2a41c1f14a | ||
|  | 4f0cbd7206 | ||
|  | 0823d5319c | ||
|  | 001e7a4bff | ||
|  | aba89218e6 | ||
|  | e533af4ecb | ||
|  | 4a7046211b | ||
|  | 48e902c556 | ||
|  | e178428624 | ||
|  | 7b4f7c9174 | ||
|  | d84424ee5b | ||
|  | a4ad5f9211 | ||
|  | 9fbdc61d3c | ||
|  | 7db6d372da | ||
|  | c334f14cd2 | ||
|  | d584b3c1a3 | ||
|  | b06a74c5cb | ||
|  | 5b723e9176 | ||
|  | bf69340e4b | ||
|  | b6aeac0c4e | ||
|  | c1da01ba6e | ||
|  | ecb0d9a329 | ||
|  | c3189adf9f | ||
|  | 8a7b8a7a54 | ||
|  | 3d35eed39c | ||
|  | 37afef846f | ||
|  | 57a3fbd2d5 | ||
|  | 378347ae35 | ||
|  | fc8ec4f993 | ||
|  | bd404080b0 | ||
|  | 54ba3ea998 | ||
|  | 13ee559a29 | ||
|  | 69b6fc4603 | ||
|  | f1dc07be57 | ||
|  | ac9151ed86 | ||
|  | 71080c9c7d | ||
|  | a929982faf | ||
|  | 5e3d5919a0 | ||
|  | 98a3161ef0 | ||
|  | 74bf3146b3 | ||
|  | b272c89791 | ||
|  | 632a86c5b7 | ||
|  | 958d6b771e | ||
|  | b95233b18a | ||
|  | aa4ec88ef2 | ||
|  | 45ecf340f1 | ||
|  | 81830c8ad4 | ||
|  | 37152229fa | ||
|  | 182afc58c4 | ||
|  | bc658bbc57 | ||
|  | 35f81322b1 | ||
|  | 9e0b69bfa4 | ||
|  | 5890e28151 | ||
|  | dfc0c5674c | ||
|  | 271feb71c9 | ||
|  | eadc398748 | ||
|  | 8f2f8cb04c | ||
|  | 7a2d6b71ac | ||
|  | 99a503a1e1 | ||
|  | e60f8fdecc | ||
|  | 3f3698f32a | ||
|  | 366796947f | ||
|  | 84f7726cbd | ||
|  | 06f0f181df | ||
|  | 741aa6948f | ||
|  | 8618e11a33 | ||
|  | 59f414d1b1 | ||
|  | 4b5b61e669 | ||
|  | 50a2707069 | ||
|  | 82605c1d42 | ||
|  | 72d118c23c | ||
|  | 9f7285d13d | ||
|  | 118a55e358 | ||
|  | 2a9265fb30 | ||
|  | 57f02054c4 | ||
|  | 5cb66ebbd0 | ||
|  | f872e2dc9c | ||
|  | b34fdb8f75 | ||
|  | 0a77cca00d | ||
|  | a18ab6fdd1 | ||
|  | d78e61acde | ||
|  | 1508b599cc | ||
|  | 0b7909be40 | ||
|  | 75b9388a12 | ||
|  | 8936db78a5 | ||
|  | c475114030 | ||
|  | 11c4537a53 | ||
|  | e79c2c1792 | ||
|  | b94cb56fa1 | ||
|  | 40f76a9005 | ||
|  | eda63061b8 | ||
|  | b05b51d055 | ||
|  | d6614b900f | ||
|  | 032a3ad73e | ||
|  | d49b261611 | ||
|  | f18a48470b | ||
|  | f87687b632 | ||
|  | f632b1e34b | ||
|  | ed4de81428 | ||
|  | 101eb1843d | ||
|  | 9e7b8fcdce | ||
|  | 6207bfa33c | ||
|  | 6a8102ce81 | ||
|  | 47977a3fae | ||
|  | 4f2fa0bb77 | ||
|  | 43480468af | ||
|  | 92d010842a | ||
|  | a66a13f03b | ||
|  | 473db4f8c3 | ||
|  | bba3f3129e | ||
|  | 34a660e8fa | ||
|  | c1bd3416f0 | ||
|  | 90fea37339 | ||
|  | 14addaee2d | ||
|  | 59fcc1dbd2 | ||
|  | 7ef4f21c02 | ||
|  | fdd9b30854 | ||
|  | 81be6a63e9 | ||
|  | 7d07fcfadd | ||
|  | 56c92c9717 | ||
|  | 8c4a6882f3 | ||
|  | 96d29a1e07 | ||
|  | 6a49f8d82d | ||
|  | 22efbe0fa9 | ||
|  | a5643285eb | ||
|  | 9cd4c1bb3b | ||
|  | 5c9c4f906e | ||
|  | 9f2d3c9df3 | ||
|  | 96f1c9ac7e | ||
|  | f5e9e1cf1b | ||
|  | fdf0e502dc | ||
|  | e0a3307e7b | ||
|  | ad0e08e888 | ||
|  | 12455d37b6 | ||
|  | a575fb2a76 | ||
|  | a3732ce389 | ||
|  | 0f7dc33fe3 | ||
|  | 15cd38cd06 | ||
|  | 818d55c0d5 | ||
|  | 3da0d23bbc | ||
|  | 19ff7d2d8d | ||
|  | 77e18133cc | ||
|  | cc58af56cf | ||
|  | 496cc45f22 | ||
|  | 6d0ecac664 | ||
|  | 7c0f6998ec | ||
|  | cc9fe10c05 | ||
|  | e139a14914 | ||
|  | b73858c3fb | ||
|  | d531e9a9ea | ||
|  | 9ae834956a | ||
|  | 0aedca8365 | ||
|  | 6320621f0d | ||
|  | 69a01309fb | ||
|  | ebb153d8c7 | ||
|  | e7802ec42e | ||
|  | 96e1b1c533 | ||
|  | fc87e136eb | ||
|  | f187aa40b8 | ||
|  | 11860b0439 | ||
|  | da31ad770b | ||
|  | 31f3521952 | ||
|  | d253bb4174 | ||
|  | c6d3313378 | ||
|  | d5069526c6 | ||
|  | 6c9e8eb8f0 | ||
|  | 356f2f6bcb | ||
|  | 29ef840b8a | ||
|  | 90298c3df7 | ||
|  | 7d39fe0be6 | ||
|  | d377ef86f0 | ||
|  | 2fa9a80bcf | ||
|  | da80d4c98c | ||
|  | 6adb6a145b | ||
|  | 597822d18f | ||
|  | 94ecbe7423 | ||
|  | 444fa5f74d | ||
|  | 41bea282a6 | ||
|  | aad4a2a5b8 | ||
|  | 52dfa72da1 | ||
|  | 63a685f6fa | ||
|  | 37caea4946 | ||
|  | 346fa18bc9 | ||
|  | 0846347003 | ||
|  | 4f7fe1db48 | ||
|  | 6f27737d90 | ||
|  | 921a266708 | ||
|  | b3b569cfb7 | ||
|  | 5e5e5b0065 | ||
|  | 1773916bd8 | ||
|  | ba0fd9cec4 | ||
|  | c27130145a | ||
|  | dc59b4ed66 | ||
|  | a42cc36b4e | ||
|  | 4ed61ff6fc | ||
|  | a904122d50 | ||
|  | c92aaf5971 | ||
|  | c1a02281f2 | ||
|  | 78ab42e913 | ||
|  | bf6a2e6bfa | ||
|  | 85920def46 | ||
|  | b88fab188e | ||
|  | 767f513aa5 | ||
|  | b79daf0349 | ||
|  | 657dd5bf7a | ||
|  | 7dff462ac9 | ||
|  | 24c31ee9ab | ||
|  | f1a3aa696e | ||
|  | bf3e7390f5 | ||
|  | b4bf6e0e39 | ||
|  | fa73d88db2 | ||
|  | 9b9874aa48 | ||
|  | d17915227f | ||
|  | c83a9b956e | ||
|  | 7fc2caca5a | ||
|  | 901936410e | 
							
								
								
									
										6
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/dependabot.yml
									
									
									
									
										vendored
									
									
								
							| @@ -158,3 +158,9 @@ updates: | ||||
|     - "8.16" | ||||
|   registries: | ||||
|   - maven-repository-artifacts-alfresco-com-nexus-content-groups-int | ||||
| - package-ecosystem: "docker" | ||||
|   directory: "packaging/docker-alfresco/" | ||||
|   schedule: | ||||
|     interval: "daily" | ||||
|     time: "22:00" | ||||
|     timezone: Africa/Abidjan | ||||
|   | ||||
							
								
								
									
										731
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										731
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| --- | ||||
| dist: focal | ||||
| language: java | ||||
| jdk: openjdk11 | ||||
| jdk: openjdk17 | ||||
|  | ||||
| services: | ||||
|   - docker | ||||
| @@ -51,395 +51,346 @@ jobs: | ||||
|       install: skip | ||||
|       script: travis_retry travis_wait 80 bash scripts/travis/prepare.sh | ||||
|  | ||||
|     - name: "Source Clear Scan (SCA)" | ||||
|       stage: test | ||||
|       if: branch = master OR branch =~ /release\/.*/ | ||||
|       # Run Veracode | ||||
|       install: skip | ||||
|       script: travis_wait 30 bash scripts/travis/source_clear.sh | ||||
|  | ||||
|     - name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       script: | ||||
|         - travis_retry mvn -B test -pl core,data-model -am -DfailIfNoTests=false | ||||
|         - travis_retry mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false | ||||
|  | ||||
|     - name: "Repository - AppContext01TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext01TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext02TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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 -am -Dtest=AppContext02TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext03TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext03TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext04TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext04TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContext05TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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 -am -Dtest=AppContext05TestSuite -DfailIfNoTests=false -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" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext06TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - AppContextExtraTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContextExtraTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - MiscContextTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=MiscContextTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "Repository - SearchTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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 -am -Dtest=SearchTestSuite -DfailIfNoTests=false -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: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - MariaDB 10.4 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - MariaDB 10.5 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - MariaDB 10.6 tests" | ||||
|       # We run tests on the latest version of MariaDB on pull requests plus the normal master and release branches - ignored on feature branches | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       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.6 --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 -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: "Repository - MySQL 5.7.23 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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' --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 -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: "Repository - MySQL 8 tests" | ||||
|       # We run tests on the latest version of MySQL on pull requests plus the normal master and release branches - ignored on feature branches | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - PostgreSQL 10.9 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - PostgreSQL 11.7 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - PostgreSQL 11.12 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:11.12 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 -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: "Repository - PostgreSQL 12.4 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - PostgreSQL 12.7 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:12.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 -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: "Repository - PostgreSQL 13.1 tests" | ||||
|       # We only run DB tests on the latest version of PostgreSQL on feature branches | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       install: skip | ||||
|       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 -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: "Repository - PostgreSQL 13.3 tests" | ||||
|       # We only run DB tests on the latest version of PostgreSQL on feature branches | ||||
|       if: commit_message !~ /\[skip db\]/ OR commit_message =~ /\[latest db\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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 -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: "Repository - Messaging tests" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false | ||||
|  | ||||
|     - name: "Remote-api - AppContext01TestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       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" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       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" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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:${TRANSFORMERS_TAG} | ||||
|       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" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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" | ||||
|       # TAS tests are generally skipped on feature branches as they will be repeated on the enterprise repo or community packaging builds | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Email TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "WebDAV TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Integration TAS tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       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 verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
|  | ||||
|     - name: "Share Services - ShareServicesTestSuite" | ||||
|       if: commit_message !~ /\[skip repo\]/ | ||||
|       install: skip | ||||
|       before_script: | ||||
|         - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 postgres -c 'max_connections=300' | ||||
|       script: travis_wait 20 mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 01 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 02 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 03 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 04 (PostgreSQL)" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 01 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 02 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS        Integration Tests 03 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Unit & Integration Tests 04 (MySQL) " | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
|       script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
|  | ||||
|     - name: "AGS Community Rest API Tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
|       install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
|       addons: | ||||
|         artifacts: | ||||
|           paths: | ||||
|             - ./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports/rm-automation-community-rest-api.log | ||||
|             - alfresco.log | ||||
|             - solr.log | ||||
|           target_paths: community/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NAME} | ||||
|       before_script: | ||||
|         - ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml | ||||
|         - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco" | ||||
|       script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags | ||||
|       after_script: bash amps/ags/travis/scripts/getLogs.sh | ||||
| #    - name: "Source Clear Scan (SCA)" | ||||
| #      stage: test | ||||
| #      if: branch = master OR branch =~ /release\/.*/ | ||||
| #      # Run Veracode | ||||
| #      install: skip | ||||
| #      script: travis_wait 30 bash scripts/travis/source_clear.sh | ||||
| # | ||||
| #    - name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      script: | ||||
| #        - travis_retry mvn -B test -pl core,data-model -am -DfailIfNoTests=false | ||||
| #        - travis_retry mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false | ||||
| # | ||||
| #    - name: "Repository - AppContext01TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext01TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext02TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext02TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext03TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext03TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext04TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext04TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContext05TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - 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 -am -Dtest=AppContext05TestSuite -DfailIfNoTests=false -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" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContext06TestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - AppContextExtraTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=AppContextExtraTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - MiscContextTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=MiscContextTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "Repository - SearchTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=SearchTestSuite -DfailIfNoTests=false -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: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      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.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - MariaDB 10.4 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      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.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - MariaDB 10.5 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      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.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - MariaDB 10.6 tests" | ||||
| #      # We run tests on the latest version of MariaDB on pull requests plus the normal master and release branches - ignored on feature branches | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      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.6 --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.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - MySQL 8 tests" | ||||
| #      # We run tests on the latest version of MySQL on pull requests plus the normal master and release branches - ignored on feature branches | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/                         ) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      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.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - PostgreSQL 13.7 tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.7 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - PostgreSQL 14.4 tests" | ||||
| #      # We only run DB tests on the latest version of PostgreSQL on feature branches | ||||
| #      if: commit_message !~ /\[skip db\]/ OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 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: "Repository - Messaging tests" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      script: travis_wait 20 mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false | ||||
| # | ||||
| #    - name: "Remote-api - AppContext01TestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      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" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      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" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      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" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #        - docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG} | ||||
| #      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" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #        - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 | ||||
| #      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" | ||||
| #      # TAS tests are generally skipped on feature branches as they will be repeated on the enterprise repo or community packaging builds | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -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 =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Email TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "WebDAV TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Integration TAS tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip tas\]/) OR commit_message =~ /\[tas\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      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 verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false | ||||
| # | ||||
| #    - name: "Share Services - ShareServicesTestSuite" | ||||
| #      if: commit_message !~ /\[skip repo\]/ | ||||
| #      install: skip | ||||
| #      before_script: | ||||
| #        - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:14.4 postgres -c 'max_connections=300' | ||||
| #      script: travis_wait 20 mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 01 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 02 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 03 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 04 (PostgreSQL)" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 01 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 02 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS        Integration Tests 03 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Unit & Integration Tests 04 (MySQL) " | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_INSTALLED_ARTIFACTS=true bash scripts/travis/build.sh | ||||
| #      script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql    -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} | ||||
| # | ||||
| #    - name: "AGS Community Rest API Tests" | ||||
| #      if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ | ||||
| #      install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh | ||||
| #      addons: | ||||
| #        artifacts: | ||||
| #          paths: | ||||
| #            - ./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports/rm-automation-community-rest-api.log | ||||
| #            - alfresco.log | ||||
| #            - solr.log | ||||
| #          target_paths: community/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NAME} | ||||
| #      before_script: | ||||
| #        - ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml | ||||
| #        - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco" | ||||
| #      script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags | ||||
| #      after_script: bash amps/ags/travis/scripts/getLogs.sh | ||||
|  | ||||
|     - name: "Push to Nexus" | ||||
|       stage: release | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
| @@ -30,16 +30,20 @@ | ||||
|             <plugin> | ||||
|                <artifactId>maven-surefire-plugin</artifactId> | ||||
|                <configuration> | ||||
|                   <!-- Keeping illegal-access=permit for Java 11 compatibility, even though it has no effect on JDK 17 --> | ||||
|                   <argLine> | ||||
|                      --illegal-access=permit | ||||
|                      --add-opens=java.base/java.lang=ALL-UNNAMED | ||||
|                   </argLine> | ||||
|                </configuration> | ||||
|             </plugin> | ||||
|             <plugin> | ||||
|                <artifactId>maven-failsafe-plugin</artifactId> | ||||
|                <!-- Keeping illegal-access=permit for Java 11 compatibility, even though it has no effect on JDK 17 --> | ||||
|                <configuration> | ||||
|                   <argLine> | ||||
|                      --illegal-access=permit | ||||
|                      --add-opens=java.base/java.lang=ALL-UNNAMED | ||||
|                   </argLine> | ||||
|                </configuration> | ||||
|             </plugin> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-automation-community-repo</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <build> | ||||
| @@ -87,7 +87,7 @@ | ||||
|       <dependency> | ||||
|          <groupId>com.github.docker-java</groupId> | ||||
|          <artifactId>docker-java</artifactId> | ||||
|          <version>3.2.12</version> | ||||
|          <version>3.2.13</version> | ||||
|       </dependency> | ||||
|    </dependencies> | ||||
| </project> | ||||
|   | ||||
| @@ -161,7 +161,7 @@ public class BaseRMRestTest extends RestTest | ||||
|      */ | ||||
|     @Override | ||||
|     @BeforeClass (alwaysRun = true) | ||||
|     public void checkServerHealth() throws Exception | ||||
|     public void checkServerHealth() | ||||
|     { | ||||
|         // Create RM Site if not exist | ||||
|         createRMSiteIfNotExists(); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -1,3 +1,3 @@ | ||||
| SOLR6_TAG=2.0.3 | ||||
| POSTGRES_TAG=13.3 | ||||
| ACTIVEMQ_TAG=5.16.1 | ||||
| POSTGRES_TAG=14.4 | ||||
| ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8 | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <properties> | ||||
| @@ -434,7 +434,7 @@ | ||||
|                            </run> | ||||
|                         </image> | ||||
|                         <image> | ||||
|                            <name>alfresco/alfresco-activemq:${dependency.activemq.version}</name> | ||||
|                            <name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre11-rockylinux8</name> | ||||
|                            <run> | ||||
|                               <ports> | ||||
|                                  <port>${activemq.port1}:${activemq.port1}</port> | ||||
| @@ -505,7 +505,7 @@ | ||||
|                            </run> | ||||
|                         </image> | ||||
|                         <image> | ||||
|                            <name>alfresco/alfresco-activemq:${dependency.activemq.version}</name> | ||||
|                            <name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre11-rockylinux8</name> | ||||
|                            <run> | ||||
|                               <ports> | ||||
|                                  <port>${activemq.port1}:${activemq.port1}</port> | ||||
|   | ||||
| @@ -156,25 +156,24 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl | ||||
|      * @see org.alfresco.repo.rule.RuleServiceImpl#saveRule(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule) | ||||
|      */ | ||||
|     @Override | ||||
|     public void saveRule(final NodeRef nodeRef, final Rule rule) | ||||
|     public Rule saveRule(final NodeRef nodeRef, final Rule rule) | ||||
|     { | ||||
|         validateWormLockRuleAction(rule); | ||||
|         if (filePlanService.isFilePlanComponent(nodeRef)) | ||||
|         { | ||||
|             AuthenticationUtil.runAsSystem(new RunAsWork<Void>() | ||||
|             return AuthenticationUtil.runAsSystem(new RunAsWork<Rule>() | ||||
|             { | ||||
|                 @Override | ||||
|                 public Void doWork() | ||||
|                 public Rule doWork() | ||||
|                 { | ||||
|                     ExtendedRuleServiceImpl.super.saveRule(nodeRef, rule); | ||||
|                     return null; | ||||
|                     return ExtendedRuleServiceImpl.super.saveRule(nodeRef, rule); | ||||
|                 } | ||||
|  | ||||
|             }); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             super.saveRule(nodeRef, rule); | ||||
|             return super.saveRule(nodeRef, rule); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -82,13 +82,7 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             public void given() | ||||
|             { | ||||
|                 filePlan = createFilePlan(); | ||||
|                  | ||||
|                 // create a rule that applies to childre | ||||
|                 Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|                 rule = new Rule(); | ||||
|                 rule.setRuleType("inbound"); | ||||
|                 rule.setAction(completeRecordAction); | ||||
|                 rule.applyToChildren(true); | ||||
|                 rule = createRuleThatAppliesToChildren(); | ||||
|             } | ||||
|  | ||||
|             public void when() | ||||
| @@ -127,13 +121,7 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             public void given() | ||||
|             { | ||||
|                 filePlan = createFilePlan(); | ||||
|                  | ||||
|                 // create a rule that applies to childre | ||||
|                 Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|                 rule = new Rule(); | ||||
|                 rule.setRuleType("inbound"); | ||||
|                 rule.setAction(completeRecordAction); | ||||
|                 rule.applyToChildren(true); | ||||
|                 rule = createRuleThatAppliesToChildren(); | ||||
|             } | ||||
|  | ||||
|             public void when() | ||||
| @@ -171,13 +159,7 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             public void given() | ||||
|             { | ||||
|                 filePlan = createFilePlan(); | ||||
|                  | ||||
|                 // create a rule that applies to childre | ||||
|                 Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|                 rule = new Rule(); | ||||
|                 rule.setRuleType("inbound"); | ||||
|                 rule.setAction(completeRecordAction); | ||||
|                 rule.applyToChildren(true); | ||||
|                 rule = createRuleThatAppliesToChildren(); | ||||
|             } | ||||
|  | ||||
|             public void when() | ||||
| @@ -215,13 +197,7 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             public void given() | ||||
|             { | ||||
|                 filePlan = createFilePlan(); | ||||
|                  | ||||
|                 // create a rule that applies to childre | ||||
|                 Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|                 rule = new Rule(); | ||||
|                 rule.setRuleType("inbound"); | ||||
|                 rule.setAction(completeRecordAction); | ||||
|                 rule.applyToChildren(true); | ||||
|                 rule = createRuleThatAppliesToChildren(); | ||||
|             } | ||||
|  | ||||
|             public void when() | ||||
| @@ -261,13 +237,7 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             { | ||||
|                 filePlan = createFilePlan(); | ||||
|                 recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate()); | ||||
|                  | ||||
|                 // create a rule that applies to childre | ||||
|                 Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|                 rule = new Rule(); | ||||
|                 rule.setRuleType("inbound"); | ||||
|                 rule.setAction(completeRecordAction); | ||||
|                 rule.applyToChildren(true); | ||||
|                 rule = createRuleThatAppliesToChildren(); | ||||
|             } | ||||
|  | ||||
|             public void when() | ||||
| @@ -286,4 +256,15 @@ public class FilePlanRuleInheritanceTest extends BaseRMTestCase | ||||
|             } | ||||
|         });  | ||||
|     } | ||||
|  | ||||
|     private Rule createRuleThatAppliesToChildren() | ||||
|     { | ||||
|         Action completeRecordAction = actionService.createAction(DeclareRecordAction.NAME); | ||||
|         Rule rule = new Rule(); | ||||
|         rule.setRuleType("inbound"); | ||||
|         rule.setTitle("Rule name"); | ||||
|         rule.setAction(completeRecordAction); | ||||
|         rule.applyToChildren(true); | ||||
|         return rule; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -168,6 +168,7 @@ | ||||
|       <property name="nodeService" ref="NodeService"/> | ||||
|       <property name="ruleService" ref="RuleService"/> | ||||
|       <property name="actionService" ref="ActionService"/> | ||||
|       <property name="runtimeActionService" ref="actionService"/> | ||||
|       <property name="dictionaryService" ref="DictionaryService"/> | ||||
|       <property name="fileFolderService" ref="FileFolderService"/> | ||||
|       <property name="namespaceService" ref="NamespaceService" /> | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.action.impl; | ||||
|  | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
|  | ||||
| import org.alfresco.error.AlfrescoRuntimeException; | ||||
| import org.alfresco.module.org_alfresco_module_rm.action.BaseActionUnitTest; | ||||
| @@ -86,7 +86,7 @@ public class FileReportActionUnitTest extends BaseActionUnitTest | ||||
|         fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); | ||||
|  | ||||
|         // == then == | ||||
|         verifyZeroInteractions(mockedReportService, mockedNodeService); | ||||
|         verifyNoInteractions(mockedReportService, mockedNodeService); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -110,6 +110,6 @@ public class FileReportActionUnitTest extends BaseActionUnitTest | ||||
|         fileReportAction.executeImpl(getMockedAction(), actionedUponNodeRef); | ||||
|  | ||||
|         // == then == | ||||
|         verifyZeroInteractions(mockedReportService, mockedNodeService); | ||||
|         verifyNoInteractions(mockedReportService, mockedNodeService); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -28,7 +28,7 @@ | ||||
| package org.alfresco.module.org_alfresco_module_rm.action.impl; | ||||
|  | ||||
| import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateText; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.never; | ||||
|   | ||||
| @@ -38,8 +38,8 @@ import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagement | ||||
| import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME; | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.bootstrap; | ||||
|  | ||||
| import static org.mockito.Matchers.anyString; | ||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -28,8 +28,8 @@ | ||||
| package org.alfresco.module.org_alfresco_module_rm.capability; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
|   | ||||
| @@ -29,9 +29,9 @@ package org.alfresco.module.org_alfresco_module_rm.capability.declarative.condit | ||||
|  | ||||
| import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.anyBoolean; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyBoolean; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.times; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ package org.alfresco.module.org_alfresco_module_rm.content; | ||||
|  | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
| import static org.mockito.Mockito.when; | ||||
|  | ||||
| import java.io.File; | ||||
| @@ -125,6 +125,6 @@ public class EagerContentStoreCleanerUnitTest extends BaseUnitTest | ||||
|          | ||||
|         eagerContentStoreCleaner.deleteFromStore(AlfMock.generateText(), mock(ContentStore.class)); | ||||
|          | ||||
|         verifyZeroInteractions(mockedContentCleanser); | ||||
|         verifyNoInteractions(mockedContentCleanser); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -35,9 +35,9 @@ import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertNull; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.anyString; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.doAnswer; | ||||
| import static org.mockito.Mockito.doNothing; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
|   | ||||
| @@ -31,7 +31,7 @@ import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
|  | ||||
| import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; | ||||
| import org.junit.Test; | ||||
| @@ -73,7 +73,7 @@ public class DictionaryBootstrapPostProcessorUnitTest extends BaseUnitTest | ||||
|         // === then === | ||||
|         verify(mockedBeanFactory, times(1)).containsBean(BEAN_SITESERVICE_BOOTSTRAP); | ||||
|         verifyNoMoreInteractions(mockedBeanFactory); | ||||
|         verifyZeroInteractions(mockedBeanDefinition); | ||||
|         verifyNoInteractions(mockedBeanDefinition); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect; | ||||
|  | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -26,8 +26,8 @@ | ||||
|  */ | ||||
| package org.alfresco.module.org_alfresco_module_rm.model.rma.type; | ||||
|  | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -27,8 +27,8 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.patch.v22; | ||||
|  | ||||
| import static org.mockito.Matchers.anyString; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.HashSet; | ||||
| @@ -72,7 +72,7 @@ public class RMv22RemoveInPlaceRolesFromAllPatchUnitTest extends BaseUnitTest | ||||
|         patch.applyInternal(); | ||||
|          | ||||
|         // then | ||||
|         verifyZeroInteractions(mockedAuthorityService); | ||||
|         verifyNoInteractions(mockedAuthorityService); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -30,8 +30,8 @@ package org.alfresco.module.org_alfresco_module_rm.patch.v23; | ||||
| import static java.util.Arrays.asList; | ||||
| import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_SAVED_SEARCH; | ||||
| import static org.alfresco.module.org_alfresco_module_rm.model.rma.type.RmSiteType.DEFAULT_SITE_NAME; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.anyMap; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyMap; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -29,7 +29,7 @@ package org.alfresco.module.org_alfresco_module_rm.patch.v24; | ||||
|  | ||||
| import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateNodeRef; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
| import static org.mockito.Mockito.when; | ||||
|  | ||||
| import java.util.Collections; | ||||
| @@ -81,7 +81,7 @@ public class RMv24FilePlanContainerRuleInheritancePatchUnitTest | ||||
|         patch.applyInternal(); | ||||
|          | ||||
|         // then | ||||
|         verifyZeroInteractions(mockedNodeService); | ||||
|         verifyNoInteractions(mockedNodeService); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|   | ||||
| @@ -27,8 +27,8 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.patch.v32; | ||||
|  | ||||
| import static org.mockito.Matchers.anyMap; | ||||
| import static org.mockito.Matchers.anyObject; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyMap; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
| @@ -92,8 +92,8 @@ public class RMv32HoldReportUpdatePatchUnitTest | ||||
|  | ||||
|         patch.applyInternal(); | ||||
|         verify(mockedNodeService, times(1)).addAspect(hold_report, ContentModel.ASPECT_VERSIONABLE, null); | ||||
|         verify(mockedVersionService, times(1)).createVersion((NodeRef) anyObject(), anyMap()); | ||||
|         verify(mockedContentWriter, times(1)).putContent((InputStream) anyObject()); | ||||
|         verify(mockedVersionService, times(1)).createVersion((NodeRef) any(), anyMap()); | ||||
|         verify(mockedContentWriter, times(1)).putContent((InputStream) any()); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -28,7 +28,7 @@ | ||||
| package org.alfresco.module.org_alfresco_module_rm.patch.v33; | ||||
|  | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -33,13 +33,13 @@ import static java.util.Collections.emptyList; | ||||
| import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; | ||||
| import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASSOC_FROZEN_CONTENT; | ||||
| import static org.alfresco.module.org_alfresco_module_rm.patch.v35.RMv35HoldNewChildAssocPatch.PATCH_ASSOC_NAME; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.anyMap; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.anyMap; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.verifyZeroInteractions; | ||||
| import static org.mockito.Mockito.verifyNoInteractions; | ||||
| import static org.mockito.Mockito.when; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
|   | ||||
| @@ -32,7 +32,7 @@ import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.gener | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.doNothing; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.mock; | ||||
|   | ||||
| @@ -28,7 +28,7 @@ | ||||
| package org.alfresco.module.org_alfresco_module_rm.script.hold; | ||||
|  | ||||
| import static org.alfresco.module.org_alfresco_module_rm.test.util.WebScriptExceptionMatcher.badRequest; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.when; | ||||
|  | ||||
| import java.util.Collections; | ||||
|   | ||||
| @@ -30,8 +30,8 @@ package org.alfresco.module.org_alfresco_module_rm.test.util; | ||||
| import static java.util.Collections.emptyMap; | ||||
|  | ||||
| import static org.mockito.ArgumentMatchers.nullable; | ||||
| import static org.mockito.Matchers.anyString; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.doAnswer; | ||||
| import static org.mockito.Mockito.doReturn; | ||||
| import static org.mockito.Mockito.lenient; | ||||
|   | ||||
| @@ -28,7 +28,7 @@ package org.alfresco.module.org_alfresco_module_rm.util; | ||||
|  | ||||
| import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.times; | ||||
| import static org.mockito.Mockito.verify; | ||||
| import static org.mockito.Mockito.when; | ||||
|   | ||||
| @@ -27,8 +27,8 @@ | ||||
|  | ||||
| package org.alfresco.module.org_alfresco_module_rm.version; | ||||
|  | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.Matchers.eq; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.ArgumentMatchers.eq; | ||||
| import static org.mockito.Mockito.doAnswer; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.times; | ||||
|   | ||||
| @@ -30,7 +30,7 @@ package org.alfresco.rm.rest.api.sites; | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertNotNull; | ||||
| import static org.junit.Assert.fail; | ||||
| import static org.mockito.Matchers.any; | ||||
| import static org.mockito.ArgumentMatchers.any; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.never; | ||||
| import static org.mockito.Mockito.times; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <build> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -176,7 +176,6 @@ public class NodeBrowserScript extends NodeBrowserPost implements Serializable | ||||
| 			{ | ||||
| 				status.setCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); | ||||
| 				status.setMessage(e.getMessage()); | ||||
| 				status.setException(e); | ||||
| 				status.setRedirect(true); | ||||
| 			} | ||||
|     		return tmplMap; | ||||
|   | ||||
| @@ -40,6 +40,7 @@ import org.json.JSONObject; | ||||
| import org.junit.Assert; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.Response; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.ArrayList; | ||||
| @@ -194,13 +195,13 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content"); | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content"); | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         // uri with relative path at the end | ||||
|         String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2"; | ||||
| @@ -212,7 +213,50 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content) | ||||
|     public void testForcedAttachment() throws Exception | ||||
|     { | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef testhtml = createNodeWithTextContent(rootFolder, "testhtml", ContentModel.TYPE_CONTENT, "testhtml content", MimetypeMap.MIMETYPE_HTML); | ||||
|         NodeRef testpdf = createNodeWithTextContent(rootFolder, "testpdf", ContentModel.TYPE_CONTENT, "testpdf content", MimetypeMap.MIMETYPE_PDF); | ||||
|  | ||||
|         String uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=false"; | ||||
|         GetRequest req = new GetRequest(uri); | ||||
|         Response res = sendRequest(req, 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=false"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content, String mimetype) | ||||
|     { | ||||
|         NodeRef nodeRef = createNode(parentNode, nodeCmName, nodeType); | ||||
|  | ||||
| @@ -220,7 +264,7 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         if (content != null) | ||||
|         { | ||||
|             ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); | ||||
|             writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|             writer.setMimetype(mimetype); | ||||
|             writer.setEncoding("UTF-8"); | ||||
|             writer.putContent(content); | ||||
|         } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo</artifactId> | ||||
|       <version>17.9</version> | ||||
|       <version>17.75-SNAPSHOT</version> | ||||
|    </parent> | ||||
|  | ||||
|    <dependencies> | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * Copyright (C) 2005-2011 Alfresco Software Limited. | ||||
|  * Copyright (C) 2005-2022 Alfresco Software Limited. | ||||
|  * | ||||
|  * This file is part of Alfresco | ||||
|  * | ||||
| @@ -16,6 +16,7 @@ | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.query; | ||||
|  | ||||
| import java.util.Collections; | ||||
| @@ -55,7 +56,7 @@ public class ListBackedPagingResults<R> implements PagingResults<R> | ||||
|         } | ||||
|          | ||||
|         this.results = Collections.unmodifiableList( | ||||
|                 list.subList(start, end)); | ||||
|                 list.subList(Math.min(start, end), end)); | ||||
|         this.size = list.size(); | ||||
|         this.hasMore = ! (list.size() == end); | ||||
|     } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
| @@ -134,7 +134,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>com.fasterxml.woodstox</groupId> | ||||
|             <artifactId>woodstox-core</artifactId> | ||||
|             <version>6.2.7</version> | ||||
|             <version>6.3.0</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <!-- the cxf libs were updated, see dependencyManagement section --> | ||||
|   | ||||
| @@ -146,7 +146,7 @@ public interface NamespaceService extends NamespacePrefixResolver | ||||
|  | ||||
|     /** Email Server Application Model Prefix */ | ||||
|     static final String EMAILSERVER_MODEL_PREFIX = "emailserver"; | ||||
|      | ||||
|  | ||||
|     /** | ||||
|      * Register a prefix for namespace uri.  | ||||
|      *  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Data model classes | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -25,7 +25,7 @@ | ||||
|  */ | ||||
| package org.alfresco.repo.dictionary; | ||||
|  | ||||
| import static org.mockito.Matchers.anyString; | ||||
| import static org.mockito.ArgumentMatchers.anyString; | ||||
| import static org.mockito.Mockito.mock; | ||||
| import static org.mockito.Mockito.when; | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
|   | ||||
| @@ -9,6 +9,6 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
| </project> | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| # Fetch image based on Tomcat 9.0, Java 11 and Centos 7 | ||||
| # Fetch image based on Tomcat 9.0, Java 17 and Rocky Linux 8 | ||||
| # More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat | ||||
| FROM alfresco/alfresco-base-tomcat:tomcat9-jre11-centos7-202203091924 | ||||
| FROM alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8-202205140719 | ||||
|  | ||||
| # 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-4.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>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -1,3 +1,3 @@ | ||||
| SOLR6_TAG=2.0.3 | ||||
| POSTGRES_TAG=13.3 | ||||
| ACTIVEMQ_TAG=5.16.1 | ||||
| POSTGRES_TAG=14.4 | ||||
| ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8 | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
| @@ -106,8 +106,10 @@ | ||||
|                     <suiteXmlFiles> | ||||
|                         <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> | ||||
|                     </suiteXmlFiles> | ||||
|                     <!-- Keeping illegal-access=warn for Java 11 compatibility, even though it has no effect on JDK 17 --> | ||||
|                     <argLine> | ||||
|                         --illegal-access=warn | ||||
|                         --add-opens=java.base/java.lang=ALL-UNNAMED | ||||
|                     </argLine> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
| @@ -78,8 +78,10 @@ | ||||
|                     <suiteXmlFiles> | ||||
|                         <suiteXmlFile>${suiteXmlFile}</suiteXmlFile> | ||||
|                     </suiteXmlFiles> | ||||
|                     <!-- Keeping illegal-access=warn for Java 11 compatibility, even though it has no effect on JDK 17 --> | ||||
|                     <argLine> | ||||
|                         --illegal-access=warn | ||||
|                         --add-opens=java.base/java.lang=ALL-UNNAMED | ||||
|                     </argLine> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|   | ||||
| @@ -0,0 +1,102 @@ | ||||
| package org.alfresco.rest.actions.access; | ||||
|  | ||||
| import com.google.gson.Gson; | ||||
| import org.alfresco.rest.actions.access.pojo.Action; | ||||
| import org.alfresco.rest.actions.access.pojo.ActionCondition; | ||||
| import org.alfresco.rest.actions.access.pojo.Rule; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class AccessRestrictionUtil { | ||||
|  | ||||
|     public static final String MAIL_ACTION = "mail"; | ||||
|  | ||||
|     public static final String ERROR_MESSAGE_FIELD = "message"; | ||||
|     public static final String ERROR_MESSAGE_ACCESS_RESTRICTED = | ||||
|             "Only admin or system user is allowed to define uses of or directly execute this action"; | ||||
|     private static final String ERROR_MESSAGE_FAILED_TO_SEND_EMAIL = "Failed to send email to:"; | ||||
|  | ||||
|     public static Map<String, String> createMailParameters(UserModel sender, UserModel recipient) { | ||||
|         Map<String, String> parameterValues = new HashMap<>(); | ||||
|         parameterValues.put("from", sender.getEmailAddress()); | ||||
|         parameterValues.put("to", recipient.getEmailAddress()); | ||||
|         parameterValues.put("subject", "Test"); | ||||
|         parameterValues.put("text", "<html>content</html>"); | ||||
|  | ||||
|         return parameterValues; | ||||
|     } | ||||
|  | ||||
|     public static Rule createRuleWithAction(String actionName, Map<String, String> parameterValues) { | ||||
|         Rule rule = new Rule(); | ||||
|         rule.setId(""); | ||||
|         rule.setTitle("Test rule title"); | ||||
|         rule.setDescription("Test rule description"); | ||||
|         rule.setRuleType(List.of("inbound")); | ||||
|         rule.setDisabled(false); | ||||
|         rule.setApplyToChildren(false); | ||||
|         rule.setExecuteAsynchronously(false); | ||||
|  | ||||
|         Action compositeAction = new Action(); | ||||
|         compositeAction.setActionDefinitionName("composite-action"); | ||||
|  | ||||
|         ActionCondition actionCondition = new ActionCondition(); | ||||
|         actionCondition.setConditionDefinitionName("no-condition"); | ||||
|         actionCondition.setParameterValues(new HashMap<>()); | ||||
|  | ||||
|         compositeAction.setConditions(List.of(actionCondition)); | ||||
|  | ||||
|         Action action = createAction(actionName, parameterValues); | ||||
|  | ||||
|         compositeAction.setActions(List.of(action)); | ||||
|  | ||||
|         rule.setAction(compositeAction); | ||||
|  | ||||
|         return rule; | ||||
|     } | ||||
|  | ||||
|     public static Action createActionWithParameters(String actionName, Map<String, String> parameterValues) { | ||||
|         Action compositeAction = new Action(); | ||||
|         compositeAction.setActionDefinitionName("composite-action"); | ||||
|  | ||||
|         ActionCondition actionCondition = new ActionCondition(); | ||||
|         actionCondition.setConditionDefinitionName("no-condition"); | ||||
|         actionCondition.setParameterValues(new HashMap<>()); | ||||
|  | ||||
|         compositeAction.setConditions(List.of(actionCondition)); | ||||
|  | ||||
|         Action action = createAction(actionName, parameterValues); | ||||
|         action.setExecuteAsynchronously(false); | ||||
|  | ||||
|         compositeAction.setActions(List.of(action)); | ||||
|  | ||||
|         return action; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public static Action createAction(String actionName, Map<String, String> parameterValues) { | ||||
|         Action action = new Action(); | ||||
|         action.setActionDefinitionName(actionName); | ||||
|         action.setParameterValues(parameterValues); | ||||
|  | ||||
|         return action; | ||||
|     } | ||||
|  | ||||
|     public static String mapObjectToJSON(Object object) { | ||||
|         Gson gson = new Gson(); | ||||
|         return gson.toJson(object); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Return error message that in fact means that the action has passed access restriction correctly, | ||||
|      * but due to non-configured smtp couldn't send email. | ||||
|      * | ||||
|      * @param userModel | ||||
|      * @return | ||||
|      */ | ||||
|     public static String getExpectedEmailSendFailureMessage(UserModel userModel) { | ||||
|         return ERROR_MESSAGE_FAILED_TO_SEND_EMAIL + userModel.getEmailAddress(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,84 @@ | ||||
| package org.alfresco.rest.actions.access; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.core.RestRequest; | ||||
| import org.alfresco.rest.core.RestResponse; | ||||
| import org.alfresco.rest.core.RestWrapper; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.json.simple.JSONObject; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.HttpMethod; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.BeforeMethod; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_FIELD; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.getExpectedEmailSendFailureMessage; | ||||
| import static org.hamcrest.Matchers.containsString; | ||||
|  | ||||
| public class FormProcAdminAccessRestrictionTest extends RestTest { | ||||
|  | ||||
|     private static final String ACTION_FORM_PROCESSOR_ENDPOINT = "alfresco/service/api/action/%s/formprocessor"; | ||||
|  | ||||
|     private static final String PROPERTY_PREFIX = "prop_"; | ||||
|  | ||||
|     private UserModel adminUser; | ||||
|     private UserModel testUser; | ||||
|  | ||||
|     @Autowired | ||||
|     protected RestWrapper restClient; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() throws Exception { | ||||
|         adminUser = dataUser.getAdminUser(); | ||||
|         testUser = dataUser.createRandomTestUser(); | ||||
|     } | ||||
|  | ||||
|     @BeforeMethod(alwaysRun=true) | ||||
|     public void setup() { | ||||
|         restClient.configureRequestSpec() | ||||
|                 .setBasePath("") | ||||
|                 .addHeader("Content-Type", "application/json"); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void userShouldNotCreateAMailForm() { | ||||
|         restClient.authenticateUser(testUser); | ||||
|  | ||||
|         String body = generateBody(createMailParameters(adminUser, testUser)); | ||||
|         String endpoint = String.format(ACTION_FORM_PROCESSOR_ENDPOINT, MAIL_ACTION); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, body, endpoint); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body(ERROR_MESSAGE_FIELD, containsString(ERROR_MESSAGE_ACCESS_RESTRICTED)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void adminShouldCreateAMailForm() { | ||||
|         restClient.authenticateUser(adminUser); | ||||
|  | ||||
|         String body = generateBody(createMailParameters(adminUser, testUser)); | ||||
|         String endpoint = String.format(ACTION_FORM_PROCESSOR_ENDPOINT, MAIL_ACTION); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, body, endpoint); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body(ERROR_MESSAGE_FIELD, containsString(getExpectedEmailSendFailureMessage(testUser))); | ||||
|     } | ||||
|  | ||||
|     private String generateBody(Map<String, String> mailParameters) { | ||||
|         JSONObject json = new JSONObject(); | ||||
|         mailParameters.forEach((key, value) -> json.put(PROPERTY_PREFIX + key, value)); | ||||
|  | ||||
|         return json.toJSONString(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,102 @@ | ||||
| package org.alfresco.rest.actions.access; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.actions.access.pojo.Rule; | ||||
| import org.alfresco.rest.core.RestRequest; | ||||
| import org.alfresco.rest.core.RestResponse; | ||||
| import org.alfresco.rest.core.RestWrapper; | ||||
| import org.alfresco.utility.model.FileModel; | ||||
| import org.alfresco.utility.model.FileType; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.HttpMethod; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.BeforeMethod; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_FIELD; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createRuleWithAction; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.mapObjectToJSON; | ||||
| import static org.hamcrest.Matchers.containsString; | ||||
|  | ||||
| public class RuleAdminAccessRestrictionTest extends RestTest { | ||||
|  | ||||
|     private static final String CREATE_RULE_ENDPOINT = "alfresco/service/api/node/workspace/SpacesStore/%s/ruleset/rules"; | ||||
|  | ||||
|     private UserModel adminUser; | ||||
|     private UserModel testUser; | ||||
|     private FolderModel testFolder; | ||||
|  | ||||
|     @Autowired | ||||
|     protected RestWrapper restClient; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() throws Exception { | ||||
|         adminUser = dataUser.getAdminUser(); | ||||
|  | ||||
|         testUser = dataUser.createRandomTestUser(); | ||||
|         testSite = dataSite.usingUser(testUser) | ||||
|                 .createPublicRandomSite(); | ||||
|         testFolder = dataContent.usingUser(testUser) | ||||
|                 .usingSite(testSite) | ||||
|                 .createFolder(); | ||||
|     } | ||||
|  | ||||
|     @BeforeMethod(alwaysRun=true) | ||||
|     public void setup() { | ||||
|         restClient.configureRequestSpec().setBasePath(""); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void userShouldNotBeAbleToCreateANewRule() { | ||||
|         restClient.authenticateUser(testUser); | ||||
|  | ||||
|         Rule rule = createRuleWithAction(MAIL_ACTION, createMailParameters(adminUser, testUser)); | ||||
|         String ruleRequestBody = mapObjectToJSON(rule); | ||||
|         String ruleEndpoint = String.format(CREATE_RULE_ENDPOINT, testFolder.getNodeRef()); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, ruleRequestBody, ruleEndpoint); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body(ERROR_MESSAGE_FIELD, containsString(ERROR_MESSAGE_ACCESS_RESTRICTED)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void adminShouldBeAbleToCreateANewRule() { | ||||
|         restClient.authenticateUser(adminUser); | ||||
|  | ||||
|         Rule rule = createRuleWithAction(MAIL_ACTION, createMailParameters(adminUser, testUser)); | ||||
|         String ruleRequestBody = mapObjectToJSON(rule); | ||||
|         String ruleEndpoint = String.format(CREATE_RULE_ENDPOINT, testFolder.getNodeRef()); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, ruleRequestBody, ruleEndpoint); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.OK.value()); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void userShouldAddAFileToFolderWithMailRule() { | ||||
|         restClient.authenticateUser(adminUser); | ||||
|  | ||||
|         Rule rule = createRuleWithAction(MAIL_ACTION, createMailParameters(adminUser, testUser)); | ||||
|         String ruleRequestBody = mapObjectToJSON(rule); | ||||
|         String ruleEndpoint = String.format(CREATE_RULE_ENDPOINT, testFolder.getNodeRef()); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, ruleRequestBody, ruleEndpoint); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.OK.value()); | ||||
|  | ||||
|         dataContent.usingUser(testUser) | ||||
|                 .usingSite(testSite) | ||||
|                 .usingResource(testFolder) | ||||
|                 .createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN)); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,76 @@ | ||||
| package org.alfresco.rest.actions.access; | ||||
|  | ||||
| import org.alfresco.rest.actions.access.pojo.Action; | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.core.RestRequest; | ||||
| import org.alfresco.rest.core.RestResponse; | ||||
| import org.alfresco.rest.core.RestWrapper; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.HttpMethod; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.BeforeMethod; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_FIELD; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createActionWithParameters; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.getExpectedEmailSendFailureMessage; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.mapObjectToJSON; | ||||
| import static org.hamcrest.Matchers.containsString; | ||||
|  | ||||
| public class V0AdminAccessRestrictionTest extends RestTest { | ||||
|  | ||||
|     private static final String ACTION_QUEUE_ENDPOINT = "alfresco/service/api/actionQueue?async=false"; | ||||
|  | ||||
|     private UserModel adminUser; | ||||
|     private UserModel testUser; | ||||
|  | ||||
|     @Autowired | ||||
|     protected RestWrapper restClient; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() throws Exception { | ||||
|         adminUser = dataUser.getAdminUser(); | ||||
|  | ||||
|         testUser = dataUser.createRandomTestUser(); | ||||
|         testSite = dataSite.usingUser(testUser) | ||||
|                 .createPublicRandomSite(); | ||||
|     } | ||||
|  | ||||
|     @BeforeMethod(alwaysRun=true) | ||||
|     public void setup() { | ||||
|         restClient.configureRequestSpec().setBasePath(""); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void userShouldNotExecuteMailActionQueue() { | ||||
|         restClient.authenticateUser(testUser); | ||||
|  | ||||
|         Action action = createActionWithParameters(MAIL_ACTION, createMailParameters(adminUser, testUser)); | ||||
|         String actionRequestBody = mapObjectToJSON(action); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, actionRequestBody, ACTION_QUEUE_ENDPOINT); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body(ERROR_MESSAGE_FIELD, containsString(ERROR_MESSAGE_ACCESS_RESTRICTED)); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void adminShouldExecuteMailActionQueue() { | ||||
|         restClient.authenticateUser(adminUser); | ||||
|  | ||||
|         Action action = createActionWithParameters(MAIL_ACTION, createMailParameters(adminUser, testUser)); | ||||
|         String actionRequestBody = mapObjectToJSON(action); | ||||
|  | ||||
|         RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, actionRequestBody, ACTION_QUEUE_ENDPOINT); | ||||
|         RestResponse response = restClient.process(request); | ||||
|  | ||||
|         response.assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body(ERROR_MESSAGE_FIELD, containsString(getExpectedEmailSendFailureMessage(testUser))); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,64 @@ | ||||
| package org.alfresco.rest.actions.access; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| import org.alfresco.rest.core.RestWrapper; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION; | ||||
| import static org.alfresco.rest.actions.access.AccessRestrictionUtil.createMailParameters; | ||||
| import static org.hamcrest.Matchers.notNullValue; | ||||
| import static org.hamcrest.Matchers.nullValue; | ||||
|  | ||||
| public class V1AdminAccessRestrictionTest extends RestTest { | ||||
|  | ||||
|     private UserModel adminUser; | ||||
|     private UserModel testUser; | ||||
|     private FolderModel testFolder; | ||||
|  | ||||
|     @Autowired | ||||
|     protected RestWrapper restClient; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() throws Exception { | ||||
|         adminUser = dataUser.getAdminUser(); | ||||
|  | ||||
|         testUser = dataUser.createRandomTestUser(); | ||||
|         testSite = dataSite.usingUser(testUser) | ||||
|                            .createPublicRandomSite(); | ||||
|         testFolder = dataContent.usingUser(testUser) | ||||
|                                 .usingSite(testSite) | ||||
|                                 .createFolder(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void userShouldNotExecuteMailAction() throws Exception { | ||||
|         restClient.authenticateUser(testUser) | ||||
|                           .withCoreAPI() | ||||
|                           .usingActions() | ||||
|                           .executeAction(MAIL_ACTION, testFolder, createMailParameters(adminUser, testUser)); | ||||
|  | ||||
|         restClient.onResponse() | ||||
|                 .assertThat().statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||||
|                 .assertThat().body("entry.id", nullValue()); | ||||
|         restClient.assertLastError().containsSummary(ERROR_MESSAGE_ACCESS_RESTRICTED); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void adminShouldExecuteMailAction() throws Exception { | ||||
|         restClient.authenticateUser(adminUser) | ||||
|                           .withCoreAPI() | ||||
|                           .usingActions() | ||||
|                           .executeAction(MAIL_ACTION, testFolder, createMailParameters(adminUser, testUser)); | ||||
|  | ||||
|         restClient.onResponse() | ||||
|                 .assertThat().statusCode(HttpStatus.ACCEPTED.value()) | ||||
|                 .assertThat().body("entry.id", notNullValue()); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,57 @@ | ||||
| package org.alfresco.rest.actions.access.pojo; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| public class Action { | ||||
|     private String actionDefinitionName; | ||||
|     private String actionedUponNode; | ||||
|     private List<ActionCondition> conditions; | ||||
|     private List<Action> actions; | ||||
|     private Map<String, String> parameterValues; | ||||
|  | ||||
|     private boolean executeAsynchronously; | ||||
|  | ||||
|     public void setExecuteAsynchronously(boolean executeAsynchronously) { | ||||
|         this.executeAsynchronously = executeAsynchronously; | ||||
|     } | ||||
|     public String getActionDefinitionName() { | ||||
|         return actionDefinitionName; | ||||
|     } | ||||
|  | ||||
|     public void setActionDefinitionName(String actionDefinitionName) { | ||||
|         this.actionDefinitionName = actionDefinitionName; | ||||
|     } | ||||
|  | ||||
|     public String getActionedUponNode() { | ||||
|         return actionedUponNode; | ||||
|     } | ||||
|  | ||||
|     public void setActionedUponNode(String actionedUponNode) { | ||||
|         this.actionedUponNode = actionedUponNode; | ||||
|     } | ||||
|  | ||||
|     public List<ActionCondition> getConditions() { | ||||
|         return conditions; | ||||
|     } | ||||
|  | ||||
|     public void setConditions(List<ActionCondition> conditions) { | ||||
|         this.conditions = conditions; | ||||
|     } | ||||
|  | ||||
|     public List<Action> getActions() { | ||||
|         return actions; | ||||
|     } | ||||
|  | ||||
|     public void setActions(List<Action> actions) { | ||||
|         this.actions = actions; | ||||
|     } | ||||
|  | ||||
|     public Map<String, String> getParameterValues() { | ||||
|         return parameterValues; | ||||
|     } | ||||
|  | ||||
|     public void setParameterValues(Map<String, String> parameterValues) { | ||||
|         this.parameterValues = parameterValues; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,24 @@ | ||||
| package org.alfresco.rest.actions.access.pojo; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| public class ActionCondition { | ||||
|     private String conditionDefinitionName; | ||||
|     private Map<String, String> parameterValues; | ||||
|  | ||||
|     public String getConditionDefinitionName() { | ||||
|         return conditionDefinitionName; | ||||
|     } | ||||
|  | ||||
|     public void setConditionDefinitionName(String conditionDefinitionName) { | ||||
|         this.conditionDefinitionName = conditionDefinitionName; | ||||
|     } | ||||
|  | ||||
|     public Map<String, String> getParameterValues() { | ||||
|         return parameterValues; | ||||
|     } | ||||
|  | ||||
|     public void setParameterValues(Map<String, String> parameterValues) { | ||||
|         this.parameterValues = parameterValues; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,78 @@ | ||||
| package org.alfresco.rest.actions.access.pojo; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| public class Rule { | ||||
|     private String id; | ||||
|     private String title; | ||||
|     private String description; | ||||
|     private List<String> ruleType; | ||||
|     private boolean executeAsynchronously; | ||||
|     private boolean disabled; | ||||
|     private boolean applyToChildren; | ||||
|     private Action action; | ||||
|  | ||||
|     public String getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public void setId(String id) { | ||||
|         this.id = id; | ||||
|     } | ||||
|  | ||||
|     public String getTitle() { | ||||
|         return title; | ||||
|     } | ||||
|  | ||||
|     public void setTitle(String title) { | ||||
|         this.title = title; | ||||
|     } | ||||
|  | ||||
|     public String getDescription() { | ||||
|         return description; | ||||
|     } | ||||
|  | ||||
|     public void setDescription(String description) { | ||||
|         this.description = description; | ||||
|     } | ||||
|  | ||||
|     public List<String> getRuleType() { | ||||
|         return ruleType; | ||||
|     } | ||||
|  | ||||
|     public void setRuleType(List<String> ruleType) { | ||||
|         this.ruleType = ruleType; | ||||
|     } | ||||
|  | ||||
|     public boolean isExecuteAsynchronously() { | ||||
|         return executeAsynchronously; | ||||
|     } | ||||
|  | ||||
|     public void setExecuteAsynchronously(boolean executeAsynchronously) { | ||||
|         this.executeAsynchronously = executeAsynchronously; | ||||
|     } | ||||
|  | ||||
|     public boolean isDisabled() { | ||||
|         return disabled; | ||||
|     } | ||||
|  | ||||
|     public void setDisabled(boolean disabled) { | ||||
|         this.disabled = disabled; | ||||
|     } | ||||
|  | ||||
|     public boolean isApplyToChildren() { | ||||
|         return applyToChildren; | ||||
|     } | ||||
|  | ||||
|     public void setApplyToChildren(boolean applyToChildren) { | ||||
|         this.applyToChildren = applyToChildren; | ||||
|     } | ||||
|  | ||||
|     public Action getAction() { | ||||
|         return action; | ||||
|     } | ||||
|  | ||||
|     public void setAction(Action action) { | ||||
|         this.action = action; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,268 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createActionModel; | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.constants.UserRole.*; | ||||
| import static org.alfresco.utility.model.FileModel.getRandomFileModel; | ||||
| import static org.alfresco.utility.model.FileType.TEXT_PLAIN; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.junit.Assert.assertEquals; | ||||
| import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||||
| import static org.springframework.http.HttpStatus.CREATED; | ||||
| import static org.springframework.http.HttpStatus.FORBIDDEN; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.stream.IntStream; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.utility.constants.UserRole; | ||||
| import org.alfresco.utility.model.FileModel; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| import org.alfresco.utility.model.TestGroup; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for POST /nodes/{nodeId}/rule-sets/{ruleSetId}/rules. | ||||
|  */ | ||||
| @Test(groups = {TestGroup.RULES}) | ||||
| public class CreateRulesTests extends RestTest | ||||
| { | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|     private FolderModel ruleFolder; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|         ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|     } | ||||
|  | ||||
|     /** Check we can create a rule. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void createRule() | ||||
|     { | ||||
|         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||
|  | ||||
|         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                        .createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(CREATED); | ||||
|         rule.assertThat().field("id").isNotNull() | ||||
|             .assertThat().field("name").is("ruleName"); | ||||
|     } | ||||
|  | ||||
|     /** Check creating a rule in a non-existent folder returns an error. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void createRuleInNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to create a rule in non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|  | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|         restClient.assertLastError().containsSummary("fake-id was not found"); | ||||
|     } | ||||
|  | ||||
|     /** Check creating a rule in a non-existent rule set returns an error. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void createRuleInNonExistentRuleSet() | ||||
|     { | ||||
|         STEP("Try to create a rule in non-existent rule set."); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet("fake-id").createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|         restClient.assertLastError().containsSummary("fake-id was not found"); | ||||
|     } | ||||
|  | ||||
|     /** Try to create a rule without a name and check the error. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void createRuleWithEmptyName() | ||||
|     { | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName(""); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(BAD_REQUEST); | ||||
|         restClient.assertLastError().containsSummary("Rule name is a mandatory parameter"); | ||||
|     } | ||||
|  | ||||
|     /** Check we can create two rules with the same name. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void duplicateRuleNameIsAcceptable() | ||||
|     { | ||||
|         RestRuleModel ruleModel = createRuleModel("duplicateRuleName"); | ||||
|  | ||||
|         STEP("Create two identical rules"); | ||||
|         RestRuleModel ruleA = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|         RestRuleModel ruleB = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         // Check that the names are the same but the ids are different. | ||||
|         ruleA.assertThat().field("name").is(ruleB.getName()); | ||||
|         ruleA.assertThat().field("id").isNot(ruleB.getId()); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user without permission to view the folder cannot create a rule in it. */ | ||||
|     public void requireReadPermissionToCreateRule() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder"); | ||||
|         UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|  | ||||
|         STEP("Try to use a different user to create a rule in the private folder"); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a Collaborator cannot create a rule in a private folder. */ | ||||
|     public void siteCollaboratorCannotCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteCollaborator); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a Contributor cannot create a rule in a private folder. */ | ||||
|     public void siteContributorCannotCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteContributor); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a Consumer cannot create a rule in a private folder. */ | ||||
|     public void siteConsumerCannotCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteConsumer); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a siteManager can create a rule in a private folder. */ | ||||
|     public void siteManagerCanCreateRule() | ||||
|     { | ||||
|         testRolePermissionsWith(SiteManager) | ||||
|                 .assertThat().field("id").isNotNull() | ||||
|                 .assertThat().field("name").is("testRule"); | ||||
|         restClient.assertStatusCodeIs(CREATED); | ||||
|     } | ||||
|  | ||||
|     /** Check we can't create a rule under a document node. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void tryToCreateRuleUnderDocument() | ||||
|     { | ||||
|         STEP("Create a document."); | ||||
|         FileModel fileModel = dataContent.usingUser(user).usingSite(site).createContent(getRandomFileModel(TEXT_PLAIN)); | ||||
|  | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(fileModel).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(BAD_REQUEST); | ||||
|         restClient.assertLastError().containsSummary("folder is expected"); | ||||
|     } | ||||
|  | ||||
|     /** Check we can create several rules. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void createRules() | ||||
|     { | ||||
|         STEP("Create a list of rules in one POST request"); | ||||
|         List<String> ruleNames = List.of("ruleA", "ruleB", "ruleC"); | ||||
|         List<RestRuleModel> ruleModels = ruleNames.stream().map(RulesTestsUtils::createRuleModel).collect(toList()); | ||||
|  | ||||
|         RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                                    .createListOfRules(ruleModels); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(CREATED); | ||||
|  | ||||
|         assertEquals("Unexpected number of rules received in response.", ruleNames.size(), rules.getEntries().size()); | ||||
|         IntStream.range(0, ruleModels.size()).forEach(i -> | ||||
|                 rules.getEntries().get(i).onModel() | ||||
|                     .assertThat().field("id").isNotNull() | ||||
|                     .assertThat().field("name").is(ruleNames.get(i))); | ||||
|     } | ||||
|  | ||||
|     /** Try to create several rules with an error in one of them. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void createRulesWithOneError() | ||||
|     { | ||||
|         STEP("Try to create a three rules but the middle one has an error."); | ||||
|         RestRuleModel ruleA = createRuleModel("ruleA"); | ||||
|         RestRuleModel ruleB = new RestRuleModel(); | ||||
|         // Don't set a name for Rule B. | ||||
|         RestRuleModel ruleC = createRuleModel("ruleC"); | ||||
|         List<RestRuleModel> ruleModels = List.of(ruleA, ruleB, ruleC); | ||||
|  | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createListOfRules(ruleModels); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(BAD_REQUEST); | ||||
|         restClient.assertLastError().containsSummary("Rule name is a mandatory parameter"); | ||||
|     } | ||||
|  | ||||
|     public RestRuleModel testRolePermissionsWith(UserRole userRole) | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder"); | ||||
|         SiteModel privateSite = dataSite.usingUser(user).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(user).usingSite(privateSite).createFolder(); | ||||
|  | ||||
|         STEP(String.format("Add a user with '%s' role in the private site's folder", userRole.toString())); | ||||
|         UserModel userWithRole = dataUser.createRandomTestUser(); | ||||
|         dataUser.addUserToSite(userWithRole, privateSite, userRole); | ||||
|         RestRuleModel ruleModel = createRuleModel("testRule", List.of(createActionModel())); | ||||
|  | ||||
|         return restClient.authenticateUser(userWithRole).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,254 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteContributor; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteManager; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.springframework.http.HttpStatus.FORBIDDEN; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
| import static org.springframework.http.HttpStatus.NO_CONTENT; | ||||
| import static org.springframework.http.HttpStatus.OK; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
| import java.util.stream.Collectors; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| import org.alfresco.utility.model.TestGroup; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.junit.Assert; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for DELETE /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}. | ||||
|  */ | ||||
| @Test(groups = {TestGroup.RULES}) | ||||
| public class DeleteRulesTests extends RestTest | ||||
| { | ||||
|     private static final String FAKE_NODE_REF = "fake-node-id"; | ||||
|  | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         STEP("Create a Contributor user and a public site"); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         user.setUserRole(SiteContributor); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Delete previously created rule by its id (as Contributor). | ||||
|      */ | ||||
|     @Test(groups = {TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY}) | ||||
|     public void deleteSingleRuleAndGet204() | ||||
|     { | ||||
|         STEP("Create a few rules in the folder"); | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         final List<RestRuleModel> createdRules = Stream.of("ruleA", "ruleB", "ruleC") | ||||
|                 .map(ruleName -> { | ||||
|                     RestRuleModel ruleModel = createRuleModel(ruleName); | ||||
|                     return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                             .createSingleRule(ruleModel); | ||||
|                 }) | ||||
|                 .collect(toList()); | ||||
|  | ||||
|         STEP("Attempt delete one rule"); | ||||
|         final RestRuleModel ruleA = createdRules.get(0); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(ruleA.getId()); | ||||
|         restClient.assertStatusCodeIs(NO_CONTENT); | ||||
|  | ||||
|         STEP("Get and check the rules from the folder after deleting one of them"); | ||||
|         final RestRuleModelsCollection rulesAfterDeletion = | ||||
|                 restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules(); | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         rulesAfterDeletion.assertThat().entriesListCountIs(createdRules.size() - 1); | ||||
|         Assert.assertTrue(rulesAfterDeletion.getEntries() | ||||
|                 .stream() | ||||
|                 .noneMatch(r -> r.onModel().getId().equals(ruleA.getId())) | ||||
|         ); | ||||
|         final Set<String> ruleIdsThatShouldBeLeft = createdRules.stream() | ||||
|                 .filter(r -> !r.getName().equals("ruleA")) | ||||
|                 .map(RestRuleModel::getId) | ||||
|                 .collect(Collectors.toSet()); | ||||
|         final Set<String> ruleIdsAfterDeletion = rulesAfterDeletion.getEntries().stream() | ||||
|                 .map(r -> r.onModel().getId()) | ||||
|                 .collect(Collectors.toSet()); | ||||
|         Assert.assertEquals(ruleIdsThatShouldBeLeft, ruleIdsAfterDeletion); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Try to delete a rule in a non-existing folder and get 404. | ||||
|      */ | ||||
|     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||
|     public void deleteRuleInNonExistingFolderAndGet404() | ||||
|     { | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         final RestRuleModel testRule = createRule(ruleFolder); | ||||
|  | ||||
|         STEP("Create a non-existing folder model"); | ||||
|         final FolderModel nonExistingFolder = new FolderModel(); | ||||
|         nonExistingFolder.setNodeRef(FAKE_NODE_REF); | ||||
|  | ||||
|         STEP("Attempt delete the rule in non-existing folder"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistingFolder).usingDefaultRuleSet().deleteRule(testRule.getId()); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Try to delete a rule in a non-existing rule set and get 404. | ||||
|      */ | ||||
|     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||
|     public void deleteRuleInNonExistingRuleSetAndGet404() | ||||
|     { | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         final RestRuleModel testRule = createRule(ruleFolder); | ||||
|  | ||||
|         STEP("Attempt delete the rule in non-existing rule set"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet(FAKE_NODE_REF).deleteRule(testRule.getId()); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Try to delete a non-existing rule and get 404. | ||||
|      */ | ||||
|     @Test(groups = {TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY}) | ||||
|     public void deleteNonExistingRuleAndGet404() | ||||
|     { | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         STEP("Attempt delete non-existing rule"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(FAKE_NODE_REF); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Try to delete an existing rule passing a wrong but existing folder and get 404. | ||||
|      */ | ||||
|     @Test(groups = {TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY}) | ||||
|     public void deleteExistingRuleFromWrongFolderAndGet404() | ||||
|     { | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         final RestRuleModel testRule = createRule(ruleFolder); | ||||
|  | ||||
|         STEP("Create a second folder in the site"); | ||||
|         final FolderModel anotherFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Attempt delete an existing rule from a wrong but existing (second) folder"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(anotherFolder).usingDefaultRuleSet().deleteRule(testRule.getId()); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Check that a user without write permission on folder cannot delete a rule inside it. | ||||
|      */ | ||||
|     public void deleteSinglePrivateRuleWithoutPermissionAndGet403() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder with a rule"); | ||||
|         final UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         final SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|         final RestRuleModel ruleModel = createRuleModel("Private site rule"); | ||||
|         final RestRuleModel createdRule = | ||||
|                 restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet() | ||||
|                         .createSingleRule(ruleModel); | ||||
|  | ||||
|         STEP("Try to delete the rule with another user"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().deleteRule(createdRule.getId()); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(FORBIDDEN); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Check that a user with SiteCollaborator permissions on folder can delete a rule inside it. | ||||
|      */ | ||||
|     public void deleteSinglePublicRuleAsCollaboratorAndGet403() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder with a rule"); | ||||
|         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         final RestRuleModel testRule = createRule(ruleFolder); | ||||
|  | ||||
|         STEP("Create a manager in the private site"); | ||||
|         final UserModel siteCollaborator = dataUser.createRandomTestUser(); | ||||
|         siteCollaborator.setUserRole(SiteCollaborator); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingSite(site).addPerson(siteCollaborator); | ||||
|  | ||||
|         STEP("Check the manager can delete the rule"); | ||||
|         restClient.authenticateUser(siteCollaborator).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                 .deleteRule(testRule.getId()); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(FORBIDDEN); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Check that a user with SiteManager permissions on folder can delete a rule inside it. | ||||
|      */ | ||||
|     public void deleteSinglePrivateRuleAsSiteManagerAndGet204() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder with a rule"); | ||||
|         final UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         final SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|         final RestRuleModel ruleModel = createRuleModel("Private site rule"); | ||||
|         final RestRuleModel createdRule = | ||||
|                 restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet() | ||||
|                         .createSingleRule(ruleModel); | ||||
|  | ||||
|         STEP("Create a manager in the private site"); | ||||
|         final UserModel siteManager = dataUser.createRandomTestUser(); | ||||
|         siteManager.setUserRole(SiteManager); | ||||
|         restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(siteManager); | ||||
|  | ||||
|         STEP("Check the manager can delete the rule"); | ||||
|         restClient.authenticateUser(siteManager).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet() | ||||
|                 .deleteRule(createdRule.getId()); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(NO_CONTENT); | ||||
|     } | ||||
|  | ||||
|     private RestRuleModel createRule(FolderModel ruleFolder) | ||||
|     { | ||||
|         STEP("Create a rule in the folder"); | ||||
|         final RestRuleModel ruleModel = createRuleModel("Test rule"); | ||||
|         return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,161 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
| import static org.springframework.http.HttpStatus.OK; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.rest.model.RestRuleSetModel; | ||||
| import org.alfresco.rest.model.RestRuleSetModelsCollection; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| import org.alfresco.utility.model.TestGroup; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for GET /nodes/{nodeId}/rule-sets and /nodes/{nodeId}/rule-sets/{ruleSetId}. | ||||
|  */ | ||||
| @Test (groups = { TestGroup.RULES }) | ||||
| public class GetRuleSetsTests extends RestTest | ||||
| { | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|     private FolderModel ruleFolder; | ||||
|     private RestRuleModel rule; | ||||
|  | ||||
|     @BeforeClass (alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         STEP("Create a user, site and folder."); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|         ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Create a rule in the folder."); | ||||
|         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||
|         rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                        .createSingleRule(ruleModel); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get an empty list of rule sets. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getEmptyRuleSetsList() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Get the rule sets for the folder"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() | ||||
|                                                          .usingNode(folder).getListOfRuleSets(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         assertTrue("Expected no rule sets to be present.", ruleSets.isEmpty()); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a list of rule sets. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetsList() | ||||
|     { | ||||
|         STEP("Get the rule sets for the folder"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getListOfRuleSets(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSets.assertThat().entriesListCountIs(1); | ||||
|         ruleSets.getEntries().get(0).onModel() | ||||
|                 .assertThat().field("id").isNotNull(); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load rule sets for a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getRuleSetsForNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load rule sets for a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getListOfRuleSets(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a rule set by its id. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetById() | ||||
|     { | ||||
|         STEP("Get the rule sets for the folder and find the rule set id"); | ||||
|         RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getListOfRuleSets(); | ||||
|         ruleSets.assertThat().entriesListCountIs(1); | ||||
|         String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); | ||||
|  | ||||
|         STEP("Get the rule set using its rule set id"); | ||||
|         RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                              .getRuleSet(ruleSetId); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSet.assertThat().field("id").is(ruleSetId); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a rule set using the "-default-" synonym. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getDefaultRuleSetById() | ||||
|     { | ||||
|         STEP("Get the default rule set for the folder"); | ||||
|         RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||
|                                                          .getDefaultRuleSet(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         ruleSet.assertThat().field("id").isNotNull(); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load the default rule set for a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getDefaultRuleSetForNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load a rule set for a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getDefaultRuleSet(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we get 404 for a non-existing rule set id. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRuleSetByNonExistingId() | ||||
|     { | ||||
|         STEP("Get the rule set using fake rule set id"); | ||||
|         String ruleSetId = "fake-rule-set-id"; | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).getRuleSet(ruleSetId); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,217 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.junit.Assert.assertTrue; | ||||
| import static org.springframework.http.HttpStatus.FORBIDDEN; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
| import static org.springframework.http.HttpStatus.OK; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.stream.IntStream; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.rest.model.RestRuleModelsCollection; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| import org.alfresco.utility.model.TestGroup; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules and GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}. | ||||
|  */ | ||||
| @Test(groups = {TestGroup.RULES}) | ||||
| public class GetRulesTests extends RestTest | ||||
| { | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|     private FolderModel ruleFolder; | ||||
|     private List<RestRuleModel> createdRules; | ||||
|     private RestRuleModel createdRuleA; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         STEP("Create a user, site and folder"); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|         ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Create rules in the folder"); | ||||
|         createdRules = Stream.of("ruleA", "ruleB").map(ruleName -> { | ||||
|             RestRuleModel ruleModel = createRuleModel(ruleName); | ||||
|             return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|         }).collect(toList()); | ||||
|         createdRuleA = createdRules.get(0); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get an empty list of rules. */ | ||||
|     @Test(groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getEmptyRulesList() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|  | ||||
|         STEP("Get the rules that apply to the folder"); | ||||
|         RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getListOfRules(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|         assertTrue("Expected no rules to be present.", rules.isEmpty()); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get all the rules for a folder. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getRulesList() | ||||
|     { | ||||
|         STEP("Get the rules that apply to the folder"); | ||||
|         RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         rules.assertThat().entriesListCountIs(createdRules.size()); | ||||
|         IntStream.range(0, createdRules.size()).forEach(i -> | ||||
|                 rules.getEntries().get(i).onModel() | ||||
|                          .assertThat().field("id").is(createdRules.get(i).getId()) | ||||
|                          .assertThat().field("name").is(createdRules.get(i).getName())); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load rules for a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getRulesForNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load rules for a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load rules with a rule set id that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getRulesFromNonExistentRuleSet() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         STEP("Try to load rules for a non-existent rule set."); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getListOfRules(); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we can get a rule by its id. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void getSingleRule() | ||||
|     { | ||||
|         STEP("Load a particular rule"); | ||||
|         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId()); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|  | ||||
|         rule.assertThat().field("id").is(createdRuleA.getId()) | ||||
|             .assertThat().field("name").is(createdRuleA.getName()); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load a rule from a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getSingleRuleFromNonExistentFolder() | ||||
|     { | ||||
|         STEP("Try to load a rule from a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getSingleRule("fake-rule-id"); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load a rule with a rule set id that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getSingleRuleFromNonExistentRuleSet() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         STEP("Try to load rules for a non-existent rule set."); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getSingleRule("fake-rule-id"); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to load an existing rule providing a wrong but existing folder */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void getSingleRuleFromWrongFolder() | ||||
|     { | ||||
|         STEP("Create a folder in existing site"); | ||||
|         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|         STEP("Try to load a rule for a wrong but existing folder."); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId()); | ||||
|         restClient.assertStatusCodeIs(NOT_FOUND); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user without read permission cannot view the folder rules. */ | ||||
|     public void requireReadPermissionToGetRule() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder with a rule"); | ||||
|         UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("Private site rule"); | ||||
|         restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         STEP("Try to get the rule with another user"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules(); | ||||
|  | ||||
|         restClient.assertLastError() | ||||
|                   .statusCodeIs(FORBIDDEN) | ||||
|                   .containsSummary("Cannot read from this node"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user with only read permission can view the folder rules. */ | ||||
|     public void dontRequireWritePermissionToGetRule() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder with a rule"); | ||||
|         UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|         RestRuleModel ruleModel = createRuleModel("Private site rule"); | ||||
|         restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         STEP("Create a collaborator in the private site"); | ||||
|         UserModel collaborator = dataUser.createRandomTestUser(); | ||||
|         collaborator.setUserRole(SiteCollaborator); | ||||
|         restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(collaborator); | ||||
|  | ||||
|         STEP("Check the collaborator can view the rule"); | ||||
|         RestRuleModelsCollection rules = restClient.authenticateUser(collaborator).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules(); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         rules.assertThat().entriesListContains("name", "Private site rule"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,68 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.alfresco.rest.model.RestActionBodyExecTemplateModel; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
|  | ||||
| public class RulesTestsUtils | ||||
| { | ||||
|  | ||||
|     public static RestRuleModel createRuleModel(String name) { | ||||
|         return createRuleModel(name, List.of(createActionModel())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Create a rule model. | ||||
|      * | ||||
|      * @param name The name for the rule. | ||||
|      * @param restActionModels Rule's actions. | ||||
|      * @return The created rule model. | ||||
|      */ | ||||
|     public static RestRuleModel createRuleModel(String name, List<RestActionBodyExecTemplateModel> restActionModels) | ||||
|     { | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName(name); | ||||
|         ruleModel.setActions(restActionModels); | ||||
|         return ruleModel; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Create a rule's action model. | ||||
|      * | ||||
|      * @return The created action model. | ||||
|      */ | ||||
|     public static RestActionBodyExecTemplateModel createActionModel() | ||||
|     { | ||||
|         RestActionBodyExecTemplateModel restActionModel = new RestActionBodyExecTemplateModel(); | ||||
|         restActionModel.setActionDefinitionId("add-features"); | ||||
|         restActionModel.setParams(Map.of("aspect-name", "{http://www.alfresco.org/model/audio/1.0}audio", "actionContext", "rule")); | ||||
|         return restActionModel; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,201 @@ | ||||
| /* | ||||
|  * #%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.rest.rules; | ||||
|  | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createActionModel; | ||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||
| import static org.alfresco.utility.report.log.Step.STEP; | ||||
| import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||||
| import static org.springframework.http.HttpStatus.FORBIDDEN; | ||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||
| import static org.springframework.http.HttpStatus.OK; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.alfresco.rest.RestTest; | ||||
| import org.alfresco.rest.model.RestActionBodyExecTemplateModel; | ||||
| import org.alfresco.rest.model.RestRuleModel; | ||||
| import org.alfresco.utility.model.FolderModel; | ||||
| import org.alfresco.utility.model.SiteModel; | ||||
| import org.alfresco.utility.model.TestGroup; | ||||
| import org.alfresco.utility.model.UserModel; | ||||
| import org.testng.annotations.BeforeClass; | ||||
| import org.testng.annotations.Test; | ||||
|  | ||||
| /** | ||||
|  * Tests for PUT /nodes/{nodeId}/rule-sets/{ruleSetId}/rules. | ||||
|  */ | ||||
| @Test (groups = { TestGroup.RULES }) | ||||
| public class UpdateRulesTests extends RestTest | ||||
| { | ||||
|     private UserModel user; | ||||
|     private SiteModel site; | ||||
|     private FolderModel ruleFolder; | ||||
|  | ||||
|     @BeforeClass (alwaysRun = true) | ||||
|     public void dataPreparation() | ||||
|     { | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||
|         ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||
|     } | ||||
|  | ||||
|     /** Check we can update a rule. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||
|     public void updateRule() | ||||
|     { | ||||
|         RestRuleModel rule = createAndSaveRule("Rule name"); | ||||
|  | ||||
|         STEP("Try to update the rule."); | ||||
|         RestRuleModel updatedRuleModel = createRuleModel("Updated rule name"); | ||||
|         RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                        .updateRule(rule.getId(), updatedRuleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(OK); | ||||
|         updatedRule.assertThat().field("id").is(rule.getId()) | ||||
|                    .assertThat().field("name").is("Updated rule name"); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to update a rule in a folder that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void updateRuleForNonExistentFolder() | ||||
|     { | ||||
|         RestRuleModel rule = createAndSaveRule("Rule name"); | ||||
|  | ||||
|         STEP("Try to update a rule in a non-existent folder."); | ||||
|         FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); | ||||
|         nonExistentFolder.setNodeRef("fake-id"); | ||||
|  | ||||
|         RestRuleModel updatedRuleModel = new RestRuleModel(); | ||||
|         updatedRuleModel.setName("Updated rule name"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet() | ||||
|                   .updateRule(rule.getId(), updatedRuleModel); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND) | ||||
|                                     .containsSummary("fake-id was not found"); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to update a rule in a rule set that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void updateRuleForNonExistentRuleSet() | ||||
|     { | ||||
|         RestRuleModel rule = createAndSaveRule("Rule name"); | ||||
|  | ||||
|         STEP("Try to update a rule in a non-existent rule set."); | ||||
|         RestRuleModel updatedRuleModel = new RestRuleModel(); | ||||
|         updatedRuleModel.setName("Updated rule name"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet("fake-id") | ||||
|                   .updateRule(rule.getId(), updatedRuleModel); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND) | ||||
|                   .containsSummary("fake-id was not found"); | ||||
|     } | ||||
|  | ||||
|     /** Check we get a 404 if trying to update a rule that doesn't exist. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void updateRuleForNonExistentRuleId() | ||||
|     { | ||||
|         STEP("Try to update a rule that doesn't exist."); | ||||
|         RestRuleModel updatedRuleModel = new RestRuleModel(); | ||||
|         updatedRuleModel.setName("Updated rule name"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                   .updateRule("fake-id", updatedRuleModel); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(NOT_FOUND) | ||||
|                   .containsSummary("fake-id was not found"); | ||||
|     } | ||||
|  | ||||
|     /** Check that a user without permission cannot update a rule. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void requirePermissionToUpdateRule() | ||||
|     { | ||||
|         STEP("Create a user and use them to create a private site containing a folder"); | ||||
|         UserModel privateUser = dataUser.createRandomTestUser(); | ||||
|         SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); | ||||
|         FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); | ||||
|  | ||||
|         STEP("Create a collaborator and check they don't have permission to create a rule"); | ||||
|         UserModel collaborator = dataUser.createRandomTestUser(); | ||||
|         dataUser.addUserToSite(collaborator, privateSite, SiteCollaborator); | ||||
|         RestRuleModel ruleModel = new RestRuleModel(); | ||||
|         ruleModel.setName("ruleName"); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel); | ||||
|  | ||||
|         restClient.assertStatusCodeIs(FORBIDDEN); | ||||
|         restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); | ||||
|     } | ||||
|  | ||||
|     /** Check we get an error trying to update a rule to have no name. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void updateRuleToHaveEmptyName() | ||||
|     { | ||||
|         RestRuleModel rule = createAndSaveRule("Rule name"); | ||||
|  | ||||
|         STEP("Try to update the rule to have no name."); | ||||
|         RestRuleModel updatedRuleModel = new RestRuleModel(); | ||||
|         updatedRuleModel.setName(""); | ||||
|         restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().updateRule(rule.getId(), updatedRuleModel); | ||||
|  | ||||
|         restClient.assertLastError().statusCodeIs(BAD_REQUEST) | ||||
|                                     .containsSummary("Rule name is a mandatory parameter"); | ||||
|     } | ||||
|  | ||||
|     /** Check that updates to the rule's id are ignored. */ | ||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||
|     public void tryToUpdateRuleId() | ||||
|     { | ||||
|         RestRuleModel rule = createAndSaveRule("Rule name"); | ||||
|  | ||||
|         STEP("Try to update the rule id and check it isn't changed."); | ||||
|         RestRuleModel updatedRuleModel = createRuleModel("Rule name"); | ||||
|         updatedRuleModel.setId("new-rule-id"); | ||||
|         RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|                                               .updateRule(rule.getId(), updatedRuleModel); | ||||
|  | ||||
|         updatedRule.assertThat().field("id").is(rule.getId()); | ||||
|     } | ||||
|  | ||||
|     private RestRuleModel createAndSaveRule(String name) | ||||
|     { | ||||
|         return createAndSaveRule(name, List.of(createActionModel())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Create a rule for folder and store it. | ||||
|      * | ||||
|      * @param name The name for the rule. | ||||
|      * @param restActionModels Rule's actions. | ||||
|      * @return The created rule. | ||||
|      */ | ||||
|     private RestRuleModel createAndSaveRule(String name, List<RestActionBodyExecTemplateModel> restActionModels) | ||||
|     { | ||||
|         STEP("Create a rule called " + name + ", containing actions: " + restActionModels); | ||||
|         RestRuleModel ruleModel = createRuleModel(name, restActionModels); | ||||
|         return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||
|             .createSingleRule(ruleModel); | ||||
|     } | ||||
| } | ||||
| @@ -16,7 +16,7 @@ import org.testng.annotations.Test; | ||||
|  */ | ||||
| public class GetProcessSanityTests extends RestTest | ||||
| { | ||||
|     private UserModel userWhoStartsProcess, assignee; | ||||
|     private UserModel userWhoStartsProcess, assignee, user; | ||||
|     private RestProcessModel addedProcess, process; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
| @@ -24,6 +24,7 @@ public class GetProcessSanityTests extends RestTest | ||||
|     { | ||||
|         userWhoStartsProcess = dataUser.createRandomTestUser(); | ||||
|         assignee = dataUser.createRandomTestUser(); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); | ||||
|     } | ||||
|  | ||||
| @@ -59,4 +60,13 @@ public class GetProcessSanityTests extends RestTest | ||||
|         process.assertThat().field("id").is(addedProcess.getId()) | ||||
|                 .and().field("startUserId").is(addedProcess.getStartUserId()); | ||||
|     } | ||||
|  | ||||
|     @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, | ||||
|             description = "Verify User that is not involved in a process cannot get that process using REST API and status code is FORBIDDEN (403)") | ||||
|     @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) | ||||
|     public void shouldNotGetProcessesByNotInvolvedUser() throws Exception | ||||
|     { | ||||
|         process = restClient.authenticateUser(user).withWorkflowAPI().usingProcess(addedProcess).getProcess(); | ||||
|         restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> | ||||
| <suite name="REST API tests part1" preserve-order="true"> | ||||
| 	<listeners> | ||||
|     <listeners> | ||||
|         <listener class-name="org.alfresco.utility.report.HtmlReportListener"/> | ||||
|         <listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"/> | ||||
|         <listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"/> | ||||
| 	</listeners> | ||||
|     </listeners> | ||||
|  | ||||
|     <test name="Part1"> | ||||
|         <packages> | ||||
| @@ -14,6 +14,7 @@ | ||||
|             <package name="org.alfresco.rest.comments.*"/> | ||||
|             <package name="org.alfresco.rest.downloads.*"/> | ||||
|             <package name="org.alfresco.rest.favorites.*"/> | ||||
|             <package name="org.alfresco.rest.rules.*" /> | ||||
|             <package name="org.alfresco.rest.servlet.*"/> | ||||
|         </packages> | ||||
|     </test> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
| @@ -144,7 +144,7 @@ | ||||
|             <plugin> | ||||
|                 <groupId>org.codehaus.mojo</groupId> | ||||
|                 <artifactId>buildnumber-maven-plugin</artifactId> | ||||
|                 <version>1.4</version> | ||||
|                 <version>3.0.0</version> | ||||
|                 <executions> | ||||
|                     <execution> | ||||
|                         <phase>validate</phase> | ||||
|   | ||||
							
								
								
									
										95
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										95
									
								
								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>17.9</version> | ||||
|     <version>17.75-SNAPSHOT</version> | ||||
|     <packaging>pom</packaging> | ||||
|     <name>Alfresco Community Repo Parent</name> | ||||
|  | ||||
| @@ -53,52 +53,53 @@ | ||||
|         <dependency.activiti.version>5.23.0</dependency.activiti.version> | ||||
|         <dependency.alfresco-transform-service.version>1.5.3</dependency.alfresco-transform-service.version> | ||||
|         <dependency.alfresco-transform-core.version>2.6.0</dependency.alfresco-transform-core.version> | ||||
|         <dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version> | ||||
|         <dependency.acs-event-model.version>0.0.13</dependency.acs-event-model.version> | ||||
|         <dependency.alfresco-greenmail.version>6.4</dependency.alfresco-greenmail.version> | ||||
|         <dependency.acs-event-model.version>0.0.16</dependency.acs-event-model.version> | ||||
|  | ||||
|         <dependency.spring.version>5.3.18</dependency.spring.version> | ||||
|         <dependency.spring.version>5.3.22</dependency.spring.version> | ||||
|         <dependency.antlr.version>3.5.2</dependency.antlr.version> | ||||
|         <dependency.jackson.version>2.13.1</dependency.jackson.version> | ||||
|         <dependency.jackson-databind.version>2.13.1</dependency.jackson-databind.version> | ||||
|         <dependency.cxf.version>3.5.0</dependency.cxf.version> | ||||
|         <dependency.jackson.version>2.13.3</dependency.jackson.version> | ||||
|         <dependency.jackson-databind.version>2.13.3</dependency.jackson-databind.version> | ||||
|         <dependency.cxf.version>3.5.3</dependency.cxf.version> | ||||
|         <dependency.opencmis.version>1.0.0</dependency.opencmis.version> | ||||
|         <dependency.webscripts.version>8.29</dependency.webscripts.version> | ||||
|         <dependency.webscripts.version>8.31</dependency.webscripts.version> | ||||
|         <dependency.bouncycastle.version>1.70</dependency.bouncycastle.version> | ||||
|         <dependency.mockito-core.version>3.11.2</dependency.mockito-core.version> | ||||
|         <dependency.org-json.version>20211205</dependency.org-json.version> | ||||
|         <dependency.mockito-core.version>4.6.1</dependency.mockito-core.version> | ||||
|         <dependency.assertj.version>3.23.1</dependency.assertj.version> | ||||
|         <dependency.org-json.version>20220320</dependency.org-json.version> | ||||
|         <dependency.commons-dbcp.version>2.9.0</dependency.commons-dbcp.version> | ||||
|         <dependency.commons-io.version>2.11.0</dependency.commons-io.version> | ||||
|         <dependency.gson.version>2.8.5</dependency.gson.version> | ||||
|         <dependency.gson.version>2.8.9</dependency.gson.version> | ||||
|         <dependency.httpclient.version>4.5.13</dependency.httpclient.version> | ||||
|         <dependency.httpcore.version>4.4.15</dependency.httpcore.version> | ||||
|         <dependency.commons-httpclient.version>3.1-HTTPCLIENT-1265</dependency.commons-httpclient.version> | ||||
|         <dependency.xercesImpl.version>2.12.2</dependency.xercesImpl.version> | ||||
|         <dependency.slf4j.version>1.7.35</dependency.slf4j.version> | ||||
|         <dependency.gytheio.version>0.16</dependency.gytheio.version> | ||||
|         <dependency.groovy.version>3.0.9</dependency.groovy.version> | ||||
|         <dependency.tika.version>2.2.1</dependency.tika.version> | ||||
|         <dependency.spring-security.version>5.6.1</dependency.spring-security.version> | ||||
|         <dependency.groovy.version>3.0.12</dependency.groovy.version> | ||||
|         <dependency.tika.version>2.4.1</dependency.tika.version> | ||||
|         <dependency.spring-security.version>5.7.2</dependency.spring-security.version> | ||||
|         <dependency.truezip.version>7.7.10</dependency.truezip.version> | ||||
|         <dependency.poi.version>4.1.2</dependency.poi.version> | ||||
|         <dependency.poi.version>5.2.2</dependency.poi.version> | ||||
|         <dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version> | ||||
|         <dependency.keycloak.version>15.0.2</dependency.keycloak.version> | ||||
|         <dependency.jboss.logging.version>3.4.3.Final</dependency.jboss.logging.version> | ||||
|         <dependency.jboss.logging.version>3.5.0.Final</dependency.jboss.logging.version> | ||||
|         <dependency.camel.version>3.15.0</dependency.camel.version> <!-- when bumping this version, please keep track/sync with included netty.io dependencies (can cause dependency conflicts)--> | ||||
|         <dependency.activemq.version>5.16.1</dependency.activemq.version> | ||||
|         <dependency.activemq.version>5.17.1</dependency.activemq.version> | ||||
|         <dependency.apache-compress.version>1.21</dependency.apache-compress.version> | ||||
|         <dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version> | ||||
|         <dependency.awaitility.version>4.1.1</dependency.awaitility.version> | ||||
|         <dependency.awaitility.version>4.2.0</dependency.awaitility.version> | ||||
|         <dependency.swagger-ui.version>3.38.0</dependency.swagger-ui.version> | ||||
|         <dependency.swagger-parser.version>1.0.56</dependency.swagger-parser.version> | ||||
|         <dependency.swagger-parser.version>1.0.61</dependency.swagger-parser.version> | ||||
|         <dependency.maven-filtering.version>3.1.1</dependency.maven-filtering.version> | ||||
|         <dependency.maven-artifact.version>3.8.4</dependency.maven-artifact.version> | ||||
|         <dependency.maven-artifact.version>3.8.6</dependency.maven-artifact.version> | ||||
|         <dependency.jdom2.version>2.0.6.1</dependency.jdom2.version> | ||||
|  | ||||
|         <dependency.jakarta-jaxb-api.version>2.3.3</dependency.jakarta-jaxb-api.version> | ||||
|         <dependency.jakarta-ws-api.version>2.3.3</dependency.jakarta-ws-api.version> | ||||
|         <dependency.jakarta-soap-api.version>1.4.2</dependency.jakarta-soap-api.version> | ||||
|         <dependency.jakarta-activation-api.version>1.2.2</dependency.jakarta-activation-api.version> | ||||
|         <dependency.jakarta-annotation-api.version>1.3.5</dependency.jakarta-annotation-api.version> | ||||
|         <dependency.jakarta-annotation-api.version>2.1.1</dependency.jakarta-annotation-api.version> | ||||
|         <dependency.jakarta-transaction-api.version>1.3.3</dependency.jakarta-transaction-api.version> | ||||
|         <dependency.jakarta-jws-api.version>2.1.0</dependency.jakarta-jws-api.version> | ||||
|         <dependency.jakarta-mail-api.version>1.6.5</dependency.jakarta-mail-api.version> | ||||
| @@ -106,20 +107,20 @@ | ||||
|         <dependency.jakarta-json-path.version>2.7.0</dependency.jakarta-json-path.version> | ||||
|         <dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version> | ||||
|  | ||||
|         <alfresco.googledrive.version>3.2.1.3</alfresco.googledrive.version> | ||||
|         <alfresco.googledrive.version>3.2.2</alfresco.googledrive.version> | ||||
|         <alfresco.aos-module.version>1.4.1</alfresco.aos-module.version>  | ||||
|         <alfresco.api-explorer.version>7.2.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share --> | ||||
|         <alfresco.api-explorer.version>7.2.1</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share --> | ||||
|  | ||||
|         <alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version> | ||||
|         <license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version> | ||||
|  | ||||
|         <dependency.postgresql.version>42.3.2</dependency.postgresql.version> | ||||
|         <dependency.mysql.version>8.0.27</dependency.mysql.version> | ||||
|         <dependency.postgresql.version>42.4.1</dependency.postgresql.version> | ||||
|         <dependency.mysql.version>8.0.30</dependency.mysql.version> | ||||
|         <dependency.mysql-image.version>8</dependency.mysql-image.version> | ||||
|         <dependency.mariadb.version>2.7.4</dependency.mariadb.version> | ||||
|         <dependency.tas-utility.version>3.0.47</dependency.tas-utility.version> | ||||
|         <dependency.tas-utility.version>3.0.49</dependency.tas-utility.version> | ||||
|         <dependency.rest-assured.version>3.3.0</dependency.rest-assured.version> | ||||
|         <dependency.tas-restapi.version>1.80</dependency.tas-restapi.version> | ||||
|         <dependency.tas-restapi.version>1.101</dependency.tas-restapi.version> | ||||
|         <dependency.tas-cmis.version>1.31</dependency.tas-cmis.version> | ||||
|         <dependency.tas-email.version>1.8</dependency.tas-email.version> | ||||
|         <dependency.tas-webdav.version>1.6</dependency.tas-webdav.version> | ||||
| @@ -147,7 +148,7 @@ | ||||
|         <connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection> | ||||
|         <developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection> | ||||
|         <url>https://github.com/Alfresco/alfresco-community-repo</url> | ||||
|         <tag>17.9</tag> | ||||
|         <tag>HEAD</tag> | ||||
|     </scm> | ||||
|  | ||||
|     <distributionManagement> | ||||
| @@ -404,7 +405,7 @@ | ||||
|             <dependency> | ||||
|                 <groupId>org.apache.xmlbeans</groupId> | ||||
|                 <artifactId>xmlbeans</artifactId> | ||||
|                 <version>3.1.0</version> | ||||
|                 <version>5.1.0</version> | ||||
|             </dependency> | ||||
|             <dependency> | ||||
|                 <groupId>org.json</groupId> | ||||
| @@ -632,13 +633,13 @@ | ||||
|             <dependency> | ||||
|                 <groupId>com.drewnoakes</groupId> | ||||
|                 <artifactId>metadata-extractor</artifactId> | ||||
|                 <version>2.16.0</version> | ||||
|                 <version>2.18.0</version> | ||||
|             </dependency> | ||||
|             <!-- upgrade dependency from TIKA --> | ||||
|             <dependency> | ||||
|                 <groupId>com.github.junrar</groupId> | ||||
|                 <artifactId>junrar</artifactId> | ||||
|                 <version>7.4.1</version> | ||||
|                 <version>7.5.2</version> | ||||
|             </dependency> | ||||
|             <dependency> | ||||
|                 <groupId>com.github.fge</groupId> | ||||
| @@ -649,7 +650,7 @@ | ||||
|             <dependency> | ||||
|                 <groupId>org.jsoup</groupId> | ||||
|                 <artifactId>jsoup</artifactId> | ||||
|                 <version>1.14.3</version> | ||||
|                 <version>1.15.2</version> | ||||
|             </dependency> | ||||
|             <!-- upgrade dependency from TIKA --> | ||||
|             <dependency> | ||||
| @@ -728,7 +729,7 @@ | ||||
|             <dependency> | ||||
|                 <groupId>joda-time</groupId> | ||||
|                 <artifactId>joda-time</artifactId> | ||||
|                 <version>2.10.13</version> | ||||
|                 <version>2.10.14</version> | ||||
|             </dependency> | ||||
|  | ||||
|             <!-- provided dependencies --> | ||||
| @@ -755,6 +756,11 @@ | ||||
|                 <artifactId>mockito-core</artifactId> | ||||
|                 <version>${dependency.mockito-core.version}</version> | ||||
|             </dependency> | ||||
|             <dependency> | ||||
|                 <groupId>org.assertj</groupId> | ||||
|                 <artifactId>assertj-core</artifactId> | ||||
|                 <version>${dependency.assertj.version}</version> | ||||
|             </dependency> | ||||
|             <dependency> | ||||
|                 <groupId>org.apache.commons</groupId> | ||||
|                 <artifactId>commons-dbcp2</artifactId> | ||||
| @@ -868,9 +874,20 @@ | ||||
|             <dependency> | ||||
|                 <groupId>org.projectlombok</groupId> | ||||
|                 <artifactId>lombok</artifactId> | ||||
|                 <version>1.18.22</version> | ||||
|                 <version>1.18.24</version> | ||||
|                 <scope>provided</scope> | ||||
|             </dependency> | ||||
|             <dependency> | ||||
|                 <groupId>org.activiti</groupId> | ||||
|                 <artifactId>activiti-spring</artifactId> | ||||
|                 <version>${dependency.activiti.version}</version> | ||||
|                 <exclusions> | ||||
|                     <exclusion> | ||||
|                         <groupId>commons-dbcp</groupId> | ||||
|                         <artifactId>commons-dbcp</artifactId> | ||||
|                     </exclusion> | ||||
|                 </exclusions> | ||||
|             </dependency> | ||||
|         </dependencies> | ||||
|     </dependencyManagement> | ||||
|  | ||||
| @@ -888,7 +905,7 @@ | ||||
|                 <plugin> | ||||
|                     <groupId>io.fabric8</groupId> | ||||
|                     <artifactId>docker-maven-plugin</artifactId> | ||||
|                     <version>0.39.1</version> | ||||
|                     <version>0.40.2</version> | ||||
|                 </plugin> | ||||
|                 <plugin> | ||||
|                     <artifactId>maven-surefire-plugin</artifactId> | ||||
| @@ -909,21 +926,21 @@ | ||||
|                 <plugin> | ||||
|                     <groupId>org.apache.maven.plugins</groupId> | ||||
|                     <artifactId>maven-javadoc-plugin</artifactId> | ||||
|                     <version>3.3.1</version> | ||||
|                     <version>3.4.0</version> | ||||
|                 </plugin> | ||||
|                 <plugin> | ||||
|                     <groupId>org.apache.maven.plugins</groupId> | ||||
|                     <artifactId>maven-resources-plugin</artifactId> | ||||
|                     <version>3.2.0</version> | ||||
|                     <version>3.3.0</version> | ||||
|                 </plugin> | ||||
|                 <plugin> | ||||
|                     <groupId>org.apache.maven.plugins</groupId> | ||||
|                     <artifactId>maven-dependency-plugin</artifactId> | ||||
|                     <version>3.1.2</version> | ||||
|                     <version>3.3.0</version> | ||||
|                 </plugin> | ||||
|                 <plugin> | ||||
|                     <artifactId>maven-assembly-plugin</artifactId> | ||||
|                     <version>3.3.0</version> | ||||
|                     <version>3.4.2</version> | ||||
|                 </plugin> | ||||
|                 <plugin> | ||||
|                     <groupId>org.alfresco.maven.plugin</groupId> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>17.9</version> | ||||
|         <version>17.75-SNAPSHOT</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
| @@ -47,7 +47,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.apache.santuario</groupId> | ||||
|             <artifactId>xmlsec</artifactId> | ||||
|             <version>2.3.0</version> | ||||
|             <version>3.0.0</version> | ||||
|         </dependency> | ||||
|         <!-- newer version, see REPO-3133 --> | ||||
|         <dependency> | ||||
| @@ -87,6 +87,11 @@ | ||||
|             <artifactId>mockito-core</artifactId> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.assertj</groupId> | ||||
|             <artifactId>assertj-core</artifactId> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework</groupId> | ||||
|             <artifactId>spring-test</artifactId> | ||||
| @@ -125,7 +130,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-server</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|             <exclusions> | ||||
|                 <exclusion> | ||||
| @@ -137,19 +142,19 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-security</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.jetty</groupId> | ||||
|             <artifactId>jetty-webapp</artifactId> | ||||
|             <version>8.2.0.v20160908</version> | ||||
|             <version>10.0.11</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.alfresco.cmis.client</groupId> | ||||
|             <artifactId>alfresco-opencmis-extension</artifactId> | ||||
|             <version>2.0</version> | ||||
|             <version>2.1</version> | ||||
|             <scope>test</scope> | ||||
|             <exclusions> | ||||
|               <!-- Duplicates classes from jakarta.transaction:jakarta.transaction-api --> | ||||
|   | ||||
| @@ -0,0 +1,64 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts; | ||||
|  | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.MimetypeService; | ||||
| import org.springframework.extensions.webscripts.WebScriptRequest; | ||||
|  | ||||
| public class MimeTypeUtil | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * Get the file mimetype from the file ContentReader, and if its null then set the mimetype to binary by default | ||||
|      * and try to get the correct one from file extension | ||||
|      * | ||||
|      * | ||||
|      * @param reader            reader of the file in the request | ||||
|      * @param req               request relating to the file | ||||
|      * @param mimetypeService   MimetypeService | ||||
|      * | ||||
|      * @return  mimetype of the file as a string | ||||
|      */ | ||||
|     public static String determineMimetype(ContentReader reader, WebScriptRequest req, MimetypeService mimetypeService) | ||||
|     { | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             String extensionPath = req.getExtensionPath(); | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         return mimetype; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -1,32 +1,33 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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 Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is  | ||||
|  * provided under the following open source license terms: | ||||
|  *  | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  *  | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  *  | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts.action; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.alfresco.repo.action.access.ActionAccessRestriction; | ||||
| import org.alfresco.service.cmr.action.Action; | ||||
| import org.alfresco.service.cmr.action.ExecutionSummary; | ||||
| import org.springframework.extensions.webscripts.Cache; | ||||
| @@ -58,6 +59,7 @@ public abstract class AbstractExecuteActionWebscript extends AbstractActionWebsc | ||||
|             | ||||
|            // Ask for it to be run in the background | ||||
|            // It will be available to execute once the webscript finishes | ||||
|            ActionAccessRestriction.setActionContext(action, ActionAccessRestriction.V0_ACTION_CONTEXT); | ||||
|            actionService.executeAction( | ||||
|                  action, null,  | ||||
|                  false, true | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -26,14 +26,18 @@ | ||||
| package org.alfresco.repo.web.scripts.content; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import javax.servlet.ServletContext; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.dictionary.DictionaryService; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.ContentService; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.NamespaceService; | ||||
| @@ -65,6 +69,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|     private NamespaceService namespaceService; | ||||
|     private ContentService contentService; | ||||
|  | ||||
|     private List<String> nonAttachContentTypes = Collections.emptyList(); | ||||
|  | ||||
|     /** | ||||
|      * @param nonAttachContentTypes List<String> | ||||
|      */ | ||||
|     public void setNonAttachContentTypes(List<String> nonAttachContentTypes) | ||||
|     { | ||||
|         if (nonAttachContentTypes != null && !nonAttachContentTypes.isEmpty()) | ||||
|         { | ||||
|             this.nonAttachContentTypes = nonAttachContentTypes; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param servletContext ServletContext | ||||
|      */ | ||||
| @@ -121,9 +138,7 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|         { | ||||
|             throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); | ||||
|         } | ||||
|          | ||||
|         // determine attachment | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|  | ||||
|          | ||||
|         // render content | ||||
|         QName propertyQName = ContentModel.PROP_CONTENT; | ||||
| @@ -140,6 +155,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|                 propertyQName = QName.createQName(propertyName, namespaceService); | ||||
|             } | ||||
|         } | ||||
|         // determine attachment and force download for specific mimetypes - see PRODSEC-5862 | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|         ContentReader reader = contentService.getReader(nodeRef, propertyQName); | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         if (!attach) | ||||
|         { | ||||
|             if (nonAttachContentTypes == null || !nonAttachContentTypes.contains(mimetype)) | ||||
|             { | ||||
|                 attach = true; | ||||
|                 logger.warn("Ignored a=false for " + nodeRef.getId() + " since " + mimetype + " is not in the whitelist for non-attach content types"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Stream the content | ||||
|         streamContentLocal(req, res, nodeRef, attach, propertyQName, null); | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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 Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is  | ||||
|  * provided under the following open source license terms: | ||||
|  *  | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  *  | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  *  | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts.content; | ||||
|  | ||||
| import java.io.IOException; | ||||
| @@ -33,7 +33,7 @@ import java.util.Map; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.QName; | ||||
| @@ -79,18 +79,7 @@ public class ContentInfo extends StreamContent | ||||
|         delegate.setAttachment(req, res, attach, attachFileName); | ||||
|  | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         // set mimetype for the content and the character encoding + length for the stream | ||||
|         res.setContentType(mimetype); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -43,6 +43,7 @@ import javax.servlet.http.HttpServletResponse; | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.content.filestore.FileContentReader; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.sync.repo.events.EventPublisher; | ||||
| import org.alfresco.repo.web.util.HttpRangeProcessor; | ||||
| import org.alfresco.rest.framework.resource.content.CacheDirective; | ||||
| @@ -361,18 +362,7 @@ public class ContentStreamer implements ResourceLoaderAware | ||||
|         setAttachment(req, res, attach, attachFileName); | ||||
|      | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|          | ||||
|         res.setHeader(HEADER_ACCEPT_RANGES, "bytes"); | ||||
|         try | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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 Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is  | ||||
|  * provided under the following open source license terms: | ||||
|  *  | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  *  | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  *  | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts.rule; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| @@ -38,6 +38,8 @@ import org.alfresco.error.AlfrescoRuntimeException; | ||||
| import org.alfresco.repo.action.ActionConditionImpl; | ||||
| import org.alfresco.repo.action.ActionImpl; | ||||
| import org.alfresco.repo.action.CompositeActionImpl; | ||||
| import org.alfresco.repo.action.RuntimeActionService; | ||||
| import org.alfresco.repo.action.access.ActionAccessRestriction; | ||||
| import org.alfresco.service.cmr.action.Action; | ||||
| import org.alfresco.service.cmr.action.ActionCondition; | ||||
| import org.alfresco.service.cmr.action.ActionService; | ||||
| @@ -85,6 +87,8 @@ public abstract class AbstractRuleWebScript extends DeclarativeWebScript | ||||
|     protected FileFolderService fileFolderService; | ||||
|     protected NamespaceService namespaceService; | ||||
|  | ||||
|     private RuntimeActionService runtimeActionService; | ||||
|  | ||||
|     /** | ||||
|      * Sets the node service instance | ||||
|      *  | ||||
| @@ -145,6 +149,10 @@ public abstract class AbstractRuleWebScript extends DeclarativeWebScript | ||||
|         this.namespaceService = namespaceService; | ||||
|     } | ||||
|  | ||||
|     public void setRuntimeActionService(RuntimeActionService runtimeActionService) { | ||||
|         this.runtimeActionService = runtimeActionService; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Parses the request and providing it's valid returns the NodeRef. | ||||
|      *  | ||||
| @@ -432,10 +440,22 @@ public abstract class AbstractRuleWebScript extends DeclarativeWebScript | ||||
|  | ||||
|     protected void checkRule(Rule rule) | ||||
|     { | ||||
|         List<String> ruleTypes = rule.getRuleTypes(); | ||||
|         if (ruleTypes.contains(RULE_OUTBOUND)) | ||||
|         List<Action> actions = ((CompositeActionImpl) rule.getAction()).getActions(); | ||||
|  | ||||
|         checkRestrictedAccessActions(actions); | ||||
|         checkRuleOutboundHasNoCheckOutAction(rule, actions); | ||||
|     } | ||||
|  | ||||
|     private void checkRestrictedAccessActions(List<Action> actions) { | ||||
|         for (Action action : actions) { | ||||
|             ActionAccessRestriction.setActionContext(action, ActionAccessRestriction.RULE_ACTION_CONTEXT); | ||||
|             runtimeActionService.verifyActionAccessRestrictions(action); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void checkRuleOutboundHasNoCheckOutAction(Rule rule, List<Action> actions) { | ||||
|         if (rule.getRuleTypes().contains(RULE_OUTBOUND)) | ||||
|         { | ||||
|             List<Action> actions = ((CompositeActionImpl) rule.getAction()).getActions(); | ||||
|             for (Action action : actions) | ||||
|             { | ||||
|                 if (action.getActionDefinitionName().equalsIgnoreCase(ACTION_CHECK_OUT)) | ||||
|   | ||||
| @@ -1,28 +1,28 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * 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 Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is  | ||||
|  * provided under the following open source license terms: | ||||
|  *  | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  *  | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  *  | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts.rule; | ||||
|  | ||||
| import java.io.IOException; | ||||
| @@ -30,6 +30,7 @@ import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.alfresco.repo.action.ActionImpl; | ||||
| import org.alfresco.repo.action.access.ActionAccessRestriction; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| @@ -89,6 +90,7 @@ public class ActionQueuePost extends AbstractRuleWebScript | ||||
|             } | ||||
|  | ||||
|             // Execute action | ||||
|             ActionAccessRestriction.setActionContext(action, ActionAccessRestriction.V0_ACTION_CONTEXT); | ||||
|             actionService.executeAction(action, actionedUponNode, true, async); | ||||
|  | ||||
|             // Prepair model | ||||
|   | ||||
							
								
								
									
										61
									
								
								remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.rest.api; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
|  | ||||
| /** | ||||
|  * Rule sets API. | ||||
|  */ | ||||
| @Experimental | ||||
| public interface RuleSets | ||||
| { | ||||
|     /** | ||||
|      * Get rule sets for a folder. | ||||
|      * | ||||
|      * @param folderNodeId Folder node ID | ||||
|      * @param paging {@link Paging} information | ||||
|      * @param includes List of fields to include in the rule set | ||||
|      * @return {@link CollectionWithPagingInfo} containing a list page of rule sets | ||||
|      */ | ||||
|     CollectionWithPagingInfo<RuleSet> getRuleSets(String folderNodeId, List<String> includes, Paging paging); | ||||
|  | ||||
|     /** | ||||
|      * Get the rule set with the given ID and check associations with the folder node. | ||||
|      * | ||||
|      * @param folderNodeId Folder node ID | ||||
|      * @param ruleSetId Rule set ID | ||||
|      * @param includes List of fields to include in the rule set | ||||
|      * @return {@link RuleSet} definition | ||||
|      */ | ||||
|     RuleSet getRuleSetById(String folderNodeId, String ruleSetId, List<String> includes); | ||||
| } | ||||
							
								
								
									
										96
									
								
								remote-api/src/main/java/org/alfresco/rest/api/Rules.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								remote-api/src/main/java/org/alfresco/rest/api/Rules.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,96 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api; | ||||
|  | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.rule.RuleServiceException; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Folder node rules API. | ||||
|  * | ||||
|  */ | ||||
| @Experimental | ||||
| public interface Rules | ||||
| { | ||||
|     /** | ||||
|      * Get rules for node's and rule set's IDs | ||||
|      * | ||||
|      * @param folderNodeId - folder node ID | ||||
|      * @param ruleSetId - rule set ID | ||||
|      * @param paging - {@link Paging} information | ||||
|      * @return {@link CollectionWithPagingInfo} containing a list page of folder rules | ||||
|      */ | ||||
|     CollectionWithPagingInfo<Rule> getRules(String folderNodeId, String ruleSetId, Paging paging); | ||||
|  | ||||
|     /** | ||||
|      * Get rule for rule's ID and check associations with folder node and rule set node | ||||
|      * | ||||
|      * @param folderNodeId - folder node ID | ||||
|      * @param ruleSetId - rule set ID | ||||
|      * @param ruleId - rule ID | ||||
|      * @return {@link Rule} definition | ||||
|      */ | ||||
|     Rule getRuleById(String folderNodeId, String ruleSetId, String ruleId); | ||||
|  | ||||
|     /** | ||||
|      * Create new rules (and potentially a rule set if "_default_" is supplied). | ||||
|      * | ||||
|      * @param folderNodeId The node id of a folder. | ||||
|      * @param ruleSetId The id of a rule set (or "_default_" to use/create the default rule set for the folder). | ||||
|      * @param rule The definition of the rule. | ||||
|      * @return The newly created rules. | ||||
|      * @throws InvalidArgumentException If the nodes are not the expected types, or the rule set does not correspond to the folder. | ||||
|      * @throws RuleServiceException If the folder is already linked to another rule set. | ||||
|      */ | ||||
|     List<Rule> createRules(String folderNodeId, String ruleSetId, List<Rule> rule); | ||||
|  | ||||
|     /** | ||||
|      * Update a rule. | ||||
|      * | ||||
|      * @param folderNodeId The id of a folder. | ||||
|      * @param ruleSetId The id of a rule set within the folder (or "_default_" to use the default rule set for the folder). | ||||
|      * @param ruleId The rule id. | ||||
|      * @param rule The new version of the rule. | ||||
|      * @return The newly updated rule. | ||||
|      */ | ||||
|     Rule updateRuleById(String folderNodeId, String ruleSetId, String ruleId, Rule rule); | ||||
|  | ||||
|     /** | ||||
|      * Delete rule for rule's ID and check associations with folder node and rule set node | ||||
|      * | ||||
|      * @param folderNodeId - folder node ID | ||||
|      * @param ruleSetId - rule set ID | ||||
|      * @param ruleId - rule ID     * | ||||
|      */ | ||||
|     void deleteRuleById(String folderNodeId, String ruleSetId, String ruleId); | ||||
| } | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2017 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
| @@ -26,6 +26,7 @@ | ||||
| package org.alfresco.rest.api.impl; | ||||
|  | ||||
| import org.alfresco.error.AlfrescoRuntimeException; | ||||
| import org.alfresco.repo.action.access.ActionAccessRestriction; | ||||
| import org.alfresco.rest.api.Actions; | ||||
| import org.alfresco.rest.api.model.Action; | ||||
| import org.alfresco.rest.api.model.ActionDefinition; | ||||
| @@ -286,6 +287,7 @@ public class ActionsImpl implements Actions | ||||
|             cmrAction = actionService.createAction(action.getActionDefinitionId()); | ||||
|         } | ||||
|  | ||||
|         ActionAccessRestriction.setActionContext(cmrAction, ActionAccessRestriction.V1_ACTION_CONTEXT); | ||||
|         actionService.executeAction(cmrAction, actionedUponNodeRef, true, true); | ||||
|  | ||||
|         // Create user result. | ||||
|   | ||||
| @@ -0,0 +1,185 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.rest.api.impl.rules; | ||||
|  | ||||
| import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED; | ||||
| import static org.alfresco.service.cmr.security.PermissionService.CHANGE_PERMISSIONS; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.rule.RuleModel; | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; | ||||
| import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.alfresco.service.cmr.security.PermissionService; | ||||
| import org.alfresco.service.namespace.QName; | ||||
|  | ||||
| /** Responsible for validating nodes when working with rules. */ | ||||
| public class NodeValidator | ||||
| { | ||||
|     private static final String RULE_SET_EXPECTED_TYPE_NAME = "rule set"; | ||||
|  | ||||
|     private Nodes nodes; | ||||
|     private RuleService ruleService; | ||||
|     private PermissionService permissionService; | ||||
|  | ||||
|     /** | ||||
|      * Validates if folder node exists and the user has permission to use it. | ||||
|      * | ||||
|      * @param folderNodeId - folder node ID | ||||
|      * @param requireChangePermission - Whether to require change permission or just read permission. | ||||
|      * @return folder node reference | ||||
|      * @throws InvalidArgumentException if node is not of an expected type | ||||
|      * @throws PermissionDeniedException if the user doesn't have the appropriate permission for the folder. | ||||
|      */ | ||||
|     public NodeRef validateFolderNode(final String folderNodeId, boolean requireChangePermission) | ||||
|     { | ||||
|         final NodeRef nodeRef = nodes.validateOrLookupNode(folderNodeId, null); | ||||
|         if (requireChangePermission) | ||||
|         { | ||||
|             if (permissionService.hasPermission(nodeRef, CHANGE_PERMISSIONS) != ALLOWED) | ||||
|             { | ||||
|                 throw new PermissionDeniedException("Insufficient permissions to manage rules."); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if (permissionService.hasReadPermission(nodeRef) != ALLOWED) | ||||
|             { | ||||
|                 throw new PermissionDeniedException("Cannot read from this node!"); | ||||
|             } | ||||
|         } | ||||
|         verifyNodeType(nodeRef, ContentModel.TYPE_FOLDER, null); | ||||
|  | ||||
|         return nodeRef; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Validates if rule set ID is default, node exists and associated folder node matches. | ||||
|      * | ||||
|      * @param ruleSetId - rule set node ID | ||||
|      * @param associatedFolderNodeRef - folder node ref to check the association | ||||
|      * @return rule set node reference | ||||
|      * @throws InvalidArgumentException in case of not matching associated folder node | ||||
|      */ | ||||
|     public NodeRef validateRuleSetNode(final String ruleSetId, final NodeRef associatedFolderNodeRef) | ||||
|     { | ||||
|         if (RuleSet.isDefaultId(ruleSetId)) | ||||
|         { | ||||
|             final NodeRef ruleSetNodeRef = ruleService.getRuleSetNode(associatedFolderNodeRef); | ||||
|             if (ruleSetNodeRef == null) | ||||
|             { | ||||
|                 //folder doesn't have a -default- rule set | ||||
|                 throw new RelationshipResourceNotFoundException(associatedFolderNodeRef.getId(), ruleSetId); | ||||
|             } | ||||
|             return ruleSetNodeRef; | ||||
|         } | ||||
|  | ||||
|         final NodeRef ruleSetNodeRef = validateNode(ruleSetId, ContentModel.TYPE_SYSTEM_FOLDER, RULE_SET_EXPECTED_TYPE_NAME); | ||||
|         if (!ruleService.isRuleSetAssociatedWithFolder(ruleSetNodeRef, associatedFolderNodeRef)) | ||||
|         { | ||||
|             throw new InvalidArgumentException("Rule set is not associated with folder node!"); | ||||
|         } | ||||
|  | ||||
|         return ruleSetNodeRef; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Validates if rule node exists and associated rule set node matches. | ||||
|      * | ||||
|      * @param ruleId - rule node ID | ||||
|      * @param associatedRuleSetNodeRef - rule set node ref to check the association. Can be null | ||||
|      * @return rule node reference | ||||
|      * @throws InvalidArgumentException in case of not matching associated rule set node | ||||
|      */ | ||||
|     public NodeRef validateRuleNode(final String ruleId, final NodeRef associatedRuleSetNodeRef) | ||||
|     { | ||||
|         final NodeRef ruleNodeRef = validateNode(ruleId, RuleModel.TYPE_RULE, null); | ||||
|         if (associatedRuleSetNodeRef != null && !ruleService.isRuleAssociatedWithRuleSet(ruleNodeRef, associatedRuleSetNodeRef)) | ||||
|         { | ||||
|             throw new InvalidArgumentException("Rule is not associated with rule set node!"); | ||||
|         } | ||||
|  | ||||
|         return ruleNodeRef; | ||||
|     } | ||||
|  | ||||
|     private NodeRef validateNode(final String nodeId, final QName expectedType, final String expectedTypeName) | ||||
|     { | ||||
|         final NodeRef nodeRef = nodes.validateNode(nodeId); | ||||
|         verifyNodeType(nodeRef, expectedType, expectedTypeName); | ||||
|  | ||||
|         return nodeRef; | ||||
|     } | ||||
|  | ||||
|     private void verifyNodeType(final NodeRef nodeRef, final QName expectedType, final String expectedTypeName) | ||||
|     { | ||||
|         final Set<QName> expectedTypes = Set.of(expectedType); | ||||
|         if (!nodes.nodeMatches(nodeRef, expectedTypes, null)) | ||||
|         { | ||||
|             final String expectedTypeLocalName = (expectedTypeName != null) ? expectedTypeName : expectedType.getLocalName(); | ||||
|             throw new InvalidArgumentException(String.format("NodeId of a %s is expected!", expectedTypeLocalName)); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef, final NodeRef folderNodeRef) | ||||
|     { | ||||
|         if (ruleSetNodeRef == null && folderNodeRef != null) | ||||
|         { | ||||
|             final NodeRef ruleSetNode = ruleService.getRuleSetNode(folderNodeRef); | ||||
|             return ruleSetNode != null && ruleService.isRuleSetShared(ruleSetNode); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public boolean isRuleSetNotNullAndShared(final NodeRef ruleSetNodeRef) | ||||
|     { | ||||
|         return ruleSetNodeRef != null && ruleService.isRuleSetShared(ruleSetNodeRef); | ||||
|     } | ||||
|  | ||||
|     public void setPermissionService(PermissionService permissionService) | ||||
|     { | ||||
|         this.permissionService = permissionService; | ||||
|     } | ||||
|  | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
|  | ||||
|     public void setNodes(Nodes nodes) | ||||
|     { | ||||
|         this.nodes = nodes; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,80 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.impl.rules; | ||||
|  | ||||
| import static java.util.stream.Collectors.toList; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| import org.alfresco.rest.api.RuleSets; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.ListPage; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
|  | ||||
| @Experimental | ||||
| public class RuleSetsImpl implements RuleSets | ||||
| { | ||||
|     private RuleService ruleService; | ||||
|     private NodeValidator validator; | ||||
|  | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<RuleSet> getRuleSets(String folderNodeId, List<String> includes, Paging paging) | ||||
|     { | ||||
|         NodeRef folderNode = validator.validateFolderNode(folderNodeId, false); | ||||
|  | ||||
|         NodeRef ruleSetNode = ruleService.getRuleSetNode(folderNode); | ||||
|         List<RuleSet> ruleSets = Optional.ofNullable(ruleSetNode) | ||||
|                                          .map(NodeRef::getId) | ||||
|                                          .map(RuleSet::of).stream().collect(toList()); | ||||
|  | ||||
|         return ListPage.of(ruleSets, paging); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public RuleSet getRuleSetById(String folderNodeId, String ruleSetId, List<String> includes) | ||||
|     { | ||||
|         NodeRef folderNode = validator.validateFolderNode(folderNodeId, false); | ||||
|         NodeRef ruleSetNode = validator.validateRuleSetNode(ruleSetId, folderNode); | ||||
|  | ||||
|         return RuleSet.of(ruleSetNode.getId()); | ||||
|     } | ||||
|  | ||||
|     public void setValidator(NodeValidator validator) | ||||
|     { | ||||
|         this.validator = validator; | ||||
|     } | ||||
|  | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,129 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.impl.rules; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.api.Rules; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.ListPage; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.cmr.rule.RuleService; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| @Experimental | ||||
| public class RulesImpl implements Rules | ||||
| { | ||||
|     private static final Logger LOGGER = LoggerFactory.getLogger(RulesImpl.class); | ||||
|  | ||||
|     private Nodes nodes; | ||||
|     private RuleService ruleService; | ||||
|     private NodeValidator validator; | ||||
|  | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<Rule> getRules(final String folderNodeId, final String ruleSetId, final Paging paging) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|  | ||||
|         final boolean isShared = validator.isRuleSetNotNullAndShared(ruleSetNodeRef); | ||||
|         final List<Rule> rules = ruleService.getRules(folderNodeRef).stream() | ||||
|             .map(ruleModel -> Rule.from(ruleModel, isShared)) | ||||
|             .collect(Collectors.toList()); | ||||
|  | ||||
|         return ListPage.of(rules, paging); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Rule getRuleById(final String folderNodeId, final String ruleSetId, final String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, false); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|  | ||||
|         return Rule.from(ruleService.getRule(ruleNodeRef), validator.isRuleSetNotNullAndShared(ruleSetNodeRef)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<Rule> createRules(final String folderNodeId, final String ruleSetId, final List<Rule> rules) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         // Don't validate the ruleset node if -default- is passed since we may need to create it. | ||||
|         final NodeRef ruleSetNodeRef = (RuleSet.isNotDefaultId(ruleSetId)) ? validator.validateRuleSetNode(ruleSetId, folderNodeRef) : null; | ||||
|  | ||||
|         return rules.stream() | ||||
|                     .map(rule -> rule.toServiceModel(nodes)) | ||||
|                     .map(rule -> ruleService.saveRule(folderNodeRef, rule)) | ||||
|                     .map(rule -> Rule.from(rule, validator.isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef))) | ||||
|                     .collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Rule updateRuleById(String folderNodeId, String ruleSetId, String ruleId, Rule rule) | ||||
|     { | ||||
|         LOGGER.debug("Updating rule in folder {}, rule set {}, rule {} to {}", folderNodeId, ruleSetId, ruleId, rule); | ||||
|  | ||||
|         NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|  | ||||
|         boolean shared = validator.isRuleSetNotNullAndShared(ruleSetNodeRef, folderNodeRef); | ||||
|         return Rule.from(ruleService.saveRule(folderNodeRef, rule.toServiceModel(nodes)), shared); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteRuleById(String folderNodeId, String ruleSetId, String ruleId) | ||||
|     { | ||||
|         final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, true); | ||||
|         final NodeRef ruleSetNodeRef = validator.validateRuleSetNode(ruleSetId, folderNodeRef); | ||||
|         final NodeRef ruleNodeRef = validator.validateRuleNode(ruleId, ruleSetNodeRef); | ||||
|         final org.alfresco.service.cmr.rule.Rule rule = ruleService.getRule(ruleNodeRef); | ||||
|         ruleService.removeRule(folderNodeRef, rule); | ||||
|     } | ||||
|  | ||||
|     public void setNodes(Nodes nodes) | ||||
|     { | ||||
|         this.nodes = nodes; | ||||
|     } | ||||
|  | ||||
|     public void setRuleService(RuleService ruleService) | ||||
|     { | ||||
|         this.ruleService = ruleService; | ||||
|     } | ||||
|  | ||||
|     public void setValidator(NodeValidator validator) | ||||
|     { | ||||
|         this.validator = validator; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,170 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.alfresco.repo.action.ActionImpl; | ||||
| import org.alfresco.repo.action.CompositeActionImpl; | ||||
| import org.alfresco.repo.action.executer.SetPropertyValueActionExecuter; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.util.GUID; | ||||
|  | ||||
| @Experimental | ||||
| public class Action | ||||
| { | ||||
|     private String actionDefinitionId; | ||||
|     private Map<String, Serializable> params; | ||||
|  | ||||
|     /** | ||||
|      * Converts service POJO action to REST model action. | ||||
|      * | ||||
|      * @param actionModel - {@link org.alfresco.service.cmr.action.Action} service POJO | ||||
|      * @return {@link Action} REST model | ||||
|      */ | ||||
|     public static Action from(final org.alfresco.service.cmr.action.Action actionModel) | ||||
|     { | ||||
|         if (actionModel == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         final Action.Builder builder = builder().actionDefinitionId(actionModel.getActionDefinitionName()); | ||||
|         if (actionModel.getParameterValues() != null) | ||||
|         { | ||||
|             builder.params(new HashMap<>(actionModel.getParameterValues())); | ||||
|         } | ||||
|  | ||||
|         return builder.create(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Convert the REST model object to the equivalent service POJO. | ||||
|      * | ||||
|      * @param nodeRef The node reference. | ||||
|      * @return The action service POJO. | ||||
|      */ | ||||
|     public org.alfresco.service.cmr.action.Action toServiceModel(final NodeRef nodeRef) | ||||
|     { | ||||
|         return new ActionImpl(nodeRef, GUID.generate(), SetPropertyValueActionExecuter.NAME, params); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Convert the REST model objects to composite action service POJO. | ||||
|      * | ||||
|      * @param actions List of actions. | ||||
|      * @return The composite action service POJO. | ||||
|      */ | ||||
|     public static org.alfresco.service.cmr.action.Action toCompositeAction(final List<Action> actions) { | ||||
|         if (actions == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         final org.alfresco.service.cmr.action.CompositeAction compositeAction = new CompositeActionImpl(null, GUID.generate()); | ||||
|         actions.forEach(action -> compositeAction.addAction(action.toServiceModel(null))); | ||||
|         return compositeAction; | ||||
|     } | ||||
|  | ||||
|     public String getActionDefinitionId() | ||||
|     { | ||||
|         return actionDefinitionId; | ||||
|     } | ||||
|  | ||||
|     public void setActionDefinitionId(String actionDefinitionId) | ||||
|     { | ||||
|         this.actionDefinitionId = actionDefinitionId; | ||||
|     } | ||||
|  | ||||
|     public Map<String, Serializable> getParams() | ||||
|     { | ||||
|         return params; | ||||
|     } | ||||
|  | ||||
|     public void setParams(Map<String, Serializable> params) | ||||
|     { | ||||
|         this.params = params; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() | ||||
|     { | ||||
|         return "Action{" + "actionDefinitionId='" + actionDefinitionId + '\'' + ", params=" + params + '}'; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object o) | ||||
|     { | ||||
|         if (this == o) | ||||
|             return true; | ||||
|         if (o == null || getClass() != o.getClass()) | ||||
|             return false; | ||||
|         Action action = (Action) o; | ||||
|         return Objects.equals(actionDefinitionId, action.actionDefinitionId) && Objects.equals(params, action.params); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() | ||||
|     { | ||||
|         return Objects.hash(actionDefinitionId, params); | ||||
|     } | ||||
|  | ||||
|     public static Builder builder() | ||||
|     { | ||||
|         return new Builder(); | ||||
|     } | ||||
|  | ||||
|     public static class Builder | ||||
|     { | ||||
|         private String actionDefinitionId; | ||||
|         private Map<String, Serializable> params; | ||||
|  | ||||
|         public Builder actionDefinitionId(String actionDefinitionId) | ||||
|         { | ||||
|             this.actionDefinitionId = actionDefinitionId; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder params(Map<String, Serializable> params) | ||||
|         { | ||||
|             this.params = params; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Action create() { | ||||
|             final Action action = new Action(); | ||||
|             action.setActionDefinitionId(actionDefinitionId); | ||||
|             action.setParams(params); | ||||
|             return action; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,230 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.action.ActionCondition; | ||||
| import org.apache.commons.collections.CollectionUtils; | ||||
|  | ||||
| @Experimental | ||||
| public class CompositeCondition | ||||
| { | ||||
|     private boolean inverted; | ||||
|     private ConditionOperator booleanMode = ConditionOperator.AND; | ||||
|     private List<CompositeCondition> compositeConditions; | ||||
|     private List<SimpleCondition> simpleConditions; | ||||
|  | ||||
|     /** | ||||
|      * Converts Action conditions (service POJO) list to composite condition (REST model). | ||||
|      * | ||||
|      * @param actionConditions - list of {@link ActionCondition} service POJOs | ||||
|      * @return {@link CompositeCondition} REST model | ||||
|      */ | ||||
|     public static CompositeCondition from(final List<ActionCondition> actionConditions) | ||||
|     { | ||||
|         if (actionConditions == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         final CompositeCondition conditions = new CompositeCondition(); | ||||
|         conditions.compositeConditions = new ArrayList<>(); | ||||
|         // group action conditions by inversion flag | ||||
|         actionConditions.stream().filter(Objects::nonNull).collect(Collectors.groupingBy(ActionCondition::getInvertCondition)) | ||||
|             // map action condition sub lists | ||||
|             .forEach((inverted, actionConditionsPart) -> Optional.ofNullable(CompositeCondition.ofActionConditions(actionConditionsPart, inverted, ConditionOperator.AND)) | ||||
|                 // if composite condition present add to final list | ||||
|                 .ifPresent(compositeCondition -> conditions.compositeConditions.add(compositeCondition))); | ||||
|  | ||||
|         if (conditions.compositeConditions.isEmpty()) { | ||||
|             conditions.compositeConditions = null; | ||||
|         } | ||||
|  | ||||
|         return conditions; | ||||
|     } | ||||
|  | ||||
|     private static CompositeCondition ofActionConditions(final List<ActionCondition> actionConditions, final boolean inverted, final ConditionOperator conditionOperator) | ||||
|     { | ||||
|         if (actionConditions == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         return ofSimpleConditions(SimpleCondition.listOf(actionConditions), inverted, conditionOperator); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Creates a composite condition instance of simple conditions. | ||||
|      * | ||||
|      * @param simpleConditions - list of {@link SimpleCondition} | ||||
|      * @param inverted - determines if condition should be inverted | ||||
|      * @param conditionOperator - determines the operation, see {@link ConditionOperator} | ||||
|      * @return {@link CompositeCondition} | ||||
|      */ | ||||
|     public static CompositeCondition ofSimpleConditions(final List<SimpleCondition> simpleConditions, final boolean inverted, final ConditionOperator conditionOperator) | ||||
|     { | ||||
|         return of(simpleConditions, null, inverted, conditionOperator); | ||||
|     } | ||||
|  | ||||
|     private static CompositeCondition of(final List<SimpleCondition> simpleConditions, final List<CompositeCondition> compositeConditions, | ||||
|         final boolean inverted, final ConditionOperator conditionOperator) | ||||
|     { | ||||
|         if (CollectionUtils.isEmpty(simpleConditions) && CollectionUtils.isEmpty(compositeConditions)) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         return builder() | ||||
|             .inverted(inverted) | ||||
|             .booleanMode(conditionOperator) | ||||
|             .simpleConditions(simpleConditions) | ||||
|             .compositeConditions(compositeConditions) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     public boolean isInverted() | ||||
|     { | ||||
|         return inverted; | ||||
|     } | ||||
|  | ||||
|     public void setInverted(boolean inverted) | ||||
|     { | ||||
|         this.inverted = inverted; | ||||
|     } | ||||
|  | ||||
|     public String getBooleanMode() | ||||
|     { | ||||
|         if (booleanMode == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|         return booleanMode.name().toLowerCase(); | ||||
|     } | ||||
|  | ||||
|     public void setBooleanMode(ConditionOperator booleanMode) | ||||
|     { | ||||
|         this.booleanMode = booleanMode; | ||||
|     } | ||||
|  | ||||
|     public List<CompositeCondition> getCompositeConditions() | ||||
|     { | ||||
|         return compositeConditions; | ||||
|     } | ||||
|  | ||||
|     public void setCompositeConditions(List<CompositeCondition> compositeConditions) | ||||
|     { | ||||
|         this.compositeConditions = compositeConditions; | ||||
|     } | ||||
|  | ||||
|     public List<SimpleCondition> getSimpleConditions() | ||||
|     { | ||||
|         return simpleConditions; | ||||
|     } | ||||
|  | ||||
|     public void setSimpleConditions(List<SimpleCondition> simpleConditions) | ||||
|     { | ||||
|         this.simpleConditions = simpleConditions; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() | ||||
|     { | ||||
|         return "CompositeCondition{" + "inverted=" + inverted + ", booleanMode=" + booleanMode + ", compositeConditions=" + compositeConditions + ", simpleConditions=" | ||||
|             + simpleConditions + '}'; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object o) | ||||
|     { | ||||
|         if (this == o) | ||||
|             return true; | ||||
|         if (o == null || getClass() != o.getClass()) | ||||
|             return false; | ||||
|         CompositeCondition that = (CompositeCondition) o; | ||||
|         return inverted == that.inverted && booleanMode == that.booleanMode && Objects.equals(compositeConditions, that.compositeConditions) && Objects.equals( | ||||
|             simpleConditions, that.simpleConditions); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() | ||||
|     { | ||||
|         return Objects.hash(inverted, booleanMode, compositeConditions, simpleConditions); | ||||
|     } | ||||
|  | ||||
|     public static Builder builder() | ||||
|     { | ||||
|         return new Builder(); | ||||
|     } | ||||
|  | ||||
|     public static class Builder | ||||
|     { | ||||
|         private boolean inverted; | ||||
|         private ConditionOperator booleanMode = ConditionOperator.AND; | ||||
|         private List<CompositeCondition> compositeConditions; | ||||
|         private List<SimpleCondition> simpleConditions; | ||||
|  | ||||
|         public Builder inverted(boolean inverted) | ||||
|         { | ||||
|             this.inverted = inverted; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder booleanMode(ConditionOperator booleanMode) | ||||
|         { | ||||
|             this.booleanMode = booleanMode; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder compositeConditions(List<CompositeCondition> compositeConditions) | ||||
|         { | ||||
|             this.compositeConditions = compositeConditions; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder simpleConditions(List<SimpleCondition> simpleConditions) | ||||
|         { | ||||
|             this.simpleConditions = simpleConditions; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public CompositeCondition create() | ||||
|         { | ||||
|             final CompositeCondition condition = new CompositeCondition(); | ||||
|             condition.setInverted(inverted); | ||||
|             condition.setBooleanMode(booleanMode); | ||||
|             condition.setCompositeConditions(compositeConditions); | ||||
|             condition.setSimpleConditions(simpleConditions); | ||||
|             return condition; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import org.alfresco.service.Experimental; | ||||
|  | ||||
| @Experimental | ||||
| public enum ConditionOperator | ||||
| { | ||||
|     AND, OR | ||||
| } | ||||
| @@ -0,0 +1,362 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.alfresco.repo.action.executer.ScriptActionExecuter; | ||||
| import org.alfresco.rest.api.Nodes; | ||||
| import org.alfresco.rest.framework.resource.UniqueId; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.action.CompositeAction; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
|  | ||||
| @Experimental | ||||
| public class Rule | ||||
| { | ||||
|     private String id; | ||||
|     private String name; | ||||
|     private String description; | ||||
|     private boolean enabled; | ||||
|     private boolean cascade; | ||||
|     private boolean asynchronous; | ||||
|     private boolean shared; | ||||
|     private String errorScript; | ||||
|     private List<RuleTrigger> triggers; | ||||
|     private CompositeCondition conditions; | ||||
|     private List<Action> actions; | ||||
|  | ||||
|     /** | ||||
|      * Converts service POJO rule to REST model rule. | ||||
|      * | ||||
|      * @param ruleModel - {@link org.alfresco.service.cmr.rule.Rule} service POJO | ||||
|      * @return {@link Rule} REST model | ||||
|      */ | ||||
|     public static Rule from(final org.alfresco.service.cmr.rule.Rule ruleModel, final boolean shared) | ||||
|     { | ||||
|         if (ruleModel == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         final Rule.Builder builder = builder() | ||||
|             .name(ruleModel.getTitle()) | ||||
|             .description(ruleModel.getDescription()) | ||||
|             .enabled(!ruleModel.getRuleDisabled()) | ||||
|             .cascade(ruleModel.isAppliedToChildren()) | ||||
|             .asynchronous(ruleModel.getExecuteAsynchronously()) | ||||
|             .shared(shared); | ||||
|  | ||||
|         if (ruleModel.getNodeRef() != null) { | ||||
|             builder.id(ruleModel.getNodeRef().getId()); | ||||
|         } | ||||
|         if (ruleModel.getRuleTypes() != null) | ||||
|         { | ||||
|             builder.triggers(ruleModel.getRuleTypes().stream().map(RuleTrigger::of).collect(Collectors.toList())); | ||||
|         } | ||||
|         if (ruleModel.getAction() != null) | ||||
|         { | ||||
|             builder.conditions(CompositeCondition.from(ruleModel.getAction().getActionConditions())); | ||||
|             if (ruleModel.getAction().getCompensatingAction() != null && ruleModel.getAction().getCompensatingAction().getParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF) != null) | ||||
|             { | ||||
|                 builder.errorScript(ruleModel.getAction().getCompensatingAction().getParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF).toString()); | ||||
|             } | ||||
|             if (ruleModel.getAction() instanceof CompositeAction && ((CompositeAction) ruleModel.getAction()).getActions() != null) | ||||
|             { | ||||
|                 builder.actions(((CompositeAction) ruleModel.getAction()).getActions().stream().map(Action::from).collect(Collectors.toList())); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return builder.create(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Convert the REST model object to the equivalent service POJO. | ||||
|      * | ||||
|      * @param nodes The nodes API. | ||||
|      * @return The rule service POJO. | ||||
|      */ | ||||
|     public org.alfresco.service.cmr.rule.Rule toServiceModel(Nodes nodes) | ||||
|     { | ||||
|         final org.alfresco.service.cmr.rule.Rule ruleModel = new org.alfresco.service.cmr.rule.Rule(); | ||||
|         final NodeRef nodeRef = (id != null) ? nodes.validateOrLookupNode(id, null) : null; | ||||
|         ruleModel.setNodeRef(nodeRef); | ||||
|         ruleModel.setTitle(name); | ||||
|  | ||||
|         ruleModel.setAction(Action.toCompositeAction(actions)); | ||||
|  | ||||
|         return ruleModel; | ||||
|     } | ||||
|  | ||||
|     @UniqueId | ||||
|     public String getId() | ||||
|     { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public void setId(String id) | ||||
|     { | ||||
|         this.id = id; | ||||
|     } | ||||
|  | ||||
|     public String getName() | ||||
|     { | ||||
|         return name; | ||||
|     } | ||||
|  | ||||
|     public void setName(String name) | ||||
|     { | ||||
|         this.name = name; | ||||
|     } | ||||
|  | ||||
|     public String getDescription() | ||||
|     { | ||||
|         return description; | ||||
|     } | ||||
|  | ||||
|     public void setDescription(String description) | ||||
|     { | ||||
|         this.description = description; | ||||
|     } | ||||
|  | ||||
|     public boolean isEnabled() | ||||
|     { | ||||
|         return enabled; | ||||
|     } | ||||
|  | ||||
|     public void setEnabled(boolean enabled) | ||||
|     { | ||||
|         this.enabled = enabled; | ||||
|     } | ||||
|  | ||||
|     public boolean isCascade() | ||||
|     { | ||||
|         return cascade; | ||||
|     } | ||||
|  | ||||
|     public void setCascade(boolean cascade) | ||||
|     { | ||||
|         this.cascade = cascade; | ||||
|     } | ||||
|  | ||||
|     public boolean isAsynchronous() | ||||
|     { | ||||
|         return asynchronous; | ||||
|     } | ||||
|  | ||||
|     public void setAsynchronous(boolean asynchronous) | ||||
|     { | ||||
|         this.asynchronous = asynchronous; | ||||
|     } | ||||
|  | ||||
|     public String getErrorScript() | ||||
|     { | ||||
|         return errorScript; | ||||
|     } | ||||
|  | ||||
|     public void setErrorScript(String errorScript) | ||||
|     { | ||||
|         this.errorScript = errorScript; | ||||
|     } | ||||
|  | ||||
|     public boolean isShared() | ||||
|     { | ||||
|         return shared; | ||||
|     } | ||||
|  | ||||
|     public void setShared(boolean shared) | ||||
|     { | ||||
|         this.shared = shared; | ||||
|     } | ||||
|  | ||||
|     public List<String> getTriggers() | ||||
|     { | ||||
|         if (triggers == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|         return triggers.stream().map(RuleTrigger::getValue).collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     public void setTriggers(List<RuleTrigger> triggers) | ||||
|     { | ||||
|         this.triggers = triggers; | ||||
|     } | ||||
|  | ||||
|     public CompositeCondition getConditions() | ||||
|     { | ||||
|         return conditions; | ||||
|     } | ||||
|  | ||||
|     public void setConditions(CompositeCondition conditions) | ||||
|     { | ||||
|         this.conditions = conditions; | ||||
|     } | ||||
|  | ||||
|     public List<Action> getActions() | ||||
|     { | ||||
|         return actions; | ||||
|     } | ||||
|  | ||||
|     public void setActions(List<Action> actions) | ||||
|     { | ||||
|         this.actions = actions; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() | ||||
|     { | ||||
|         return "Rule{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", description='" + description + '\'' + ", enabled=" + enabled + ", cascade=" + cascade | ||||
|             + ", asynchronous=" + asynchronous + ", shared=" + shared + ", errorScript='" + errorScript + '\'' + ", triggers=" + triggers + ", conditions=" + conditions | ||||
|             + ", actions=" + actions + '}'; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object o) | ||||
|     { | ||||
|         if (this == o) | ||||
|             return true; | ||||
|         if (o == null || getClass() != o.getClass()) | ||||
|             return false; | ||||
|         Rule rule = (Rule) o; | ||||
|         return enabled == rule.enabled && cascade == rule.cascade && asynchronous == rule.asynchronous && shared == rule.shared && Objects.equals(id, rule.id) && Objects.equals( | ||||
|             name, rule.name) && Objects.equals(description, rule.description) && Objects.equals(errorScript, rule.errorScript) && Objects.equals(triggers, rule.triggers) | ||||
|             && Objects.equals(conditions, rule.conditions) && Objects.equals(actions, rule.actions); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() | ||||
|     { | ||||
|         return Objects.hash(id, name, description, enabled, cascade, asynchronous, shared, errorScript, triggers, conditions, actions); | ||||
|     } | ||||
|  | ||||
|     public static Builder builder() | ||||
|     { | ||||
|         return new Builder(); | ||||
|     } | ||||
|  | ||||
|     /** Builder class. */ | ||||
|     public static class Builder | ||||
|     { | ||||
|         private String id; | ||||
|         private String name; | ||||
|         private String description; | ||||
|         private boolean enabled; | ||||
|         private boolean cascade; | ||||
|         private boolean asynchronous; | ||||
|         private boolean shared; | ||||
|         private String errorScript; | ||||
|         private List<RuleTrigger> triggers; | ||||
|         private CompositeCondition conditions; | ||||
|         private List<Action> actions; | ||||
|  | ||||
|         public Builder id(String id) | ||||
|         { | ||||
|             this.id = id; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder name(String name) | ||||
|         { | ||||
|             this.name = name; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder description(String description) | ||||
|         { | ||||
|             this.description = description; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder enabled(boolean enabled) | ||||
|         { | ||||
|             this.enabled = enabled; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder cascade(boolean cascade) | ||||
|         { | ||||
|             this.cascade = cascade; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder asynchronous(boolean asynchronous) | ||||
|         { | ||||
|             this.asynchronous = asynchronous; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder shared(boolean shared) | ||||
|         { | ||||
|             this.shared = shared; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder errorScript(String errorScript) | ||||
|         { | ||||
|             this.errorScript = errorScript; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder triggers(List<RuleTrigger> triggers) | ||||
|         { | ||||
|             this.triggers = triggers; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder conditions(CompositeCondition conditions) | ||||
|         { | ||||
|             this.conditions = conditions; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder actions(List<Action> actions) | ||||
|         { | ||||
|             this.actions = actions; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Rule create() | ||||
|         { | ||||
|             Rule rule = new Rule(); | ||||
|             rule.setId(id); | ||||
|             rule.setName(name); | ||||
|             rule.setDescription(description); | ||||
|             rule.setEnabled(enabled); | ||||
|             rule.setCascade(cascade); | ||||
|             rule.setAsynchronous(asynchronous); | ||||
|             rule.setShared(shared); | ||||
|             rule.setErrorScript(errorScript); | ||||
|             rule.setTriggers(triggers); | ||||
|             rule.setConditions(conditions); | ||||
|             rule.setActions(actions); | ||||
|             return rule; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,110 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.alfresco.service.Experimental; | ||||
|  | ||||
| @Experimental | ||||
| public class RuleSet | ||||
| { | ||||
|     public static final String DEFAULT_ID = "-default-"; | ||||
|  | ||||
|     private String id; | ||||
|  | ||||
|     public static RuleSet of(String id) | ||||
|     { | ||||
|         return builder() | ||||
|             .id(id) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     public static boolean isNotDefaultId(final String id) { | ||||
|         return !isDefaultId(id); | ||||
|     } | ||||
|  | ||||
|     public static boolean isDefaultId(final String id) { | ||||
|         return DEFAULT_ID.equals(id); | ||||
|     } | ||||
|  | ||||
|     public String getId() | ||||
|     { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public void setId(String id) | ||||
|     { | ||||
|         this.id = id; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() | ||||
|     { | ||||
|         return "RuleSet{" + "id='" + id + '\'' + '}'; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object o) | ||||
|     { | ||||
|         if (this == o) | ||||
|             return true; | ||||
|         if (o == null || getClass() != o.getClass()) | ||||
|             return false; | ||||
|         RuleSet ruleSet = (RuleSet) o; | ||||
|         return Objects.equals(id, ruleSet.id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() | ||||
|     { | ||||
|         return Objects.hash(id); | ||||
|     } | ||||
|  | ||||
|     public static Builder builder() | ||||
|     { | ||||
|         return new Builder(); | ||||
|     } | ||||
|  | ||||
|     public static class Builder | ||||
|     { | ||||
|         private String id; | ||||
|  | ||||
|         public Builder id(String id) | ||||
|         { | ||||
|             this.id = id; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public RuleSet create() | ||||
|         { | ||||
|             final RuleSet ruleSet = new RuleSet(); | ||||
|             ruleSet.setId(id); | ||||
|             return ruleSet; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,61 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import org.alfresco.service.Experimental; | ||||
|  | ||||
| @Experimental | ||||
| public enum RuleTrigger | ||||
| { | ||||
|     INBOUND("inbound"), | ||||
|     UPDATE("update"), | ||||
|     OUTBOUND("outbound"); | ||||
|  | ||||
|     RuleTrigger(String value) | ||||
|     { | ||||
|         this.value = value; | ||||
|     } | ||||
|  | ||||
|     private final String value; | ||||
|  | ||||
|     public String getValue() | ||||
|     { | ||||
|         return value; | ||||
|     } | ||||
|  | ||||
|     public static RuleTrigger of(final String value) | ||||
|     { | ||||
|         for (RuleTrigger ruleTrigger : values()) | ||||
|         { | ||||
|             if (ruleTrigger.value.equals(value)) { | ||||
|                 return ruleTrigger; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return null; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,277 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.model.rules; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.HasAspectEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.HasChildEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.HasTagEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.HasVersionHistoryEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.InCategoryEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator; | ||||
| import org.alfresco.repo.action.evaluator.NoConditionEvaluator; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.service.cmr.action.ActionCondition; | ||||
| import org.apache.commons.collections.CollectionUtils; | ||||
|  | ||||
| @Experimental | ||||
| public class SimpleCondition | ||||
| { | ||||
|     private static final String COMPARATOR_EQUALS = "equals"; | ||||
|  | ||||
|     private String field; | ||||
|     private String comparator; | ||||
|     private String parameter; | ||||
|  | ||||
|     /** | ||||
|      * Converts list of service POJO action conditions to list of REST model simple conditions. | ||||
|      * | ||||
|      * @param actionConditions - list of {@link ActionCondition} service POJOs | ||||
|      * @return list of {@link SimpleCondition} REST models | ||||
|      */ | ||||
|     public static List<SimpleCondition> listOf(final List<ActionCondition> actionConditions) | ||||
|     { | ||||
|         if (CollectionUtils.isEmpty(actionConditions)) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         return actionConditions.stream() | ||||
|             .map(SimpleCondition::from) | ||||
|             .filter(Objects::nonNull) | ||||
|             .collect(Collectors.toList()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Creates simple condition REST model instance from service POJO action condition. | ||||
|      * | ||||
|      * @param actionCondition - {@link ActionCondition} service POJO | ||||
|      * @return {@link SimpleCondition} REST model | ||||
|      */ | ||||
|     public static SimpleCondition from(final ActionCondition actionCondition) | ||||
|     { | ||||
|         if (actionCondition == null || actionCondition.getActionConditionDefinitionName() == null || actionCondition.getParameterValues() == null) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         switch (actionCondition.getActionConditionDefinitionName()) | ||||
|         { | ||||
|         case ComparePropertyValueEvaluator.NAME: | ||||
|             return createComparePropertyValueCondition(actionCondition); | ||||
|         case CompareMimeTypeEvaluator.NAME: | ||||
|             return createCompareMimeTypeCondition(actionCondition); | ||||
|         case HasAspectEvaluator.NAME: | ||||
|             return createHasAspectCondition(actionCondition); | ||||
|         case HasChildEvaluator.NAME: | ||||
|             return createHasChildCondition(actionCondition); | ||||
|         case HasTagEvaluator.NAME: | ||||
|             return createHasTagCondition(actionCondition); | ||||
|         case HasVersionHistoryEvaluator.NAME: | ||||
|             return createHasVersionHistoryCondition(actionCondition); | ||||
|         case InCategoryEvaluator.NAME: | ||||
|             return createInCategoryCondition(actionCondition); | ||||
|         case IsSubTypeEvaluator.NAME: | ||||
|             return createIsSubtypeCondition(actionCondition); | ||||
|         case NoConditionEvaluator.NAME: | ||||
|         default: | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public String getField() | ||||
|     { | ||||
|         return field; | ||||
|     } | ||||
|  | ||||
|     public void setField(String field) | ||||
|     { | ||||
|         this.field = field; | ||||
|     } | ||||
|  | ||||
|     public String getComparator() | ||||
|     { | ||||
|         return comparator; | ||||
|     } | ||||
|  | ||||
|     public void setComparator(String comparator) | ||||
|     { | ||||
|         this.comparator = comparator; | ||||
|     } | ||||
|  | ||||
|     public String getParameter() | ||||
|     { | ||||
|         return parameter; | ||||
|     } | ||||
|  | ||||
|     public void setParameter(String parameter) | ||||
|     { | ||||
|         this.parameter = parameter; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String toString() | ||||
|     { | ||||
|         return "SimpleCondition{" + "field='" + field + '\'' + ", comparator='" + comparator + '\'' + ", parameter='" + parameter + '\'' + '}'; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(Object o) | ||||
|     { | ||||
|         if (this == o) | ||||
|             return true; | ||||
|         if (o == null || getClass() != o.getClass()) | ||||
|             return false; | ||||
|         SimpleCondition that = (SimpleCondition) o; | ||||
|         return Objects.equals(field, that.field) && Objects.equals(comparator, that.comparator) && Objects.equals(parameter, that.parameter); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() | ||||
|     { | ||||
|         return Objects.hash(field, comparator, parameter); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createComparePropertyValueCondition(final ActionCondition actionCondition) { | ||||
|         final SimpleCondition.Builder builder = builder(); | ||||
|         if (actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_CONTENT_PROPERTY) != null) | ||||
|         { | ||||
|             builder.field(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_CONTENT_PROPERTY).toString().toLowerCase()); | ||||
|         } else { | ||||
|             builder.field(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_PROPERTY).toString().toLowerCase()); | ||||
|         } | ||||
|         return builder | ||||
|             .comparator(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_OPERATION).toString().toLowerCase()) | ||||
|             .parameter(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_VALUE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createCompareMimeTypeCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_PROPERTY).toString().toLowerCase()) | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_VALUE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createHasAspectCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(HasAspectEvaluator.PARAM_ASPECT) | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(HasAspectEvaluator.PARAM_ASPECT).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createHasChildCondition(final ActionCondition actionCondition) { | ||||
|         final SimpleCondition.Builder builder = builder(); | ||||
|         if (actionCondition.getParameterValues().get(HasChildEvaluator.PARAM_ASSOC_TYPE) != null) | ||||
|         { | ||||
|             builder.field(actionCondition.getParameterValues().get(HasChildEvaluator.PARAM_ASSOC_TYPE).toString().toLowerCase()); | ||||
|         } else { | ||||
|             builder.field(actionCondition.getParameterValues().get(HasChildEvaluator.PARAM_ASSOC_NAME).toString().toLowerCase()); | ||||
|         } | ||||
|         return builder | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_VALUE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createHasTagCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(HasTagEvaluator.PARAM_TAG) | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(HasTagEvaluator.PARAM_TAG).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createHasVersionHistoryCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_PROPERTY).toString().toLowerCase()) | ||||
|             .comparator(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_OPERATION).toString().toLowerCase()) | ||||
|             .parameter(actionCondition.getParameterValues().get(ComparePropertyValueEvaluator.PARAM_VALUE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createInCategoryCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(actionCondition.getParameterValues().get(InCategoryEvaluator.PARAM_CATEGORY_ASPECT).toString().toLowerCase()) | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(InCategoryEvaluator.PARAM_CATEGORY_VALUE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     private static SimpleCondition createIsSubtypeCondition(final ActionCondition actionCondition) { | ||||
|         return builder() | ||||
|             .field(IsSubTypeEvaluator.PARAM_TYPE) | ||||
|             .comparator(COMPARATOR_EQUALS) | ||||
|             .parameter(actionCondition.getParameterValues().get(IsSubTypeEvaluator.PARAM_TYPE).toString()) | ||||
|             .create(); | ||||
|     } | ||||
|  | ||||
|     public static Builder builder() | ||||
|     { | ||||
|         return new Builder(); | ||||
|     } | ||||
|  | ||||
|     public static class Builder | ||||
|     { | ||||
|         private String field; | ||||
|         private String comparator; | ||||
|         private String parameter; | ||||
|  | ||||
|         public Builder field(String field) | ||||
|         { | ||||
|             this.field = field; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder comparator(String comparator) | ||||
|         { | ||||
|             this.comparator = comparator; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public Builder parameter(String parameter) | ||||
|         { | ||||
|             this.parameter = parameter; | ||||
|             return this; | ||||
|         } | ||||
|  | ||||
|         public SimpleCondition create() { | ||||
|             final SimpleCondition condition = new SimpleCondition(); | ||||
|             condition.setField(field); | ||||
|             condition.setComparator(comparator); | ||||
|             condition.setParameter(parameter); | ||||
|             return condition; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,109 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.nodes; | ||||
|  | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import org.alfresco.rest.api.RuleSets; | ||||
| import org.alfresco.rest.api.model.rules.RuleSet; | ||||
| import org.alfresco.rest.framework.WebApiDescription; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.RelationshipResource; | ||||
| import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Paging; | ||||
| import org.alfresco.rest.framework.resource.parameters.Parameters; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.util.PropertyCheck; | ||||
| import org.springframework.beans.factory.InitializingBean; | ||||
|  | ||||
| /** | ||||
|  * Folder node rule sets. | ||||
|  */ | ||||
| @Experimental | ||||
| @RelationshipResource(name = "rule-sets", entityResource = NodesEntityResource.class, title = "Folder node rule sets") | ||||
| public class NodeRuleSetsRelation implements RelationshipResourceAction.Read<RuleSet>, | ||||
|                                              RelationshipResourceAction.ReadById<RuleSet>, | ||||
|                                              InitializingBean | ||||
| { | ||||
|     private RuleSets ruleSets; | ||||
|  | ||||
|     @Override | ||||
|     public void afterPropertiesSet() throws Exception | ||||
|     { | ||||
|         PropertyCheck.mandatory(this, "ruleSets", ruleSets); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * List rule sets for given folder. | ||||
|      * <p> | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets | ||||
|      * | ||||
|      * @param folderNodeId The id of the folder node. | ||||
|      * @param parameters Contains paging information and information about which fields to include | ||||
|      * @return {@link CollectionWithPagingInfo} containing a page of rule sets | ||||
|      */ | ||||
|     @WebApiDescription ( | ||||
|             title = "Get rule sets for a folder", | ||||
|             description = "Returns a paged list of rule sets for given node", | ||||
|             successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<RuleSet> readAll(String folderNodeId, Parameters parameters) | ||||
|     { | ||||
|         return ruleSets.getRuleSets(folderNodeId, parameters.getInclude(), parameters.getPaging()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get single folder rule for given node's, rule set's and rule's IDs. | ||||
|      * <p> | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets/{ruleSetId} | ||||
|      * | ||||
|      * @param folderNodeId - entity resource context for this relationship | ||||
|      * @param ruleSetId - rule set node ID (associated with folder node) | ||||
|      * @param parameters Contains information about which fields to include | ||||
|      * @return {@link RuleSet} definition | ||||
|      * @throws RelationshipResourceNotFoundException in case resource was not found | ||||
|      */ | ||||
|     @WebApiDescription ( | ||||
|             title = "Get rule set", | ||||
|             description = "Returns a single rule set for the given node", | ||||
|             successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public RuleSet readById(String folderNodeId, String ruleSetId, Parameters parameters) throws RelationshipResourceNotFoundException | ||||
|     { | ||||
|         return ruleSets.getRuleSetById(folderNodeId, ruleSetId, parameters.getInclude()); | ||||
|     } | ||||
|  | ||||
|     public void setRuleSets(RuleSets ruleSets) | ||||
|     { | ||||
|         this.ruleSets = ruleSets; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,185 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
|  | ||||
| package org.alfresco.rest.api.nodes; | ||||
|  | ||||
| import org.alfresco.rest.api.Rules; | ||||
| import org.alfresco.rest.api.model.rules.Rule; | ||||
| import org.alfresco.rest.framework.WebApiDescription; | ||||
| import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; | ||||
| import org.alfresco.rest.framework.resource.RelationshipResource; | ||||
| import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction; | ||||
| import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; | ||||
| import org.alfresco.rest.framework.resource.parameters.Parameters; | ||||
| import org.alfresco.service.Experimental; | ||||
| import org.alfresco.util.PropertyCheck; | ||||
| import org.springframework.beans.factory.InitializingBean; | ||||
|  | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Folder node's rules. | ||||
|  * | ||||
|  */ | ||||
| @Experimental | ||||
| @RelationshipResource(name = "rules", entityResource = NodeRuleSetsRelation.class, title = "Folder node rules") | ||||
| public class NodeRulesRelation implements RelationshipResourceAction.Read<Rule>, | ||||
|                                           RelationshipResourceAction.ReadById<Rule>, | ||||
|                                           RelationshipResourceAction.Create<Rule>, | ||||
|                                           RelationshipResourceAction.Update<Rule>, | ||||
|                                           RelationshipResourceAction.Delete, | ||||
|                                           InitializingBean | ||||
| { | ||||
|  | ||||
|     private Rules rules; | ||||
|  | ||||
|     @Override | ||||
|     public void afterPropertiesSet() throws Exception | ||||
|     { | ||||
|         PropertyCheck.mandatory(this, "rules", this.rules); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * List folder rules for given folder node's and rule set's IDs as a page. | ||||
|      * | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets/{ruleSetId}/rules | ||||
|      * | ||||
|      * @param folderNodeId - entity resource context for this relationship | ||||
|      * @param parameters - will never be null. Contains i.a. paging information and ruleSetId (relationshipId) | ||||
|      * @return {@link CollectionWithPagingInfo} containing a page of folder rules | ||||
|      */ | ||||
|     @WebApiDescription( | ||||
|         title = "Get folder node rules", | ||||
|         description = "Returns a paged list of folder rules for given node's and rule set's IDs", | ||||
|         successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public CollectionWithPagingInfo<Rule> readAll(String folderNodeId, Parameters parameters) | ||||
|     { | ||||
|         final String ruleSetId = parameters.getRelationshipId(); | ||||
|  | ||||
|         return rules.getRules(folderNodeId, ruleSetId, parameters.getPaging()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get single folder rule for given node's, rule set's and rule's IDs. | ||||
|      * | ||||
|      * - GET /nodes/{folderNodeId}/rule-sets/{ruleSetId}/rules/{ruleId} | ||||
|      * | ||||
|      * @param folderNodeId - entity resource context for this relationship | ||||
|      * @param ruleSetId - rule set node ID (associated with folder node) | ||||
|      * @param parameters - will never be null. Contains i.a. ruleId (relationship2Id) | ||||
|      * @return {@link Rule} definition | ||||
|      * @throws RelationshipResourceNotFoundException in case resource was not found | ||||
|      */ | ||||
|     @WebApiDescription( | ||||
|         title="Get folder node rule", | ||||
|         description = "Returns a folder single rule definition for given node's, rule set's and rule's IDs", | ||||
|         successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public Rule readById(String folderNodeId, String ruleSetId, Parameters parameters) throws RelationshipResourceNotFoundException | ||||
|     { | ||||
|         final String ruleId = parameters.getRelationship2Id(); | ||||
|  | ||||
|         return rules.getRuleById(folderNodeId, ruleSetId, ruleId); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Create one or more rules inside a given folder and rule set. | ||||
|      * <p> | ||||
|      * POST /nodes/{folderNodeId}/rule-sets/{ruleSetId}/rules | ||||
|      * | ||||
|      * @param folderNodeId The folder in which to create the rule. | ||||
|      * @param ruleList The list of rules to create. | ||||
|      * @param parameters List of parameters including the rule set id as the relationship. | ||||
|      * @return The newly created rules. | ||||
|      */ | ||||
|     @WebApiDescription( | ||||
|             title = "Create folder rule", | ||||
|             description = "Creates one or more folder rules for the given folder and rule set", | ||||
|             successStatus = HttpServletResponse.SC_CREATED | ||||
|     ) | ||||
|     @Override | ||||
|     public List<Rule> create(String folderNodeId, List<Rule> ruleList, Parameters parameters) | ||||
|     { | ||||
|         final String ruleSetId = parameters.getRelationshipId(); | ||||
|  | ||||
|         return rules.createRules(folderNodeId, ruleSetId, ruleList); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Update the specified folder rule. | ||||
|      * <p> | ||||
|      * PUT /nodes/{folderNodeId}/rule-sets/{ruleSetId}/rules/{ruleId} | ||||
|      * | ||||
|      * @param folderNodeId The id of the folder containing the rule. | ||||
|      * @param rule The updated rule. | ||||
|      * @param parameters List of parameters including the rule set id and rule id. | ||||
|      * @return The updated rule. | ||||
|      * @throws RelationshipResourceNotFoundException in case resource was not found | ||||
|      */ | ||||
|     @WebApiDescription ( | ||||
|             title = "Update folder node rule", | ||||
|             description = "Update a single rule definition for given node's, rule set's and rule's IDs", | ||||
|             successStatus = HttpServletResponse.SC_OK | ||||
|     ) | ||||
|     @Override | ||||
|     public Rule update(String folderNodeId, Rule rule, Parameters parameters) | ||||
|     { | ||||
|         String ruleSetId = parameters.getRelationshipId(); | ||||
|         String ruleId = parameters.getRelationship2Id(); | ||||
|         return rules.updateRuleById(folderNodeId, ruleSetId, ruleId, rule); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Delete single folder rule for given node's, rule set's and rule's IDs. | ||||
|      * | ||||
|      * - DELETE /nodes/{folderNodeId}/rule-sets/{ruleSetId}/rules/{ruleId} | ||||
|      * | ||||
|      * @param folderNodeId - entity resource context for this relationship | ||||
|      * @param ruleSetId - rule set node ID (associated with folder node) | ||||
|      * @param parameters - Should not be null. Should contain at least ruleId (relationship2Id) | ||||
|      * @throws RelationshipResourceNotFoundException in case resource was not found | ||||
|      */ | ||||
|     @WebApiDescription( | ||||
|             title="Delete folder node rule", | ||||
|             description = "Deletes a single rule definition for given node's, rule set's and rule's IDs", | ||||
|             successStatus = HttpServletResponse.SC_NO_CONTENT | ||||
|     ) | ||||
|     @Override | ||||
|     public void delete(String folderNodeId, String ruleSetId, Parameters parameters) | ||||
|     { | ||||
|         final String ruleId = parameters.getRelationship2Id(); | ||||
|         rules.deleteRuleById(folderNodeId, ruleSetId, ruleId); | ||||
|     } | ||||
|  | ||||
|     public void setRules(Rules rules) | ||||
|     { | ||||
|         this.rules = rules; | ||||
|     } | ||||
| } | ||||
| @@ -121,8 +121,8 @@ public class ResourceLookupDictionary implements ResourceLocator | ||||
|                     return resource; | ||||
|                 } | ||||
|             } | ||||
|             logger.warn("Unable to locate resource resource for :"+entityResource+" "+relationResource==null?"":relationResource+" "+property==null?"":property); | ||||
|             throw new NotFoundException("Unable to locate resource resource for :"+entityResource+" "+(relationResource==null?"":relationResource+" "+property==null?"":property)); | ||||
|             logger.warn("Unable to locate resource for: "+entityResource+" "+relationResource==null ? "" : relationResource+" "+property==null ? "" : property); | ||||
|             throw new NotFoundException("Unable to locate resource for: "+entityResource+" "+(relationResource==null ? "" : relationResource+" "+property==null ? "" : property)); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
| @@ -160,8 +160,8 @@ public class ResourceLookupDictionary implements ResourceLocator | ||||
|                   return resource; | ||||
|               } | ||||
|           } | ||||
|           logger.warn("Unable to locate resource resource for :"+entityResource+" "+relationResource==null?"":relationResource); | ||||
|           throw new NotFoundException("Unable to locate resource resource for :"+entityResource+" "+(relationResource==null?"":relationResource)); | ||||
|           logger.warn("Unable to locate resource for: "+entityResource+" "+relationResource==null ? "" : relationResource); | ||||
|           throw new NotFoundException("Unable to locate resource for: "+entityResource+" "+relationResource==null ? "" : relationResource); | ||||
|         }  | ||||
|         else | ||||
|         { | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user