mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
275 Commits
17.24
...
hack/hacka
Author | SHA1 | Date | |
---|---|---|---|
|
cd8ef77b3e | ||
|
8622e0e102 | ||
|
69170dde35 | ||
|
c848024130 | ||
|
553f78bb1e | ||
|
9a3ceb21a8 | ||
|
57d0ff62dc | ||
|
42bd94c1da | ||
|
c5dd6538f8 | ||
|
152c036d86 | ||
|
f2055f91dc | ||
|
a1d7f0d479 | ||
|
8476f01b35 | ||
|
6c4b9e458a | ||
|
0f99dec012 | ||
|
06c7836e70 | ||
|
2ceb7384bf | ||
|
d848c83a57 | ||
|
be7572a978 | ||
|
ef45aaf9cc | ||
|
6f834909f6 | ||
|
b928598bd7 | ||
|
678eeab278 | ||
|
45f9bd6569 | ||
|
23b8c0e7a6 | ||
|
9c98f7b0fb | ||
|
6e1d5c81e2 | ||
|
092d895f6a | ||
|
a568c87571 | ||
|
3aac7be11c | ||
|
700fbce572 | ||
|
7be96e788b | ||
|
0af001be2a | ||
|
f38a36910f | ||
|
972f81ab8b | ||
|
1bd0dfd114 | ||
|
775de0e94c | ||
|
78d2ed247a | ||
|
5ca3630398 | ||
|
ee7383dcab | ||
|
36b3dc25c0 | ||
|
0b94042b6f | ||
|
27d3701c8b | ||
|
dc0102001f | ||
|
12bc363bcd | ||
|
2ab89f0d79 | ||
|
807e509859 | ||
|
403da286e8 | ||
|
cc3f8aaff4 | ||
|
be925ab67d | ||
|
de4ac000dd | ||
|
b2b866e0f9 | ||
|
984bc151af | ||
|
b057455cde | ||
|
40edaccd1a | ||
|
a802a17d92 | ||
|
332626421b | ||
|
1baf8d6fae | ||
|
4bae0f2060 | ||
|
0c017ac30c | ||
|
cc0940e519 | ||
|
0190b9060a | ||
|
596e964553 | ||
|
5d22e161d7 | ||
|
bb27430f6a | ||
|
1af879a7ed | ||
|
c029f5afa3 | ||
|
3b93814d76 | ||
|
656ecdc41d | ||
|
8150abf8b7 | ||
|
cab6fd6d2c | ||
|
e45211ad0f | ||
|
414cba0c1a | ||
|
75b74a5d77 | ||
|
d3efea8873 | ||
|
6c407b1ef5 | ||
|
f7dcbc6551 | ||
|
ed1ee00cee | ||
|
bba1664fef | ||
|
d675d58929 | ||
|
4f37b984be | ||
|
9d228add35 | ||
|
58d9d0b093 | ||
|
f8d66ec76d | ||
|
94a47d0368 | ||
|
8884cc9563 | ||
|
594f02e7cd | ||
|
cb29f1e9ec | ||
|
59816bd071 | ||
|
bb77023e1f | ||
|
fa7cb58044 | ||
|
4962ce1111 | ||
|
20a0bb7194 | ||
|
1e1bebd19c | ||
|
03dedb4140 | ||
|
66f6174b87 | ||
|
885f21ff86 | ||
|
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 |
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
|
||||
|
11
.github/workflows/hackathon.yml
vendored
Normal file
11
.github/workflows/hackathon.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: Hackathon
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
sleep:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: sleep 240
|
135
.travis.yml
135
.travis.yml
@@ -1,7 +1,7 @@
|
||||
---
|
||||
dist: focal
|
||||
language: java
|
||||
jdk: openjdk11
|
||||
jdk: openjdk17
|
||||
|
||||
services:
|
||||
- docker
|
||||
@@ -69,8 +69,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -78,16 +78,16 @@ jobs:
|
||||
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 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: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 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
|
||||
|
||||
@@ -95,8 +95,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -104,8 +104,8 @@ jobs:
|
||||
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 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' ')
|
||||
@@ -116,8 +116,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -125,8 +125,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -134,8 +134,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -143,8 +143,8 @@ jobs:
|
||||
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 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"
|
||||
@@ -152,7 +152,7 @@ jobs:
|
||||
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
|
||||
- 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"
|
||||
@@ -160,7 +160,7 @@ jobs:
|
||||
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
|
||||
- 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"
|
||||
@@ -168,7 +168,7 @@ jobs:
|
||||
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
|
||||
- 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"
|
||||
@@ -177,105 +177,56 @@ jobs:
|
||||
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
|
||||
- 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 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
|
||||
- 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 10.9 tests"
|
||||
- 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:10.9 postgres -c 'max_connections=300'
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
- 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 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"
|
||||
- name: "Repository - PostgreSQL 14.4 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\]/
|
||||
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: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
|
||||
- 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.16.1
|
||||
- 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: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 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: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 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
|
||||
|
||||
@@ -283,8 +234,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -292,8 +243,8 @@ jobs:
|
||||
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 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
|
||||
|
||||
@@ -301,8 +252,8 @@ jobs:
|
||||
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 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"
|
||||
@@ -382,7 +333,7 @@ jobs:
|
||||
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 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)"
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
@@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>1.7.35</version>
|
||||
<version>${dependency.slf4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -74,4 +74,27 @@ public class RecordFoldersAPI extends BaseAPI
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpResponse postFolderAction(String user, String password, JSONObject requestParams, String recordFolder) {
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
|
||||
try {
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
catch (Exception error) {
|
||||
LOGGER.error("Unable to extract response parameter", error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpResponse postRecordAction(String user, String password, JSONObject requestParams, String recordId) {
|
||||
try {
|
||||
requestParams.put("nodeRef", recordId);
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
catch (JSONException error) {
|
||||
LOGGER.error("Unable to extract response parameter", error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -53,9 +53,12 @@ import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -91,6 +94,7 @@ import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@@ -121,6 +125,8 @@ public class BaseRMRestTest extends RestTest
|
||||
@Getter(value = PROTECTED)
|
||||
private SearchAPI searchApi;
|
||||
|
||||
protected static final String iso8601_DateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
||||
|
||||
/**
|
||||
* Asserts the given status code
|
||||
*
|
||||
@@ -161,7 +167,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();
|
||||
@@ -628,8 +634,8 @@ public class BaseRMRestTest extends RestTest
|
||||
* Returns search results for the given search term
|
||||
*
|
||||
* @param user
|
||||
* @param term
|
||||
* @param query language
|
||||
* @param q
|
||||
* @param queryLanguage language
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -956,5 +962,34 @@ public class BaseRMRestTest extends RestTest
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Helper method to get the Previous Date in the YYYY-MM-ddTHH:mm:ss.SSSXXX format
|
||||
* @param previousDays number of previous days while calculating the date as output
|
||||
* @return previousDate as String in the ISO 8601 Date Format
|
||||
*/
|
||||
protected String getIso8601Date(int previousDays) {
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
Date previousDate = new Date(date.getTime() - previousDays);
|
||||
// Conversion
|
||||
SimpleDateFormat sdf= new SimpleDateFormat(iso8601_DateFormat);;
|
||||
sdf.setTimeZone(TimeZone.getDefault());
|
||||
return sdf.format(previousDate);
|
||||
}
|
||||
/**
|
||||
* Helper method to provide the Edited Disposition Date Json
|
||||
* The Edited Disposition Date is modified to previous date so that CUTOFF & DESTROY Steps will be enabled
|
||||
* @return JsonObject with the format {"name":"editDispositionActionAsOfDate","params":{"asOfDate":{"iso8601":"Previous Date"}}}
|
||||
*/
|
||||
protected JSONObject editDispositionDateJson() {
|
||||
JSONObject requestParams = new JSONObject();
|
||||
|
||||
requestParams.put("name","editDispositionActionAsOfDate");
|
||||
JSONObject params = new JSONObject();
|
||||
requestParams.put("params",params);
|
||||
|
||||
JSONObject asOfDate = new JSONObject();
|
||||
params.put("asOfDate",asOfDate);
|
||||
asOfDate.put("iso8601",getIso8601Date(1));
|
||||
return requestParams;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.rest.v0.service.RMAuditService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.DELETE_PERSON;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.LOGIN_SUCCESSFUL;
|
||||
import static org.alfresco.rest.rm.community.records.SearchRecordsTests.*;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.testng.AssertJUnit.assertTrue;
|
||||
|
||||
/**
|
||||
* Audit Access tests
|
||||
* @author Kavit Shah
|
||||
*/
|
||||
public class AuditAccessTests extends BaseRMRestTest {
|
||||
|
||||
private Optional<UserModel> deletedUser;
|
||||
private final String TEST_PREFIX = generateTestPrefix(AuditAccessTests.class);
|
||||
private static final String DELETE_USER_EVENT = "Delete User";
|
||||
private final String record1 = TEST_PREFIX + "RM-2967 uploaded record";
|
||||
private final String classifiedRecord = TEST_PREFIX + "RM-2967 classified record";
|
||||
private final String folderName = TEST_PREFIX + "RM-2967 folder";
|
||||
private final String categoryName = TEST_PREFIX + "RM-2967 category";
|
||||
private final String editedCategoryName = "edited " + categoryName;
|
||||
private final String editedFolderName = "edited " + folderName;
|
||||
private final String editedRecordName = "edited " + record1;
|
||||
private final String login_successfull = "Login Successful";
|
||||
private RecordCategory categoryAll;
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RecordsAPI recordsAPI;
|
||||
@Autowired
|
||||
private RMAuditService rmAuditService;
|
||||
|
||||
@Test(priority = 1)
|
||||
@AlfrescoTest(jira = "RM-2967")
|
||||
public void deleteRMUsersShowFullAuditTest() {
|
||||
|
||||
createTestPrecondition();
|
||||
updateCategoryMetadata();
|
||||
updateFolderMetadata();
|
||||
updateRecordMetadata();
|
||||
|
||||
// delete record category and folder with rm_admin_deleted
|
||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(deletedUser.get().getUsername(), deletedUser.get().getPassword(),
|
||||
RM_SITE_ID, editedFolderName);
|
||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(deletedUser.get().getUsername(), deletedUser.get().getPassword(),
|
||||
RM_SITE_ID, editedCategoryName);
|
||||
|
||||
// delete the user
|
||||
Optional.of(deletedUser).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
||||
|
||||
//check for RM-5235 fix
|
||||
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getDataUser().usingAdmin().getAdminUser(),
|
||||
DELETE_PERSON);
|
||||
|
||||
assertTrue("Delete user event not found in the audit log.", auditEntries.stream().anyMatch(
|
||||
auditEntry -> auditEntry.getEvent().equals(DELETE_USER_EVENT)));
|
||||
}
|
||||
|
||||
|
||||
@Test(priority = 2)
|
||||
public void filterEventsByLoginSuccessful()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getDataUser().usingAdmin().getAdminUser(),
|
||||
LOGIN_SUCCESSFUL);
|
||||
|
||||
assertFalse("Audit results should contain at least one Login Successful event",
|
||||
auditEntries.isEmpty());
|
||||
|
||||
assertTrue("Audit results contain only Login Successful events",
|
||||
auditEntries.stream()
|
||||
.allMatch(e -> e.getEvent().startsWith(LOGIN_SUCCESSFUL.toString()) || e.getEvent().startsWith(login_successfull)));
|
||||
}
|
||||
/**
|
||||
* Creates the required precondition for the test
|
||||
* <p/>
|
||||
* See Precondition in current class JavaDoc
|
||||
*/
|
||||
private void createTestPrecondition() {
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// create "rm deleted user" user if it does not exist and assign it to RM Administrator role
|
||||
createDeletedUser();
|
||||
|
||||
// create category and folder
|
||||
categoryAll = createCategoryIfDoesNotExist(categoryName,deletedUser.get());
|
||||
createRecordFolderInCategory(folderName,categoryAll,deletedUser.get());
|
||||
// upload an electronic record
|
||||
|
||||
recordsAPI.uploadElectronicRecord(deletedUser.get().getUsername(), deletedUser.get().getPassword(), getDefaultElectronicRecordProperties(record1), folderName, CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
// upload another electronic record and classify it
|
||||
recordsAPI.uploadElectronicRecord(deletedUser.get().getUsername(), deletedUser.get().getPassword(), getDefaultElectronicRecordProperties(classifiedRecord), folderName, CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
private void createDeletedUser() {
|
||||
// create Deleted User
|
||||
deletedUser = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
deletedUser.get().getUsername(),
|
||||
ADMIN
|
||||
);
|
||||
}
|
||||
|
||||
private void updateCategoryMetadata() {
|
||||
HashMap<BaseAPI.RMProperty, String> categoryProperties = new HashMap<>();
|
||||
categoryProperties.put(BaseAPI.RMProperty.NAME, editedCategoryName);
|
||||
categoryProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
||||
categoryProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
||||
|
||||
// edit some category's properties
|
||||
String categoryNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + categoryName);
|
||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), categoryNodeRef, categoryProperties);
|
||||
}
|
||||
|
||||
private void updateFolderMetadata() {
|
||||
HashMap<BaseAPI.RMProperty, String> folderProperties = new HashMap<>();
|
||||
folderProperties.put(BaseAPI.RMProperty.NAME, editedFolderName);
|
||||
folderProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
||||
folderProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
||||
|
||||
// edit some folder's properties
|
||||
String folderNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + editedCategoryName + "/" + folderName);
|
||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), folderNodeRef, folderProperties);
|
||||
}
|
||||
|
||||
private void updateRecordMetadata() {
|
||||
HashMap<BaseAPI.RMProperty, String> recordProperties = new HashMap<>();
|
||||
recordProperties.put(BaseAPI.RMProperty.NAME, editedRecordName);
|
||||
recordProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
||||
recordProperties.put(BaseAPI.RMProperty.AUTHOR, "edited author");
|
||||
recordProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
||||
|
||||
// edit some record's properties
|
||||
String recordName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), editedFolderName, record1);
|
||||
String recordNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + editedCategoryName + "/" + editedFolderName + "/" + recordName);
|
||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), recordNodeRef, recordProperties);
|
||||
}
|
||||
|
||||
|
||||
private RecordCategory createCategoryIfDoesNotExist(String CATEGORY_ALL, UserModel deletedUser) {
|
||||
return createRootCategory(deletedUser, CATEGORY_ALL);
|
||||
}
|
||||
|
||||
private RecordCategoryChild createRecordFolderInCategory(String FOLDER_SEARCH, RecordCategory recordCategory, UserModel deletedUser) {
|
||||
return createFolder(deletedUser, recordCategory.getId(), FOLDER_SEARCH);
|
||||
}
|
||||
|
||||
private Map<BaseAPI.RMProperty, String> getDefaultElectronicRecordProperties(String recordName) {
|
||||
Map<BaseAPI.RMProperty, String> defaultProperties = new HashMap<>();
|
||||
defaultProperties.put(BaseAPI.RMProperty.NAME, recordName);
|
||||
defaultProperties.put(BaseAPI.RMProperty.TITLE, TITLE);
|
||||
defaultProperties.put(BaseAPI.RMProperty.DESCRIPTION, DESCRIPTION);
|
||||
defaultProperties.put(BaseAPI.RMProperty.CONTENT, TEST_CONTENT);
|
||||
return defaultProperties;
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
public class BasicRulesIntegrationTests extends BaseRMRestTest {
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
private final static String title = "Rule to complete";
|
||||
private final static String description = "Rule to describe";
|
||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2794")
|
||||
public void basicRulesIntegration() {
|
||||
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
|
||||
STEP("Create record categories and record folders");
|
||||
RecordCategory Category = createRootCategory(getRandomName("recordCategory"));
|
||||
String recordFolder1 = createRecordFolder(Category.getId(), getRandomName("recFolder")).getId();
|
||||
|
||||
|
||||
//create a rule for completing a record
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.applyToChildren(true).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.COMPLETE_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + Category.getId(), ruleDefinition);
|
||||
|
||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||
|
||||
//create two electronic record in record folder
|
||||
String electronicRecordId1 = createElectronicRecord(recordFolder1, ELECTRONIC_RECORD_NAME).getId();
|
||||
String electronicRecordId2 = createElectronicRecord(recordFolder1, ELECTRONIC_RECORD_NAME).getId();
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
|
||||
// Update the rules for record Category
|
||||
rulesAPI.updateRule(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
||||
NODE_PREFIX + Category.getId(), ruleDefinition.description("description").id(description));
|
||||
|
||||
//Delete the root category and rules
|
||||
deleteRecordCategory(Category.getId());
|
||||
rulesAPI.deleteAllRulesOnContainer(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + Category.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
public class CreateCategoriesTests extends BaseRMRestTest {
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
private RecordCategory rootCategory;
|
||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private RecordCategory Category1;
|
||||
private RecordCategory Category2;
|
||||
private RecordCategory SubCategory1;
|
||||
private RecordCategory SubCategory2;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForCreateCategoriesTests()
|
||||
{
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
|
||||
STEP("Create two category");
|
||||
Category1 = createRootCategory(getRandomName("Category1"));
|
||||
|
||||
Category2= createRootCategory(getRandomName("Category2"));
|
||||
|
||||
STEP("Create Sub category");
|
||||
RecordCategoryChild subCategory1 = createRecordCategory(Category1.getId(), getRandomName("subCategory1"));
|
||||
RecordCategoryChild subCategory2 = createRecordCategory(Category2.getId(), getRandomName("subCategory2"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test @AlfrescoTest(jira = "RM-2756")
|
||||
public void createCategories() throws Exception {
|
||||
|
||||
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
||||
|
||||
STEP("copy category 1 to File Plan.");
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(Category1.getId())).copy(createBodyForMoveCopy(filePlan.getId()));
|
||||
|
||||
STEP("copy category 1 to category 2");
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(Category1.getId())).copy(createBodyForMoveCopy(Category2.getId()));
|
||||
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
||||
|
||||
|
||||
// Create the root record category
|
||||
RecordCategory Category1 = createRootCategory(categoryName, categoryTitle);
|
||||
|
||||
String newCategoryName = "Rename " + categoryName;
|
||||
|
||||
// Build the properties which will be updated
|
||||
RecordCategory recordCategoryUpdated = Category1.builder().name(newCategoryName).build();
|
||||
|
||||
// Update the record category
|
||||
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated,Category1.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(OK);
|
||||
|
||||
// verify renamed component and editTitle component still has this parent
|
||||
assertEquals(renamedRecordCategory.getParentId(), filePlan.getId());
|
||||
|
||||
STEP("move category 1 edited copy to File Plan");
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(renamedRecordCategory.getId())).move(createBodyForMoveCopy(filePlan.getId()));
|
||||
assertStatusCode(OK);
|
||||
|
||||
// delete All the categories
|
||||
deleteRecordCategory(Category1.getId());
|
||||
deleteRecordCategory(Category2.getId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
|
||||
public class CreateFoldersTests extends BaseRMRestTest {
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
|
||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private RecordCategory Category1;
|
||||
private RecordCategory Category2;
|
||||
private RecordCategoryChild recordCategoryChild;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForCreateFolderTests() {
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
|
||||
STEP("Create two category");
|
||||
Category1 = createRootCategory(getRandomName("Category1"));
|
||||
|
||||
Category2 = createRootCategory(getRandomName("Category2"));
|
||||
|
||||
// Create a record folder inside the category 1
|
||||
recordCategoryChild = createRecordFolder(Category1.getId(), getRandomName("recFolder"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2757")
|
||||
public void createFolders() throws Exception {
|
||||
|
||||
// Create record category first
|
||||
String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
|
||||
String folderName = "The folder name is updated" + getRandomAlphanumeric();
|
||||
String folderTitle = "Update title " + getRandomAlphanumeric();
|
||||
String location = "Location "+ getRandomAlphanumeric();
|
||||
|
||||
// Create the record folder properties to update
|
||||
RecordFolder recordFolder = RecordFolder.builder()
|
||||
.name(folderName)
|
||||
.properties(RecordFolderProperties.builder()
|
||||
.title(folderTitle)
|
||||
.description(folderDescription)
|
||||
.vitalRecordIndicator(true)
|
||||
.reviewPeriod(new ReviewPeriod("month","1"))
|
||||
.location(location)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
// Update the record folder
|
||||
RecordFolder updatedRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordCategoryChild.getId());
|
||||
|
||||
// Check the Response Status Code
|
||||
assertStatusCode(OK);
|
||||
|
||||
STEP("copy updated Record in category 1 and category 2");
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).copy(createBodyForMoveCopy(Category1.getId()));
|
||||
//assertStatusCode(OK);
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).copy(createBodyForMoveCopy(Category2.getId()));
|
||||
//assertStatusCode(OK);
|
||||
|
||||
|
||||
// Delete the Updated folder
|
||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||
String recordFolderId = updatedRecordFolder.getId();
|
||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
||||
|
||||
// Check the response status code
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
// Check the record folder is not found
|
||||
recordFolderAPI.getRecordFolder(recordFolderId);
|
||||
|
||||
// Check the response status code
|
||||
assertStatusCode(NOT_FOUND);
|
||||
|
||||
STEP("move updated Record from category 1 to category 2");
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).move(createBodyForMoveCopy(Category2.getId()));
|
||||
|
||||
// move category 2 to category 1
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(Category2.getId())).move(createBodyForMoveCopy(Category1.getId()));
|
||||
|
||||
// Delete the record category
|
||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||
String recordCategoryId = Category1.getId();
|
||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
public class DeclareDocsAsRecordsOnUpdateRuleNewVersionTests extends BaseRMRestTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
private DataSite dataSite;
|
||||
private SiteModel publicSite;
|
||||
private RecordCategory recordCategory;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
@Autowired
|
||||
@Getter(value = PROTECTED)
|
||||
protected DataUserAIS dataUser;
|
||||
private final static String title = "Rule to convert document as record";
|
||||
|
||||
@BeforeClass (alwaysRun = true)
|
||||
public void setUp()
|
||||
{
|
||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-1521")
|
||||
public void declareDocsAsRecordsOnUpdateRuleNewVersion() {
|
||||
FolderModel testFolder;
|
||||
|
||||
STEP("Create test collaboration site to store documents in.");
|
||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
|
||||
STEP("Create a record folder with a DECLARE_AS_RECORD");
|
||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||
|
||||
STEP("Create a document in the collaboration site");
|
||||
FileModel testFile = dataContent.usingSite(publicSite)
|
||||
.usingAdmin()
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
// verify the declared record is in Unfilled Records folder
|
||||
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(e -> e.getEntry().getId().equals(testFile.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//delete rm items
|
||||
deleteRecordCategory(recordCategory.getId());
|
||||
STEP("Delete the record.");
|
||||
//delete created collaboration site
|
||||
dataSite.deleteSite(publicSite);
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.v0.RecordCategoriesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class FileAsRecordTests extends BaseRMRestTest {
|
||||
|
||||
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String CATEGORY_ADMIN = "catAdmin" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||
|
||||
private UserModel nonRMuser,rmManager;
|
||||
private SiteModel testSite;
|
||||
private FileModel document, documentDeclared;
|
||||
private RecordCategory category_manager, category_admin;
|
||||
private RecordCategoryChild folder_admin, folder_manager ;
|
||||
@Autowired
|
||||
private DataSite dataSite;
|
||||
@Autowired
|
||||
private DataContent dataContent;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private RecordCategoriesAPI recordCategoriesAPI;
|
||||
/**
|
||||
* Create preconditions:
|
||||
* <pre>
|
||||
* 1. RM site is created
|
||||
* 2. Two users: user without RM role and a user with RM manager role
|
||||
* 3. Two Record categories with one folder each
|
||||
* 4. User with RM MANAGER role has Filling permission over one category
|
||||
* </pre>
|
||||
*/
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForFileAsRecordRecordTests()
|
||||
{
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create a user");
|
||||
nonRMuser = dataUser.createRandomTestUser("testUser");
|
||||
|
||||
STEP("Create a collaboration site");
|
||||
testSite = dataSite.usingUser(nonRMuser).createPublicRandomSite();
|
||||
|
||||
STEP("Create a document with the user without RM role");
|
||||
document = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMuser)
|
||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
STEP("Create two categories with two folders");
|
||||
category_manager = createRootCategory(CATEGORY_MANAGER);
|
||||
category_admin = createRootCategory(CATEGORY_ADMIN);
|
||||
folder_admin = createFolder(category_admin.getId(),FOLDER_ADMIN);
|
||||
folder_manager = createFolder(category_manager.getId(),FOLDER_MANAGER);
|
||||
|
||||
STEP("Create an rm user and give filling permission over CATEGORY_MANAGER record category");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId())
|
||||
.build();
|
||||
rmManager = roleService.createCollaboratorWithRMRoleAndPermission(testSite, recordCategory,
|
||||
UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have selected the record folder I want to file my declared record to
|
||||
* When I confirm the action
|
||||
* Then the dialog closes
|
||||
* And the document is now shown as a record in the collaboration site
|
||||
* And if I navigated to the record folder, as any user who had the right permissions, then I would see the
|
||||
* record filed
|
||||
*/
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-6780")
|
||||
public void checkFileAsRecordToRecordFolder() throws Exception {
|
||||
|
||||
AtomicReference<RecordFolderCollection> apiChildren = new AtomicReference<>();
|
||||
STEP("Create a document with the user with RM role");
|
||||
documentDeclared = dataContent.usingSite(testSite).usingUser(rmManager)
|
||||
.createContent(new FileModel("checkDeclareAndFileToRecordFolder", FileType.TEXT_PLAIN));
|
||||
|
||||
STEP("Declare and file into a record folder the document uploaded");
|
||||
|
||||
getRestAPIFactory().getActionsAPI(rmManager).declareAndFile(documentDeclared,
|
||||
Utility.buildPath(CATEGORY_MANAGER, FOLDER_MANAGER));
|
||||
|
||||
STEP("Check the file is a record within the collaboration site");
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 40000, () ->
|
||||
{
|
||||
JSONObject collaboratorSearchJson = getSearchApi().liveSearchForDocuments(rmManager.getUsername(),
|
||||
rmManager.getPassword(),
|
||||
documentDeclared.getName());
|
||||
assertTrue("Rm Manager not able to find the document.", collaboratorSearchJson.getJSONArray("items").length() != 0);
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
STEP("Check the record is filed into the record folder.");
|
||||
// Get children from API
|
||||
// List children from API
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 40000, () ->
|
||||
{
|
||||
apiChildren.set((RecordFolderCollection) getRestAPIFactory()
|
||||
.getRecordFolderAPI(rmManager).getRecordFolderChildren(folder_manager.getId(), "include=properties")
|
||||
.assertThat().entriesListIsNotEmpty().assertThat().entriesListIsNotEmpty());
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
assertEquals(apiChildren.get()
|
||||
.getEntries()
|
||||
.get(0)
|
||||
.getEntry()
|
||||
.getProperties()
|
||||
.getOriginalName(),documentDeclared.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have selected the "File As Record" action
|
||||
* When I confirm the action without selecting a location to file to
|
||||
* Then the record is declared in the unfiled folder
|
||||
*/
|
||||
@Test
|
||||
@AlfrescoTest (jira = "RM-6780")
|
||||
public void fileAsRecordToUnfiledRecordFolder() throws Exception {
|
||||
STEP("Create a document with the user without RM role");
|
||||
FileModel inplaceRecord = dataContent.usingSite(testSite).usingUser(rmManager)
|
||||
.createContent(new FileModel("declareAndFileToIntoUnfiledRecordFolder",
|
||||
FileType.TEXT_PLAIN));
|
||||
|
||||
STEP("Click on Declare and file without selecting a record folder");
|
||||
getRestAPIFactory().getActionsAPI(rmManager).declareAndFile(inplaceRecord,"");
|
||||
|
||||
STEP("Check the file is declared in unfiled record folder");
|
||||
Assert.assertTrue(isMatchingRecordInUnfiledRecords(inplaceRecord), "Record should be filed to Unfiled Records folder");
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanUpForFileAsRecordRecordTests() {
|
||||
STEP("Delete the collaboration site");
|
||||
dataSite.usingUser(nonRMuser).deleteSite(testSite);
|
||||
|
||||
STEP("Empty the trashcan.");
|
||||
restClient.authenticateUser(nonRMuser).withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(toContentModel(testSite.getId()));
|
||||
|
||||
getRestAPIFactory()
|
||||
.getUnfiledContainersAPI(rmManager)
|
||||
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
.getEntries()
|
||||
.stream()
|
||||
.forEach(x -> getRestAPIFactory()
|
||||
.getRecordsAPI()
|
||||
.deleteRecord(x.getEntry().getId()));
|
||||
|
||||
STEP("Cleanup Documents inside folders");
|
||||
|
||||
STEP("Delete folders");
|
||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(folder_admin.getId());
|
||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(folder_manager.getId());
|
||||
|
||||
STEP("Delete categories");
|
||||
recordCategoriesAPI.deleteCategory(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), category_manager.getName());
|
||||
recordCategoriesAPI.deleteCategory(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), category_admin.getName());
|
||||
|
||||
STEP("Delete Users");
|
||||
dataUser.deleteUser(nonRMuser);
|
||||
dataUser.deleteUser(rmManager);
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
public class FoldersDispositionScheduleTests extends BaseRMRestTest {
|
||||
|
||||
private RecordCategory Category1;
|
||||
@Autowired
|
||||
private DispositionScheduleService dispositionScheduleService;
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
private final String TEST_PREFIX = generateTestPrefix(FoldersDispositionScheduleTests.class);
|
||||
private final String folderDisposition = TEST_PREFIX + "RM-2937 folder ghosting";
|
||||
private final String electronicRecord = "RM-2937 electronic 2 record";
|
||||
private final String nonElectronicRecord = "RM-2937 non-electronic record";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
private void setUp(){
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create record category");
|
||||
Category1 = createRootCategory(getRandomName("Title"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest (jira = "RM-2937")
|
||||
public void foldersDispositionScheduleWithGhosting() {
|
||||
|
||||
//create retention schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
|
||||
// add destroy step with ghosting
|
||||
dispositionScheduleService.addDestroyWithGhostingImmediatelyAfterCutOff(Category1.getName());
|
||||
|
||||
//create folders
|
||||
RecordCategoryChild FOLDER_DESTROY = createFolder(getAdminUser(),Category1.getId(),folderDisposition);
|
||||
|
||||
Record elRecord = createElectronicRecord(FOLDER_DESTROY.getId(),electronicRecord);
|
||||
Record nonElRecord = createNonElectronicRecord(FOLDER_DESTROY.getId(),nonElectronicRecord);
|
||||
|
||||
// complete records
|
||||
completeRecord(elRecord.getId());
|
||||
completeRecord(nonElRecord.getId());
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),FOLDER_DESTROY.getName());
|
||||
|
||||
// cut off the FOLDER_DESTROY
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),FOLDER_DESTROY.getName());
|
||||
|
||||
// Destroy the FOLDER_DESTROY
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),FOLDER_DESTROY.getName());
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun = true)
|
||||
private void deletePreconditions() {
|
||||
deleteRecordCategory(Category1.getId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
|
||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
public class FoldersDispositionScheduleWithoutGhostRecordTests extends BaseRMRestTest {
|
||||
|
||||
private RecordCategory Category1;
|
||||
@Autowired
|
||||
private DispositionScheduleService dispositionScheduleService;
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
private final String TEST_PREFIX = generateTestPrefix(FoldersDispositionScheduleWithoutGhostRecordTests.class);
|
||||
private final String folderDisposition = TEST_PREFIX + "RM-2937 folder ghosting";
|
||||
private final String electronicRecord = "RM-2937 electronic 2 record";
|
||||
private final String nonElectronicRecord = "RM-2937 non-electronic record";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
private void setUp(){
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create record category");
|
||||
Category1 = createRootCategory(getRandomName("Title"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira="RM-2937")
|
||||
public void foldersDispositionScheduleWithoutGhosting() {
|
||||
|
||||
//create retention schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
|
||||
// add destroy step with ghosting
|
||||
dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(Category1.getName(), "day|1", CUT_OFF_DATE);
|
||||
|
||||
//create folders
|
||||
RecordCategoryChild FOLDER_DESTROY = createFolder(getAdminUser(),Category1.getId(),folderDisposition);
|
||||
|
||||
Record elRecord = createElectronicRecord(FOLDER_DESTROY.getId(),electronicRecord);
|
||||
Record nonElRecord = createNonElectronicRecord(FOLDER_DESTROY.getId(),nonElectronicRecord);
|
||||
|
||||
// complete records
|
||||
completeRecord(elRecord.getId());
|
||||
completeRecord(nonElRecord.getId());
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),FOLDER_DESTROY.getName());
|
||||
|
||||
// cut off the FOLDER_DESTROY
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),FOLDER_DESTROY.getName());
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),FOLDER_DESTROY.getName());
|
||||
|
||||
Utility.waitToLoopTime(5,"Waiting for Edit Disposition to be processed");
|
||||
|
||||
// Destroy the FOLDER_DESTROY
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),FOLDER_DESTROY.getName());
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun = true)
|
||||
private void deletePreconditions() {
|
||||
deleteRecordCategory(Category1.getId());
|
||||
}
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.core.v0.RMEvents;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
|
||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
/**
|
||||
* Contains recordsDispositionScheduleWithoutGhosting test which checks disposition schedule cut off, transfer and destroy without maintaining metadata steps applied to records
|
||||
* <p/>
|
||||
* Precondition:
|
||||
* <p/>
|
||||
* RM site created, contains an empty category "RM-2801 disposition for records". <p/>
|
||||
* RM user has RM admin role. <p/>
|
||||
* A transfer location named "transferred files" is created to which RM user has access
|
||||
* <p/>
|
||||
* <img src="doc-files/Disposition Schedule without ghosting.png" alt="Records Disposition Schedule without ghosting" />
|
||||
*
|
||||
* @author Kavit Shah
|
||||
*/
|
||||
|
||||
public class RecordsDispositionScheduleTests extends BaseRMRestTest {
|
||||
|
||||
/** data prep 6services */
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RecordsAPI recordsAPI;
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
@Autowired
|
||||
private DispositionScheduleService dispositionScheduleService;
|
||||
private RecordCategory Category1;
|
||||
private final String TEST_PREFIX = generateTestPrefix(RecordsDispositionScheduleTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private final String recordsCategory = TEST_PREFIX + "RM-2801 category";
|
||||
private final String folderDisposition = TEST_PREFIX + "RM-2801 folder";
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira="RM-2801")
|
||||
public void recordsDispositionScheduleWithoutGhosting() {
|
||||
|
||||
// create test precondition
|
||||
createTestPrecondition(recordsCategory);
|
||||
|
||||
// create disposition schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), true);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffImmediatelyStep(Category1.getName());
|
||||
|
||||
// add transfer step
|
||||
dispositionScheduleService.addTransferAfterEventStep(Category1.getName(),"transferred records","all_allowances_granted_are_terminated");
|
||||
|
||||
// add destroy step without retaining metadata
|
||||
dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(Category1.getName(), "day|1", CUT_OFF_DATE);
|
||||
|
||||
// create a folder and an electronic and a non-electronic record in it
|
||||
RecordCategoryChild FOLDER_DESTROY = createFolder(getAdminUser(),Category1.getId(),folderDisposition);
|
||||
|
||||
String electronicRecord = "RM-2801 electronic record";
|
||||
Record elRecord = createElectronicRecord(FOLDER_DESTROY.getId(), electronicRecord);
|
||||
String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
Record nonElRecord = createNonElectronicRecord(FOLDER_DESTROY.getId(), nonElectronicRecord);
|
||||
|
||||
// complete records and cut them off
|
||||
String nonElRecordName = recordsAPI.getRecordFullName(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), folderDisposition, nonElectronicRecord);
|
||||
String elRecordName = recordsAPI.getRecordFullName(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), folderDisposition, electronicRecord);
|
||||
|
||||
// complete records and cut them off
|
||||
completeRecord(elRecord.getId());
|
||||
completeRecord(nonElRecord.getId());
|
||||
|
||||
String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordName, "/" + Category1.getName() + "/" + folderDisposition);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
|
||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordName, "/" + Category1.getName() + "/" + folderDisposition);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
|
||||
// ensure the complete event action is displayed for both events
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), nonElRecordName, RMEvents.ALL_ALLOWANCES_GRANTED_ARE_TERMINATED, Instant.now());
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), elRecordName, RMEvents.ALL_ALLOWANCES_GRANTED_ARE_TERMINATED, Instant.now());
|
||||
|
||||
// Create and Complete transfer
|
||||
HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordName, "/" + Category1.getName() + "/" + folderDisposition));
|
||||
|
||||
String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
|
||||
HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordName, "/" + Category1.getName() + "/" + folderDisposition));
|
||||
|
||||
String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
|
||||
// edit the disposition schedule date to current date
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
|
||||
Utility.waitToLoopTime(5,"Waiting for Edit Disposition to be processed");
|
||||
|
||||
// destroy records
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
|
||||
// delete category
|
||||
deleteRecordCategory(Category1.getId());
|
||||
}
|
||||
|
||||
private void createTestPrecondition(String categoryName) {
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// create "rm admin" user if it does not exist and assign it to RM Administrator role
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
RM_ADMIN, DEFAULT_PASSWORD, "Administrator");
|
||||
|
||||
// create category
|
||||
STEP("Create two category");
|
||||
Category1 = createRootCategory(categoryName,"Title");
|
||||
}
|
||||
|
||||
private String getTransferId(HttpResponse httpResponse,String nodeRef) {
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
String responseString = null;
|
||||
try {
|
||||
responseString = EntityUtils.toString(entity, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject result = new JSONObject(responseString);
|
||||
return result
|
||||
.getJSONObject("results")
|
||||
.get(nodeRef)
|
||||
.toString();
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
import org.alfresco.rest.core.v0.RMEvents;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
/**
|
||||
* Contains recordsDispositionScheduleWithGhosting test which checks disposition schedule cut off, transfer and destroy with maintaining record metadata steps applied to records
|
||||
* <p/>
|
||||
* Precondition:
|
||||
* <p/>
|
||||
* RM site created, contains an empty category "RM-2937 disposition for records with ghosting". <p/>
|
||||
* RM user has RM admin role. <p/>
|
||||
* A transfer location named "transferred files with ghosting" is created to which RM user has access
|
||||
* <p/>
|
||||
* <img src="doc-files/Disposition Schedule with ghosting.png" alt="Records Disposition Schedule with ghosting" />
|
||||
*
|
||||
* @author Kavit Shah
|
||||
*/
|
||||
public class RecordsDispositionScheduleWithGhostingTests extends BaseRMRestTest {
|
||||
|
||||
/** data prep 6services */
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RecordsAPI recordsAPI;
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
@Autowired
|
||||
private DispositionScheduleService dispositionScheduleService;
|
||||
private RecordCategory Category1;
|
||||
private final String TEST_PREFIX = generateTestPrefix(RecordsDispositionScheduleTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private final String recordsCategory = TEST_PREFIX + "RM-2801 category";
|
||||
private final String folderDisposition = TEST_PREFIX + "RM-2801 folder";
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira="RM-2801")
|
||||
public void recordsDispositionScheduleWithGhosting() {
|
||||
|
||||
// create test precondition
|
||||
createTestPrecondition(recordsCategory);
|
||||
|
||||
// create disposition schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), true);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffImmediatelyStep(Category1.getName());
|
||||
|
||||
// add transfer step
|
||||
dispositionScheduleService.addTransferAfterEventStep(Category1.getName(),"transferred records","all_allowances_granted_are_terminated");
|
||||
|
||||
// add destroy step without retaining metadata
|
||||
dispositionScheduleService.addDestroyWithGhostingImmediatelyAfterCutOff(Category1.getName());
|
||||
|
||||
// create a folder and an electronic and a non-electronic record in it
|
||||
RecordCategoryChild FOLDER_DESTROY = createFolder(getAdminUser(),Category1.getId(),folderDisposition);
|
||||
|
||||
String electronicRecord = "RM-2801 electronic record";
|
||||
Record elRecord = createElectronicRecord(FOLDER_DESTROY.getId(), electronicRecord);
|
||||
String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
Record nonElRecord = createNonElectronicRecord(FOLDER_DESTROY.getId(), nonElectronicRecord);
|
||||
|
||||
// complete records and cut them off
|
||||
String nonElRecordName = recordsAPI.getRecordFullName(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), folderDisposition, nonElectronicRecord);
|
||||
String elRecordName = recordsAPI.getRecordFullName(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), folderDisposition, electronicRecord);
|
||||
|
||||
// complete records and cut them off
|
||||
completeRecord(elRecord.getId());
|
||||
completeRecord(nonElRecord.getId());
|
||||
|
||||
String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordName, "/" + Category1.getName() + "/" + folderDisposition);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
|
||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordName, "/" + Category1.getName() + "/" + folderDisposition);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
|
||||
// ensure the complete event action is displayed for both events
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), nonElRecordName, RMEvents.ALL_ALLOWANCES_GRANTED_ARE_TERMINATED, Instant.now());
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), elRecordName, RMEvents.ALL_ALLOWANCES_GRANTED_ARE_TERMINATED, Instant.now());
|
||||
|
||||
// Create and Complete transfer
|
||||
HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordName, "/" + Category1.getName() + "/" + folderDisposition));
|
||||
|
||||
String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
|
||||
HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordName, "/" + Category1.getName() + "/" + folderDisposition));
|
||||
|
||||
String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
|
||||
// edit the disposition schedule date to current date
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
|
||||
Utility.waitToLoopTime(5,"Waiting for Edit Disposition to be processed");
|
||||
|
||||
// destroy records
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
|
||||
// delete category
|
||||
deleteRecordCategory(Category1.getId());
|
||||
}
|
||||
|
||||
private void createTestPrecondition(String categoryName) {
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
// create "rm admin" user if it does not exist and assign it to RM Administrator role
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
RM_ADMIN, DEFAULT_PASSWORD, "Administrator");
|
||||
|
||||
// create category
|
||||
STEP("Create two category");
|
||||
Category1 = createRootCategory(categoryName,"Title");
|
||||
}
|
||||
|
||||
private String getTransferId(HttpResponse httpResponse,String nodeRef) {
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
String responseString = null;
|
||||
try {
|
||||
responseString = EntityUtils.toString(entity, "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
JSONObject result = new JSONObject(responseString);
|
||||
return result
|
||||
.getJSONObject("results")
|
||||
.get(nodeRef)
|
||||
.toString();
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.smoke;
|
||||
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.record.RecordContent;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.*;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
public class UnfiledRecordsRuleTests extends BaseRMRestTest {
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private RecordCategory Category2;
|
||||
private RecordCategoryChild Folder2;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2794")
|
||||
public void unfiledRecordsRule() {
|
||||
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
|
||||
STEP("Create record categories and record folders");
|
||||
Category2 = createRootCategory(getRandomName("recordCategory"));
|
||||
Folder2 = createFolder(Category2.getId(), getRandomName("recordFolder"));
|
||||
|
||||
STEP("Get the unfiled records container");
|
||||
UnfiledContainer container = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
|
||||
// Check the response code
|
||||
assertStatusCode(OK);
|
||||
|
||||
//create a rule
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.FILE_TO.getActionValue()));
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + container.getId(), ruleDefinition);
|
||||
|
||||
//upload an electronic record
|
||||
UnfiledContainerChild electronicRecord = UnfiledContainerChild.builder()
|
||||
.name(ELECTRONIC_RECORD_NAME)
|
||||
.nodeType(CONTENT_TYPE)
|
||||
.content(RecordContent.builder().mimeType("text/plain").build())
|
||||
.build();
|
||||
assertStatusCode(OK);
|
||||
|
||||
|
||||
// create a non-electronic record
|
||||
UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder()
|
||||
.properties(UnfiledContainerChildProperties.builder()
|
||||
.description(NONELECTRONIC_RECORD_NAME)
|
||||
.title("Title")
|
||||
.build())
|
||||
.name(NONELECTRONIC_RECORD_NAME)
|
||||
.nodeType(NON_ELECTRONIC_RECORD_TYPE)
|
||||
.build();
|
||||
assertStatusCode(OK);
|
||||
|
||||
//delete the record created, delete the rule from UnfilledRecord page, delete the category created
|
||||
rulesAPI.deleteAllRulesOnContainer(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + container.getId());
|
||||
deleteRecordCategory(Category2.getId());
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005 - 2020 Alfresco Software Limited.
|
||||
* Copyright 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.
|
||||
@@ -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.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -134,7 +134,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<version>6.2.8</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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-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.24</version>
|
||||
<version>17.102-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,395 @@
|
||||
/*
|
||||
* #%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.*;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteConsumer;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteContributor;
|
||||
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
||||
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.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||
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 static final String IGNORE_ID = "id";
|
||||
private static final String IGNORE_IS_SHARED = "isShared";
|
||||
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.
|
||||
* <p>
|
||||
* Also check that the isShared field is not returned when not requested.
|
||||
*/
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void createRule()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithModifiedValues();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
|
||||
expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions()));
|
||||
expectedRuleModel.setConditions(createEmptyConditionModel());
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED)
|
||||
.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
|
||||
/** 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 = createRuleModel("");
|
||||
|
||||
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 = createRuleModel("");
|
||||
// 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");
|
||||
}
|
||||
|
||||
/** Check we can create a rule without description. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createRuleWithoutDescription()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("name").is(RULE_NAME_DEFAULT)
|
||||
.assertThat().field("description").isNull();
|
||||
}
|
||||
|
||||
/** Check we can create a rule without specifying triggers but with the default "inbound" value. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createRuleWithoutTriggers()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("name").is(RULE_NAME_DEFAULT)
|
||||
.assertThat().field("triggers").is(List.of("inbound"));
|
||||
}
|
||||
|
||||
/** Check we can create a rule without error script. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createRuleWithoutErrorScript()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("name").is(RULE_NAME_DEFAULT)
|
||||
.assertThat().field("errorScript").isNull();
|
||||
}
|
||||
|
||||
/** Check we can create a rule with irrelevant isShared flag, and it doesn't have impact to the process. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void createRuleWithSharedFlag()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setIsShared(true);
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("name").is(RULE_NAME_DEFAULT)
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
|
||||
/** Check we can create a rule. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void createRuleAndIncludeFieldsInResponse()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().field("isShared").isNotNull();
|
||||
}
|
||||
|
||||
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(createDefaultActionModel()));
|
||||
|
||||
return restClient.authenticateUser(userWithRole).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can create a rule with several actions.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void createRuleWithActions()
|
||||
{
|
||||
final Map<String, Serializable> copyParams =
|
||||
Map.of("destination-folder", "dummy-folder-node", "deep-copy", true);
|
||||
final RestActionBodyExecTemplateModel copyAction = createCustomActionModel("copy", copyParams);
|
||||
final Map<String, Serializable> checkOutParams =
|
||||
Map.of("destination-folder", "dummy-folder-node", "assoc-name", "cm:checkout", "assoc-type",
|
||||
"cm:contains");
|
||||
final RestActionBodyExecTemplateModel checkOutAction = createCustomActionModel("check-out", checkOutParams);
|
||||
final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id");
|
||||
final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel("script", scriptParams);
|
||||
final RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction));
|
||||
|
||||
final UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
final RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
final RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
expectedRuleModel.setActions(addActionContextParams(Arrays.asList(copyAction, checkOutAction, scriptAction)));
|
||||
expectedRuleModel.setConditions(createEmptyConditionModel());
|
||||
expectedRuleModel.setTriggers(List.of("inbound"));
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED)
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
}
|
@@ -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,210 @@
|
||||
/*
|
||||
* #%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.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;
|
||||
private String ruleSetId;
|
||||
|
||||
@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);
|
||||
|
||||
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);
|
||||
ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
}
|
||||
|
||||
/** 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 the id of the folder that owns a list of rule sets. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetsAndOwningFolders()
|
||||
{
|
||||
STEP("Get the rule sets and owning folders");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("owningFolder")
|
||||
.getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSets.getEntries().get(0).onModel()
|
||||
.assertThat().field("owningFolder").is(ruleFolder.getNodeRef())
|
||||
.assertThat().field("id").is(ruleSetId);
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
}
|
||||
|
||||
/** Check we can get the reason that a rule set is included in the list. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetsAndInclusionType()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSets.getEntries().get(0).onModel()
|
||||
.assertThat().field("inclusionType").is("owned")
|
||||
.assertThat().field("id").is(ruleSetId);
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
}
|
||||
|
||||
/** 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 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 })
|
||||
public void getRuleSetByNonExistingId()
|
||||
{
|
||||
STEP("Get the rule set using fake rule set id");
|
||||
String fakeRuleSetId = "fake-rule-set-id";
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).getRuleSet(fakeRuleSetId);
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/** Check we can get the id of the folder that owns a rule set. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetAndOwningFolder()
|
||||
{
|
||||
STEP("Get the rule set and owning folder");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("owningFolder")
|
||||
.getRuleSet(ruleSetId);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSet.assertThat().field("owningFolder").is(ruleFolder.getNodeRef())
|
||||
.assertThat().field("id").is(ruleSetId);
|
||||
}
|
||||
}
|
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* #%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.*;
|
||||
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 static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
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;
|
||||
private static final String IGNORE_ID = "id";
|
||||
private static final String IGNORE_IS_SHARED = "isShared";
|
||||
|
||||
@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.
|
||||
* <p>
|
||||
* Also check that the isShared field is not returned when not requested.
|
||||
*/
|
||||
@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())
|
||||
.assertThat().field("isShared").isNull());
|
||||
}
|
||||
|
||||
/** 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 all the rules for a folder along with the extra "include" and "other" fields. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getRulesListWithIncludedFields()
|
||||
{
|
||||
STEP("Get the rules that apply to the folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.getListOfRules();
|
||||
|
||||
rules.assertThat().entriesListCountIs(createdRules.size());
|
||||
IntStream.range(0, createdRules.size()).forEach(i ->
|
||||
rules.getEntries().get(i).onModel()
|
||||
.assertThat().field("isShared").isNotNull()
|
||||
.assertThat().field("description").isNull()
|
||||
.assertThat().field("enabled").is(false)
|
||||
.assertThat().field("cascade").is(false)
|
||||
.assertThat().field("asynchronous").is(false)
|
||||
.assertThat().field("errorScript").isNull()
|
||||
.assertThat().field("shared").isNull()
|
||||
.assertThat().field("triggers").is("[inbound]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can get a rule by its id.
|
||||
* <p>
|
||||
* Also check that the isShared field is not returned when not requested.
|
||||
*/
|
||||
@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())
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
|
||||
/** Check we can get rule's other fields */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getRulesOtherFieldsModified()
|
||||
{
|
||||
STEP("Create a rule with all other fields default values modified");
|
||||
RestRuleModel ruleModel = createRuleModelWithModifiedValues();
|
||||
ruleModel.setTriggers(List.of("update"));
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
|
||||
expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions()));
|
||||
expectedRuleModel.setTriggers(List.of("update"));
|
||||
expectedRuleModel.setConditions(createEmptyConditionModel());
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED)
|
||||
.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("isShared").isNull();
|
||||
|
||||
}
|
||||
|
||||
/** Check we can get rule's "other" fields */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getRulesDefaultFields()
|
||||
{
|
||||
STEP("Create a rule with all other fields default values");
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions()));
|
||||
expectedRuleModel.setTriggers(List.of("inbound"));
|
||||
expectedRuleModel.setConditions(createEmptyConditionModel());
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED)
|
||||
.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
|
||||
/** 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 we can get a rule by its id along with any included fields. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getSingleRuleWithIncludedFields()
|
||||
{
|
||||
STEP("Load a particular rule");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.getSingleRule(createdRuleA.getId());
|
||||
|
||||
rule.assertThat().field("isShared").isNotNull();
|
||||
}
|
||||
|
||||
/** 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,313 @@
|
||||
/*
|
||||
* #%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.rules;
|
||||
|
||||
import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
||||
import org.alfresco.rest.model.RestRuleSetModel;
|
||||
import org.alfresco.rest.model.RestRuleSetModelsCollection;
|
||||
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 /nodes/{nodeId}/rule-set-links.
|
||||
*/
|
||||
@Test(groups = {TestGroup.RULES})
|
||||
public class RuleSetLinksTests extends RestTest
|
||||
{
|
||||
private UserModel user;
|
||||
private SiteModel site;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation()
|
||||
{
|
||||
STEP("Create a user and site.");
|
||||
user = dataUser.createRandomTestUser();
|
||||
site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can link to folder containing a rule set.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToFolderContainingRules()
|
||||
{
|
||||
STEP("Create folders in existing site");
|
||||
final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Create a rule in the rule folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
|
||||
STEP("Link to a rule folder");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(ruleFolder.getNodeRef());
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel();
|
||||
expectedLink.setId(ruleSetId);
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
linkedRules.assertThat().entriesListCountIs(1);
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
linkedRuleSets.assertThat().entriesListCountIs(1);
|
||||
final RestRuleSetModel expectedRuleSet = new RestRuleSetModel();
|
||||
expectedRuleSet.setId(ruleSetId);
|
||||
expectedRuleSet.setInclusionType("linked");
|
||||
linkedRuleSets.getEntries()
|
||||
.get(0).onModel().assertThat().isEqualTo(expectedRuleSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can link to a rule set.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToRuleSet()
|
||||
{
|
||||
STEP("Create folders in existing site");
|
||||
final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Create a rule in the rule folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
|
||||
STEP("Link to a rule set");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(ruleSetId);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel();
|
||||
expectedLink.setId(ruleSetId);
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
linkedRules.assertThat().entriesListCountIs(1);
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection likedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
likedRuleSets.assertThat().entriesListCountIs(1);
|
||||
final RestRuleSetModel expectedRuleSet = new RestRuleSetModel();
|
||||
expectedRuleSet.setId(ruleSetId);
|
||||
expectedRuleSet.setInclusionType("linked");
|
||||
likedRuleSets.getEntries()
|
||||
.get(0).onModel().assertThat().isEqualTo(expectedRuleSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check we get 404 when linking to a non-existing rule set/folder.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToNonExistingRuleSet()
|
||||
{
|
||||
STEP("Create a folder in existing site");
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Link to non-existing rule set");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId("dummy-rule-set-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 404");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get bad request error when linking to a folder without rules.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToFolderWithoutRules()
|
||||
{
|
||||
STEP("Create 2 folders without rules in existing site");
|
||||
final FolderModel folder1 = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FolderModel folder2 = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Link to a folder without rules");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(folder2.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
.assertLastError().containsSummary("The target node has no rules to link.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get bad request error when linking from a folder which already has rules.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkFromFolderWithRules()
|
||||
{
|
||||
STEP("Create folders in existing site");
|
||||
final FolderModel folder1 = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FolderModel folder2 = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Create rules in both folders.");
|
||||
RestRuleModel ruleModel1 = createRuleModel("ruleName1");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel1);
|
||||
RestRuleModel ruleModel2 = createRuleModel("ruleName2");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder2).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel2);
|
||||
|
||||
STEP("Link from a folder with rules");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(folder2.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
.assertLastError().containsSummary(
|
||||
"Unable to link to a ruleset because the folder has pre-existing rules or is already linked to a ruleset.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we get bad request error when linking to a file node.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToFileNode()
|
||||
{
|
||||
STEP("Create a folder in existing site");
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FileModel fileContent = dataContent.usingUser(user).usingSite(site).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
STEP("Link to a file node");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(fileContent.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
.assertLastError().containsSummary("NodeId of a folder is expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check we can link to a parent folder with rules.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.RULES})
|
||||
public void linkToParentNodeWithRules()
|
||||
{
|
||||
STEP("Create parent/child folders in existing site");
|
||||
final FolderModel parentFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final FolderModel childFolder = dataContent.usingUser(user).usingSite(site).usingResource(parentFolder).createFolder();
|
||||
|
||||
STEP("Create a rule in the parent folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
|
||||
STEP("Link to the parent folder");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(parentFolder.getNodeRef());
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel();
|
||||
expectedLink.setId(ruleSetId);
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if child folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(childFolder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
linkedRules.assertThat().entriesListCountIs(1);
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if child folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(childFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
linkedRuleSets.assertThat().entriesListCountIs(1);
|
||||
final RestRuleSetModel expectedRuleSet = new RestRuleSetModel();
|
||||
expectedRuleSet.setId(ruleSetId);
|
||||
expectedRuleSet.setInclusionType("linked");
|
||||
linkedRuleSets.getEntries()
|
||||
.get(0).onModel().assertThat().isEqualTo(expectedRuleSet);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* #%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.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
|
||||
public class RulesTestsUtils
|
||||
{
|
||||
static final String RULE_NAME_DEFAULT = "ruleName";
|
||||
static final String RULE_DESCRIPTION_DEFAULT = "rule description";
|
||||
static final boolean RULE_ENABLED_DEFAULT = true;
|
||||
static final boolean RULE_CASCADE_DEFAULT = true;
|
||||
static final boolean RULE_ASYNC_DEFAULT = true;
|
||||
static final boolean RULE_SHARED_DEFAULT = false;
|
||||
static final String RULE_ERROR_SCRIPT_DEFAULT = "error-script";
|
||||
static final List<String> ruleTriggersDefault = List.of("inbound", "update", "outbound");
|
||||
|
||||
/**
|
||||
* Create a rule model filled with default values.
|
||||
*
|
||||
* @return The created rule model.
|
||||
*/
|
||||
public static RestRuleModel createRuleModelWithModifiedValues()
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setDescription(RULE_DESCRIPTION_DEFAULT);
|
||||
ruleModel.setEnabled(RULE_ENABLED_DEFAULT);
|
||||
ruleModel.setCascade(RULE_CASCADE_DEFAULT);
|
||||
ruleModel.setAsynchronous(RULE_ASYNC_DEFAULT);
|
||||
ruleModel.setIsShared(RULE_SHARED_DEFAULT);
|
||||
ruleModel.setTriggers(ruleTriggersDefault);
|
||||
ruleModel.setErrorScript(RULE_ERROR_SCRIPT_DEFAULT);
|
||||
|
||||
return ruleModel;
|
||||
}
|
||||
|
||||
public static RestRuleModel createRuleModelWithDefaultValues()
|
||||
{
|
||||
return createRuleModel(RULE_NAME_DEFAULT, List.of(createDefaultActionModel()));
|
||||
}
|
||||
|
||||
public static RestRuleModel createRuleModel(String name)
|
||||
{
|
||||
return createRuleModel(name, List.of(createDefaultActionModel()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 createDefaultActionModel()
|
||||
{
|
||||
RestActionBodyExecTemplateModel restActionModel = new RestActionBodyExecTemplateModel();
|
||||
restActionModel.setActionDefinitionId("set-property-value");
|
||||
restActionModel.setParams(Map.of("aspect-name", "cm:audio"));
|
||||
return restActionModel;
|
||||
}
|
||||
|
||||
public static List<RestActionBodyExecTemplateModel> addActionContextParams(List<RestActionBodyExecTemplateModel> inputActions)
|
||||
{
|
||||
inputActions.forEach(inputAction -> {
|
||||
final Map<String, Serializable> params = new HashMap<>((Map<String, Serializable>) inputAction.getParams());
|
||||
params.put("actionContext", "rule");
|
||||
inputAction.setParams(params);
|
||||
});
|
||||
return inputActions;
|
||||
}
|
||||
|
||||
public static RestActionBodyExecTemplateModel createCustomActionModel(String actionDefinitionId, Map<String, Serializable> params)
|
||||
{
|
||||
RestActionBodyExecTemplateModel restActionModel = new RestActionBodyExecTemplateModel();
|
||||
restActionModel.setActionDefinitionId(actionDefinitionId);
|
||||
restActionModel.setParams(params);
|
||||
return restActionModel;
|
||||
}
|
||||
|
||||
public static RestCompositeConditionDefinitionModel createEmptyConditionModel()
|
||||
{
|
||||
RestCompositeConditionDefinitionModel conditions = new RestCompositeConditionDefinitionModel();
|
||||
conditions.setInverted(false);
|
||||
conditions.setBooleanMode("and");
|
||||
return conditions;
|
||||
}
|
||||
}
|
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* #%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.requests.RuleSettings.IS_INHERITANCE_ENABLED;
|
||||
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 org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestRuleSettingsModel;
|
||||
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 and PUT /nodes/{nodeId}/rule-settings/{ruleSettingKey}.
|
||||
*/
|
||||
@Test (groups = { TestGroup.RULES })
|
||||
public class SetInheritanceTests extends RestTest
|
||||
{
|
||||
private UserModel siteOwner;
|
||||
private SiteModel site;
|
||||
|
||||
@BeforeClass (alwaysRun = true)
|
||||
public void dataPreparation()
|
||||
{
|
||||
STEP("Create a user, site and folder.");
|
||||
siteOwner = dataUser.createRandomTestUser();
|
||||
site = dataSite.usingUser(siteOwner).createPrivateRandomSite();
|
||||
}
|
||||
|
||||
/** Check we can get the -isInheritanceEnabled- rule setting for the folder. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getIsInherited()
|
||||
{
|
||||
STEP("Create a folder for the test.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Get the -isInheritanceEnabled- rule settings for the folder.");
|
||||
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
RestRuleSettingsModel expected = new RestRuleSettingsModel();
|
||||
expected.setKey(IS_INHERITANCE_ENABLED);
|
||||
expected.setValue(true);
|
||||
ruleSettingsModel.assertThat().isEqualTo(expected);
|
||||
}
|
||||
|
||||
/** Check we get an error when trying to get settings from a non-existent folder. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getIsInheritedFromNonExistentFolder()
|
||||
{
|
||||
STEP("Try to get the -isInheritanceEnabled- rule settings for a fake folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(nonExistentFolder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
.containsSummary("The entity with id: fake-id was not found");
|
||||
}
|
||||
|
||||
/** Check we get an error when trying to retrieve a non-existent setting. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getNonExistentSetting()
|
||||
{
|
||||
STEP("Create a folder for the test.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Try to get a fake setting from the folder.");
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
.retrieveSetting();
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
.containsSummary("Unrecognised rule setting key -fakeRuleSetting-");
|
||||
}
|
||||
|
||||
/** Check a user without permission for the folder cannot get the -isInheritanceEnabled- rule setting. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getIsInheritedWithoutPermission()
|
||||
{
|
||||
STEP("Create a folder and a user without permission to access it.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
UserModel noPermissionUser = dataUser.createRandomTestUser();
|
||||
|
||||
STEP("Try to get the -isInheritanceEnabled- setting without permission.");
|
||||
restClient.authenticateUser(noPermissionUser)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
restClient.assertLastError().statusCodeIs(FORBIDDEN)
|
||||
.containsSummary("Cannot read from this node");
|
||||
}
|
||||
|
||||
/** Check we can change the -isInheritanceEnabled- rule setting for the folder. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void updateIsInherited()
|
||||
{
|
||||
STEP("Create a folder for the test.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Set -isInheritanceEnabled- to false.");
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(false);
|
||||
|
||||
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
RestRuleSettingsModel expected = new RestRuleSettingsModel();
|
||||
expected.setKey(IS_INHERITANCE_ENABLED);
|
||||
expected.setValue(false);
|
||||
ruleSettingsModel.assertThat().isEqualTo(expected);
|
||||
}
|
||||
|
||||
/** Check we get an error when trying to set -isInheritanceEnabled- to something other than a boolean. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void updateInheritedWithBadValue()
|
||||
{
|
||||
STEP("Create a folder for the test.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Try to set -isInheritanceEnabled- to \"banana\".");
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue("banana");
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(BAD_REQUEST)
|
||||
.containsSummary("Rule setting " + IS_INHERITANCE_ENABLED + " requires a boolean value.");
|
||||
}
|
||||
|
||||
/** Check we get an error when the folder is not found. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void updateInheritedWithNonExistentFolder()
|
||||
{
|
||||
STEP("Try to set -isInheritanceEnabled- against a fake folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(nonExistentFolder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
.containsSummary("The entity with id: fake-id was not found");
|
||||
}
|
||||
|
||||
/** Check we get an error when trying to set a non-existent setting. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void updateNonExistentSetting()
|
||||
{
|
||||
STEP("Create a folder for the test.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Try to set a fake setting on the folder.");
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
.containsSummary("Unrecognised rule setting key -fakeRuleSetting-");
|
||||
}
|
||||
|
||||
/** Check a user without manage permission cannot update the -isInheritanceEnabled- rule setting. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void updateIsInheritedWithoutPermission()
|
||||
{
|
||||
STEP("Create a folder and a collaborator.");
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
UserModel collaborator = dataUser.createRandomTestUser();
|
||||
collaborator.setUserRole(SiteCollaborator);
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingSite(site).addPerson(collaborator);
|
||||
|
||||
STEP("Try to update the -isInheritanceEnabled- setting without permission.");
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(collaborator).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(FORBIDDEN)
|
||||
.containsSummary("Insufficient permissions to manage rules");
|
||||
}
|
||||
}
|
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* #%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.createDefaultActionModel;
|
||||
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.
|
||||
* <p>
|
||||
* Also check that the isShared field is not returned when not requested.
|
||||
*/
|
||||
@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")
|
||||
.assertThat().field("isShared").isNull();
|
||||
}
|
||||
|
||||
/** 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 = createRuleModel("");
|
||||
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());
|
||||
}
|
||||
|
||||
/** Check we can update a rule and get the included fields. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void updateRuleWithIncludedFields()
|
||||
{
|
||||
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()
|
||||
.include("isShared")
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
updatedRule.assertThat().field("isShared").isNotNull();
|
||||
}
|
||||
|
||||
private RestRuleModel createAndSaveRule(String name)
|
||||
{
|
||||
return createAndSaveRule(name, List.of(createDefaultActionModel()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
@@ -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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
93
pom.xml
93
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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -45,26 +45,27 @@
|
||||
|
||||
<dependency.alfresco-hb-data-sender.version>1.0.12</dependency.alfresco-hb-data-sender.version>
|
||||
<dependency.alfresco-trashcan-cleaner.version>2.4.1</dependency.alfresco-trashcan-cleaner.version>
|
||||
<dependency.alfresco-jlan.version>7.1</dependency.alfresco-jlan.version>
|
||||
<dependency.alfresco-jlan.version>7.2</dependency.alfresco-jlan.version>
|
||||
<dependency.alfresco-server-root.version>6.0.1</dependency.alfresco-server-root.version>
|
||||
<dependency.alfresco-messaging-repo.version>1.2.19</dependency.alfresco-messaging-repo.version>
|
||||
<dependency.alfresco-messaging-repo.version>1.2.20</dependency.alfresco-messaging-repo.version>
|
||||
<dependency.alfresco-log-sanitizer.version>0.2</dependency.alfresco-log-sanitizer.version>
|
||||
<dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version>
|
||||
<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.15</dependency.acs-event-model.version>
|
||||
<dependency.alfresco-transform-service.version>1.5.4-A3</dependency.alfresco-transform-service.version>
|
||||
<dependency.alfresco-transform-core.version>2.7.0-A1</dependency.alfresco-transform-core.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.21</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.3</dependency.jackson.version>
|
||||
<dependency.jackson-databind.version>2.13.3</dependency.jackson-databind.version>
|
||||
<dependency.cxf.version>3.5.2</dependency.cxf.version>
|
||||
<dependency.cxf.version>3.5.3</dependency.cxf.version>
|
||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||
<dependency.webscripts.version>8.30</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.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>
|
||||
@@ -73,18 +74,18 @@
|
||||
<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.slf4j.version>1.7.36</dependency.slf4j.version>
|
||||
<dependency.gytheio.version>0.16</dependency.gytheio.version>
|
||||
<dependency.groovy.version>3.0.11</dependency.groovy.version>
|
||||
<dependency.tika.version>2.2.1</dependency.tika.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.keycloak.version>18.0.0</dependency.keycloak.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.2.0</dependency.awaitility.version>
|
||||
@@ -106,24 +107,24 @@
|
||||
<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.4.0</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.48</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-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>
|
||||
<dependency.tas-ftp.version>1.5</dependency.tas-ftp.version>
|
||||
<dependency.tas-utility.version>3.0.49</dependency.tas-utility.version>
|
||||
<dependency.rest-assured.version>5.1.1</dependency.rest-assured.version>
|
||||
<dependency.tas-restapi.version>1.115</dependency.tas-restapi.version>
|
||||
<dependency.tas-cmis.version>1.32</dependency.tas-cmis.version>
|
||||
<dependency.tas-email.version>1.9</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
|
||||
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>
|
||||
<dependency.tas-dataprep.version>2.6</dependency.tas-dataprep.version>
|
||||
|
||||
<!-- AGS properties shared between community and enterprise -->
|
||||
@@ -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.24</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>
|
||||
@@ -615,6 +616,12 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>${dependency.slf4j.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
<artifactId>reload4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
@@ -638,7 +645,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.junrar</groupId>
|
||||
<artifactId>junrar</artifactId>
|
||||
<version>7.5.2</version>
|
||||
<version>7.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.fge</groupId>
|
||||
@@ -649,7 +656,7 @@
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.15.1</version>
|
||||
<version>1.15.2</version>
|
||||
</dependency>
|
||||
<!-- upgrade dependency from TIKA -->
|
||||
<dependency>
|
||||
@@ -755,6 +762,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>
|
||||
@@ -871,6 +883,17 @@
|
||||
<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 +911,7 @@
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.40.1</version>
|
||||
<version>0.40.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
@@ -914,7 +937,7 @@
|
||||
<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>
|
||||
@@ -923,7 +946,7 @@
|
||||
</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.24</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -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
|
||||
@@ -30,6 +30,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.SocketException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -43,6 +44,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;
|
||||
@@ -58,6 +60,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.cxf.attachment.Rfc5987Util;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
@@ -361,18 +364,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
|
||||
@@ -482,7 +474,7 @@ public class ContentStreamer implements ResourceLoaderAware
|
||||
|
||||
if (req == null)
|
||||
{
|
||||
headerValue += "; filename*=UTF-8''" + URLEncoder.encode(attachFileName, StandardCharsets.UTF_8)
|
||||
headerValue += "; filename*=UTF-8''" + encodeFilename(attachFileName)
|
||||
+ "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"";
|
||||
}
|
||||
else
|
||||
@@ -491,12 +483,12 @@ public class ContentStreamer implements ResourceLoaderAware
|
||||
boolean isLegacy = (null != userAgent) && (userAgent.contains("MSIE 8") || userAgent.contains("MSIE 7"));
|
||||
if (isLegacy)
|
||||
{
|
||||
headerValue += "; filename=\"" + URLEncoder.encode(attachFileName, StandardCharsets.UTF_8);
|
||||
headerValue += "; filename=\"" + encodeFilename(attachFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
headerValue += "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"; filename*=UTF-8''"
|
||||
+ URLEncoder.encode(attachFileName, StandardCharsets.UTF_8);
|
||||
+ encodeFilename(attachFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,6 +498,21 @@ public class ContentStreamer implements ResourceLoaderAware
|
||||
res.setHeader("Content-Disposition", headerValue);
|
||||
}
|
||||
}
|
||||
|
||||
private String encodeFilename(String attachFileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Rfc5987Util.encode(attachFileName);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info(e.getMessage() + " Changing encoder from Rfc5987Util to java.net.URLEncoder.");
|
||||
|
||||
return URLEncoder.encode(attachFileName, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
protected String filterNameForQuotedString(String s)
|
||||
{
|
||||
|
@@ -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;
|
||||
@@ -76,7 +78,7 @@ public abstract class AbstractRuleWebScript extends DeclarativeWebScript
|
||||
private static final String RULE_OUTBOUND = "outbound";
|
||||
private static final String ACTION_CHECK_OUT = "check-out";
|
||||
|
||||
private static final String CANNOT_CREATE_RULE = "cannot.create.rule.checkout.outbound";
|
||||
public static final String CANNOT_CREATE_RULE = "cannot.create.rule.checkout.outbound";
|
||||
|
||||
protected NodeService nodeService;
|
||||
protected RuleService ruleService;
|
||||
@@ -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
|
||||
|
66
remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
Normal file
66
remote-api/src/main/java/org/alfresco/rest/api/RuleSets.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* #%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.RuleSet;
|
||||
import org.alfresco.rest.api.model.rules.RuleSetLink;
|
||||
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);
|
||||
|
||||
/**
|
||||
* Link a rule set to a folder
|
||||
*/
|
||||
RuleSetLink linkToRuleSet(String folderNodeId, String linkToNodeId);
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* #%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.RuleSetting;
|
||||
import org.alfresco.service.Experimental;
|
||||
|
||||
/**
|
||||
* Rule settings API.
|
||||
*/
|
||||
@Experimental
|
||||
public interface RuleSettings
|
||||
{
|
||||
/**
|
||||
* Get the rule setting with the given key.
|
||||
*
|
||||
* @param folderId Folder node ID
|
||||
* @param ruleSettingKey Rule setting key
|
||||
* @return {@link RuleSetting} The retrieved rule setting object.
|
||||
*/
|
||||
RuleSetting getRuleSetting(String folderId, String ruleSettingKey);
|
||||
|
||||
/**
|
||||
* Set the rule setting against the specified folder.
|
||||
*
|
||||
* @param folderId The folder to update.
|
||||
* @param ruleSetting The new rule setting.
|
||||
* @return The updated rule setting object.
|
||||
*/
|
||||
RuleSetting setRuleSetting(String folderId, RuleSetting ruleSetting);
|
||||
}
|
100
remote-api/src/main/java/org/alfresco/rest/api/Rules.java
Normal file
100
remote-api/src/main/java/org/alfresco/rest/api/Rules.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* #%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.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;
|
||||
|
||||
/**
|
||||
* 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 includes - The list of optional fields to include in the response.
|
||||
* @param paging - {@link Paging} information
|
||||
* @return {@link CollectionWithPagingInfo} containing a list page of folder rules
|
||||
*/
|
||||
CollectionWithPagingInfo<Rule> getRules(String folderNodeId, String ruleSetId, List<String> includes, 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
|
||||
* @param includes - The list of optional fields to include in the response.
|
||||
* @return {@link Rule} definition
|
||||
*/
|
||||
Rule getRuleById(String folderNodeId, String ruleSetId, String ruleId, List<String> includes);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param includes The list of optional fields to include in the response.
|
||||
* @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, List<String> includes);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param includes The list of optional fields to include in the response.
|
||||
* @return The newly updated rule.
|
||||
*/
|
||||
Rule updateRuleById(String folderNodeId, String ruleSetId, String ruleId, Rule rule, List<String> includes);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user