mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
619 Commits
18.5
...
rm-7187-ev
Author | SHA1 | Date | |
---|---|---|---|
|
3875f0b170 | ||
|
31d5b0985f | ||
|
15ebb627ce | ||
|
90ca0dea6c | ||
|
e48315e4b5 | ||
|
0902766f6e | ||
|
9b94dcaac3 | ||
|
d6b54568ac | ||
|
c72f175126 | ||
|
ace4691540 | ||
|
8a605c3678 | ||
|
0c811ae1fc | ||
|
375da138e8 | ||
|
b15ad3c72e | ||
|
7112fba951 | ||
|
7426a2eaa2 | ||
|
b8994d990e | ||
|
f67516fb19 | ||
|
6d883709a2 | ||
|
b9ccd79a73 | ||
|
7cd154ef86 | ||
|
728e305a93 | ||
|
490805b116 | ||
|
752b64e320 | ||
|
8bc9d13d35 | ||
|
dece409b38 | ||
|
1d59b20adb | ||
|
85349293c4 | ||
|
ba7be5999b | ||
|
8503b2c96c | ||
|
f43806b9f4 | ||
|
1eebb8ec12 | ||
|
008b340851 | ||
|
6d3e249149 | ||
|
bf276c60d6 | ||
|
54be23513a | ||
|
fa0fdff8d4 | ||
|
c37b26e678 | ||
|
b5e13e253a | ||
|
5b5164420f | ||
|
17c09efb93 | ||
|
f96304bd28 | ||
|
499f679c8c | ||
|
80c6a0127d | ||
|
901e4f4fea | ||
|
74e44acb1c | ||
|
f4d66debea | ||
|
af838043c9 | ||
|
1245647a9f | ||
|
fe35f312bb | ||
|
a5f16f1b11 | ||
|
38a9f6d3e1 | ||
|
dc512e5ab0 | ||
|
5c8db99231 | ||
|
e39a97ed8d | ||
|
ad0ad081c6 | ||
|
8b9513ca8f | ||
|
5b3582c051 | ||
|
dec17c4003 | ||
|
ccba1768bd | ||
|
fde8ff084b | ||
|
93a7790d44 | ||
|
f03790e278 | ||
|
2c979ea71e | ||
|
cc23d94054 | ||
|
19b5af2eee | ||
|
227c74a8bd | ||
|
24aa64c165 | ||
|
183873166c | ||
|
6e4bb33fb1 | ||
|
ae37c9273f | ||
|
783efca1d2 | ||
|
1c9419d635 | ||
|
0b7c52f0e2 | ||
|
03f80ace94 | ||
|
e2a62cf315 | ||
|
1cd7253f76 | ||
|
17b04d7321 | ||
|
fe5faa3263 | ||
|
85e2d84add | ||
|
7e7d86aca8 | ||
|
6eab9d2cfb | ||
|
5588cc45a2 | ||
|
b32da2af76 | ||
|
ee912bf126 | ||
|
38c638b0ce | ||
|
db2982ea62 | ||
|
71454395cb | ||
|
9059d5a87b | ||
|
71f8784a7e | ||
|
088d8f9448 | ||
|
0d43100018 | ||
|
93800b6906 | ||
|
82f8b938a6 | ||
|
8727ee18e8 | ||
|
a688d475dc | ||
|
83b1c323de | ||
|
e063e1d816 | ||
|
65c62c7d03 | ||
|
7a6949a059 | ||
|
1a0e45b6c8 | ||
|
1d1dead902 | ||
|
6a69b3fd86 | ||
|
f391cfa38c | ||
|
fbef1156a8 | ||
|
5d93c2efd4 | ||
|
c94807cd8c | ||
|
ff979314ae | ||
|
7f6bd86b0c | ||
|
fd2f793722 | ||
|
489b0058fe | ||
|
14572d328f | ||
|
759927c37b | ||
|
42ef2160ef | ||
|
4f561166b7 | ||
|
295a8f7ba2 | ||
|
fd73ebe45a | ||
|
3bbaabd755 | ||
|
63b0ff8cf4 | ||
|
15c99b0c10 | ||
|
0f24f453c8 | ||
|
ed50b9bb9b | ||
|
361a674a19 | ||
|
9f839b5372 | ||
|
c76d3b99c4 | ||
|
4998f19da9 | ||
|
b1340d12ef | ||
|
2b79a4489d | ||
|
e41fc6af02 | ||
|
162264a8d7 | ||
|
a5977fedb2 | ||
|
024e4e072b | ||
|
5c33911e5f | ||
|
2a6eb91ebd | ||
|
c588b915d5 | ||
|
4e2384fd9a | ||
|
6071188405 | ||
|
03ce7e37d4 | ||
|
1a5740eec1 | ||
|
f55602842d | ||
|
7819e29bcc | ||
|
91031ca72a | ||
|
32314480a1 | ||
|
f49b7a393f | ||
|
d32ba12405 | ||
|
7430c80a41 | ||
|
4c2d9ef64d | ||
|
f71f243b9b | ||
|
3f10227c0f | ||
|
a361596512 | ||
|
4ad2bda8b9 | ||
|
1339dd59a9 | ||
|
af2c11063b | ||
|
0d74540b2b | ||
|
d68ceb1a4b | ||
|
379f65db0d | ||
|
9dad28ee4d | ||
|
308dd9825a | ||
|
609aa750d6 | ||
|
def0201274 | ||
|
a7d885c630 | ||
|
3fcbb076a2 | ||
|
9ab4d29ff6 | ||
|
1388a76dc7 | ||
|
1944186ef8 | ||
|
66ea8c0534 | ||
|
571f4b121d | ||
|
2f2e7ade80 | ||
|
2d69d44049 | ||
|
6ad58b137e | ||
|
4c086751e6 | ||
|
7cb98f2d5d | ||
|
5822065f5c | ||
|
0f8b7740b0 | ||
|
dd017f2535 | ||
|
ddb5f56a64 | ||
|
2d4298ee45 | ||
|
f844fe45f8 | ||
|
c76a220dd4 | ||
|
c1862bed27 | ||
|
62285171b9 | ||
|
830d44dbcc | ||
|
c77964ba34 | ||
|
3d39b49d43 | ||
|
dac17894c7 | ||
|
9d282ef5c2 | ||
|
763dbe7964 | ||
|
0b4a8c15a4 | ||
|
f8d3788332 | ||
|
a51c1e2761 | ||
|
12cc55fde6 | ||
|
6008419f39 | ||
|
def7ebc7bc | ||
|
69a39d71d5 | ||
|
3a8fde44ec | ||
|
646bbe3436 | ||
|
7c706dbac6 | ||
|
2ab4c70217 | ||
|
ed0bbf576d | ||
|
f3e43badfe | ||
|
e99b6a98de | ||
|
64644505b3 | ||
|
aca9e15668 | ||
|
1852309798 | ||
|
ee2e248e39 | ||
|
b2f90ff6bc | ||
|
59641e833e | ||
|
6dd7d32b2e | ||
|
83bf4d0a2f | ||
|
1af9f31b68 | ||
|
2b98e73468 | ||
|
966dd7d144 | ||
|
375c68f932 | ||
|
8ce6117a95 | ||
|
08e393c39f | ||
|
2f4303f4eb | ||
|
953a1cc3f9 | ||
|
23a1ddca6a | ||
|
439dd3771f | ||
|
df7ebe30b3 | ||
|
c482153183 | ||
|
cdbd153151 | ||
|
8564f9eace | ||
|
b5d7500ecc | ||
|
e875e1fbbe | ||
|
32179dc810 | ||
|
97ed056103 | ||
|
af97fd5d6a | ||
|
cef6e8fc7b | ||
|
31d0578a98 | ||
|
2e1ae3bb69 | ||
|
9af05df046 | ||
|
71801e9e5e | ||
|
52149bf292 | ||
|
6cb07e1b86 | ||
|
fa3df0987d | ||
|
fde20c948f | ||
|
9ea1336a18 | ||
|
b007740dd0 | ||
|
15b10ba605 | ||
|
8983a11d3d | ||
|
6fd482b492 | ||
|
0a0c90a230 | ||
|
109af6abff | ||
|
43532eebf5 | ||
|
5dc3424fe2 | ||
|
133670cd17 | ||
|
909e95685e | ||
|
91e7b0d66f | ||
|
cc40cf05a9 | ||
|
4629c20b51 | ||
|
ee88946b1c | ||
|
b1faf15806 | ||
|
367ad20fb7 | ||
|
80e770f2da | ||
|
e8cf525792 | ||
|
a594341bb5 | ||
|
058e8d6302 | ||
|
91fcbb0b59 | ||
|
830898c605 | ||
|
d214040bc8 | ||
|
1b071cb555 | ||
|
37e04ee2fc | ||
|
10f32aa74c | ||
|
bea386ddc8 | ||
|
2449d1d8f3 | ||
|
3883fd22e3 | ||
|
183ac4c7cd | ||
|
fa1b8d46dd | ||
|
df35137d12 | ||
|
1d1b454978 | ||
|
deaee78d09 | ||
|
9e3c144a7d | ||
|
d0b100a88b | ||
|
9d807242ee | ||
|
5f2b5fe9af | ||
|
7edee67997 | ||
|
5f151aaa96 | ||
|
dcf25d89d0 | ||
|
7d5aafecb5 | ||
|
1d8f1bd8a2 | ||
|
fe04e621e1 | ||
|
ee03296733 | ||
|
c5e89242ba | ||
|
0fbeffe80a | ||
|
d1e9cf0144 | ||
|
b51146c868 | ||
|
515f243911 | ||
|
a7263931f5 | ||
|
2c23c674a7 | ||
|
2b929b747a | ||
|
1fd36cf903 | ||
|
d45bc9e6c6 | ||
|
6ae2ff6cd9 | ||
|
e3fbdd5904 | ||
|
575f4f26c0 | ||
|
c11cd252d4 | ||
|
74141cf4b7 | ||
|
0105b87153 | ||
|
c2ed150a7d | ||
|
d47bf8c3ac | ||
|
6372e9124c | ||
|
dcf5e8325b | ||
|
ebabe9a16b | ||
|
bbb6d610fa | ||
|
20ccedfee8 | ||
|
fcc1eef0f5 | ||
|
f757fb6be8 | ||
|
439c578b8d | ||
|
55c53a6789 | ||
|
ea1d13a5a6 | ||
|
0b0b89a1be | ||
|
3e7200d65f | ||
|
9ed945504f | ||
|
ab18be55a4 | ||
|
80548d0c3f | ||
|
11a8824fd3 | ||
|
a73610c143 | ||
|
d43872a4ab | ||
|
7a66b812bb | ||
|
732fa806e7 | ||
|
c9d115664b | ||
|
0f1f67230f | ||
|
5f303be26d | ||
|
9d27f2099a | ||
|
0588182c81 | ||
|
85cdad32d0 | ||
|
976670de8a | ||
|
a5dc3d767c | ||
|
42a42fd941 | ||
|
709ebd2e12 | ||
|
6e27433ac5 | ||
|
2d7697bf2c | ||
|
a47409268f | ||
|
db7f49afbd | ||
|
b324c07568 | ||
|
63a47002f9 | ||
|
31e557261e | ||
|
5eb54e9b0c | ||
|
f7642f99f2 | ||
|
c9f6f1bdd4 | ||
|
9c54707ad8 | ||
|
52e5b2bc8a | ||
|
62cc9419c6 | ||
|
8a0f3849ff | ||
|
55e6f1c9b1 | ||
|
d62b8b0942 | ||
|
b2c38d9bb0 | ||
|
d16d88cd22 | ||
|
c8a3ce3af5 | ||
|
fc4a47a71a | ||
|
d6a3d3db2a | ||
|
45b9f63351 | ||
|
84269b568f | ||
|
b9ee972ff2 | ||
|
c95be234a0 | ||
|
bcd304abab | ||
|
170e82ad75 | ||
|
8c6cebec1d | ||
|
d822a4d7ac | ||
|
a9d9daf6bb | ||
|
9bfbc3a623 | ||
|
7bd1efb1f0 | ||
|
6b1b240da7 | ||
|
e9ce710f3c | ||
|
26d29b0bc0 | ||
|
df8e315d48 | ||
|
458a8c17ff | ||
|
0cecb28903 | ||
|
19584814f0 | ||
|
4ac6cf4088 | ||
|
04225ce5ef | ||
|
c7464e7501 | ||
|
793ff892b7 | ||
|
7c6d35d38c | ||
|
b2dc3fa5cd | ||
|
54c91e8770 | ||
|
da2db2c339 | ||
|
84b62f2386 | ||
|
bcc3c30985 | ||
|
c457fafc1b | ||
|
fcf7d017b0 | ||
|
94be653375 | ||
|
d9c37d5f9f | ||
|
2555ff04f6 | ||
|
668e14182f | ||
|
e0e27f6448 | ||
|
0c7fe86cc0 | ||
|
c631cdba82 | ||
|
aabbcf449f | ||
|
ec4958a6e2 | ||
|
751643bac1 | ||
|
08b603cc33 | ||
|
410759bb37 | ||
|
29b25ea8ce | ||
|
cd6c38347f | ||
|
5ce6a774cc | ||
|
13529c0408 | ||
|
718968e77f | ||
|
2b59c3ad71 | ||
|
4c984b3b52 | ||
|
764e47b472 | ||
|
0c24c55296 | ||
|
5d74ca8323 | ||
|
a45137fc48 | ||
|
3595ffd7cf | ||
|
586f5f546c | ||
|
f129a47be0 | ||
|
f8287e59e2 | ||
|
79c7310a34 | ||
|
5039d4d0d0 | ||
|
f68299aa37 | ||
|
e63b0a8751 | ||
|
3d2b7a733a | ||
|
4bcffcd820 | ||
|
c552a7b660 | ||
|
3f41f8e4eb | ||
|
71ed6d1155 | ||
|
c04a83e3c2 | ||
|
e946bfcf71 | ||
|
1cee8f46bd | ||
|
dfb05bb00e | ||
|
c33dde8f41 | ||
|
f93d07d116 | ||
|
a88d0b07f2 | ||
|
da6e08b0e3 | ||
|
48c0546bd0 | ||
|
2c0fb3fe95 | ||
|
ea308c1c0a | ||
|
a02f0e7e2f | ||
|
9f32368582 | ||
|
b42b08559a | ||
|
95af4d6876 | ||
|
9c17870040 | ||
|
e93028c30e | ||
|
7741456b79 | ||
|
27f7b2ec33 | ||
|
078ae4cd32 | ||
|
ab3a0f00c4 | ||
|
829c7ef65d | ||
|
0d40d455b2 | ||
|
3d91bf154d | ||
|
d87532ce55 | ||
|
e6f97e979a | ||
|
b800d4b7e4 | ||
|
92bad68c5b | ||
|
d77e02f9a8 | ||
|
8a6584540f | ||
|
2dec33388e | ||
|
2c149b412e | ||
|
10b427209d | ||
|
a53eb13f9f | ||
|
c0a90dd32b | ||
|
d2a414f8a7 | ||
|
e484360980 | ||
|
691855bed2 | ||
|
e81a33d770 | ||
|
9dab62b490 | ||
|
44f602eee4 | ||
|
c04c149779 | ||
|
9cfa31ca63 | ||
|
a061d8d4df | ||
|
8052f7f299 | ||
|
962ce7a740 | ||
|
57603871d3 | ||
|
7d7cc446a4 | ||
|
2733ece40f | ||
|
f01204bf0a | ||
|
add073938a | ||
|
472becd973 | ||
|
d9293fff27 | ||
|
361e6b0221 | ||
|
3aec98cb92 | ||
|
cfd0dd388e | ||
|
8aadb2baf1 | ||
|
ca6b4cce24 | ||
|
eb2c76f600 | ||
|
fa910faea6 | ||
|
d428c542fc | ||
|
d0d5ce8d9d | ||
|
3e4a3a0a31 | ||
|
7d5f01f3d5 | ||
|
1ae1f87cdf | ||
|
a5ceb3df00 | ||
|
18dc254813 | ||
|
b737775fd3 | ||
|
175a525b64 | ||
|
8dba7f9468 | ||
|
838794f274 | ||
|
917961569d | ||
|
8e1c10aae0 | ||
|
580dda50e6 | ||
|
d0bc3f1ece | ||
|
a05f2eb20f | ||
|
51029868a9 | ||
|
e0b1c6f776 | ||
|
9930f18291 | ||
|
ca785cda74 | ||
|
308a60dcfa | ||
|
2518910fe1 | ||
|
4ddfb16bff | ||
|
ffb4df068b | ||
|
7fdb040b50 | ||
|
c2e587d640 | ||
|
bed12e40ca | ||
|
a53daf152f | ||
|
cc03aaf92f | ||
|
f9102eae0d | ||
|
8f252b69f1 | ||
|
50f884556c | ||
|
b1ad95a756 | ||
|
581f82f332 | ||
|
80fda4ed56 | ||
|
086ca9229e | ||
|
6d84baa34e | ||
|
d048054903 | ||
|
faf6cafe5a | ||
|
13a134da27 | ||
|
5e93e937f9 | ||
|
36c830ecdb | ||
|
013f3fac1c | ||
|
ec675d6123 | ||
|
e115c673e1 | ||
|
2453b3c9c7 | ||
|
761554ad83 | ||
|
20738f6ac5 | ||
|
1a90c129bc | ||
|
76ba1ce813 | ||
|
91bb8651d3 | ||
|
bbdc41555c | ||
|
1d77e2e852 | ||
|
8155132d69 | ||
|
d0e94e0d68 | ||
|
5c50dbef83 | ||
|
ef6d2531fb | ||
|
0c3c584ed9 | ||
|
516d15796f | ||
|
c2a2541a62 | ||
|
397979a4f9 | ||
|
ec85dd7e61 | ||
|
69ccd06cf2 | ||
|
6002440be5 | ||
|
1973a9d578 | ||
|
8d1e16e9c2 | ||
|
9e0b26f612 | ||
|
9080d3e0d9 | ||
|
f916a625d0 | ||
|
e0c278e277 | ||
|
bb64b05534 | ||
|
28be182040 | ||
|
ee88b0bf0c | ||
|
cd60067bbf | ||
|
bd64391527 | ||
|
126ece3dbe | ||
|
f7b7eeaf56 | ||
|
53937c963c | ||
|
671116b500 | ||
|
82369a3dcf | ||
|
9e9caec601 | ||
|
27caf48c79 | ||
|
e1b1e66e8d | ||
|
9186cead13 | ||
|
6c2d084209 | ||
|
81e0cb939d | ||
|
2bd64e48b5 | ||
|
3d6c34c8d6 | ||
|
506dd32b31 | ||
|
70ed927b3c | ||
|
3c818df7f1 | ||
|
612b65798e | ||
|
d0724a0a06 | ||
|
beea540ad0 | ||
|
099e1328c0 | ||
|
0f01dea5d2 | ||
|
38edaf79c2 | ||
|
d7e7545482 | ||
|
2cdcc7d5ce | ||
|
de7431b917 | ||
|
14e500cb1f | ||
|
4c37f4cda6 | ||
|
8470a1962b | ||
|
914ad394c3 | ||
|
1668baac05 | ||
|
17118db32f | ||
|
13f6aa2044 | ||
|
f6b3b62841 | ||
|
46c59e50f6 | ||
|
7870db5370 | ||
|
78a8d8d6cb | ||
|
60083c6145 | ||
|
c9a6c633ed | ||
|
1de92e61c4 | ||
|
e246eb31cf | ||
|
4261615fb4 | ||
|
6cc81beab5 | ||
|
9a77903d8c | ||
|
0049eefcdb | ||
|
918d5575ca | ||
|
3c7b48d95c | ||
|
85635663a2 | ||
|
46d42c0910 | ||
|
5cd309d5ff | ||
|
5b5c3ee584 | ||
|
ee3513ddc8 | ||
|
98d90b8008 | ||
|
1847b4e3b0 | ||
|
81dfbe0baf | ||
|
068eb23f88 | ||
|
344caf4904 | ||
|
47bfefb3c4 | ||
|
21c63e382c | ||
|
12a2bb249e | ||
|
48a22a88f2 | ||
|
d3a78b59a6 | ||
|
97657229c9 | ||
|
bbe7da71c2 | ||
|
219d62e005 | ||
|
c17d35da27 | ||
|
05090ef2dc |
14
.travis.yml
14
.travis.yml
@@ -264,6 +264,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-restapi"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- name: "REST API TAS tests part2"
|
||||
@@ -273,6 +274,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-restapi"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- name: "REST API TAS tests part3"
|
||||
@@ -282,6 +284,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 60 mvn -B verify -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-restapi"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-restapi"
|
||||
|
||||
- name: "CMIS TAS tests - BROWSER binding"
|
||||
@@ -291,6 +294,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-cmis"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- name: "CMIS TAS tests - ATOM binding"
|
||||
@@ -300,6 +304,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-cmis"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- name: "CMIS TAS tests - WEBSERVICES binding"
|
||||
@@ -309,6 +314,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal+transforms.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 40 mvn -B verify -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-cmis"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-cmis"
|
||||
|
||||
- name: "Email TAS tests"
|
||||
@@ -318,6 +324,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 30 mvn -B verify -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-email"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-email"
|
||||
|
||||
- name: "WebDAV TAS tests"
|
||||
@@ -327,6 +334,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
script: travis_wait 30 mvn -B verify -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-webdav"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-webdav"
|
||||
|
||||
- name: "Integration TAS tests"
|
||||
@@ -337,6 +345,7 @@ jobs:
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
|
||||
- travis_retry travis_wait 40 mvn install -pl :alfresco-community-repo-integration-test -am -DskipTests -Pall-tas-tests
|
||||
script: travis_wait 30 mvn -B verify -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
|
||||
after_success: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/tas-integration"
|
||||
after_failure: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/tas-integration"
|
||||
|
||||
- name: "Share Services - ShareServicesTestSuite"
|
||||
@@ -387,7 +396,7 @@ jobs:
|
||||
script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN}
|
||||
|
||||
- name: "AGS Community Rest API Tests"
|
||||
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/
|
||||
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/ AND commit_message !~ /\[skip tas\]/) OR (commit_message =~ /\[ags\]/ AND commit_message =~ /\[tas\]/)
|
||||
install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh
|
||||
addons:
|
||||
artifacts:
|
||||
@@ -399,7 +408,8 @@ jobs:
|
||||
before_script:
|
||||
- ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml
|
||||
- ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco"
|
||||
script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags
|
||||
- travis_wait 40 mvn -B install -pl :alfresco-governance-services-automation-community-rest-api -am -Pags -Pall-tas-tests -DskipTests
|
||||
script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests
|
||||
after_script: bash amps/ags/travis/scripts/getLogs.sh
|
||||
|
||||
- name: "Push to Nexus"
|
||||
|
@@ -7,14 +7,22 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>rm-community</module>
|
||||
<module>rm-automation</module>
|
||||
</modules>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>all-tas-tests</id>
|
||||
<modules>
|
||||
<module>rm-automation</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
@@ -43,14 +43,21 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<version>${dependency.slf4j.version}</version>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j2-impl</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
@@ -62,6 +69,17 @@
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>${dependency.tas-utility.version}</version>
|
||||
<!-- These exclusions can be removed once tas-utility does not rely on Reload4j anymore -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
<artifactId>reload4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
package org.alfresco.rest.v0;
|
||||
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -36,6 +37,7 @@ import java.util.List;
|
||||
import org.alfresco.rest.core.v0.BaseAPI;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.util.PojoUtility;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -58,6 +60,8 @@ public class RMAuditAPI extends BaseAPI
|
||||
private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog";
|
||||
private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}";
|
||||
|
||||
private static final String RM_AUDIT_LOG_AS_RECORD = "{0}node/{1}/rmauditlog";
|
||||
|
||||
/**
|
||||
* Returns a list of rm audit entries .
|
||||
*
|
||||
@@ -84,6 +88,21 @@ public class RMAuditAPI extends BaseAPI
|
||||
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of rm audit entries .
|
||||
*
|
||||
* @param user The username of the user to use.
|
||||
* @param password The password of the user.
|
||||
* @param size Maximum number of log entries to return
|
||||
* @return return All return log entries
|
||||
*/
|
||||
public List<AuditEntry> getRMAuditLogAll(String user, String password, final int size) {
|
||||
String parameters = "size=" + size;
|
||||
JSONArray auditEntries = doGetRequest(user, password,
|
||||
MessageFormat.format(RM_AUDIT_LOG_API,"{0}", parameters)).getJSONObject("data").getJSONArray("entries");
|
||||
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of audit entries.
|
||||
*
|
||||
@@ -100,5 +119,19 @@ public class RMAuditAPI extends BaseAPI
|
||||
&& getRMAuditLog(username, password, 100, null).size() == 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the Audit Log as Record.
|
||||
*
|
||||
* @param username The username of the user to use.
|
||||
* @param password The password of the user.
|
||||
* @param recNodeRef The Record Node reference for which Audit log should be created as record
|
||||
* @param destinationNodeRef The Folder id Node reference where the html file should be placed
|
||||
* @throws AssertionError If the API call didn't create the Audit Log as Record.
|
||||
*/
|
||||
public HttpResponse logsAuditLogAsRecord(String username, String password, String recNodeRef, String destinationNodeRef) {
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("destination", destinationNodeRef);
|
||||
return doPostJsonRequest(username, password, SC_OK, requestParams, RM_AUDIT_LOG_AS_RECORD,recNodeRef);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -97,4 +97,16 @@ public class RecordFoldersAPI extends BaseAPI
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public HttpResponse reOpenRecordFolder(String user, String password, String recordFolder)
|
||||
{
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
|
||||
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "openRecordFolder");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -360,4 +360,25 @@ public class RecordsAPI extends BaseAPI
|
||||
{
|
||||
return getNodeRefSpacesStore() + getItemNodeRef(username, password, recordPath + "/" + recordName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reopens the record given as parameter
|
||||
*
|
||||
* @param user the user declaring the document as record
|
||||
* @param password the user's password
|
||||
* @param recordName the record name
|
||||
* @return The HTTP Response.
|
||||
*/
|
||||
|
||||
public HttpResponse reOpenRecord(String user, String password, String recordName)
|
||||
{
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
|
||||
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "undeclareRecord");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
|
||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* #%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.audit;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.*;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD;
|
||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD;
|
||||
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.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.testng.AssertJUnit.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEvents;
|
||||
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.rm.community.model.recordfolder.RecordFolder;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.v0.HoldsAPI;
|
||||
import org.alfresco.rest.v0.service.RMAuditService;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
public class AuditHoldsTest extends BaseRMRestTest {
|
||||
private final String PREFIX = generateTestPrefix(AuditAddToHoldTests.class);
|
||||
private final String HOLD1 = PREFIX + "hold1";
|
||||
private SiteModel publicSite;
|
||||
private FileModel testFile;
|
||||
@Autowired
|
||||
private RMAuditService rmAuditService;
|
||||
@Autowired
|
||||
private HoldsAPI holdsAPI;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
private UserModel rmAdmin;
|
||||
private RecordCategory recordCategory;
|
||||
private RecordCategoryChild recordFolder1,recordFolder2;
|
||||
private List<AuditEntry> auditEntries;
|
||||
private String hold1NodeRef;
|
||||
public static final String RECORD_FOLDER_THREE = "record-folder-three";
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForAuditAddToHoldTests()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
||||
|
||||
STEP("Create a hold");
|
||||
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1, HOLD_REASON,
|
||||
HOLD_DESCRIPTION);
|
||||
|
||||
STEP("Create a collaboration site with a test file.");
|
||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
||||
testFile = dataContent.usingAdmin().usingSite(publicSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
STEP("Create a record category with 2 folders and 1 record");
|
||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
||||
recordFolder1 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder1");
|
||||
recordFolder2 = createRecordFolder(recordCategory.getId(), PREFIX + "recFolder2");
|
||||
Record recordToBeAdded = createElectronicRecord(recordFolder1.getId(), PREFIX + "record");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Add some items to the hold, then remove them from the hold");
|
||||
final List<String> itemsList = asList(testFile.getNodeRefWithoutVersion(), recordToBeAdded.getId(), recordFolder2.getId());
|
||||
final List<String> holdsList = Collections.singletonList(HOLD1);
|
||||
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), recordToBeAdded.getId(), HOLD1);
|
||||
holdsAPI.removeItemsFromHolds(rmAdmin.getUsername(), rmAdmin.getPassword(), itemsList, holdsList);
|
||||
|
||||
STEP("Delete the record folder that was held");
|
||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(recordFolder2.getId());
|
||||
|
||||
STEP("Rename the parent of the record that was held");
|
||||
RecordFolder recordFolder = RecordFolder.builder().name(RECORD_FOLDER_THREE).build();
|
||||
getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordFolder1.getId());
|
||||
}
|
||||
/**
|
||||
* Data provider with hold events that have links to held items
|
||||
*
|
||||
* @return the hold events
|
||||
*/
|
||||
@DataProvider (name = "holdsEvents")
|
||||
public Object[][] getHoldEvents()
|
||||
{
|
||||
return new AuditEvents[][]
|
||||
{
|
||||
{ ADD_TO_HOLD },
|
||||
{ REMOVE_FROM_HOLD }
|
||||
};
|
||||
}
|
||||
@Test (dataProvider = "holdsEvents")
|
||||
public void checkItemPathLink(AuditEvents event) {
|
||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), event);
|
||||
assertFalse("Audit results should not be empty",auditEntries.size()==0);
|
||||
final String auditedEvent = event + " - " + testFile.getName();
|
||||
assertTrue("Audit results should contain one " + auditedEvent + " event",auditEntries.stream().anyMatch(e -> e.getEvent().startsWith(event.eventDisplayName)));
|
||||
STEP("Check the audit log contains only an entry for add to hold.");
|
||||
assertThat(auditEntries, is(not(empty())));
|
||||
}
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void cleanup() {
|
||||
dataSite.usingAdmin().deleteSite(publicSite);
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordFolder(recordFolder2.getId());
|
||||
deleteRecordCategory(recordCategory.getId());
|
||||
rmAuditService.clearAuditLog();
|
||||
}
|
||||
}
|
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* #%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.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
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.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
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.AssertJUnit;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class ElectronicRecordAuditLogTest extends BaseRMRestTest {
|
||||
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
@Autowired
|
||||
private RecordsAPI recordApi;
|
||||
/* electronic record details */
|
||||
private static final String AUDIT_ELECTRONIC_RECORD = generateTestPrefix(ElectronicRecordAuditLogTest.class) + "electronic record";
|
||||
private static final String AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD = "Complete Reopen Electronic Record";
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private Record electronicRecord, electronicRecord2;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void electronicRecordsAuditLogSetup()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(),TITLE);
|
||||
|
||||
electronicRecord = createElectronicRecord(recordFolder1.getId(),AUDIT_ELECTRONIC_RECORD,rmAdmin.get());
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for newly filed electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void newElectronicRecordAudit() {
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
|
||||
// newly created record contains 2 events: "file to" and metadata update
|
||||
// the order in which object creation and metadata update are listed isn't always identical due to
|
||||
// both happening in the same transaction
|
||||
assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to")));
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "newElectronicRecordAudit",
|
||||
description = "Viewing electronic record audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void electronicRecordAuditIsEvent()
|
||||
{
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "electronicRecordAuditIsEvent",
|
||||
description = "Rename electronic record is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameElectronicRecord() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
Record renameElectronicRecord = createRecordModel("edited " + electronicRecord.getName(), "", "");
|
||||
|
||||
// rename record
|
||||
getRestAPIFactory().getRecordsAPI().updateRecord(renameElectronicRecord, electronicRecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test (
|
||||
dependsOnMethods = "newElectronicRecordAudit",
|
||||
description = "Complete and reopen electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void completeAndReopenElectronicRecord() {
|
||||
electronicRecord2 = createElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_ELECTRONIC_RECORD);
|
||||
|
||||
// complete record
|
||||
recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
electronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames();
|
||||
// a record must be completed
|
||||
assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record")));
|
||||
|
||||
// Reopen record
|
||||
recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
electronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(electronicRecord2.getId()).getAspectNames();
|
||||
// a record mustn't be completed
|
||||
assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "completeAndReopenElectronicRecord",
|
||||
description = "File electronic record's audit log as record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void fileElectronicRecordAuditLogAsRecord()
|
||||
{
|
||||
// audit log is stored in the same folder, refresh it so that it appears in the list
|
||||
HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
getRecordNodeRef(electronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId()));
|
||||
JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse);
|
||||
Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString()
|
||||
.replace("workspace://SpacesStore/",""));
|
||||
// check audit log
|
||||
AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html"));
|
||||
AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD)));
|
||||
}
|
||||
|
||||
private String getFolderNodeRef(String folderId) {
|
||||
return "workspace://SpacesStore/" + folderId;
|
||||
}
|
||||
|
||||
private String getRecordNodeRef(String recordId) {
|
||||
return "workspace/SpacesStore/" + recordId;
|
||||
}
|
||||
|
||||
private JSONObject getAuditPropertyValues(HttpResponse httpResponse) {
|
||||
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;
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
private void closeAuditLog() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void electronicRecordAuditLogCleanup() {
|
||||
deleteRecord(electronicRecord.getId());
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* #%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.audit;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||
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.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
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.AssertJUnit;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
||||
public class NonElectronicRecordAuditLogTest extends BaseRMRestTest {
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
@Autowired
|
||||
private RecordsAPI recordApi;
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private Record nonElectronicRecord , nonElectronicRecord2;
|
||||
private static final String AUDIT_NON_ELECTRONIC_RECORD = generateTestPrefix(NonElectronicRecordAuditLogTest.class) + "non electronic record";
|
||||
private static final String AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD = "Complete Reopen Non-Electronic Record";
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void nonElectronicRecordAuditLogSetup()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(),TITLE);
|
||||
nonElectronicRecord = createNonElectronicRecord(recordFolder1.getId(),AUDIT_NON_ELECTRONIC_RECORD,rmAdmin.get());
|
||||
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for newly filed non-electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void newNonElectronicRecordAudit()
|
||||
{
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
|
||||
// newly created record contains 3 events: "created object", "file to" and metadata update
|
||||
assertTrue("File To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("File to")));
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
assertTrue("Created Object Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "newNonElectronicRecordAudit",
|
||||
description = "Viewing Non electronic record audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void nonElectronicRecordAuditIsEvent()
|
||||
{
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Audit View Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "nonElectronicRecordAuditIsEvent",
|
||||
description = "Rename electronic record is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameNonElectronicRecord()
|
||||
{
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
Record renameNonElectronicRecord = createRecordModel("edited " + nonElectronicRecord.getName(), "", "");
|
||||
|
||||
// rename record
|
||||
getRestAPIFactory().getRecordsAPI().updateRecord(renameNonElectronicRecord, nonElectronicRecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Updated metadata Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test (dependsOnMethods = "newNonElectronicRecordAudit",description = "Complete and reopen electronic record")
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void completeAndReopenNonElectronicRecord()
|
||||
{
|
||||
nonElectronicRecord2 = createNonElectronicRecord(recordFolder1.getId(),AUDIT_COMPLETE_REOPEN_NON_ELECTRONIC_RECORD);
|
||||
|
||||
// complete record
|
||||
recordApi.completeRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
nonElectronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames();
|
||||
// a record must be completed
|
||||
assertTrue("Record is not completed.",aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
List<AuditEntry> auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Complete Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Complete Record")));
|
||||
|
||||
// Reopen record
|
||||
recordApi.reOpenRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
nonElectronicRecord2.getName());
|
||||
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
List<String> aspects = recordsAPI.getRecord(nonElectronicRecord2.getId()).getAspectNames();
|
||||
// a record mustn't be completed
|
||||
assertFalse(aspects.contains(ASPECTS_COMPLETED_RECORD));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
auditEntries= auditLog.getRMAuditLogAll(getAdminUser().getUsername(),getAdminUser().getPassword(),100);
|
||||
assertTrue("Reopen Record Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Reopen Record")));
|
||||
|
||||
}
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "completeAndReopenNonElectronicRecord",
|
||||
description = "File electronic record's audit log as record"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void fileNonElectronicRecordAuditLogAsRecord()
|
||||
{
|
||||
// audit log is stored in the same folder, refresh it so that it appears in the list
|
||||
HttpResponse auditRecordHttpResponse = auditLog.logsAuditLogAsRecord(rmAdmin.get().getUsername(),rmAdmin.get().getPassword(),
|
||||
getRecordNodeRef(nonElectronicRecord2.getId()),getFolderNodeRef(recordFolder1.getId()));
|
||||
JSONObject auditRecordProperties = getAuditPropertyValues(auditRecordHttpResponse);
|
||||
Record auditRecord = getRestAPIFactory().getRecordsAPI().getRecord(auditRecordProperties.get("record").toString()
|
||||
.replace("workspace://SpacesStore/",""));
|
||||
// check audit log
|
||||
AssertJUnit.assertTrue(auditRecordProperties.get("recordName").toString().endsWith(".html"));
|
||||
AssertJUnit.assertTrue(auditRecord.getAspectNames().stream().noneMatch(x -> x.startsWith(ASPECTS_COMPLETED_RECORD)));
|
||||
|
||||
}
|
||||
|
||||
private String getFolderNodeRef(String folderId) {
|
||||
return "workspace://SpacesStore/" + folderId;
|
||||
}
|
||||
|
||||
private String getRecordNodeRef(String recordId) {
|
||||
return "workspace/SpacesStore/" + recordId;
|
||||
}
|
||||
|
||||
private JSONObject getAuditPropertyValues(HttpResponse httpResponse) {
|
||||
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;
|
||||
}
|
||||
@AfterMethod
|
||||
private void closeAuditLog() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void nonElectronicRecordAuditLogCleanup() {
|
||||
deleteRecord(nonElectronicRecord.getId());
|
||||
deleteRecord(nonElectronicRecord2.getId());
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* #%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.audit;
|
||||
|
||||
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.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
|
||||
public class RecordCategoryAuditLogTest extends BaseRMRestTest {
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
|
||||
private final String TEST_PREFIX = generateTestPrefix(RecordCategoryAuditLogTest.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private static final String AUDIT_CATEGORY = generateTestPrefix(RecordCategoryAuditLogTest.class) + "category";
|
||||
private RecordCategory recordCategoryAudit;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void recordCategoryAuditLogSetup() {
|
||||
STEP("Create RM Site");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create RM Admin user");
|
||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
||||
getAdminUser().getPassword(),
|
||||
"Administrator");
|
||||
}
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2768")
|
||||
public void recordCategoryAudit() throws Exception {
|
||||
STEP("Create root level category");
|
||||
recordCategoryAudit = createRootCategory(AUDIT_CATEGORY);
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
// newly created record category contains 3 events: object creation, inherited permissions set to false and metadata update
|
||||
// the order in which object creation and metadata update are listed isn't always identical due to
|
||||
// both happening in the same transaction
|
||||
assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordCategoryAudit",
|
||||
description = "Viewing audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void recordCategoryAuditIsEvent() {
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordCategoryAuditIsEvent",
|
||||
description = "Record category rename is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira="RM-4303")
|
||||
public void renameRecordCategory() {
|
||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
||||
RecordCategory rootRecordCategory = createRootCategory(categoryName);
|
||||
String newCategoryName = "Rename " + categoryName;
|
||||
RecordCategory recordCategoryUpdated = RecordCategory.builder().name(newCategoryName).build();
|
||||
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated, rootRecordCategory.getId());
|
||||
|
||||
assertStatusCode(OK);
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
}
|
||||
@AfterClass(alwaysRun = true)
|
||||
private void electronicRecordAuditLogCleanup() {
|
||||
deleteRecordCategory(recordCategoryAudit.getId());
|
||||
dataUser.deleteUser(new UserModel(RM_ADMIN,
|
||||
getAdminUser().getPassword()));
|
||||
auditLog.clearAuditLog(getAdminUser().getUsername(), getAdminUser().getPassword());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* #%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.audit;
|
||||
|
||||
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.rm.community.model.recordfolder.RecordFolder;
|
||||
import org.alfresco.rest.v0.RMAuditAPI;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordFolderModel;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class RecordFolderAuditLogTest extends BaseRMRestTest {
|
||||
|
||||
private Optional<UserModel> rmAdmin;
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
@Autowired
|
||||
private RMAuditAPI auditLog;
|
||||
|
||||
@Autowired
|
||||
private RecordFoldersAPI recordFoldersAPI;
|
||||
private RecordCategory category1;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
public static final String TITLE = "Title";
|
||||
public static final String DESCRIPTION = "Description";
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void recordFolderAuditLogSetup() {
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = Optional.ofNullable(getDataUser().createRandomTestUser());
|
||||
rmRolesAndActionsAPI.assignRoleToUser(
|
||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
||||
rmAdmin.get().getUsername(),
|
||||
"Administrator");
|
||||
}
|
||||
|
||||
@Test(description = "Audit log for empty record folder")
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void recordFolderAudit() {
|
||||
category1 = createRootCategory(TITLE, DESCRIPTION);
|
||||
recordFolder1 = createFolder(category1.getId(), TITLE);
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Created Object Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Created Object")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordFolderAudit",
|
||||
description = "Viewing record folder audit log is itself an auditable event"
|
||||
)
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void recordFolderAuditIsEvent() {
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Audit View Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Audit View")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
(
|
||||
dependsOnMethods = "recordFolderAuditIsEvent",
|
||||
description = "Record folder rename is an edit metadata event"
|
||||
)
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void renameRecordFolder() {
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(), rmAdmin.get().getPassword());
|
||||
RecordFolder renameRecordFolder = createRecordFolderModel(category1.getId(), "edited");
|
||||
getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(renameRecordFolder, recordFolder1.getId());
|
||||
assertStatusCode(OK);
|
||||
// we expect 1 new event: "metadata update"
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
// assertTrue("Move To Event is not present.",auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Move to")));
|
||||
assertTrue("Updated metadata Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Updated Metadata")));
|
||||
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "recordFolderAudit",
|
||||
description = "Close and reopen folder")
|
||||
@AlfrescoTest(jira = "RM-4303")
|
||||
public void closeReopenFolder() {
|
||||
//close folder
|
||||
recordFoldersAPI.closeRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(),
|
||||
recordFolder1.getName());
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Folder Close Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Close Record Folder")));
|
||||
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
|
||||
//reopen folder
|
||||
recordFoldersAPI.reOpenRecordFolder(rmAdmin.get().getUsername(), rmAdmin.get().getPassword(),
|
||||
recordFolder1.getName());
|
||||
try
|
||||
{
|
||||
Utility.sleep(1000, 30000, () ->
|
||||
{
|
||||
|
||||
List<AuditEntry> auditEntries = auditLog.getRMAuditLogAll(getAdminUser().getUsername(), getAdminUser().getPassword(), 100);
|
||||
assertTrue("Reopen Record Event is not present.", auditEntries.stream().anyMatch(x -> x.getEvent().startsWith("Open Record Folder")));
|
||||
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("InterruptedException received while waiting for results.");
|
||||
}
|
||||
}
|
||||
@AfterMethod
|
||||
private void closeAuditLog()
|
||||
{
|
||||
auditLog.clearAuditLog(rmAdmin.get().getUsername(),rmAdmin.get().getPassword());
|
||||
}
|
||||
|
||||
@AfterClass (alwaysRun = true)
|
||||
public void recordFolderAuditLogCleanup()
|
||||
{
|
||||
deleteRecordFolder(recordFolder1.getId());
|
||||
deleteRecordCategory(category1.getId());
|
||||
dataUser.usingAdmin().deleteUser(new UserModel(rmAdmin.get().getUsername(), rmAdmin.get().getPassword()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* #%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.rules;
|
||||
|
||||
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.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.CreateCategoriesTests;
|
||||
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.CoreUtil.createBodyForMoveCopy;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
||||
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 CopyToRuleOnFoldersTest extends BaseRMRestTest {
|
||||
|
||||
private RecordCategory category;
|
||||
private RecordCategoryChild folder1,folder2;
|
||||
private final static String title = "Run in background";
|
||||
private final String TEST_PREFIX = generateTestPrefix(CopyToRuleOnFoldersTest.class);
|
||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
||||
private final String electronicRecord = TEST_PREFIX + "record_electronic_for_copyTo";
|
||||
private final String nonElectronicRecord = TEST_PREFIX + "record_non_electronic_for_copyTo";
|
||||
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-2994")
|
||||
public void copyToRuleOnFoldersTest()
|
||||
{
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(true).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.COPY_TO.getActionValue()));
|
||||
|
||||
|
||||
STEP("Create the RM site if doesn't exist");
|
||||
createRMSiteIfNotExists();
|
||||
|
||||
STEP("Create record categories and record folders");
|
||||
category= createRootCategory(getRandomName("recordCategory"));
|
||||
String folder1 = createCategoryFolderInFilePlan().getId();
|
||||
String folder2 = createCategoryFolderInFilePlan().getId();
|
||||
|
||||
// create a rule on folder
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folder1, ruleDefinition);
|
||||
|
||||
// create electronic record in record folder
|
||||
String electronicRecordId = createElectronicRecord(folder1, ELECTRONIC_RECORD_NAME).getId();
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// create non-electronic record in record folder
|
||||
String nonElectronicRecord = createElectronicRecord(folder1, NONELECTRONIC_RECORD_NAME).getId();
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// Move the electronic and non-electronic records from "Category with records"> "Folder with rule"
|
||||
// to "Copy Category with records" > "Folder with rule"
|
||||
getRestAPIFactory().getNodeAPI(toContentModel(folder1)).copy(createBodyForMoveCopy(category.getId()));
|
||||
getRestAPIFactory().getNodeAPI(toContentModel( electronicRecord)).move(createBodyForMoveCopy(folder2));
|
||||
getRestAPIFactory().getNodeAPI(toContentModel( nonElectronicRecord)).move(createBodyForMoveCopy(folder2));
|
||||
|
||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
// Delete the record category
|
||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||
String recordCategoryId = category.getId();
|
||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||
recordsAPI.deleteRecord(electronicRecord);
|
||||
recordsAPI.deleteRecord(nonElectronicRecord);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* #%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.rules;
|
||||
|
||||
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.model.user.UserRoles;
|
||||
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.test.AlfrescoTest;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
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 org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
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.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
@AlfrescoTest (jira = "APPS-36")
|
||||
public class FileAsRecordRuleTests extends BaseRMRestTest
|
||||
{
|
||||
private UserModel nonRMUser, rmManager;
|
||||
private RecordCategory category_manager, category_admin;
|
||||
private RecordCategoryChild folder_admin, folder_manager ;
|
||||
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 FolderModel testFolder;
|
||||
private FileModel document,inPlaceRecord;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
/**
|
||||
* Create preconditions:
|
||||
* 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
|
||||
* 5. A collaboration folder with rule set to declare and file as record to a record folder
|
||||
**/
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForDeclareFileAsRecordRuleTests()
|
||||
{
|
||||
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 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);
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record to a record folder");
|
||||
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);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
/**
|
||||
* Given I am a user that can create a rule on a folder in a collaboration site
|
||||
* When I am creating the rule
|
||||
* Then I have the option of adding a "Declare and File as Record" action to the rule
|
||||
* <p>
|
||||
* Given I am creating a rule
|
||||
* When I add the "Declare and File as Record" action to the rule
|
||||
* Then I am able to select the record folder I want the declared record to be filed to
|
||||
* <p>
|
||||
* Given I am configuring a "Declare and File as Record" action within a rule
|
||||
* And I have at least one records management role (eg RM User)
|
||||
* When I am selecting the record folder location to file the declared record to
|
||||
* Then I see the record folders in the file plan that I have file access to as the creator of the record
|
||||
**/
|
||||
@Test
|
||||
public void declareAsRecordRuleAsRMUserWithFilingPermissions() {
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(rmManager)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
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);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
/**
|
||||
* Given I am configuring a "Declare and File as Record" action within a rule
|
||||
* And I don't have a records management role
|
||||
* When I am selecting the record folder location to file the declared record to
|
||||
* Then I can see only the file plan
|
||||
*/
|
||||
@Test
|
||||
public void declareAsRecordRuleAsNonRMUser()
|
||||
{
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMUser)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMUser.getUsername(), nonRMUser.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given I have not selected a record folder location
|
||||
* When the rule is triggered
|
||||
* Then the file is declared as record to the UnFiled Records folder
|
||||
*/
|
||||
@Test
|
||||
public void triggerDeclareToUnfiledRuleAsNonRMUser()
|
||||
{
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
||||
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
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);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Create as nonRMUser a new file into the previous folder in order to trigger the rule");
|
||||
inPlaceRecord = dataContent.usingUser(nonRMUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
// Verify that 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(inPlaceRecord.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanupDeclareAsRecordRuleTests()
|
||||
{
|
||||
STEP("Delete the collaboration site");
|
||||
dataSite.usingUser(nonRMUser).deleteSite(testSite);
|
||||
|
||||
STEP("Delete Users");
|
||||
dataUser.deleteUser(nonRMUser);
|
||||
dataUser.deleteUser(rmManager);
|
||||
|
||||
STEP("Delete categories");
|
||||
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* #%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.rules;
|
||||
|
||||
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.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
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.testng.annotations.AfterClass;
|
||||
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 org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
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.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
||||
|
||||
private UserModel nonRMuser, rmManager;
|
||||
private RecordCategory category_manager, category_admin;
|
||||
private RecordCategoryChild folder_admin, folder_manager ;
|
||||
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 FolderModel testFolder;
|
||||
private FileModel document,inPlaceRecord;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void createTestPrecondition()
|
||||
{
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file version as record to a record folder");
|
||||
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);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void declareVersionAsRecordRuleAsRMUserWithFilingPermissions()
|
||||
{
|
||||
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(rmManager)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
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(rmManager.getUsername(), rmManager.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void declareVersionAsRecordRuleAsNonRMUser()
|
||||
{
|
||||
|
||||
STEP("Create a collaboration folder");
|
||||
testFolder = dataContent.usingSite(testSite)
|
||||
.usingUser(nonRMuser)
|
||||
.createFolder();
|
||||
|
||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void triggerDeclareToUnfiledRuleAsNonRMUser() throws Exception {
|
||||
|
||||
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
||||
|
||||
|
||||
FileModel inplaceRecord = dataContent.usingSite(testSite).usingUser(nonRMuser)
|
||||
.createContent(new FileModel("declareAndFileToIntoUnfiledRecordFolder",
|
||||
FileType.TEXT_PLAIN));
|
||||
|
||||
RecordCategory recordCategory = new RecordCategory().builder()
|
||||
.id(category_manager.getId()).build();
|
||||
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||
.applyToChildren(true)
|
||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + inplaceRecord.getNodeRef(), ruleDefinition);
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("Create as nonRMuser a new file into the previous folder in order to trigger the rule");
|
||||
inPlaceRecord = dataContent.usingUser(nonRMuser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
// 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(inplaceRecord.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanupDeclareVersionAsRecordRuleTests()
|
||||
{
|
||||
|
||||
STEP("Delete the collaboration site");
|
||||
dataSite.usingUser(nonRMuser).deleteSite(testSite);
|
||||
|
||||
STEP("Delete Users");
|
||||
dataUser.deleteUser(nonRMuser);
|
||||
dataUser.deleteUser(rmManager);
|
||||
|
||||
|
||||
STEP("Delete categories");
|
||||
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* #%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.rules;
|
||||
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
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.rm.community.model.rules.ActionsOnRule;
|
||||
import org.alfresco.rest.rm.community.model.rules.ConditionsOnRule;
|
||||
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.UnfiledContainerChildEntry;
|
||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.v0.HoldsAPI;
|
||||
import org.alfresco.rest.v0.RecordsAPI;
|
||||
import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_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.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
||||
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.*;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
|
||||
public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
|
||||
|
||||
private RecordCategoryChild recordFolder2;
|
||||
private RecordCategoryChild recordFolder1;
|
||||
private String nonElectronicId;
|
||||
|
||||
public Record electronicRecord;
|
||||
|
||||
private String ruleType = ConditionsOnRule.UPDATE.getWhenConditionValue();
|
||||
private UserModel rmAdmin;
|
||||
public RecordCategory RecordCategoryOne;
|
||||
private RecordCategoryChild recordFolder;
|
||||
public static final String RECORD_FOLDER_ONE = "record-folder-one";
|
||||
private final String TEST_PREFIX = generateTestPrefix(MoveToRuleOnFoldersTest.class);
|
||||
|
||||
private final String RECORD_CATEGORY_ONE = TEST_PREFIX + "category";
|
||||
|
||||
private final String recordName = "Test record";
|
||||
private final String recordTitle = recordName + " title";
|
||||
private final String recordDescription = recordName + " description";
|
||||
private Record nonElectrinicRecordModel;
|
||||
private RecordFolderAPI recordFolderAPI;
|
||||
public String title,description,box,file,shelf,storageLocation,name;
|
||||
@Autowired
|
||||
private RulesAPI rulesAPI;
|
||||
@Autowired
|
||||
private HoldsAPI holdsAPI;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
public RecordsAPI recordsAPI;
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void precondition()
|
||||
{
|
||||
//create RM site
|
||||
createRMSiteIfNotExists();
|
||||
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
||||
//create root category, create folders , add electronic and non electronic records
|
||||
RecordCategoryOne = createRootCategory(RECORD_CATEGORY_ONE);
|
||||
recordFolder1=createRecordFolder(RecordCategoryOne.getId(), getRandomName("recFolder"));
|
||||
// recordFolder1_id = createRecordFolder(RecordCategoryOne.getId(), getRandomName("recFolder")).getId();
|
||||
recordFolder2 = createFolder(getAdminUser(),RecordCategoryOne.getId(),getRandomName("recFolder"));
|
||||
|
||||
|
||||
STEP("CREATE ELECTRONIC RECORD");
|
||||
recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
||||
electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder1.getId(), getFile(IMAGE_FILE));
|
||||
STEP("Check the electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
STEP("Create a non-electronic record by completing some of the fields");
|
||||
// Use these properties for non-electronic record to be created
|
||||
title = "Title " + getRandomAlphanumeric();
|
||||
description = "Description " + getRandomAlphanumeric();
|
||||
box = "Box "+ getRandomAlphanumeric();
|
||||
file = "File " + getRandomAlphanumeric();
|
||||
shelf = "Shelf " + getRandomAlphanumeric();
|
||||
storageLocation = "Storage Location " + getRandomAlphanumeric();
|
||||
name = "Record " + getRandomAlphanumeric();
|
||||
Random random = new Random();
|
||||
Integer numberOfCopies = random.nextInt(MAX_VALUE);
|
||||
Integer physicalSize = random.nextInt(MAX_VALUE);
|
||||
|
||||
// Set values of all available properties for the non electronic records
|
||||
nonElectrinicRecordModel = createFullNonElectronicRecordModel(name, title, description, box, file, shelf, storageLocation, numberOfCopies, physicalSize);
|
||||
// Create non-electronic record
|
||||
nonElectronicId = recordFolderAPI.createRecord(nonElectrinicRecordModel, recordFolder1.getId()).getId();
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MoveToRuleFoldersTest()
|
||||
{
|
||||
|
||||
String CatName=RecordCategoryOne.getName();
|
||||
String folder2name=recordFolder2.getName();
|
||||
String recfolder2_path="/"+CatName+"/"+folder2name;
|
||||
|
||||
STEP("create a rule MOVE_TO for folder 1");
|
||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(true).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.MOVE_TO.getActionValue())).ruleType(ruleType).path(recfolder2_path);
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder1.getId() , ruleDefinition);
|
||||
|
||||
|
||||
|
||||
STEP("Update metadata for Non-Electronic Record");
|
||||
updateRecordMetadata();
|
||||
|
||||
STEP("Delete ELECTRONIC AND NON-ELECTRONIC RECORDS IN FOLDER 2");
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
recordsAPI.deleteRecord(electronicRecord.getId());
|
||||
assertStatusCode(NO_CONTENT);
|
||||
recordsAPI.deleteRecord(nonElectronicId);
|
||||
assertStatusCode(NO_CONTENT);
|
||||
|
||||
STEP("RULE CREATION FOR FOLDER 1 WITHOUT RUNNING IN BACKGROUND");
|
||||
|
||||
RuleDefinition ruleDefinition_notinbackground = RuleDefinition.createNewRule().title("name").description("description1")
|
||||
.runInBackground(false).title(title)
|
||||
.actions(Collections.singletonList(ActionsOnRule.MOVE_TO.getActionValue())).ruleType(ruleType).path(recfolder2_path);
|
||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder1.getId() , ruleDefinition);
|
||||
|
||||
STEP("CREATE ELECTRONIC AND NON-ELECTRONIC RECORDS");
|
||||
electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder1.getId(), getFile(IMAGE_FILE));
|
||||
STEP("Check the electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
nonElectronicId = recordFolderAPI.createRecord(nonElectrinicRecordModel, recordFolder1.getId()).getId();
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
STEP("UPDATE METADATA");
|
||||
updateRecordMetadata();
|
||||
|
||||
STEP("CHECK IF ELECTRONIC AND NON-ELECTRONIC RECORDS MOVED TO FOLDER2");
|
||||
updateRecordMetadata();
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanMoveToRuleOnFoldersTest()
|
||||
{
|
||||
deleteRecordCategory(RecordCategoryOne.getId());
|
||||
|
||||
getDataUser().deleteUser(rmAdmin);
|
||||
}
|
||||
|
||||
private String getModifiedPropertyValue(String originalValue) {
|
||||
/* to be used to append to modifications */
|
||||
String MODIFIED_PREFIX = "modified_";
|
||||
return MODIFIED_PREFIX + originalValue;
|
||||
}
|
||||
private void updateRecordMetadata(){
|
||||
STEP("Update metadata for Non-Electronic Record");
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
Record nonelecrecord = recordsAPI.getRecord(nonElectronicId);
|
||||
String nonelecnewName = getModifiedPropertyValue(nonElectrinicRecordModel.getName());
|
||||
String nonelecnewTitle = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getTitle());
|
||||
String nonelecnewDescription = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(nonelecnewName, nonelecnewDescription, nonelecnewTitle),nonelecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
STEP("Update metadata for Electronic Record");
|
||||
Record elecrecord = recordsAPI.getRecord(electronicRecord.getId());
|
||||
String elecnewName = getModifiedPropertyValue(electronicRecord.getName());
|
||||
String elecnewTitle = getModifiedPropertyValue(electronicRecord.getProperties().getTitle());
|
||||
String elecnewDescription = getModifiedPropertyValue(electronicRecord.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(elecnewName, elecnewDescription, elecnewTitle),elecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
# Root logger option
|
||||
log4j.rootLogger=INFO, file
|
||||
|
||||
# Direct log messages to a log file
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=./target/reports/rm-automation-community-rest-api.log
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
log4j.logger.com.example=debug
|
@@ -0,0 +1,20 @@
|
||||
###### Root Logger #######
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.rolling.ref=RollingAppender
|
||||
|
||||
###### File appender definition #######
|
||||
appender.rolling.type=RollingFile
|
||||
appender.rolling.name=RollingAppender
|
||||
appender.rolling.fileName=target/reports/rm-automation-community-rest-api.log
|
||||
appender.rolling.filePattern=target/reports/rm-automation-community-rest-api.log.%i
|
||||
appender.rolling.layout.type=PatternLayout
|
||||
appender.rolling.layout.pattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %replace{%m}{[\r\n]+}{}%n
|
||||
appender.rolling.policies.type=Policies
|
||||
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
|
||||
appender.rolling.policies.size.size=10MB
|
||||
appender.rolling.strategy.type=DefaultRolloverStrategy
|
||||
appender.rolling.strategy.max=10
|
||||
|
||||
###### Loggers definitions #######
|
||||
logger.com-example.name=com.example
|
||||
logger.com-example.level=debug
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.5
|
||||
SOLR6_TAG=2.0.6-A4
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -1,60 +0,0 @@
|
||||
#
|
||||
# Warnings
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn
|
||||
|
||||
#
|
||||
# Module patches
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
||||
|
||||
#
|
||||
# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be
|
||||
# removed to enhance performance.
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor=info
|
||||
|
||||
#
|
||||
# RM permission debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter=debug
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider=debug
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.capability.declarative=debug
|
||||
|
||||
#
|
||||
# RM Audit service debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug
|
||||
|
||||
#
|
||||
# Job debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||
|
||||
#
|
||||
# Script logging level
|
||||
#
|
||||
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=error
|
||||
|
||||
#
|
||||
# Behaviour debug
|
||||
#
|
||||
log4j.logger.org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor=info
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean=info
|
||||
|
||||
#
|
||||
# Patch debug
|
||||
#
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
||||
#
|
||||
# RM Audit service debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService=debug
|
||||
|
||||
#
|
||||
# Job debug
|
||||
#
|
||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||
log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info
|
||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl=info
|
@@ -0,0 +1,50 @@
|
||||
# Warnings
|
||||
logger.alfresco-module-org_alfresco_module_rm-caveat.name=org.alfresco.module.org_alfresco_module_rm.caveat
|
||||
logger.alfresco-module-org_alfresco_module_rm-caveat.level=warn
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityPostProcessor.name=org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityPostProcessor.level=warn
|
||||
|
||||
# Module patches
|
||||
logger.alfresco-module-org_alfresco_module_rm-patch.name=org.alfresco.module.org_alfresco_module_rm.patch
|
||||
logger.alfresco-module-org_alfresco_module_rm-patch.level=info
|
||||
|
||||
# Set to 'debug' to see details of capability failures when AccessDenied is thrown. May be
|
||||
# removed to enhance performance.
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityInterceptor.name=org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityInterceptor
|
||||
logger.alfresco-module-org_alfresco_module_rm-security-RMMethodSecurityInterceptor.level=info
|
||||
|
||||
# RM permission debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMEntryVoter.name=org.alfresco.module.org_alfresco_module_rm.capability.RMEntryVoter
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMEntryVoter.level=debug
|
||||
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMAfterInvocationProvider.name=org.alfresco.module.org_alfresco_module_rm.capability.RMAfterInvocationProvider
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-RMAfterInvocationProvider.level=debug
|
||||
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-declarative.name=org.alfresco.module.org_alfresco_module_rm.capability.declarative
|
||||
#logger.alfresco-module-org_alfresco_module_rm-capability-declarative.level=debug
|
||||
|
||||
# RM Audit service debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-audit-RecordsManagementAuditService.name=org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService
|
||||
#logger.alfresco-module-org_alfresco_module_rm-audit-RecordsManagementAuditService.level=debug
|
||||
|
||||
# Job debug
|
||||
#logger.alfresco-module-org_alfresco_module_rm-job.name=org.alfresco.module.org_alfresco_module_rm.job
|
||||
#logger.alfresco-module-org_alfresco_module_rm-job.level=debug
|
||||
|
||||
# Script logging level
|
||||
logger.alfresco-repo-jscript-ScriptLogger.name=org.alfresco.repo.jscript.ScriptLogger
|
||||
logger.alfresco-repo-jscript-ScriptLogger.level=error
|
||||
|
||||
# Behaviour debug
|
||||
logger.alfresco-repo-policy-annotation-AnnotatedBehaviourPostProcessor.name=org.alfresco.repo.policy.annotation.AnnotatedBehaviourPostProcessor
|
||||
logger.alfresco-repo-policy-annotation-AnnotatedBehaviourPostProcessor.level=info
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-behaviour-BaseBehaviourBean.name=org.alfresco.module.org_alfresco_module_rm.behaviour.BaseBehaviourBean
|
||||
logger.alfresco-module-org_alfresco_module_rm-behaviour-BaseBehaviourBean.level=info
|
||||
|
||||
logger.alfresco-repo-web-scripts-roles-DynamicAuthoritiesGet.name=org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet
|
||||
logger.alfresco-repo-web-scripts-roles-DynamicAuthoritiesGet.level=info
|
||||
|
||||
logger.alfresco-module-org_alfresco_module_rm-query-RecordsManagementQueryDAOImpl.name=org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl
|
||||
logger.alfresco-module-org_alfresco_module_rm-query-RecordsManagementQueryDAOImpl.level=info
|
@@ -175,6 +175,14 @@
|
||||
<property name="nodesModelFactory" ref="nodesModelFactory" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.events.EventEntityResource">
|
||||
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rm.rest.api.events.EventTypeEntityResource">
|
||||
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
|
||||
</bean>
|
||||
|
||||
<!-- extended sites bean definition -->
|
||||
<bean id="rm.sites" class="org.alfresco.rm.rest.api.impl.RMSitesImpl" parent="sites">
|
||||
<property name="siteSurfConfig" ref="rm.siteSurfConfig" />
|
||||
@@ -209,6 +217,8 @@
|
||||
<entry key="org.alfresco.service.cmr.attributes.DuplicateAttributeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
|
||||
<entry key="org.alfresco.module.org_alfresco_module_rm.record.RecordCreationException" value="422" />
|
||||
<entry key="org.alfresco.service.cmr.model.FileExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="404" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -30,8 +30,10 @@ package org.alfresco.module.org_alfresco_module_rm.job;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.action.RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -47,7 +49,6 @@ import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,7 +65,6 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
/** batching properties */
|
||||
private int batchSize;
|
||||
public static final int DEFAULT_BATCH_SIZE = 500;
|
||||
private static final String MSG_NODE_FROZEN = "rm.action.node.frozen.error-message";
|
||||
|
||||
/** list of disposition actions to automatically execute */
|
||||
private List<String> dispositionActions;
|
||||
@@ -194,6 +194,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
|
||||
boolean hasMore = true;
|
||||
int skipCount = 0;
|
||||
List<NodeRef> resultNodes = new ArrayList<>();
|
||||
|
||||
if (batchSize < 1)
|
||||
{
|
||||
@@ -214,7 +215,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
|
||||
// execute search
|
||||
ResultSet results = searchService.query(params);
|
||||
List<NodeRef> resultNodes = results.getNodeRefs();
|
||||
if(results != null)
|
||||
{
|
||||
// filtering out the hold/freezed cases from the result set
|
||||
resultNodes =
|
||||
results.getNodeRefs().stream().filter(node -> nodeService.getPrimaryParent(node) == null ?
|
||||
!freezeService.isFrozenOrHasFrozenChildren(node) :
|
||||
!freezeService.isFrozenOrHasFrozenChildren(nodeService.getPrimaryParent(node).getParentRef())).collect(Collectors.toList());
|
||||
}
|
||||
hasMore = results.hasMore();
|
||||
skipCount += resultNodes.size(); // increase by page size
|
||||
results.close();
|
||||
@@ -265,12 +273,6 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
}
|
||||
Map<String, Serializable> props = Map.of(PARAM_NO_ERROR_CHECK, false);
|
||||
|
||||
if (freezeService.isFrozenOrHasFrozenChildren(parent.getParentRef()))
|
||||
{
|
||||
log.debug(I18NUtil.getMessage(MSG_NODE_FROZEN, dispAction));
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// execute disposition action
|
||||
|
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.EventBody;
|
||||
import org.alfresco.rm.rest.api.model.EventInfo;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||
|
||||
/**
|
||||
* Event entity resource
|
||||
*/
|
||||
@EntityResource(name = "events", title = "Events")
|
||||
public class EventEntityResource implements EntityResourceAction.Read<EventInfo>,
|
||||
EntityResourceAction.ReadById<EventInfo>,
|
||||
EntityResourceAction.Update<EventBody>,
|
||||
EntityResourceAction.Create<EventBody> {
|
||||
|
||||
private RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
/**
|
||||
* Set the records management event service
|
||||
*
|
||||
* @param rmEventService
|
||||
*/
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
|
||||
{
|
||||
this.recordsManagementEventService = rmEventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a single event identified by 'eventId'")
|
||||
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
|
||||
public EventInfo readById(String eventId, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
mandatory("eventId", eventId);
|
||||
|
||||
RecordsManagementEvent event = null;
|
||||
if (eventExists(eventId))
|
||||
{
|
||||
// Get the event
|
||||
event = recordsManagementEventService.getEvent(eventId);
|
||||
}
|
||||
|
||||
return EventInfo.fromRecordsManagementEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a list of events")
|
||||
public CollectionWithPagingInfo<EventInfo> readAll(Parameters params)
|
||||
{
|
||||
Paging paging = params.getPaging();
|
||||
|
||||
List<EventInfo> eventInfoList = recordsManagementEventService.getEvents().stream()
|
||||
.map(EventInfo::fromRecordsManagementEvent)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int totalCount = eventInfoList.size();
|
||||
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
|
||||
return CollectionWithPagingInfo.asPaged(paging, eventInfoList.stream()
|
||||
.skip(paging.getSkipCount())
|
||||
.limit(paging.getMaxItems())
|
||||
.collect(Collectors.toList()), hasMoreItems, totalCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Create a new event")
|
||||
public List<EventBody> create(List<EventBody> eventBodyList, Parameters parameters)
|
||||
{
|
||||
//TODO: 403 User not allowed to update event error still needs to be implemented
|
||||
mandatory("eventBodyList", eventBodyList);
|
||||
for (EventBody eventBody : eventBodyList) {
|
||||
mandatory("eventName", eventBody.getName());
|
||||
mandatory("eventType", eventBody.getType());
|
||||
}
|
||||
|
||||
List<EventBody> responseEventBodyList = new ArrayList<>();
|
||||
for (EventBody eventBody : eventBodyList) {
|
||||
String eventId = GUID.generate();
|
||||
String eventName = eventBody.getName();
|
||||
String eventType = eventBody.getType();
|
||||
|
||||
if(canCreateEvent(eventId, eventName)) {
|
||||
RecordsManagementEvent event = recordsManagementEventService.addEvent(eventType, eventId, eventName);
|
||||
responseEventBodyList.add(EventBody.fromRecordsManagementEvent(event));
|
||||
}
|
||||
}
|
||||
return responseEventBodyList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Update a single event identified by 'eventId'")
|
||||
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
|
||||
public EventBody update(String eventId, EventBody eventBody, Parameters parameters)
|
||||
{
|
||||
//TODO: 403 User not allowed to update event error still needs to be implemented
|
||||
mandatory("eventId", eventId);
|
||||
mandatory("eventName", eventBody.getName());
|
||||
mandatory("eventType", eventBody.getType());
|
||||
|
||||
RecordsManagementEvent event = null;
|
||||
if (canEditEvent(eventBody.getName(), eventId, eventBody.getType()))
|
||||
{
|
||||
// Create event
|
||||
event = recordsManagementEventService.addEvent(eventBody.getType(), eventId, eventBody.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get event
|
||||
event = recordsManagementEventService.getEvent(eventId);
|
||||
}
|
||||
|
||||
return EventBody.fromRecordsManagementEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event exists or not. Throws an
|
||||
* error if the event does not exist.
|
||||
*
|
||||
* @param eventId The id of the event
|
||||
*/
|
||||
private boolean eventExists(String eventId)
|
||||
{
|
||||
boolean eventExists = true;
|
||||
|
||||
// Check the event exists
|
||||
if (!recordsManagementEventService.existsEvent(eventId))
|
||||
{
|
||||
throw new EntityNotFoundException(eventId);
|
||||
}
|
||||
|
||||
return eventExists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event can be created or not. Throws an
|
||||
* error if the event already exists.
|
||||
*
|
||||
* @param eventId The id of the event
|
||||
* @param eventName The name of the event
|
||||
*/
|
||||
private boolean canCreateEvent(String eventId, String eventName)
|
||||
{
|
||||
boolean canCreateEvent = true;
|
||||
|
||||
if (!recordsManagementEventService.canCreateEvent(eventName, eventId))
|
||||
{
|
||||
throw new EventAlreadyExistsException("framework.exception.CreateEventAlreadyExists", new Object[] {eventName});
|
||||
}
|
||||
|
||||
return canCreateEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for checking if an event can be edited or not. Throws an
|
||||
* error if an event with the same display label already exists.
|
||||
*
|
||||
* @param eventName The name of the event
|
||||
* @param eventId The id of the event
|
||||
* @param eventType The type of the event
|
||||
* @return true if the event can be edited, false otherwise
|
||||
*/
|
||||
private boolean canEditEvent(String eventName, String eventId, String eventType)
|
||||
{
|
||||
boolean canEditEvent = false;
|
||||
if (eventExists(eventId)) {
|
||||
try
|
||||
{
|
||||
canEditEvent = recordsManagementEventService.canEditEvent(eventName, eventId, eventType);
|
||||
}
|
||||
catch (AlfrescoRuntimeException are)
|
||||
{
|
||||
throw new EventAlreadyExistsException("framework.exception.UpdateEventAlreadyExists", new Object[] {eventName});
|
||||
}
|
||||
}
|
||||
return canEditEvent;
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.resource.EntityResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.model.EventTypeInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Event Type entity resource
|
||||
*/
|
||||
@EntityResource(name = "event-types", title = "Event Types")
|
||||
public class EventTypeEntityResource implements EntityResourceAction.Read<EventTypeInfo> {
|
||||
private RecordsManagementEventService recordsManagementEventService;
|
||||
|
||||
/**
|
||||
* Set the records management event service
|
||||
* @param rmEventService
|
||||
*/
|
||||
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
|
||||
{
|
||||
this.recordsManagementEventService = rmEventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@WebApiDescription(title = "Return a list of different event types")
|
||||
public CollectionWithPagingInfo<EventTypeInfo> readAll(Parameters params)
|
||||
{
|
||||
// TODO: AssociationName and ActionOnAssociatedNode properties still need to be assigned.
|
||||
Paging paging = params.getPaging();
|
||||
|
||||
List<EventTypeInfo> eventTypeInfoList = recordsManagementEventService.getEventTypes().stream()
|
||||
.map(EventTypeInfo::fromRecordsManagementEventType)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int totalCount = eventTypeInfoList.size();
|
||||
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
|
||||
return CollectionWithPagingInfo.asPaged(paging, eventTypeInfoList.stream()
|
||||
.skip(paging.getSkipCount())
|
||||
.limit(paging.getMaxItems())
|
||||
.collect(Collectors.toList()), hasMoreItems, totalCount);
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* 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 info that defines the Information Governance Events REST API
|
||||
*/
|
||||
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
|
||||
package org.alfresco.rm.rest.api.events;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
|
||||
/**
|
||||
* The EventBody model to be exposed through REST API.
|
||||
*/
|
||||
public class EventBody {
|
||||
private String name;
|
||||
private String type;
|
||||
|
||||
public static EventBody fromRecordsManagementEvent(RecordsManagementEvent event)
|
||||
{
|
||||
EventBody eventBody = new EventBody();
|
||||
if(event != null) {
|
||||
eventBody.setName(event.getDisplayLabel());
|
||||
eventBody.setType(event.getType());
|
||||
}
|
||||
return eventBody;
|
||||
}
|
||||
|
||||
public EventBody() {}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
|
||||
/**
|
||||
* The EventInfo model to be exposed through REST API.
|
||||
*/
|
||||
public class EventInfo {
|
||||
private String id;
|
||||
private String name;
|
||||
private String type;
|
||||
|
||||
public static EventInfo fromRecordsManagementEvent(RecordsManagementEvent event)
|
||||
{
|
||||
EventInfo eventInfo = new EventInfo();
|
||||
if (event != null) {
|
||||
eventInfo.setName(event.getDisplayLabel());
|
||||
eventInfo.setId(event.getName());
|
||||
eventInfo.setType(event.getType());
|
||||
}
|
||||
return eventInfo;
|
||||
}
|
||||
|
||||
public EventInfo() {}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* -
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
* -
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* -
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* -
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rm.rest.api.model;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
|
||||
/**
|
||||
* The EventTypeInfo model to be exposed through REST API.
|
||||
*/
|
||||
public class EventTypeInfo {
|
||||
private String id;
|
||||
private String name;
|
||||
private boolean isAutomatic;
|
||||
private String associationName;
|
||||
private String actionOnAssociatedNode;
|
||||
|
||||
public static EventTypeInfo fromRecordsManagementEventType(RecordsManagementEventType eventType)
|
||||
{
|
||||
EventTypeInfo eventTypeInfo = new EventTypeInfo();
|
||||
if (eventType != null) {
|
||||
eventTypeInfo.setName(eventType.getDisplayLabel());
|
||||
eventTypeInfo.setId(eventType.getName());
|
||||
eventTypeInfo.setAutomatic(eventType.isAutomaticEvent());
|
||||
}
|
||||
return eventTypeInfo;
|
||||
}
|
||||
|
||||
public EventTypeInfo() {}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isAutomatic()
|
||||
{
|
||||
return isAutomatic;
|
||||
}
|
||||
|
||||
public void setAutomatic(boolean automatic)
|
||||
{
|
||||
isAutomatic = automatic;
|
||||
}
|
||||
|
||||
public String getAssociationName()
|
||||
{
|
||||
return associationName;
|
||||
}
|
||||
|
||||
public void setAssociationName(String associationName)
|
||||
{
|
||||
this.associationName = associationName;
|
||||
}
|
||||
|
||||
public String getActionOnAssociatedNode()
|
||||
{
|
||||
return actionOnAssociatedNode;
|
||||
}
|
||||
|
||||
public void setActionOnAssociatedNode(String actionOnAssociatedNode)
|
||||
{
|
||||
this.actionOnAssociatedNode = actionOnAssociatedNode;
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
# Version label
|
||||
version.major=7
|
||||
version.minor=3
|
||||
version.minor=4
|
||||
version.revision=0
|
||||
version.label=
|
||||
|
||||
|
@@ -170,7 +170,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
executer.executeImpl();
|
||||
|
||||
// then
|
||||
|
||||
verify(mockedNodeService, times(2)).getPrimaryParent(any(NodeRef.class));
|
||||
// ensure the query is executed and closed
|
||||
verifyQueryTimes(2);
|
||||
|
||||
@@ -206,7 +206,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
executer.executeImpl();
|
||||
|
||||
// then
|
||||
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(any(NodeRef.class));
|
||||
// ensure the query is executed and closed
|
||||
verifyQueryTimes(1);
|
||||
|
||||
@@ -262,11 +262,11 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
// ensure each node is process correctly
|
||||
// node1
|
||||
verify(mockedNodeService, times(1)).getProperty(node1, RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(node1);
|
||||
verify(mockedNodeService, times(3)).getPrimaryParent(node1);
|
||||
verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(CUTOFF), anyMap());
|
||||
// node2
|
||||
verify(mockedNodeService, times(1)).getProperty(node2, RecordsManagementModel.PROP_DISPOSITION_ACTION);
|
||||
verify(mockedNodeService, times(1)).getPrimaryParent(node2);
|
||||
verify(mockedNodeService, times(3)).getPrimaryParent(node2);
|
||||
verify(mockedRecordsManagementActionService, times(1)).executeRecordsManagementAction(eq(parent), eq(RETAIN), anyMap());
|
||||
|
||||
// ensure no more interactions
|
||||
@@ -329,7 +329,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
// call the service
|
||||
executer.executeImpl();
|
||||
|
||||
// check the loop iterated trough all the elements
|
||||
// check the loop iterated through all the elements
|
||||
verify(mockedNodeService).exists(node1);
|
||||
verify(mockedNodeService).exists(node2);
|
||||
verify(mockedNodeService).exists(node3);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -38,6 +38,9 @@ tags:
|
||||
description: Retrieve and manage unfiled records containers
|
||||
- name: unfiled-record-folders
|
||||
description: Retrieve and manage unfiled record folders
|
||||
- name: events
|
||||
description: Retrieve and manage retention events
|
||||
|
||||
paths:
|
||||
## GS sites
|
||||
'/gs-sites':
|
||||
@@ -2091,7 +2094,172 @@ paths:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
'/events':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: List all available retention events
|
||||
description: |
|
||||
Gets the list of events that can be used by retention steps
|
||||
operationId: getAllEvents
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/skipCountParam'
|
||||
- $ref: '#/parameters/maxItemsParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventPaging'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: value of **maxItems** or **skipCount** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
post:
|
||||
tags:
|
||||
- events
|
||||
summary: Create a new retention event
|
||||
description: |
|
||||
Creates a new event that can be used by retention schedules.
|
||||
operationId: createEvent
|
||||
parameters:
|
||||
- in: body
|
||||
name: eventBodyCreate
|
||||
description: The new event.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/EventBody'
|
||||
consumes:
|
||||
- application/json
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
'201':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **name** or **type** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'403':
|
||||
description: Current user does not have permission to create event
|
||||
'409':
|
||||
description: Cannot create event. An event with the name **name** already exists
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
'/events/{eventId}':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: Return event for given eventId
|
||||
description: |
|
||||
Gets information about the retention event with id **eventId**.
|
||||
operationId: getEvent
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/eventIdParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **eventId** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'404':
|
||||
description: "**eventId** does not exist"
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
put:
|
||||
tags:
|
||||
- events
|
||||
summary: Update event for given eventId
|
||||
operationId: updateEvent
|
||||
description: |
|
||||
Updates retention event with id **eventId**.
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/eventIdParam'
|
||||
- in: body
|
||||
name: eventBodyUpdate
|
||||
description: The event information to update.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/EventBody'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: The update request is invalid or **eventId** is not a valid format or **eventBodyUpdate** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'403':
|
||||
description: Current user does not have permission to update events
|
||||
'404':
|
||||
description: "**eventId** does not exist"
|
||||
'409':
|
||||
description: Cannot update event. An event with the name **name** already exists
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
'/event-types':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: List all the retention event types
|
||||
description: |
|
||||
Gets a list of all the retention event types.
|
||||
operationId: getAllEventTypes
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/skipCountParam'
|
||||
- $ref: '#/parameters/maxItemsParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventTypePaging'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: value of **maxItems** or **skipCount** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
parameters:
|
||||
## event
|
||||
eventIdParam:
|
||||
name: eventId
|
||||
in: path
|
||||
description: The identifier of an event.
|
||||
required: true
|
||||
type: string
|
||||
## File plans
|
||||
filePlanEntryIncludeParam:
|
||||
name: include
|
||||
@@ -3760,3 +3928,91 @@ definitions:
|
||||
- SiteCollaborator
|
||||
- SiteContributor
|
||||
- SiteManager
|
||||
EventPaging:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: object
|
||||
properties:
|
||||
pagination:
|
||||
$ref: '#/definitions/Pagination'
|
||||
entries:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
EventEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/Event'
|
||||
Event:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- type
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: this is the id of the event
|
||||
name:
|
||||
type: string
|
||||
description: This is the unique display label of the event
|
||||
type:
|
||||
type: string
|
||||
description: this is event type
|
||||
EventBody:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: This is the unique display label of the event
|
||||
type:
|
||||
type: string
|
||||
description: this is event type
|
||||
default: Simple
|
||||
EventTypePaging:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: object
|
||||
properties:
|
||||
pagination:
|
||||
$ref: '#/definitions/Pagination'
|
||||
entries:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/EventTypeEntry'
|
||||
EventTypeEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/EventType'
|
||||
EventType:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: this is the event type id
|
||||
name:
|
||||
type: string
|
||||
description: this is event type name
|
||||
isAutomatic:
|
||||
type: boolean
|
||||
description: Whether events of this type need completing manually or can be completed automatically
|
||||
default: true
|
||||
associationName:
|
||||
type: string
|
||||
description: The association used to determine whether automatic events of this type are complete
|
||||
actionOnAssociatedNode:
|
||||
type: string
|
||||
description: If an association name is set for this event type then it is possible to require an action to be completed on the associated node
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
17
core/pom.xml
17
core/pom.xml
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -54,9 +54,14 @@
|
||||
<classifier>asl</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.reload4j</groupId>
|
||||
<artifactId>reload4j</artifactId>
|
||||
<version>1.2.18.3</version>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${dependency.log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
@@ -113,8 +118,8 @@
|
||||
|
||||
<!-- Test only dependencies, as popped up while running mvn test -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-reload4j</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j2-impl</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2022 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* A stand in for the org.apache.log4j.NDC class that avoids introducing runtime dependencies against the otherwise
|
||||
* A stand in for the org.apache.logging.log4j.ThreadContext class that avoids introducing runtime dependencies against the otherwise
|
||||
* optional log4j.
|
||||
*
|
||||
* @author dward
|
||||
@@ -32,7 +32,7 @@ public class NDC
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(NDC.class);
|
||||
|
||||
/** Log4J delegate for NDC */
|
||||
/** Log4J2 delegate for NDC */
|
||||
private static NDCDelegate ndcDelegate;
|
||||
|
||||
static
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2022 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -25,19 +25,19 @@
|
||||
package org.alfresco.util.log.log4j;
|
||||
|
||||
import org.alfresco.util.log.NDCDelegate;
|
||||
import org.apache.log4j.NDC;
|
||||
import org.apache.logging.log4j.ThreadContext;
|
||||
|
||||
/**
|
||||
* A stand in for the org.apache.log4j.NDC class that avoids introducing runtime dependencies against the otherwise
|
||||
* A stand in for the org.apache.logging.log4j.ThreadContext class that avoids introducing runtime dependencies against the otherwise
|
||||
* optional log4j.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class Log4JNDC implements NDCDelegate
|
||||
{
|
||||
// Force resolution of the log4j NDC class by the classloader (thus forcing an error if unavailable)
|
||||
// Force resolution of the log4j2 ThreadContext class by the classloader (thus forcing an error if unavailable)
|
||||
@SuppressWarnings("unused")
|
||||
private static final Class<?> NDC_REF = NDC.class;
|
||||
private static final Class<?> NDC_REF = ThreadContext.class;
|
||||
|
||||
/**
|
||||
* Push new diagnostic context information for the current thread.
|
||||
@@ -47,7 +47,7 @@ public class Log4JNDC implements NDCDelegate
|
||||
*/
|
||||
public void push(String message)
|
||||
{
|
||||
NDC.push(message);
|
||||
ThreadContext.push(message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +55,6 @@ public class Log4JNDC implements NDCDelegate
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
NDC.remove();
|
||||
ThreadContext.clearAll();
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -134,7 +134,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<version>6.3.1</version>
|
||||
<version>6.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- the cxf libs were updated, see dependencyManagement section -->
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -42,10 +42,6 @@ RUN sed -i "s/shared.loader=/shared.loader=\${catalina.base}\/shared\/classes/"
|
||||
|
||||
RUN mkdir -p ${TOMCAT_DIR}/amps
|
||||
|
||||
#RUN echo -e '\n\
|
||||
#log4j.logger.org.alfresco.repo.content.transform.TransformerDebug=debug\n\
|
||||
#' >> ${TOMCAT_DIR}/shared/classes/alfresco/extension/custom-log4j.propertiesRUN mkdir -p ${TOMCAT_DIR}/amps
|
||||
|
||||
# Copy the amps from build context to the appropriate location for your application server
|
||||
COPY ${resource_path}/amps ${TOMCAT_DIR}/amps
|
||||
|
||||
@@ -55,13 +51,14 @@ RUN java -jar ${TOMCAT_DIR}/alfresco-mmt/alfresco-mmt*.jar install \
|
||||
${TOMCAT_DIR}/webapps/alfresco -directory -nobackup
|
||||
|
||||
# Move the log file
|
||||
RUN sed -i -e "s_log4j.appender.File.File\=alfresco.log_log4j.appender.File.File\=${TOMCAT_DIR}/logs\/alfresco.log_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j.properties && \
|
||||
|
||||
RUN sed -i -e "s_appender.rolling.fileName\=alfresco.log_appender.rolling.fileName\=${TOMCAT_DIR}/logs\/alfresco.log_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j2.properties && \
|
||||
sed -i -e "s_appender.rolling.filePattern=alfresco.log.%d{yyyy-MM-dd}_appender.rolling.filePattern\=${TOMCAT_DIR}/logs\/alfresco.log.%d{yyyy-MM-dd}_" \
|
||||
${TOMCAT_DIR}/webapps/alfresco/WEB-INF/classes/log4j2.properties && \
|
||||
# Add catalina.policy to ROOT.war and alfresco.war
|
||||
# Grant all security permissions to alfresco webapp because of numerous permissions required in order to work properly.
|
||||
# Grant only deployXmlPermission to ROOT webapp.
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" ${TOMCAT_DIR}/conf/catalina.policy
|
||||
sed -i -e "\$a\grant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/alfresco\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/_vti_bin\/-\" \{\n\ permission\ java.security.AllPermission\;\n\};\ngrant\ codeBase\ \"file:\$\{catalina.base\}\/webapps\/ROOT\/-\" \{\n\ permission org.apache.catalina.security.DeployXmlPermission \"ROOT\";\n\};" ${TOMCAT_DIR}/conf/catalina.policy
|
||||
|
||||
# fontconfig is required by Activiti worflow diagram generator
|
||||
# installing pinned dependencies as well
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -78,7 +78,6 @@
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>copy-amps</id>
|
||||
<phase>process-resources</phase>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.5
|
||||
SOLR6_TAG=2.0.6-A4
|
||||
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.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
7
packaging/tests/scripts/output_tests_run.sh
Executable file
7
packaging/tests/scripts/output_tests_run.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
TAS_DIRECTORY=$1
|
||||
|
||||
cd ${TAS_DIRECTORY}
|
||||
|
||||
cat target/reports/alfresco-tas.log | grep "*** STARTING"
|
@@ -1,9 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
export DOCKER_COMPOSE_PATH=$1
|
||||
export CLEAN_UP="$2"
|
||||
export DOCKER_COMPOSES=""
|
||||
export CLEAN_UP=""
|
||||
|
||||
if [ -z "$DOCKER_COMPOSE_PATH" ]
|
||||
for var in "$@"
|
||||
do
|
||||
if [ "$var" == "no-clean-up" ]
|
||||
then
|
||||
export CLEAN_UP="$var"
|
||||
else
|
||||
export DOCKER_COMPOSES+="--file $var "
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$DOCKER_COMPOSES" ]
|
||||
then
|
||||
echo "Please provide path to docker-compose.yml: \"${0##*/} /path/to/docker-compose.yml\""
|
||||
exit 1
|
||||
@@ -15,8 +27,8 @@ fi
|
||||
# The second parameter can be used to avoid doing a clean up if we are doing a restart test.
|
||||
if [ "$CLEAN_UP" != "no-clean-up" ]
|
||||
then
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" kill
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" rm -f
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") kill
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") rm -f
|
||||
|
||||
export GENERATED_IMAGES=$(docker images | grep '^environment_' | awk '{ print $3 }')
|
||||
if [ -n "$GENERATED_IMAGES" ]
|
||||
@@ -31,7 +43,7 @@ export TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-tra
|
||||
export TRANSFORM_ROUTER_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-service.version -q -DforceStdout)
|
||||
|
||||
# .env files are picked up from project directory correctly on docker-compose 1.23.0+
|
||||
docker-compose --file "${DOCKER_COMPOSE_PATH}" --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
docker-compose ${DOCKER_COMPOSES} --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
@@ -66,6 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
564
packaging/tests/tas-restapi/README.md
Normal file
564
packaging/tests/tas-restapi/README.md
Normal file
@@ -0,0 +1,564 @@
|
||||

|
||||
|
||||
Back to [TAS Master Documentation](https://git.alfresco.com/tas/alfresco-tas-utility/wikis/home)
|
||||
|
||||
---
|
||||
## Table of Contents
|
||||
* [Synopsis](#synopsis)
|
||||
* [Prerequisite](#prerequisite)
|
||||
* [Installation](#installation-if-you-want-to-contribute)
|
||||
* [Package Presentation](#package-presentation)
|
||||
* [Sample Usage](#sample-usage)
|
||||
* [How to write a test](#how-to-write-a-test)
|
||||
* [How to generate models or check coverage](#how-to-generate-models-or-check-coverage)
|
||||
* [How to run tests?](#how-to-run-tests)
|
||||
* [from IDE](#from-ide)
|
||||
* [from command line](#from-command-line)
|
||||
* [Listeners](#listeners)
|
||||
* [Test Results](#test-results)
|
||||
* [Test Rail Integration](#test-rail-integration)
|
||||
* [Configuration](#configuration)
|
||||
* [How to enable Test Rail Integration?](#how-to-enable-test-rail-integration)
|
||||
* [Reference](#reference)
|
||||
* [Change Log](docs/CHANGELOG.md) 🌟
|
||||
* [Contributors](#contributors)
|
||||
* [Releasing](#releasing)
|
||||
* [License](#license)
|
||||
|
||||
## Synopsis
|
||||
|
||||
**TAS**( **T**est **A**utomation **S**ystem)- **RESTAPI** is the project that handles the automated tests related only to [Alfresco REST API](http://docs.alfresco.com/5.1/pra/1/topics/pra-welcome.html).
|
||||
|
||||
It is based on Apache Maven, compatible with major IDEs and is using also Spring capabilities for dependency injection.
|
||||
|
||||
As a high level overview, this project makes use of the following functionality useful in automation testing as:
|
||||
* reading/defining test environment settings (e.g. alfresco server details, authentication, etc.)
|
||||
* managing resource (i.e. creating files and folders)
|
||||
* test data generators (for site, users, content, etc)
|
||||
* helpers (i.e. randomizers, test environment information)
|
||||
* test logging generated on runtime and test reporting capabilities
|
||||
* test management tool integration (at this point we support integration with [Test Rail](https://alfresco.testrail.net) (v5.2.1)
|
||||
* health checks (verify if server is reachable, if server is online)
|
||||
* generic Internal-DSL (Domain Specific Language)
|
||||
|
||||
Using Nexus -Release Repository, everyone will be able to use individual interfaces in their projects by extending the automation core functionalities.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Prerequisite
|
||||
(tested on unix/non-unix destribution)
|
||||
* [Java SE 1.8](http://www.oracle.com/technetwork/java/javase/downloads/index.html).
|
||||
* [Maven 3.3](https://maven.apache.org/download.cgi) installed and configure according to [Windows OS](https://maven.apache.org/guides/getting-started/windows-prerequisites.html) or [Mac OS](https://maven.apache.org/install.html).
|
||||
* Configure Maven to use Alfresco alfresco-internal repository following this [Guide](https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Maven_Setup).
|
||||
* Your favorite IDE as [Eclipse](https://eclipse.org/downloads/) or [InteliJ](https://www.jetbrains.com/idea).
|
||||
* Access to [Nexus](https://nexus.alfresco.com/nexus/) repository.
|
||||
* Access to Gitlab [TAS](https://gitlab.alfresco.com/tas/) repository.
|
||||
* GitLab client for your operating system. (we recommend [SourceTree](https://www.sourcetreeapp.com) - use your google account for initial setup).
|
||||
* Getting familiar with [Basic Git Commands](http://docs.gitlab.com/ee/gitlab-basics/basic-git-commands.html).
|
||||
* Getting familiar with [Maven](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
|
||||
* Getting familiar with [Spring](http://docs.spring.io).
|
||||
* Getting familiar with [TestNG](http://testng.org/doc/index.html)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Installation (if you want to contribute)
|
||||
|
||||
* Open your Gitlab client and clone the repository of this project.
|
||||
* You can do this also from command line (or in your terminal) adding:
|
||||
|
||||
```bash
|
||||
$ git clone https://git.alfresco.com/tas/alfresco-tas-restapi-test.git
|
||||
# this clone will have the latest changes from repository. If you want to checkout a specific version released, take a look at the [Change Log](docs/CHANGELOG.md) page
|
||||
$ cd alfresco-tas-tester
|
||||
# this command will checkout the remove v2.0.0 tagged repository and create locally a new branch v2.0.0
|
||||
$ git checkout tags/v2.0.0 -b v2.0.0
|
||||
|
||||
```
|
||||
|
||||
* Install and check if all dependencies are downloaded
|
||||
|
||||
```bash
|
||||
> cd alfresco-tas-restapi-test
|
||||
> mvn clean install -DskipTests
|
||||
# you should see one [INFO] BUILD SUCCESS message displayed
|
||||
```
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Package Presentation
|
||||
|
||||
The project uses a maven layout [archetype](https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/simple.html):
|
||||
```ruby
|
||||
├── pom.xml
|
||||
├── report.html
|
||||
├── src
|
||||
│ ├── main
|
||||
│ │ └── java
|
||||
│ │ └── org
|
||||
│ │ └── alfresco
|
||||
│ │ └── rest
|
||||
│ │ ├── core
|
||||
│ │ │ ├── assertion
|
||||
│ │ │ │ ├── IModelAssertion.java
|
||||
│ │ │ │ ├── IModelsCollectionAssertion.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── PaginationAssertionVerbs.java
|
||||
│ │ │ ├── swagger
|
||||
│ │ │ │ ├── Generator.java
|
||||
│ │ │ │ ├── RestModelProperty.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── SwaggerYamlParser.java
|
||||
│ │ │ ├── IRestModel.java
|
||||
│ │ │ ├── IRestModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── RestResponse.java
|
||||
│ │ │ └── RestWrapper.java
|
||||
│ │ ├── exception
|
||||
│ │ │ ├── EmptyJsonResponseException.java
|
||||
│ │ │ ├── EmptyRestModelCollectionException.java
|
||||
│ │ │ └── JsonToModelConversionException.java
|
||||
│ │ ├── model
|
||||
│ │ │ ├── builder
|
||||
│ │ │ │ └── NodesBuilder.java
|
||||
│ │ │ ├── RestActivityModel.java
|
||||
│ │ │ ├── RestActivityModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── RestVariableModelsCollection.java
|
||||
│ │ ├── requests
|
||||
│ │ │ ├── authAPI
|
||||
│ │ │ │ └── RestAuthAPI.java
|
||||
│ │ │ ├── coreAPI
|
||||
│ │ │ │ └── RestCoreAPI.java
|
||||
│ │ │ ├── workflowAPI
|
||||
│ │ │ │ └── RestWorkflowAPI.java
|
||||
│ │ │ ├── Deployments.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── Tenant.java
|
||||
│ │
|
||||
│ ├── test
|
||||
│ │ ├── java
|
||||
│ │ │ └── org
|
||||
│ │ │ └── alfresco
|
||||
│ │ │ └── rest
|
||||
│ │ │ ├── auth
|
||||
│ │ │ │ └── AuthTests.java
|
||||
│ │ │ ├── comments
|
||||
│ │ │ │ ├── AddCommentCoreTests.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── workflow
|
||||
│ │ │ │ ├── deployments
|
||||
│ │ │ │ │ ├── DeleteDeploymentCoreFullTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── processDefinitions
|
||||
│ │ │ │ │ ├── GetProcessDefinitionCoreTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── FunctionalCasesTests.java
|
||||
│ │ │ └── RestTest.java
|
||||
│ │ └── resources
|
||||
│ │ ├── alfresco-restapi-context.xml
|
||||
│ │ ├── default.properties
|
||||
│ │ └── log4j.properties
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Sample Usage
|
||||
|
||||
Following the standard layout for Maven projects, the application sources locate in src/main/java and test sources locate in src/test/java.
|
||||
Application sources consist in defining the REST API object that simulates the calls: get, post, put, delete.
|
||||
The tests are based on an abstract object: Rest.java that handles the common behavior: checking the health status of the test server, configuration settings, getting the general properties, etc.
|
||||
|
||||
Please take a look at [RestDemoTests.java](src/test/java/org/alfresco/rest/demo/RestDemoTests.java) class for an example.
|
||||
|
||||
Common configuration settings required for this project are stored in properties file, see [default.properties](src/test/resources/default.properties).
|
||||
Please analyze and update it accordingly with Alfresco test server IP, port, credentials, etc.
|
||||
|
||||
Example:
|
||||
```java
|
||||
# Alfresco HTTP Server Settings
|
||||
alfresco.scheme=http
|
||||
alfresco.server=<add-here-the-ip-of-your-test-server>
|
||||
alfresco.port=<default-port-for-alfresco-not-share>
|
||||
```
|
||||
|
||||
* optional update the logging level in [log4j](src/test/resources/log4j.properties) file (you can increase/decrease the deails of the [logging file](https://logging.apache.org/log4j/1.2/manual.html), setting the ```log4j.rootLogger=DEBUG``` if you want.)
|
||||
* go to [running](#how-to-run-tests) section for more information on how to run this tests.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to write a test
|
||||
|
||||
* Please also take a look at the [Rest-API desing and implementation](https://ts.alfresco.com/share/page/site/eng/document-details?nodeRef=workspace://SpacesStore/9f7823e7-0597-4435-9fd1-6ec8a4791259) guidelines.
|
||||
* Tests are organized in java classes and located on src/test/java as per maven layout.
|
||||
* One test class should contain the tests that cover one functionality as we want to have a clear separation of test scope: tests for sanity/core/full, tests that verify manage of folder/files etc.
|
||||
* These are the conventions that need to follow when you write a test:
|
||||
* The test class has @Test annotation with the group defined: rest-api. You can add more groups like sanity, regression
|
||||
|
||||
```java
|
||||
@Test(groups={ TestGroup.COMMENTS}
|
||||
```
|
||||
|
||||
* The test has @TestRail annotation in order to assure that the details and results will be submitted on TestRail. The fields for TestRail annotation will be explained on next chapter.
|
||||
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets person with Rest API and response is not empty")
|
||||
public void adminShouldRetrievePerson() throws Exception
|
||||
{
|
||||
peopleAPI.getPerson(userModel.getUsername())
|
||||
.assertResponseIsNotEmpty();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
* Use Spring capabilities to initialize the objects(Models, Wrappers) with @Autowired
|
||||
|
||||
* To view a simple class that is using this utility, just browse on [RestDemoTests.java]((src/test/java/org/alfresco/rest/demo/RestDemoTests.java)
|
||||
Notice the class definition and inheritance value:
|
||||
|
||||
```java
|
||||
public class RestDemoTest extends RestTest
|
||||
```
|
||||
|
||||
* as a convention, before running your test, check if the test environment is reachable and your alfresco test server is online.
|
||||
(this will stop the test if the server defined in your property file is not healthy - method available in parent class)
|
||||
|
||||
```java
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupRestTest() throws Exception{
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
```
|
||||
* the test name are self explanatory:
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets sites with Rest API and status code is 200")
|
||||
public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
siteAPI.getSites();
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
```
|
||||
* Asserting on imbricated keys:
|
||||
|
||||
Let's say your response is something like:
|
||||
|
||||
```json
|
||||
{"entry": {
|
||||
"createdAt": "2017-08-01T12:01:24.979+0000",
|
||||
"edited": false,
|
||||
"modifiedBy": {
|
||||
"firstName": "Administrator"
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
if you want to assert that firstName is "Administrator" you can do that using the following DSL:
|
||||
|
||||
```java
|
||||
restClient.onResponse().assertThat().body("entry.modifiedBy.firstName", org.hamcrest.Matchers.is("Administrator"));
|
||||
```
|
||||
|
||||
(notice that i'm using Hamcrest Matcher to finalize this assertion)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to generate models or check coverage
|
||||
|
||||
There are some simple generators that could parse [Swagger YAML](http://docs.alfresco.com/community/concepts/alfresco-sdk-tutorials-using-rest-api-explorer.html) files and provide some usefull information to you like:
|
||||
|
||||
a) Show on screen the actual coverage of TAS vs requests that exists in each YAML file - defined in pom.xml)
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dcoverage
|
||||
```
|
||||
Any missing request are saved under "missing-requests```<yaml-file-name>```.txt" file for further analysis
|
||||
All current implementation are saved under "implemented-requests```<yaml-file-name>```.txt"
|
||||

|
||||
|
||||
b) Generate all missing models
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels
|
||||
```
|
||||
|
||||
This command will read all definitions of models from swagger YAML file predefined in pom.xml file.
|
||||
It will compare with this file pattern: 'Rest```<model-definition-name>```Model.java', file created under ```/src/main/java/org/alfresco/rest/model``` ignoring the ones that are specified in [ignore-models](src/main/java/org/alfresco/rest/model/ignore-models) file.
|
||||
|
||||

|
||||
|
||||
At this time you you will be prompted to select (based on displayed ID) what models you want to generate (separate each one by comma).
|
||||
(you can also skip the generation of models from select yaml file or generate all missing models)
|
||||
|
||||
|
||||
c) Generate specific models
|
||||
Maybe you want to generate/regenerate just one model or multiple ones.
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels=Error,SiteModel
|
||||
```
|
||||
|
||||
This command will parse the Swagger YAML file, and will generate the definition of only those specified models, even if those models exist locally (in this case you will be prompted to override that file or not)
|
||||
|
||||
_NOTE_: there are some fields that are marked as ```required``` in swagger file. We also generate those fields with annotation ```@JsonProperty(required = true)```
|
||||
|
||||
All models are generated based on a [freemarker](http://freemarker.org) template found [here](src/main/resources/rest-model.ftl).
|
||||
|
||||
### How to run tests
|
||||
|
||||
#### from IDE
|
||||
|
||||
* The project can be imported into a development environment tool (Eclipse or IntelliJ). You have the possibility to execute tests or suite of tests using [TestNG plugin](http://testng.org/doc/eclipse.html) previously installed in IDE.
|
||||
|
||||
* In case you are using the default settings that points to localhost (127.0.0.1) and you don't have Alfresco installed on your machine, you will see one exception thrown (as expected):
|
||||
```java
|
||||
org.alfresco.utility.exception.ServerUnreachableException: Server {127.0.0.1} is unreachable.
|
||||
```
|
||||
|
||||
#### from command line
|
||||
|
||||
* In terminal or CMD, navigate (with CD) to root folder of your project (you can use the sample project):
|
||||
|
||||
|
||||
|
||||
The tests can be executed on command line/terminal using Maven command
|
||||
|
||||
```bash
|
||||
mvn test
|
||||
```
|
||||
|
||||
This command with trigger the tests specified in the default testng suite from POM file: <suiteXmlFile>src/main/resources/shared-resources/restapi-acs-community-suite.xml</suiteXmlFile>
|
||||
|
||||
You can use -Dtest parameter to run the test/suites through command line (http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html).
|
||||
|
||||
You can also specify a different suiteXMLFile like:
|
||||
|
||||
```bash
|
||||
mvn test -DsuiteXmlFile=src/resources/your-custom-suite.xml
|
||||
```
|
||||
|
||||
Or even a single test:
|
||||
|
||||
```bash
|
||||
mvn test -Dtest=org.alfresco.rest.RestDemoTest
|
||||
```
|
||||
But pay attention that you will not have enabled all the [listeners](#listeners) in this case (the Reporting listener or TestRail integration one)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Listeners
|
||||
|
||||
With the help of Listeners we can modify the behavior of TestNG framework. There are a lot of testNG listener interfaces that we can override in order to provide new functionalities.
|
||||
The TAS framework provides out of the box a couple of listeners that you could use. These could be enabled and added at the class level or suite level.
|
||||
|
||||
### a) org.alfresco.utility.report.ReportListenerAdapter
|
||||
|
||||
* if added at the class level:
|
||||
|
||||
```java
|
||||
@Listeners(value=ReportListenerAdapter.class)
|
||||
public class MyTestClass extends RestTest
|
||||
{
|
||||
(...)
|
||||
}
|
||||
```
|
||||
|
||||
* or suite xml level
|
||||
|
||||
```java
|
||||
<suite name="Your Suite test" parallel="classes">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
|
||||
</listeners>
|
||||
(...)
|
||||
</suite>
|
||||
```
|
||||
It will automatically generate one html named "report.html" in ./target/report folder.
|
||||
Please also take a look at [Test Results](#test-results) section.
|
||||
|
||||
### b) org.alfresco.utility.testrail.TestRailExecutorListener
|
||||
It will automatically update Test Rail application with the test cases that you've automated.
|
||||
Please take a look at [Test Rail Integration](#test-rail-integration) section for more details.
|
||||
|
||||
### c) org.alfresco.utility.report.log.LogsListener
|
||||
This is a new listener that will generate further details in one XML format of the automated test steps that you will write.
|
||||
|
||||
Example:
|
||||
|
||||
```java
|
||||
public void myDSLMethod1()
|
||||
{
|
||||
STEP("Lorem ipsum dolor sit amet");
|
||||
//code for first step
|
||||
|
||||
STEP("consectetur adipiscing elit");
|
||||
//code for the next description
|
||||
}
|
||||
|
||||
public void myDSLMethod2()
|
||||
{
|
||||
STEP("sed do eiusmod tempor incididunt ut labore");
|
||||
//code for first step
|
||||
|
||||
STEP("et dolore magna aliqua");
|
||||
//code for the next description
|
||||
}
|
||||
```
|
||||
|
||||
If these methods will be executed insite a test method, all those steps will be automatically logged in the XML report generated.
|
||||
Example:
|
||||
|
||||
```java
|
||||
@Test
|
||||
public void adminShouldCreateFileInSite()
|
||||
{
|
||||
myDSLMethod1();
|
||||
myDSLMethod2()
|
||||
}
|
||||
```
|
||||
|
||||
So if "testingSomething" will be executed this is what you will see on the XML file generated. (please take a look at [Test Results](#test-results) section for defining the defaul location)
|
||||
|
||||
Here is one example of XML file generated with these steps:
|
||||
|
||||

|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Results
|
||||
We already executed a couple of tests using command line as indicated above. Sweet! Please take a look at [rest-suites.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) one more time.
|
||||
You will see there that we have one listener added:
|
||||
|
||||
```java
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
```
|
||||
This will tell our framework, after we run all tests, to generate one HTML report file with graphs and metrics.
|
||||
|
||||
Take a look at the target/reports folder (created after running the tests) and open the report.html file.
|
||||
|
||||

|
||||
|
||||
Playing with this report, you will notice that you will be able to:
|
||||
* search tests cases by name
|
||||
* filter test cases by errors, labels, groups, test types, date when it was executed, protocol used, etc.
|
||||
* view overall pass/fail metrics of current test suite, history of tests execution, etc.
|
||||
|
||||
The report path can be configured in default.properties):
|
||||
|
||||
```
|
||||
# The location of the reports path
|
||||
reports.path=your-new-location-of-reports
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Rail Integration
|
||||
|
||||
Alfresco is using now https://alfresco.testrail.net (v5.3.0.3601).
|
||||
|
||||
We aim to accelerate the delivery of automated test by minimizing the interaction with the test management tool - TestRail. In this scope we developed the following capabilities:
|
||||
* creating automatically the manual tests in TestRail
|
||||
* submitting the test results (with stack trace) after each execution into TestRail Test Runs
|
||||
* adding the test steps for each test.
|
||||
|
||||
### Configuration
|
||||
In order to use Test Rail Integration you will need to add a couple of information in [default.properties](src/test/resources/default.properties) file:
|
||||
(the document is pretty self explanatory)
|
||||
|
||||
```java
|
||||
# Example of configuration:
|
||||
# ------------------------------------------------------
|
||||
# testManagement.enabled=<true/false>
|
||||
# testManagement.endPoint=https://alfresco.testrail.com/
|
||||
# testManagement.username=<yourusername-that-you-connect-to-testrail>
|
||||
# testManagement.apiKey=<api-key>
|
||||
# testManagement.project=<id-of-your-project
|
||||
# testManagement.includeOnlyTestCasesExecuted=<true/false>
|
||||
# testManagement.rateLimitInSeconds= 1
|
||||
# testManagement.testRun=<test-run-name>
|
||||
# testManagement.suiteId=<suite-id>
|
||||
```
|
||||
!This settings are already defined in default.properties for you.
|
||||
|
||||
|
||||
For generating a new API Key take a look at the official documentation, TestRail [APIv2](http://docs.gurock.com/testrail-api2)
|
||||
* _testManagement.project= **<id-of-your-project**_ this is the ID of the project where you want to store your test cases.
|
||||
If you want to use [Alfresco ONE](https://alfresco.testrail.net/index.php?/projects/overview/1) project in TestRail, open that project and notice the URL, after "/overview/**1**" link you will see the ID of the project (1 in this case)
|
||||
If you want to use [TAS Project](https://alfresco.testrail.net/index.php?/projects/overview/7) you will notice the ID 7, so _"testManagement.project=7"_
|
||||
* "_testManagement.testRun=<test-run-name>_" this represents the name of the Test Run from your project.
|
||||
* In Test Rail, navigating to Test Runs & Results, create a new Test Run and include all/particular test cases. If this test run name is "Automation", update _testManagement.testRun= **Automation**_.
|
||||
All test results will be updated only on this test run at runtime as each test is executed by TAS framework.
|
||||
|
||||
### How to enable Test Rail Integration?
|
||||
|
||||
We wanted to simplify the Test Rail integration, so we used listeners in order to enable/disable the integration of Test Rail.
|
||||
* first configure your default.properties as indicated above
|
||||
|
||||
* now on your TestNG test, add the @TestRail annotation, so let's say you will have this test:
|
||||
|
||||
```java
|
||||
@Test(groups="sample-tests")
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
add now @TestRail integration with mandatory field ```section```. This means that this tests annotated, will be uploaded in TestRail:
|
||||
|
||||
```java
|
||||
@Test(groups= TestGroup.REST_API, TestGroup.FULL,)
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES })
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
The section field, represents an array of strings, the hierarchy of sections that SHOULD be found on TestRail under the project you've selected in default.properties. Follow the TestRail [user-guide](http://docs.gurock.com/testrail-userguide/start) for more information regarding sections.
|
||||
In our example we created in Test Rail one root section "restAPI" with a child section: "processes" (you can go further and add multiple section as you wish)
|
||||
|
||||
* now, lets add the listener, the TestRailExecutorListener that will handle this TC Management interaction.
|
||||
This listener can be added at the class level or suite level (approach that we embrace)
|
||||
Take a look at [restapi-acs-community-suite.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) for further example.
|
||||
|
||||
```xml
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
(...)
|
||||
</listeners>
|
||||
```
|
||||
|
||||
Right click on sanity-suite.xml file and run it, or just "mvn test" from root if this sample project.
|
||||
After everything passes, go in Test Rail, open your project and navigate to "Test Cases" section. Notice that under restApi/processes section, you will see your test case published.
|
||||
|
||||
If you defined also the "testManagement.testRun" correctly, you will see under Test Runs, the status of this case marked as passed.
|
||||
|
||||
The @TestRail annotation offers also other options like:
|
||||
- "description" this is the description that will be updated in Test Rail for your test case
|
||||
- "testType", the default value is set to Functional test
|
||||
- "executionType", default value is set to ExecutionType.REGRESSION, but you can also use ExecutionType.SMOKE, ExecutionType.SANITY, etc
|
||||
|
||||
Take a look at the demo scenarios in this project for further examples.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Reference
|
||||
|
||||
* For any improvements, bugs, please use Jira - [TAS](https://issues.alfresco.com/jira/browse/TAS) project.
|
||||
* Setup the environment using [docker](https://gitlab.alfresco.com/tas/alfresco-docker-provisioning/blob/master/Readme.md).
|
||||
* [Bamboo Test Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI)
|
||||
|
||||
## Contributors
|
||||
|
||||
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other... [more](CODE_OF_CONDUCT.md)
|
||||
|
||||
## Releasing
|
||||
|
||||
Any commit done on this project should be automatically executed by [TAS Build Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-TAS)
|
||||
If the build passes, then you didn't broke anything.
|
||||
|
||||
If you want to perform a release, open [TAS-RestAPI](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI) Bamboo Build.
|
||||
Run the Default stage and if it passes, then manually perform the Release stage (this will auto-increment the version in pom.xml)
|
BIN
packaging/tests/tas-restapi/docs/pics/coverage.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/coverage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
BIN
packaging/tests/tas-restapi/docs/pics/html-report-sample.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/html-report-sample.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
BIN
packaging/tests/tas-restapi/docs/pics/models-all.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/models-all.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
@@ -2,27 +2,26 @@
|
||||
<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>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>alfresco-community-repo-restapi-test</artifactId>
|
||||
<name>restapi test</name>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>restapi</artifactId>
|
||||
<name>alfresco-tas-restapi</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.183</version>
|
||||
<version>20.36-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Paul Brodner</name>
|
||||
<roles>
|
||||
<role>Test Automation Architect</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<suiteXmlFile>${project.basedir}/src/test/resources/restapi-suite.xml</suiteXmlFile>
|
||||
<maven.build.sourceVersion>11</maven.build.sourceVersion>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<rest.api.explorer.branch>master</rest.api.explorer.branch>
|
||||
<httpclient-osgi-version>4.5.6</httpclient-osgi-version>
|
||||
<org.glassfish.version>1.1.4</org.glassfish.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<scribejava-apis.version>8.3.1</scribejava-apis.version>
|
||||
<license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
@@ -47,26 +46,146 @@
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<!-- fix the info log messages related to Could not instantiate TestExecutionListener
|
||||
[org.springframework.test.context.web.ServletTestExecutionListener -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- alfresco tester settings -->
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<scope>test</scope>
|
||||
<artifactId>utility</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- REST ASSURED -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient-osgi</artifactId>
|
||||
<version>${httpclient-osgi-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>xml-path</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.scribejava</groupId>
|
||||
<artifactId>scribejava-apis</artifactId>
|
||||
<version>${scribejava-apis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON to Object -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish/javax.json -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>${org.glassfish.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger parser -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--fixing java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap') -->
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
<version>3.0.12</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-json-->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-json</artifactId>
|
||||
<version>3.0.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.json</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -96,6 +215,32 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*UnitTest*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-auth.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-core.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-discovery.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-search.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-workflow.yaml</argument>
|
||||
</arguments>
|
||||
<mainClass>org.alfresco.rest.core.swagger.Generator</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@@ -0,0 +1,70 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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;
|
||||
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
public abstract class NetworkDataPrep extends RestTest
|
||||
{
|
||||
protected static UserModel adminUserModel;
|
||||
protected static UserModel adminTenantUser, secondAdminTenantUser;
|
||||
protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser;
|
||||
protected static UserModel tenantUserWithBad;
|
||||
protected static UserModel userModel;
|
||||
protected static RestNetworkModel restNetworkModel;
|
||||
protected static String tenantDomain;
|
||||
private static boolean isInitialized = false;
|
||||
|
||||
public void init()
|
||||
{
|
||||
if(!isInitialized)
|
||||
{
|
||||
isInitialized = true;
|
||||
initialization();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialization()
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
//create first tenant Admin User.
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant");
|
||||
//create second tenant Admin User.
|
||||
secondAdminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.usingTenant().createTenant(secondAdminTenantUser);
|
||||
|
||||
tenantDomain = tenantUser.getDomain();
|
||||
differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant");
|
||||
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
}
|
||||
}
|
@@ -1,3 +1,28 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -5,7 +30,6 @@ import java.lang.reflect.Method;
|
||||
import org.alfresco.dataprep.WorkflowService;
|
||||
import org.alfresco.rest.core.RestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.rules.RulesTestsUtils;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
@@ -62,15 +86,19 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests
|
||||
@Autowired
|
||||
protected WorkflowService workflow;
|
||||
|
||||
@Autowired
|
||||
protected RulesTestsUtils rulesUtils;
|
||||
|
||||
protected SiteModel testSite;
|
||||
|
||||
@BeforeSuite(alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception
|
||||
public void checkServerHealth()
|
||||
{
|
||||
super.springTestContextPrepareTestInstance();
|
||||
try
|
||||
{
|
||||
super.springTestContextPrepareTestInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalStateException("Error while preparing for test execution", e);
|
||||
}
|
||||
serverHealth.assertServerIsOnline();
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelAssertion;
|
||||
|
||||
public interface IRestModel<Model> extends IModelAssertion<Model> {
|
||||
Model onModel();
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
|
||||
public interface IRestModelsCollection<Model> {
|
||||
|
||||
public List<Model> getEntries();
|
||||
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException;
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
public RestPaginationModel getPagination();
|
||||
|
||||
}
|
@@ -0,0 +1,370 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonBuilderFactory;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.Priority;
|
||||
import org.alfresco.rest.model.RestProcessVariableModel;
|
||||
import org.alfresco.rest.model.RestVariableModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* Json builder for small post calls
|
||||
*/
|
||||
public class JsonBodyGenerator
|
||||
{
|
||||
private static JsonBuilderFactory jsonBuilder;
|
||||
|
||||
/**
|
||||
* @return {@link JsonObjectBuilder}
|
||||
*/
|
||||
public static JsonObjectBuilder defineJSON()
|
||||
{
|
||||
return jsonBuilder().createObjectBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link JsonArrayBuilder}
|
||||
*/
|
||||
public static JsonArrayBuilder defineJSONArray()
|
||||
{
|
||||
return jsonBuilder().createArrayBuilder();
|
||||
}
|
||||
/**
|
||||
* {
|
||||
* "tag":"test-tag-1"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(String key, String value)
|
||||
{
|
||||
return defineJSON().add(key, value).build().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "site": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetSiteWithGuid(SiteModel siteModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("site", defineJSON()
|
||||
.add("guid", siteModel.getGuid()))).build();
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "file": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFileWithGuid(FileModel fileModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("file", defineJSON()
|
||||
.add("guid", fileModel.getNodeRef().replace(";1.0", "")))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "folder": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFolderWithGuid(FolderModel folderModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("folder", defineJSON()
|
||||
.add("guid", folderModel.getNodeRef()))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initialized JSON builder
|
||||
*/
|
||||
private static JsonBuilderFactory jsonBuilder()
|
||||
{
|
||||
if (jsonBuilder == null)
|
||||
return Json.createBuilderFactory(null);
|
||||
else
|
||||
{
|
||||
return jsonBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
public static String likeRating(boolean likeOrNot)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "likes")
|
||||
.add("myRating", likeOrNot).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String fiveStarRating(int stars)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "fiveStar")
|
||||
.add("myRating", stars).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String siteMember(UserModel userModel)
|
||||
{
|
||||
Utility.checkObjectIsInitialized(userModel.getUserRole(), "userModel.getUserRole()");
|
||||
JsonObject value = defineJSON()
|
||||
.add("role", userModel.getUserRole().name())
|
||||
.add("id", userModel.getUsername()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String siteGroup(String authorityId, UserRole role)
|
||||
{
|
||||
Utility.checkObjectIsInitialized(authorityId, "authorityId");
|
||||
JsonObject value = defineJSON()
|
||||
.add("role", role.name())
|
||||
.add("id", authorityId).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String siteMemberhipRequest(String message, SiteModel siteModel, String title)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("message", message)
|
||||
.add("id", siteModel.getId())
|
||||
.add("title", title).build();
|
||||
return value.toString();
|
||||
}
|
||||
/**
|
||||
* Method to create a Json object for SiteBody with site title, description, visibility
|
||||
* @param siteModel
|
||||
* @return String
|
||||
*/
|
||||
public static String updateSiteRequest(SiteModel siteModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("title", siteModel.getTitle())
|
||||
.add("description", siteModel.getDescription())
|
||||
.add("visibility", siteModel.getVisibility().toString()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String process(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("processDefinitionKey", processDefinitionKey)
|
||||
.add("variables", jsonBuilder().createObjectBuilder()
|
||||
.add("bpm_assignee", assignee.getUsername())
|
||||
.add("bpm_sendEMailNotifications", sendEmailNotifications)
|
||||
.add("bpm_workflowPriority", priority.getLevel())).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String processVariable(RestProcessVariableModel variableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("name", variableModel.getName())
|
||||
.add("value", variableModel.getValue())
|
||||
.add("type", variableModel.getType()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String taskVariable(RestVariableModel taskVariableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("scope", taskVariableModel.getScope())
|
||||
.add("name", taskVariableModel.getName())
|
||||
.add("type", taskVariableModel.getType())
|
||||
.add("value", taskVariableModel.getValue().toString()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "copy",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* "params": {
|
||||
"destination-folder": "34219f79-66fa-4ebf-b371-118598af898c"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode, Map<String, Serializable> params)
|
||||
{
|
||||
JsonObjectBuilder objectBuilder = jsonBuilder().createObjectBuilder();
|
||||
for(Map.Entry<String, Serializable> param : params.entrySet())
|
||||
{
|
||||
addJsonValue(objectBuilder, param.getKey(), param.getValue());
|
||||
|
||||
}
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.add("params", objectBuilder).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/** Add a value to the JSON object. */
|
||||
private static void addJsonValue(JsonObjectBuilder objectBuilder, String key, Serializable value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
objectBuilder.add(key, JsonObject.NULL);
|
||||
}
|
||||
else if (value instanceof Boolean)
|
||||
{
|
||||
objectBuilder.add(key, (boolean) value);
|
||||
}
|
||||
else if (value instanceof String)
|
||||
{
|
||||
objectBuilder.add(key, (String) value);
|
||||
}
|
||||
else if (value instanceof Integer)
|
||||
{
|
||||
objectBuilder.add(key, (int) value);
|
||||
}
|
||||
else if (value instanceof Long)
|
||||
{
|
||||
objectBuilder.add(key, (long) value);
|
||||
}
|
||||
else if (value instanceof Double)
|
||||
{
|
||||
objectBuilder.add(key, (double) value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Unable to add entry to JsonObject: {" + key + ": " + value + "}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "check-out",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "key1":"key1",
|
||||
* "key2":"key2",
|
||||
* "key3":"key3"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(HashMap<String, String> mapJson)
|
||||
{
|
||||
JsonObjectBuilder builder= defineJSON();
|
||||
|
||||
for (Map.Entry<String, String> entry : mapJson.entrySet())
|
||||
{
|
||||
builder.add(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return builder.build().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a collection of {@link TestModel} objects to JSON for a multi-entity POST request.
|
||||
*
|
||||
* @param models The entities to convert.
|
||||
* @return The JSON string.
|
||||
*/
|
||||
public static String arrayToJson(List<? extends TestModel> models)
|
||||
{
|
||||
// Rather than convert backwards and forwards between Jackson and javax objects then we handle array creation ourselves.
|
||||
StringJoiner stringJoiner = new StringJoiner(",\n");
|
||||
for (TestModel model : models)
|
||||
{
|
||||
stringJoiner.add(model.toJson());
|
||||
}
|
||||
return "[\n" + stringJoiner.toString() + "\n]";
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.utility.data.AisToken;
|
||||
import org.alfresco.utility.data.auth.DataAIS;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.keycloak.authorization.client.util.HttpResponseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RestAisAuthentication
|
||||
{
|
||||
public static String STEP_PREFIX = "RestAisAuthProvider:";
|
||||
public static String USER_DISABLED_MSG = "Account disabled";
|
||||
|
||||
@Autowired
|
||||
private DataAIS dataAIS;
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the AIS access token for the specified user model.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
public String getAisAuthenticationToken(UserModel userModel)
|
||||
{
|
||||
STEP(String.format("%s Retrieving AIS authentication.", STEP_PREFIX));
|
||||
AisToken aisToken = getAisAccessToken(userModel);
|
||||
|
||||
return aisToken.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Alfresco Identity Service is enabled
|
||||
* @return True if Alfresco Identity Service is enabled (the identity service URL is not null or empty)
|
||||
*/
|
||||
public Boolean isAisAuthenticationEnabled()
|
||||
{
|
||||
return dataAIS.isEnabled() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid access token for valid user credentials in userModel. An
|
||||
* invalid access token is returned for invalid user credentials, which can
|
||||
* be used for tests involving non existing or unauthorized users.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
private AisToken getAisAccessToken(UserModel userModel)
|
||||
{
|
||||
String badToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJUazFPZ2JqVlo1UEw2bmtsNWFvTUlacTZ4cW9PZzc5WGtzdnJTTUcxLUFZIn0.eyJqdGkiOiI3NTVkMGZiOS03NzI5LTQ1NzYtYWM4Ny1hZWZjZWNiZDE0ZGEiLCJleHAiOjE1NTM2MjQ1NDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFsZnJlc2NvIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiNjJlN2U5YzktZmFlNS00N2RhLTk5MDItMTZjYTJhZWUwMWMwIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwOi8vbG9jYWxob3N0KiIsImh0dHBzOi8vbG9jYWxob3N0KiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoidXNlci12eGlrcXd3cG5jYmpzeHgifQ.PeLGCNCzj-P2m0knwUU9Vfx4dzLLQER9IdV7GyLel9LRN-3J9nh7GBDRQsyDJ0pqhObQyMg4V3wSsrsXRQ6gKhmUyDemmD-w1YMC2a2HKX6GlxsTEF_f1K_R15lIQOawNVErlWjZWORJGCvCYZOJ99SOmeOC6PGY79zLL94MMnf6dXcegePPMOKG-59eNjBkOylTipYebvM40nbbKrS5vzNHQlvUh4ALFeBoMSKGnLSjQd06Dj4SWojG0p1BrxurqDjW0zz6pQlEAm4vcWApRZ6qBLZcMH8adYix07zCDb87GOn1pmfEBWpwd3BEgC_LLu06guaCPHC9tpeIaDTHLg";
|
||||
String badRefreshToken = "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJmM2YyMjhjYS1jMzg5LTQ5MGUtOGU1Zi02YWI1MmJhZDVjZGEifQ.eyJqdGkiOiIyNmExZWNhYy00Zjk0LTQwYzctYjJjNS04NTlhZmQ3NjBiYWMiLCJleHAiOjE1NTM2MjYwNDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdC9hdXRoL3JlYWxtcy9hbGZyZXNjbyIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IlJlZnJlc2giLCJhenAiOiJhbGZyZXNjbyIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjYyZTdlOWM5LWZhZTUtNDdkYS05OTAyLTE2Y2EyYWVlMDFjMCIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJwcm9maWxlIGVtYWlsIn0.lRBJQc7tj0rk7JBC0zpM0dDdZgDKjm9wcxP8nzLnXe4";
|
||||
|
||||
AisToken aisToken;
|
||||
try
|
||||
{
|
||||
// Attempt to get an access token for userModel from AIS
|
||||
aisToken = dataAIS.perform().getAccessToken(userModel);
|
||||
}
|
||||
catch (HttpResponseException e)
|
||||
{
|
||||
// Trying to authenticate with invalid user credentials or disabled
|
||||
// user so return an invalid access token
|
||||
String httpResponse = new String(e.getBytes());
|
||||
if (e.getStatusCode() == 401 || httpResponse.contains(USER_DISABLED_MSG))
|
||||
{
|
||||
STEP(String.format("%s User disabled or invalid user credentials were provided %s:%s. Using invalid token for request.", STEP_PREFIX,
|
||||
userModel.getUsername(), userModel.getPassword()));
|
||||
aisToken = new AisToken(badToken, badRefreshToken, System.currentTimeMillis(), 300000);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return aisToken;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,162 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelsCollectionAssertion;
|
||||
import org.alfresco.rest.core.assertion.ModelsCollectionAssertion;
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
|
||||
/**
|
||||
* Map multiple entries of JSON response to a class <T>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* "entries": [
|
||||
{
|
||||
"entry": {
|
||||
"visibility": "PUBLIC",
|
||||
"guid": "79e140e1-5039-4efa-acaf-c22b5ba7c947",
|
||||
"description": "Description1470255221170",
|
||||
"id": "0-C2291-1470255221170",
|
||||
"title": "0-C2291-1470255221170"
|
||||
}
|
||||
},
|
||||
*
|
||||
* Having this JSON Entry, we can auto-map this to {@link RestSiteModelsCollection} class having a List of <SiteModel> based on this example
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public abstract class RestModels<Model, ModelCollection> implements IRestModelsCollection<Model>, IModelsCollectionAssertion<ModelCollection>
|
||||
{
|
||||
@JsonProperty(value = "entries")
|
||||
private List<Model> modelEntries;
|
||||
|
||||
private RestPaginationModel pagination;
|
||||
|
||||
@Override
|
||||
public List<Model> getEntries()
|
||||
{
|
||||
return modelEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a random entry from entries list
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@Override
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException
|
||||
{
|
||||
STEP("REST API: Get random one entry from response");
|
||||
Random random = new Random();
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
int index = random.nextInt(models.size());
|
||||
return models.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Example
|
||||
* <code>
|
||||
* siteMembershipRequests.getEntryByIndex(0)
|
||||
.assertThat().field("site.visibility").is(moderatedSite.getVisibility())
|
||||
.assertThat().field("site.description").is(moderatedSite.getDescription())
|
||||
.assertThat().field("site.id").is(moderatedSite.getId())
|
||||
.assertThat().field("site.title").is(moderatedSite.getTitle());
|
||||
* </code>
|
||||
* @param index
|
||||
* @return
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Model getEntryByIndex(int index) throws EmptyRestModelCollectionException{
|
||||
STEP("REST API: Get index entry from response");
|
||||
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
if(models.size() > index){
|
||||
return (Model) ((IRestModel<?>)models.get(index)).onModel();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> assertThat()
|
||||
{
|
||||
return new ModelsCollectionAssertion<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ModelCollection when()
|
||||
{
|
||||
return (ModelCollection)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if (getEntries() != null)
|
||||
return getEntries().isEmpty();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestPaginationModel getPagination()
|
||||
{
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(RestPaginationModel pagination)
|
||||
{
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:default.properties")
|
||||
@PropertySource(value = "classpath:${environment}.properties", ignoreResourceNotFound = true)
|
||||
public class RestProperties
|
||||
{
|
||||
@Autowired
|
||||
private TasProperties properties;
|
||||
|
||||
public TasProperties envProperty()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
@@ -0,0 +1,216 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.MissingFormatArgumentException;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
/**
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class RestRequest
|
||||
{
|
||||
private static final String TOKEN_REGEX = "\\{.*?}";
|
||||
private String body;
|
||||
private HttpMethod httpMethod;
|
||||
private String path;
|
||||
private Object[] pathParams;
|
||||
private String contentType = "UTF-8";
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
this(httpMethod, "", path, pathParams);
|
||||
}
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
setHttpMethod(httpMethod);
|
||||
setPath(path);
|
||||
setPathParams(pathParams);
|
||||
setBody(body);
|
||||
// Validate that the supplied path and pathParams are compatible.
|
||||
constructPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when no body is needed
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest simpleRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, path, pathParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when a body has to be provided
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param body
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest requestWithBody(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, body, path, pathParams);
|
||||
}
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body)
|
||||
{
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public HttpMethod getHttpMethod()
|
||||
{
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setHttpMethod(HttpMethod httpMethod)
|
||||
{
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
addQueryParamsIfNeeded();
|
||||
}
|
||||
|
||||
public Object[] getPathParams()
|
||||
{
|
||||
return pathParams;
|
||||
}
|
||||
|
||||
public void setPathParams(Object[] pathParams)
|
||||
{
|
||||
this.pathParams = pathParams;
|
||||
addQueryParamsIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add query parameters to the path if needed.
|
||||
* <p>
|
||||
* e.g. For a path of "api/{fruit}" and params ["apple", "size=10", "colour=red"] then this will
|
||||
* update the path to be "api/{fruit}?{param0}&{param1}" so that the tokens will be populated by
|
||||
* RestAssured to make "api/apple?size=10&colour=red".
|
||||
*/
|
||||
private void addQueryParamsIfNeeded()
|
||||
{
|
||||
// Don't do anything if the path or path params haven't been set yet.
|
||||
if (path == null || path.length() == 0 || pathParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int groupCount = (int) Pattern.compile(TOKEN_REGEX).matcher(path).results().count();
|
||||
if (pathParams.length > groupCount)
|
||||
{
|
||||
// Add the remaining parameters to the URL query.
|
||||
String queryParams = IntStream.range(0, pathParams.length - groupCount)
|
||||
.mapToObj(index -> "{parameter" + index + "}")
|
||||
.collect(Collectors.joining("&"));
|
||||
path += (path.contains("?") ? "&" : "?") + queryParams;
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentType()
|
||||
{
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws MissingFormatArgumentException If there are not enough pathParams for the path.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append("Request: ")
|
||||
.append(getHttpMethod())
|
||||
.append(" ")
|
||||
.append(RestAssured.baseURI)
|
||||
.append(":")
|
||||
.append(RestAssured.port)
|
||||
.append("/")
|
||||
.append(RestAssured.basePath)
|
||||
.append("/");
|
||||
|
||||
sb.append(constructPath());
|
||||
|
||||
if(!getBody().isEmpty())
|
||||
{
|
||||
sb.append("\nbody:")
|
||||
.append(getBody());
|
||||
}
|
||||
sb.append("\n");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the path with the pathParams.
|
||||
*
|
||||
* @return The path with tokens replaced with values.
|
||||
* @throws MissingFormatArgumentException If there are not enough pathParams for the path.
|
||||
*/
|
||||
private String constructPath()
|
||||
{
|
||||
String getPathFormatted = getPath();
|
||||
if(getPath().contains("{"))
|
||||
{
|
||||
getPathFormatted = getPath().replaceAll(TOKEN_REGEX, "%s");
|
||||
getPathFormatted = String.format(getPathFormatted, getPathParams());
|
||||
}
|
||||
return getPathFormatted;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core;
|
||||
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
|
||||
/**
|
||||
* Defines a Rest Response
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class RestResponse
|
||||
{
|
||||
private Response response;
|
||||
|
||||
public RestResponse(Response response)
|
||||
{
|
||||
this.setResponse(response);
|
||||
}
|
||||
|
||||
public String getStatusCode()
|
||||
{
|
||||
return String.valueOf(response.getStatusCode());
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(Response response)
|
||||
{
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public <T> T toModel(Class<T> classz)
|
||||
{
|
||||
return response.as(classz);
|
||||
|
||||
}
|
||||
|
||||
public ValidatableResponse assertThat()
|
||||
{
|
||||
return response.then();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
public interface IModelAssertion<Model>
|
||||
{
|
||||
default ModelAssertion<Model> assertThat()
|
||||
{
|
||||
return new ModelAssertion<>(this);
|
||||
}
|
||||
|
||||
default ModelAssertion<Model> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public interface IModelsCollectionAssertion<ModelCollection> {
|
||||
public ModelsCollectionAssertion and();
|
||||
|
||||
public ModelsCollectionAssertion assertThat();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default ModelCollection when()
|
||||
{
|
||||
return (ModelCollection) this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,435 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import io.restassured.path.json.JsonPath;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model
|
||||
* Just pass your rest model as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
|
||||
public class ModelAssertion<T>
|
||||
{
|
||||
protected static void checkFieldIsPresent(Object fieldNameToBeRetuned, Object fieldValueToBeRetuned)
|
||||
{
|
||||
if (fieldValueToBeRetuned == null)
|
||||
{
|
||||
Assert.fail(String.format("Field {%s} was not found in returned response.",fieldNameToBeRetuned));
|
||||
}
|
||||
}
|
||||
private final Object model;
|
||||
|
||||
public ModelAssertion(Object model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this DSL for asserting particular fields of your model if your model
|
||||
* is like this (basic POJO)
|
||||
* public class Person extends ModelAssertion<Person>
|
||||
* { private String id = "1234"; }
|
||||
* you can use assert the id of this person as:
|
||||
* Person p = new Person(); p.assertThat().field("id").is("1234")
|
||||
*
|
||||
* @param fieldName
|
||||
* @return
|
||||
* @throws IllegalStateException If the field cannot be converted to JSON.
|
||||
*/
|
||||
public AssertionVerbs field(String fieldName)
|
||||
{
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String jsonInString = null;
|
||||
try
|
||||
{
|
||||
jsonInString = mapper.writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
Object fieldValue = JsonPath.with(jsonInString).get(fieldName);
|
||||
|
||||
return new AssertionVerbs(model, fieldValue, fieldName);
|
||||
}
|
||||
|
||||
public AssertionItemVerbs fieldsCount()
|
||||
{
|
||||
|
||||
int actualSize = 0;
|
||||
List<Field> allFields = getAllDeclaredFields(new LinkedList<Field>(), model.getClass());
|
||||
|
||||
for (Field field : allFields)
|
||||
{
|
||||
|
||||
field.setAccessible(true);
|
||||
Object fieldValue = null;
|
||||
try
|
||||
{
|
||||
fieldValue = field.get(model);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new IllegalStateException("Unable to load model using reflection.", e);
|
||||
}
|
||||
if (fieldValue != null)
|
||||
actualSize++;
|
||||
}
|
||||
return new AssertionItemVerbs(model, actualSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method for asserting whole model with different model object. Method allows to ignore particular fields during the comparison.
|
||||
*
|
||||
* WARNING: For proper work model should implement {@code toString()} and {@code equals()} methods.
|
||||
*
|
||||
* @param expected - expected model.
|
||||
* @param ignoreFields - fields which should be ignored during assertion.
|
||||
* @return model.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T isEqualTo(T expected, String... ignoreFields)
|
||||
{
|
||||
T modelCopy = createCopyIgnoringFields((T) model, ignoreFields);
|
||||
T expectedCopy = createCopyIgnoringFields(expected, ignoreFields);
|
||||
Assert.assertEquals(modelCopy, expectedCopy, String.format("Compared objects of type: %s are not equal!", model.getClass()));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all fields declared from all classes hierarchy
|
||||
*
|
||||
* @param fields
|
||||
* @param classz
|
||||
* @return
|
||||
*/
|
||||
private List<Field> getAllDeclaredFields(List<Field> fields, Class<?> classz)
|
||||
{
|
||||
if (classz.isAssignableFrom(TestModel.class))
|
||||
{
|
||||
return fields;
|
||||
}
|
||||
|
||||
fields.addAll(Arrays.asList(classz.getDeclaredFields()));
|
||||
|
||||
if (classz.getSuperclass() != null)
|
||||
{
|
||||
fields = getAllDeclaredFields(fields, classz.getSuperclass());
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private T createCopyIgnoringFields(T model, String... ignoreFields)
|
||||
{
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.registerTypeAdapterFactory(new SerializableTypeAdapterFactory());
|
||||
Gson gson = gsonBuilder.create();
|
||||
JsonObject jsonObject = gson.fromJson(gson.toJson(model), JsonObject.class);
|
||||
for (String ignoreField : ignoreFields)
|
||||
{
|
||||
jsonObject.remove(ignoreField);
|
||||
}
|
||||
return gson.fromJson(gson.toJson(jsonObject), (Class<? extends T>) model.getClass());
|
||||
}
|
||||
|
||||
/** Workaround from https://github.com/google/gson/issues/544 */
|
||||
private class SerializableTypeAdapterFactory implements TypeAdapterFactory
|
||||
{
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
|
||||
{
|
||||
if (Serializable.class.equals(type.getRawType()))
|
||||
{
|
||||
return (TypeAdapter<T>) gson.getAdapter(Object.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL assertion on Rest Model fields
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionVerbs
|
||||
{
|
||||
private String fieldName;
|
||||
private Object model;
|
||||
private Object fieldValue;
|
||||
|
||||
public AssertionVerbs(Object model, Object fieldValue, String fieldName)
|
||||
{
|
||||
this.model = model;
|
||||
this.fieldValue = fieldValue;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
private String errorMessage(String info)
|
||||
{
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName, model.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public T isNot(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotEquals(fieldValue, expected, errorMessage("is correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
throw new UnsupportedOperationException("You probably want to use is() rather than equals()");
|
||||
}
|
||||
|
||||
public T is(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertEquals(fieldValue.toString(), expected.toString(), errorMessage("is NOT correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is a non-empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isNotEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyList(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyMap(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Integer)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Long)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Boolean)
|
||||
{
|
||||
Assert.assertNotEquals(String.valueOf(fieldValue), "", errorMessage("is empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNotNull()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotNull(fieldValue, errorMessage("is null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNull()
|
||||
{
|
||||
Assert.assertNull(fieldValue, errorMessage("is not null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is an empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is not empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertEquals((Collection<?>) fieldValue, Collections.emptyList(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, "", errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, Collections.emptyMap(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T contains(String value)
|
||||
{
|
||||
if (!fieldValue.toString().contains(value))
|
||||
{
|
||||
Assert.fail(errorMessage("does NOT contain expected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T notContains(String value)
|
||||
{
|
||||
if (fieldValue.toString().contains(value))
|
||||
{
|
||||
Assert.fail(errorMessage("does contain unexpected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
}
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is greater than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isGreaterThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Greater);
|
||||
}
|
||||
|
||||
private T validateSize(Integer value, Operation operation) throws TestConfigurationException
|
||||
{
|
||||
try
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
throw new TestConfigurationException("Input must be valid");
|
||||
}
|
||||
Integer b = Integer.valueOf(fieldValue.toString());
|
||||
switch (operation)
|
||||
{
|
||||
case Greater:
|
||||
if(value > b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not greater than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
case Less:
|
||||
if(value < b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not less than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Assert.fail(errorMessage("No operation type provided"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Assert.fail(errorMessage("The field is not numeric " + fieldValue.toString()));
|
||||
}
|
||||
catch (NullPointerException ne)
|
||||
{
|
||||
Assert.fail(errorMessage("The input value must be numeric " + value));
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is less than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isLessThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Less);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionItemVerbs
|
||||
{
|
||||
private Object model;
|
||||
private Object actual;
|
||||
|
||||
public AssertionItemVerbs(Object model, Object actual)
|
||||
{
|
||||
this.model = model;
|
||||
this.actual = actual;
|
||||
}
|
||||
|
||||
public T is(Object expected) {
|
||||
Assert.assertEquals(actual, expected, String.format("For model [%s], the expected value is not correct ",
|
||||
model.getClass().getSimpleName(), expected.toString(), actual.toString()));
|
||||
return (T) model;
|
||||
}
|
||||
}
|
||||
public static enum Operation
|
||||
{
|
||||
Less,Greater
|
||||
}
|
||||
}
|
@@ -0,0 +1,279 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.Model;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model Collection
|
||||
* Just pass your rest model collection as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class ModelsCollectionAssertion<C>
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
private IRestModelsCollection modelCollection;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public ModelsCollectionAssertion(IRestModelsCollection modelCollection)
|
||||
{
|
||||
this.modelCollection = modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is not empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsNotEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is not empty");
|
||||
Assert.assertFalse(modelCollection.isEmpty(), "Entries list from response is empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is empty");
|
||||
Assert.assertTrue(modelCollection.isEmpty(), "Entries list from response is not empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListCountIs(int expectedCount)
|
||||
{
|
||||
STEP(String.format("REST API: Assert that entries list count is %d", expectedCount));
|
||||
int actualSize = modelCollection.getEntries().size();
|
||||
Assert.assertEquals(actualSize, expectedCount);
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key, String value)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
String fieldValue = "";
|
||||
for (Model m : modelEntries) {
|
||||
Object model = loadModel(m);
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
key, getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(fieldValue, value, String.format("Entry with key: [%s] with value [%s] not found in list", key, value));
|
||||
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key, String value)
|
||||
{
|
||||
boolean exist = false;
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries) {
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry with key: %s and value %s was found in list", key, value));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key)
|
||||
{
|
||||
boolean exist = modelInList(key);
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry list contains key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key)
|
||||
{
|
||||
boolean exist = modelInList(key);
|
||||
Assert.assertTrue(exist,
|
||||
String.format("Entry list doesn't contain key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
private boolean modelInList(String key)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString;
|
||||
try
|
||||
{
|
||||
jsonInString = mapper.writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
throw new IllegalStateException("Failed to convert model to string.", e);
|
||||
}
|
||||
Object fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C paginationExist()
|
||||
{
|
||||
STEP("REST API: Assert that response has pagination");
|
||||
Assert.assertNotNull(modelCollection.getPagination(), "Pagination is was not found in the response");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check one field from pagination json body
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public PaginationAssertionVerbs paginationField(String field)
|
||||
{
|
||||
return new PaginationAssertionVerbs<C>(modelCollection, field, modelCollection.getPagination());
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered ASC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedAscBy(String field)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().isOrdered(fieldValues), String.format("Entries are not ordered ASC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered DESC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedDescBy(String field)
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Object model = loadModel(m);
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().reverse().isOrdered(fieldValues), String.format("Entries are not ordered DESC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
private Object loadModel(Model m)
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
return method.invoke(m, new Object[] {});
|
||||
}
|
||||
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e)
|
||||
{
|
||||
throw new IllegalStateException("Failed to load model using reflection.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.assertion;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Pagination related assertions
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class PaginationAssertionVerbs<C> {
|
||||
private RestPaginationModel pagination;
|
||||
private C modelCollection;
|
||||
private String fieldName;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public PaginationAssertionVerbs(IRestModelsCollection modelCollection, String fieldName, RestPaginationModel pagination) {
|
||||
this.modelCollection = (C)modelCollection;
|
||||
this.fieldName = fieldName;
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the field
|
||||
*/
|
||||
private String getFieldValue() {
|
||||
String value = "";
|
||||
try {
|
||||
value = BeanUtils.getProperty(pagination, fieldName);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
fieldName, modelCollection.getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private String errorMessage(String info) {
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName,
|
||||
modelCollection.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public C is(String expected) {
|
||||
|
||||
Assert.assertEquals(getFieldValue(), expected, errorMessage("is NOT correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNot(Object expected) {
|
||||
|
||||
Assert.assertNotEquals(getFieldValue(), expected, errorMessage("is correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotEmpty() {
|
||||
Assert.assertNotEquals(getFieldValue(), "", errorMessage("is empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotNull() {
|
||||
Assert.assertNotNull(getFieldValue(), errorMessage("is null,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotPresent() {
|
||||
Assert.assertNull(getFieldValue(), errorMessage("is present,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isEmpty() {
|
||||
Assert.assertEquals(getFieldValue(), "", errorMessage("is NOT empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
/**
|
||||
* Executed via command line/terminal from root of this project
|
||||
* Just execute <code>mvn exec:java</code> passing as arguments:
|
||||
* -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml)
|
||||
* -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.
|
||||
* -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter
|
||||
* -Dhelp => show help
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class Generator
|
||||
{
|
||||
public static String line = "********\n------------------------------------------------------------------------";
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
if (!System.getProperties().containsKey("coverage") && !System.getProperties().containsKey("models") || System.getProperties().containsKey("help") )
|
||||
{
|
||||
System.out.println(line);
|
||||
System.out.println("No parameters provided, please use the following values:\n");
|
||||
System.out.println(
|
||||
"mvn exec:java -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml).");
|
||||
System.out.println("mvn exec:java -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.");
|
||||
System.out.println("mvn exec:java -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter.");
|
||||
System.out.println(line);
|
||||
|
||||
}
|
||||
|
||||
for (String url : args)
|
||||
{
|
||||
if (System.getProperty("coverage") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dcoverage</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).computeCoverage();
|
||||
}
|
||||
else if (System.getProperty("models") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dmodels</code>
|
||||
* <code>mvn exec:java -Dmodels=a,c,e</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).generateMissingModules();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
|
||||
/**
|
||||
* Model property used by freemarker template in {@link SwaggerModel}
|
||||
*
|
||||
*/
|
||||
public class RestModelProperty
|
||||
{
|
||||
private String name;
|
||||
private String type;
|
||||
private String description;
|
||||
private Boolean isRequired = false;
|
||||
/** If the property is a ref then this is the type referenced. */
|
||||
private String simpleRef;
|
||||
/** If the property is an array then this is the type of the items in it. */
|
||||
private RestModelProperty itemsType;
|
||||
|
||||
public static RestModelProperty build(Entry<String, io.swagger.models.properties.Property> property)
|
||||
{
|
||||
RestModelProperty model = new RestModelProperty();
|
||||
model.setName(property.getKey());
|
||||
model.setType(property.getValue().getType());
|
||||
model.setDescription(property.getValue().getDescription());
|
||||
model.setIsRequired(property.getValue().getRequired());
|
||||
if (property.getValue() instanceof RefProperty)
|
||||
{
|
||||
RefProperty refProperty = (RefProperty) property.getValue();
|
||||
model.setSimpleRef(refProperty.getSimpleRef());
|
||||
}
|
||||
if (property.getValue() instanceof ArrayProperty)
|
||||
{
|
||||
ArrayProperty arrayProperty = (ArrayProperty) property.getValue();
|
||||
Entry<String, io.swagger.models.properties.Property> itemsEntry = new AbstractMap.SimpleEntry<String, io.swagger.models.properties.Property>(
|
||||
arrayProperty.getName(), arrayProperty.getItems());
|
||||
model.setItemsType(RestModelProperty.build(itemsEntry));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNameCapitalized()
|
||||
{
|
||||
return org.apache.commons.lang3.StringUtils.capitalize(name);
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
switch (this.type)
|
||||
{
|
||||
case "string":
|
||||
return "String";
|
||||
case "integer":
|
||||
return "int";
|
||||
case "object":
|
||||
return "Object";
|
||||
case "ref":
|
||||
return "Rest" + getSimpleRef() + "Model";
|
||||
case "array":
|
||||
return "List<" + getItemsType().getType() + ">";
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean isRequired()
|
||||
{
|
||||
return isRequired;
|
||||
}
|
||||
|
||||
public void setIsRequired(Boolean isRequired)
|
||||
{
|
||||
this.isRequired = isRequired;
|
||||
}
|
||||
|
||||
protected void setSimpleRef(String simpleRef)
|
||||
{
|
||||
this.simpleRef = simpleRef;
|
||||
}
|
||||
|
||||
public String getSimpleRef()
|
||||
{
|
||||
return simpleRef;
|
||||
}
|
||||
|
||||
protected void setItemsType(RestModelProperty itemsType)
|
||||
{
|
||||
this.itemsType = itemsType;
|
||||
}
|
||||
|
||||
public RestModelProperty getItemsType()
|
||||
{
|
||||
return itemsType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,222 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Console;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerDefinitions
|
||||
{
|
||||
private Swagger swagger;
|
||||
List<SwaggerModel> missingSwaggerModels = new ArrayList<SwaggerModel>();
|
||||
Path modelsPath;
|
||||
|
||||
public SwaggerDefinitions(Swagger swagger)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
}
|
||||
|
||||
public void generateMissingDefinitions()
|
||||
{
|
||||
/*
|
||||
* read the content of ignore-moldels file
|
||||
*/
|
||||
List<String> ignoreModel = new ArrayList<String>();
|
||||
try
|
||||
{
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(Paths.get(modelsPath.toFile().getPath(), "ignore-models").toFile())))
|
||||
{
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
if (!line.startsWith("#") && !line.equals(""))
|
||||
ignoreModel.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while generating missing definitions.", e);
|
||||
}
|
||||
|
||||
/*
|
||||
* filter all models, ignoring the ones from ignore-model or the ones that are already created locally
|
||||
*/
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
|
||||
//regexp
|
||||
if(swaggerModel.getName().matches(".*Paging|.*Entry"))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on regular expression: '.*Paging|.*Entry')\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignoreModel.contains(swaggerModel.getName()))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on 'ignore-models' file)\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!swaggerModel.exist())
|
||||
missingSwaggerModels.add(swaggerModel);
|
||||
}
|
||||
|
||||
System.out.println(Generator.line);
|
||||
int count = 0;
|
||||
/*
|
||||
* iterate on all missing models
|
||||
*/
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
if (count == 0) // table heather
|
||||
{
|
||||
System.out.printf("MISSING MODEL ~ THE NEW FILE THAT WILL BE GENERATED\n");
|
||||
System.out.println(" 0 -[Skip all]");
|
||||
}
|
||||
|
||||
count += 1;
|
||||
StringBuilder info = new StringBuilder();
|
||||
info.append(" ")
|
||||
.append(count)
|
||||
.append(" -")
|
||||
.append("[")
|
||||
.append(swaggerModel.getName())
|
||||
.append("] ~ [")
|
||||
.append(swaggerModel.getPath())
|
||||
.append("]");
|
||||
|
||||
System.out.println(info.toString());
|
||||
}
|
||||
System.out.println("ENTER -[All Models]");
|
||||
|
||||
/*
|
||||
* wait for input
|
||||
*/
|
||||
Console c = System.console();
|
||||
if (c != null && missingSwaggerModels.size() > 0)
|
||||
{
|
||||
c.format("%s\n", Generator.line);
|
||||
c.format("\nPlease select what Models you want to generate (ex: 1,3,4) or press <<ENTER>>to generating all missing models:");
|
||||
String prompt = c.readLine();
|
||||
|
||||
if(prompt.equals("0"))
|
||||
return;
|
||||
|
||||
if (prompt.length() == 0)
|
||||
{
|
||||
System.out.println("\nStart generating all models...");
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
generateModel(swaggerModel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prompt.contains(","))
|
||||
{
|
||||
String[] modelsIDToGen = prompt.split(",");
|
||||
for (int i = 0; i < modelsIDToGen.length; i++)
|
||||
{
|
||||
generateSelectedSwaggerModel(modelsIDToGen[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
generateSelectedSwaggerModel(prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the model based on the ID provided
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
private void generateSelectedSwaggerModel(String id)
|
||||
{
|
||||
int choice = Integer.parseInt(id);
|
||||
if ((choice - 1) >= missingSwaggerModels.size())
|
||||
{
|
||||
throw new TestConfigurationException(
|
||||
"You specified a wrong ID: [" + id + "] please select one value from the list displayed above. Run the command again!");
|
||||
}
|
||||
generateModel(missingSwaggerModels.get(choice - 1));
|
||||
}
|
||||
|
||||
public boolean generateDefinition(String modelParamValue)
|
||||
{
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
if (swaggerModel.getName().equals(modelParamValue))
|
||||
{
|
||||
generateModel(swaggerModel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
System.err.println("Model that you provided was NOT found!");
|
||||
System.err.printf("Model [%s] not found in Swagger file: %s\n", modelParamValue, swagger.getBasePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
private void generateModel(SwaggerModel swaggerModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
swaggerModel.generate();
|
||||
}
|
||||
catch (IOException | TemplateException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while generating model definition.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,186 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles swagger definitions <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerModel
|
||||
{
|
||||
private Swagger swagger;
|
||||
private Entry<String, Model> model;
|
||||
private Path modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
private List<RestModelProperty> properties = new ArrayList<RestModelProperty>();
|
||||
private Configuration cfg;
|
||||
|
||||
private Configuration getConfig() throws IOException
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerModel(Entry<String, Model> model, Swagger swagger)
|
||||
{
|
||||
this.model = model;
|
||||
this.swagger = swagger;
|
||||
|
||||
|
||||
if(model.getValue().getProperties()!=null)
|
||||
{
|
||||
/*
|
||||
* compute the properties of this model
|
||||
*/
|
||||
for (Entry<String, io.swagger.models.properties.Property> property : model.getValue().getProperties().entrySet())
|
||||
{
|
||||
if (property.getKey().equals("entry"))
|
||||
continue;
|
||||
|
||||
properties.add(RestModelProperty.build(property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if file is already generated in TAS, under 'models' package
|
||||
*/
|
||||
public boolean exist()
|
||||
{
|
||||
return getPath().exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the model in TAS
|
||||
*/
|
||||
public File getPath()
|
||||
{
|
||||
return Paths.get(modelsPath.toFile().getPath(), getNameInTAS() + ".java").toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return original model name as defined in Swagger YAML
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return model.getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name as it will be used in TAS
|
||||
*/
|
||||
public String getNameInTAS()
|
||||
{
|
||||
return String.format("Rest%sModel", getName());
|
||||
}
|
||||
|
||||
public List<RestModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<RestModelProperty> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void generate() throws IOException, TemplateException
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-model.ftl");
|
||||
|
||||
// here we will store all data passed to template
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
|
||||
data.put("author", System.getProperty("user.name"));
|
||||
data.put("yamlTitle", swagger.getInfo().getTitle());
|
||||
data.put("yamlBasePath", swagger.getBasePath());
|
||||
data.put("name", getNameInTAS());
|
||||
|
||||
if (!getProperties().isEmpty())
|
||||
data.put("properties", getProperties());
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
|
||||
System.out.println("----- " + getPath().getName() + " -----\n");
|
||||
System.out.println(Generator.line);
|
||||
System.out.println(append.toString());
|
||||
System.out.printf("\nGenerating Model: %-10s to ->'%-60s'", getName(), getPath());
|
||||
if (exist())
|
||||
{
|
||||
Console c = System.console();
|
||||
if (c != null)
|
||||
{
|
||||
System.out.printf("There is already one model created locally: \n%s\nDo you want to override it ?(ENTER=yes, any other key=no):", getPath());
|
||||
if (c.readLine().length() == 0)
|
||||
{
|
||||
writeContent(append.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeContent(append.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void writeContent(String content) throws IOException
|
||||
{
|
||||
FileWriter fw = new FileWriter(getPath());
|
||||
fw.write(content);
|
||||
fw.close();
|
||||
}
|
||||
}
|
@@ -0,0 +1,219 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import io.swagger.models.HttpMethod;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerPaths
|
||||
{
|
||||
private Swagger swagger;
|
||||
private BufferedWriter fileWithMissingRequests;
|
||||
private BufferedWriter fileWithImplementedRequests;
|
||||
private String swaggerFilePath;
|
||||
private int implementedRequestCount = 0;
|
||||
private int missingRequestCount = 0;
|
||||
|
||||
public SwaggerPaths(Swagger swagger, String swaggerFilePath)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare requests that exist in swagger yaml file vs request implemented in your code
|
||||
* any findings are saved to a missing-request txt file.
|
||||
*
|
||||
* @throws TestConfigurationException
|
||||
*/
|
||||
public void computeCoverage()
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("Start computing the coverage of TAS vs Swagger file. Stand by...");
|
||||
File missingReq = new File(String.format("missing-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
missingReq.delete();
|
||||
fileWithMissingRequests = new BufferedWriter(new FileWriter(missingReq));
|
||||
fileWithMissingRequests.write(String.format("BasePath: {%s}", swagger.getBasePath()));
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("These requests generated should be analyzed and modified according to your needs.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("PLEASE UPDATE your 'RestReturnedModel' name with the appropiate returned model by your request.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
File implReq = new File(String.format("implemented-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
implReq.delete();
|
||||
fileWithImplementedRequests = new BufferedWriter(new FileWriter(implReq));
|
||||
|
||||
for (Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet())
|
||||
{
|
||||
for (Map.Entry<HttpMethod, Operation> operation : path.getValue().getOperationMap().entrySet())
|
||||
{
|
||||
searchPattern(path.getKey(), operation);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(toString());
|
||||
|
||||
fileWithImplementedRequests.close();
|
||||
fileWithMissingRequests.close();
|
||||
|
||||
if (missingRequestCount > 0)
|
||||
{
|
||||
System.out.println("[ERROR] PLEASE ANALYSE THE GENERATED <missing-requests> file(s), it seems some request were NOT implemented!");
|
||||
}
|
||||
else
|
||||
missingReq.delete();
|
||||
|
||||
System.out.println("ALSO ANALYZE <implemented-requests.txt> for current implementation, take a look at duplicated requests if any!");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Exception while trying to create coverage report.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use RegExp to check for requests in code, line by line: no further algorithm performance analysis required at this time
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param pathUrl
|
||||
* @param methodName
|
||||
*/
|
||||
private void searchPattern(String pathUrl, Entry<HttpMethod, Operation> operation)
|
||||
{
|
||||
String originalPathUrl = pathUrl;
|
||||
String httpMethod = operation.getKey().name();
|
||||
|
||||
/* update path url, removing first "/" as implemented in TAS requests. */
|
||||
if (pathUrl.startsWith("/"))
|
||||
pathUrl = pathUrl.substring(1, pathUrl.length());
|
||||
|
||||
if (pathUrl.contains("{"))
|
||||
pathUrl = pathUrl.replace("{", "\\{");
|
||||
|
||||
/*
|
||||
* if in code we have something like: <code> "(HttpMethod.GET, "process-definitions?{parameters}" </code>
|
||||
* our regular expression will search for text insider the 'HttpMethod.GET' concatenated with found 'pathUrl" until the optional double brackets
|
||||
* RegExp: .*HttpMethod.%s.*\\\"%s\\\"?.*
|
||||
* Result: .*HttpMethod.GET."process-definition".* - if this line is found we have a match
|
||||
*/
|
||||
String patternRegEx = String.format(".*HttpMethod.%s.*\\\"%s\\\"?.*", httpMethod, pathUrl);
|
||||
|
||||
// all request are saved under this directory, but limited to the rest/request folder
|
||||
File project = Paths.get(".").toAbsolutePath().normalize().toFile();
|
||||
Path requestsPath = Paths.get(project.getPath(), "src/main/java/org/alfresco/rest/requests");
|
||||
|
||||
BufferedReader br;
|
||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(requestsPath))
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
for (Path path : directoryStream)
|
||||
{
|
||||
if (Files.isRegularFile(path) && Files.isReadable(path))
|
||||
{
|
||||
String line;
|
||||
InputStream fis = new FileInputStream(path.toFile());
|
||||
InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
|
||||
if (line.matches(patternRegEx))
|
||||
{
|
||||
// log("OK - Pattern %-60s found in: {%s} file." , originalPathUrl, path.getFileName());
|
||||
fileWithImplementedRequests.write(String.format("%-10s %-60s %s", httpMethod, pathUrl, path.getFileName()));
|
||||
fileWithImplementedRequests.newLine();
|
||||
fileWithImplementedRequests.flush();
|
||||
implementedRequestCount += 1;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
fileWithMissingRequests.write(String.format("%-10s %-60s %s", httpMethod, originalPathUrl, patternRegEx));
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
SwaggerRequest swaggerReqModel = new SwaggerRequest(httpMethod, pathUrl, operation.getValue());
|
||||
fileWithMissingRequests.write(swaggerReqModel.getRequestSample());
|
||||
fileWithMissingRequests.flush();
|
||||
missingRequestCount += 1;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("|\n").append("|------------------------------------------------------------------------\n").append("COVERAGE: ")
|
||||
.append(swaggerFilePath).append("\n");
|
||||
|
||||
int percentage = (implementedRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append("\t\tImplemented:\t").append(String.valueOf(percentage)).append("% [# ").append(implementedRequestCount).append("]\t Missing: ");
|
||||
|
||||
percentage = (missingRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append(String.valueOf(percentage)).append("% [# ").append(missingRequestCount).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Operation;
|
||||
|
||||
public class SwaggerRequest
|
||||
{
|
||||
private Configuration cfg;
|
||||
private Operation swaggerRequest;
|
||||
private String httpMethod;
|
||||
private String pathUrl;
|
||||
|
||||
private Configuration getConfig()
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
try
|
||||
{
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while configuring Freemarker template directory.", e);
|
||||
}
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerRequest(String httpMethod, String pathUrl, Operation swaggerRequest)
|
||||
{
|
||||
this.swaggerRequest = swaggerRequest;
|
||||
this.httpMethod = httpMethod;
|
||||
this.pathUrl = pathUrl;
|
||||
}
|
||||
|
||||
public String getRequestSample()
|
||||
{
|
||||
try
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-request.ftl");
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("operationId", swaggerRequest.getOperationId());
|
||||
data.put("httpMethod", httpMethod);
|
||||
data.put("pathUrl", pathUrl);
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
return append.toString();
|
||||
}
|
||||
catch (IOException | TemplateException e)
|
||||
{
|
||||
throw new IllegalStateException("Exception while loading sample request.", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.core.swagger;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
/**
|
||||
* This will handle the Swagger YAML file
|
||||
* It will contain all the models, request or any other properties needed for out generator
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerYamlParser
|
||||
{
|
||||
private Swagger swagger;
|
||||
private String swaggerFilePath;
|
||||
|
||||
public SwaggerYamlParser(String swaggerFilePath) throws TestConfigurationException
|
||||
{
|
||||
if (swaggerFilePath == null)
|
||||
throw new TestConfigurationException("'swaggerFilePath' not defined. Please update your pom.xml file with all '<swagger-file-location.yml>'");
|
||||
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
this.swagger = new SwaggerParser().read(this.swaggerFilePath);
|
||||
|
||||
}
|
||||
|
||||
public void computeCoverage()
|
||||
{
|
||||
new SwaggerPaths(swagger, this.swaggerFilePath).computeCoverage();
|
||||
}
|
||||
|
||||
public void generateMissingModules()
|
||||
{
|
||||
String modelParamValue = System.getProperty("models");
|
||||
|
||||
SwaggerDefinitions swaggerDefinitions = new SwaggerDefinitions(swagger);
|
||||
|
||||
System.out.println(Generator.line);
|
||||
System.out.println("Using SWAGGER FILE: " + this.swaggerFilePath);
|
||||
System.out.println(Generator.line);
|
||||
/*
|
||||
* multiple models, separated by comma: 'mvn exec:java -Dmodels=a,b,d'
|
||||
*/
|
||||
if (modelParamValue.contains(","))
|
||||
{
|
||||
String[] models = {};
|
||||
models = modelParamValue.split(",");
|
||||
|
||||
for (int i = 0; i < models.length; i++)
|
||||
{
|
||||
// generate model
|
||||
swaggerDefinitions.generateDefinition(models[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if no value is added after models "mvn exec:java -Dmodels"
|
||||
* then we assume that we want to generate all models
|
||||
*/
|
||||
if (modelParamValue.equals("true"))
|
||||
{
|
||||
swaggerDefinitions.generateMissingDefinitions();
|
||||
}
|
||||
/*
|
||||
* there is just one model passed as value "mvn exec:java -Dmodels=a"
|
||||
* so only model "a" is generated locally
|
||||
*/
|
||||
else
|
||||
{
|
||||
swaggerDefinitions.generateDefinition(modelParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.exception;
|
||||
|
||||
public class EmptyJsonResponseException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EmptyJsonResponseException(String message)
|
||||
{
|
||||
super(String.format("Empty JSON Response returned. Possible API bug, please investigate this further. Message: %s", message));
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.exception;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class EmptyRestModelCollectionException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public <E> EmptyRestModelCollectionException(Collection<E> models)
|
||||
{
|
||||
super(String.format("Empty Rest Model Collection of type: %s -> %s", models.getClass(), models.toString()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.exception;
|
||||
|
||||
public class JsonToModelConversionException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public <T> JsonToModelConversionException(Class<T> classz, Exception e)
|
||||
{
|
||||
super(String.format("Could not parse Json Response to model [%s] error: %s", classz.getName(), e.getMessage()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.exception;
|
||||
|
||||
public class ModelToJsonConversionException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public <T> ModelToJsonConversionException(Class<T> classz, Exception e)
|
||||
{
|
||||
super(String.format("Could not convert model for [%s] to JSON", classz.getName()), e);
|
||||
}
|
||||
}
|
@@ -0,0 +1,167 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
public class RestAbstractClassModel extends TestModel implements IRestModel<RestAbstractClassModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestAbstractClassModel model;
|
||||
|
||||
@Override
|
||||
public RestAbstractClassModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String id;
|
||||
public String title;
|
||||
public String description;
|
||||
public String parentId;
|
||||
public Boolean isContainer = null;
|
||||
public Boolean isArchive = null;
|
||||
public Boolean includedInSupertypeQuery = null;
|
||||
public List<String> mandatoryAspects = null;
|
||||
public List<RestClassAssociationModel> associations = null;
|
||||
public List <RestPropertyDefinitionModel> properties = null;
|
||||
|
||||
@JsonProperty(value = "model")
|
||||
public RestClassModel modelInfo;
|
||||
|
||||
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 String getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Boolean getContainer()
|
||||
{
|
||||
return isContainer;
|
||||
}
|
||||
|
||||
public void setContainer(Boolean container)
|
||||
{
|
||||
isContainer = container;
|
||||
}
|
||||
|
||||
public Boolean getArchive()
|
||||
{
|
||||
return isArchive;
|
||||
}
|
||||
|
||||
public void setArchive(Boolean archive)
|
||||
{
|
||||
isArchive = archive;
|
||||
}
|
||||
|
||||
public Boolean getIncludedInSupertypeQuery()
|
||||
{
|
||||
return includedInSupertypeQuery;
|
||||
}
|
||||
|
||||
public void setIncludedInSupertypeQuery(Boolean includedInSupertypeQuery)
|
||||
{
|
||||
this.includedInSupertypeQuery = includedInSupertypeQuery;
|
||||
}
|
||||
|
||||
public List<String> getMandatoryAspects()
|
||||
{
|
||||
return mandatoryAspects;
|
||||
}
|
||||
|
||||
public void setMandatoryAspects(List<String> mandatoryAspects)
|
||||
{
|
||||
this.mandatoryAspects = mandatoryAspects;
|
||||
}
|
||||
|
||||
public List<RestClassAssociationModel> getAssociations()
|
||||
{
|
||||
return associations;
|
||||
}
|
||||
|
||||
public void setAssociations(List<RestClassAssociationModel> associations)
|
||||
{
|
||||
this.associations = associations;
|
||||
}
|
||||
|
||||
public List<RestPropertyDefinitionModel> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<RestPropertyDefinitionModel> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public RestClassModel getModelInfo()
|
||||
{
|
||||
return modelInfo;
|
||||
}
|
||||
|
||||
public void setModelInfo(RestClassModel modelInfo)
|
||||
{
|
||||
this.modelInfo = modelInfo;
|
||||
}
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-14 13:22' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestActionBodyExecTemplateModel extends TestModel implements IRestModel<RestActionBodyExecTemplateModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActionBodyExecTemplateModel model;
|
||||
|
||||
@Override
|
||||
public RestActionBodyExecTemplateModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String actionDefinitionId;
|
||||
|
||||
private Map<String, Serializable> params;
|
||||
|
||||
public String getActionDefinitionId()
|
||||
{
|
||||
return this.actionDefinitionId;
|
||||
}
|
||||
|
||||
public void setActionDefinitionId(String actionDefinitionId)
|
||||
{
|
||||
this.actionDefinitionId = actionDefinitionId;
|
||||
}
|
||||
|
||||
public Map<String, Serializable> getParams()
|
||||
{
|
||||
return this.params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Serializable> params)
|
||||
{
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "RestActionBodyExecTemplateModel{" + "actionDefinitionId='" + actionDefinitionId + '\'' + ", params=" + params + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
RestActionBodyExecTemplateModel that = (RestActionBodyExecTemplateModel) o;
|
||||
return Objects.equals(actionDefinitionId, that.actionDefinitionId) && Objects.equals(params, that.params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(actionDefinitionId, params);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,100 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'mpichura' on '2022-10-05 09:58' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestActionConstraintDataModel extends TestModel implements IRestModel<RestActionConstraintDataModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActionConstraintDataModel model;
|
||||
|
||||
@Override
|
||||
public RestActionConstraintDataModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
Constraint value (this can also be a node id)
|
||||
*/
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String value;
|
||||
/**
|
||||
Constraint display label
|
||||
*/
|
||||
|
||||
private String label;
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RestActionConstraintDataModel that = (RestActionConstraintDataModel) o;
|
||||
return value.equals(that.value) && Objects.equals(label, that.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(value, label);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,136 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'mpichura' on '2022-10-05 09:58' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestActionConstraintModel extends TestModel implements IRestModel<RestActionConstraintModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActionConstraintModel model;
|
||||
|
||||
@Override
|
||||
public RestActionConstraintModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
Name of the constraint.
|
||||
|
||||
*/
|
||||
|
||||
private String constraintName;
|
||||
/**
|
||||
A list of constraint possbile values along with additional data (label, isNode flag).
|
||||
Sample object could be:
|
||||
```JSON
|
||||
"constraintValues": [
|
||||
{
|
||||
"value": "EQUALS",
|
||||
"label": "Equals"
|
||||
},
|
||||
{
|
||||
"value": "CONTAINS",
|
||||
"label": "Contains"
|
||||
},
|
||||
{
|
||||
"value": "BEGINS",
|
||||
"label": "Begins With"
|
||||
},
|
||||
{
|
||||
"value": "ENDS",
|
||||
"label": "Ends With"
|
||||
},
|
||||
{
|
||||
"value": "GREATER_THAN",
|
||||
"label": "Greater Than"
|
||||
},
|
||||
{
|
||||
"value": "GREATER_THAN_EQUAL",
|
||||
"label": "Greater Than Or Equal To"
|
||||
},
|
||||
{
|
||||
"value": "LESS_THAN",
|
||||
"label": "Less Than"
|
||||
},
|
||||
{
|
||||
"value": "LESS_THAN_EQUAL",
|
||||
"label": "Less Than Or Equal To"
|
||||
}
|
||||
]
|
||||
*/
|
||||
|
||||
private List<RestActionConstraintDataModel> constraintValues;
|
||||
|
||||
public String getConstraintName()
|
||||
{
|
||||
return this.constraintName;
|
||||
}
|
||||
|
||||
public void setConstraintName(String constraintName)
|
||||
{
|
||||
this.constraintName = constraintName;
|
||||
}
|
||||
|
||||
public List<RestActionConstraintDataModel> getConstraintValues()
|
||||
{
|
||||
return this.constraintValues;
|
||||
}
|
||||
|
||||
public void setConstraintValues(List<RestActionConstraintDataModel> constraintValues)
|
||||
{
|
||||
this.constraintValues = constraintValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RestActionConstraintModel that = (RestActionConstraintModel) o;
|
||||
return constraintName.equals(that.constraintName) && Objects.equals(constraintValues, that.constraintValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(constraintName, constraintValues);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,135 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
public class RestActionDefinitionModel extends TestModel implements IRestModel<RestActionDefinitionModel>
|
||||
{
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestActionDefinitionModel actionDefinitionModel;
|
||||
private String id;
|
||||
private String name;
|
||||
private String title;
|
||||
private String description;
|
||||
private List<String> applicableTypes;
|
||||
private boolean adhocPropertiesAllowed;
|
||||
private boolean trackStatus;
|
||||
private List<RestParameterDefinitionModel> parameterDefinitions;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String 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> getApplicableTypes()
|
||||
{
|
||||
return applicableTypes;
|
||||
}
|
||||
|
||||
public void setApplicableTypes(List<String> applicableTypes)
|
||||
{
|
||||
this.applicableTypes = applicableTypes;
|
||||
}
|
||||
|
||||
public boolean isAdhocPropertiesAllowed()
|
||||
{
|
||||
return adhocPropertiesAllowed;
|
||||
}
|
||||
|
||||
public void setAdhocPropertiesAllowed(boolean adhocPropertiesAllowed)
|
||||
{
|
||||
this.adhocPropertiesAllowed = adhocPropertiesAllowed;
|
||||
}
|
||||
|
||||
public boolean isTrackStatus()
|
||||
{
|
||||
return trackStatus;
|
||||
}
|
||||
|
||||
public void setTrackStatus(boolean trackStatus)
|
||||
{
|
||||
this.trackStatus = trackStatus;
|
||||
}
|
||||
|
||||
public List<RestParameterDefinitionModel> getParameterDefinitions()
|
||||
{
|
||||
return parameterDefinitions;
|
||||
}
|
||||
|
||||
public void setParameterDefinitions(List<RestParameterDefinitionModel> parameterDefinitions)
|
||||
{
|
||||
this.parameterDefinitions = parameterDefinitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestActionDefinitionModel onModel()
|
||||
{
|
||||
return actionDefinitionModel;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestActionDefinitionModelsCollection extends RestModels<RestActionDefinitionModel, RestActionDefinitionModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
* Handles single Activity JSON responses
|
||||
* Example:
|
||||
{
|
||||
"postedAt": "2016-09-30T12:31:54.088+0000",
|
||||
"feedPersonId": "user-vtcaquckbq",
|
||||
"postPersonId": "user-vtcaquckbq",
|
||||
"siteId": "site-mNygPRuKka",
|
||||
"activitySummary": {
|
||||
"firstName": "User-vtCaqUCKBq FirstName",
|
||||
"lastName": "LN-User-vtCaqUCKBq",
|
||||
"memberFirstName": "User-vtCaqUCKBq FirstName",
|
||||
"role": "SiteManager",
|
||||
"memberLastName": "LN-User-vtCaqUCKBq",
|
||||
"title": "User-vtCaqUCKBq FirstName LN-User-vtCaqUCKBq (User-vtCaqUCKBq)",
|
||||
"memberPersonId": "User-vtCaqUCKBq"
|
||||
},
|
||||
"id": 14689,
|
||||
"activityType": "org.alfresco.site.user-joined"
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestActivityModel extends TestModel implements IRestModel<RestActivityModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActivityModel activityModel;
|
||||
|
||||
@Override
|
||||
public RestActivityModel onModel()
|
||||
{
|
||||
return activityModel;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
String id;
|
||||
|
||||
/**
|
||||
* The id of the person who performed the activity
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
String postPersonId;
|
||||
|
||||
String siteId;
|
||||
String postedAt;
|
||||
|
||||
/**
|
||||
* The feed on which this activity was posted
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
String feedPersonId;
|
||||
|
||||
RestActivitySummaryModel activitySummary;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
String activityType;
|
||||
|
||||
public String getActivityType()
|
||||
{
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public void setActivityType(String activityType)
|
||||
{
|
||||
this.activityType = activityType;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPostPersonId()
|
||||
{
|
||||
return postPersonId;
|
||||
}
|
||||
|
||||
public void setPostPersonId(String postPersonId)
|
||||
{
|
||||
this.postPersonId = postPersonId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteID(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getPostedAt()
|
||||
{
|
||||
return postedAt;
|
||||
}
|
||||
|
||||
public void setPostedAt(String postedAt)
|
||||
{
|
||||
this.postedAt = postedAt;
|
||||
}
|
||||
|
||||
public String getFeedPersonId()
|
||||
{
|
||||
return feedPersonId;
|
||||
}
|
||||
|
||||
public void setFeedPersonId(String feedPersonId)
|
||||
{
|
||||
this.feedPersonId = feedPersonId;
|
||||
}
|
||||
|
||||
public RestActivitySummaryModel getActivitySummary()
|
||||
{
|
||||
return activitySummary;
|
||||
}
|
||||
|
||||
public void setActivitySummary(RestActivitySummaryModel activitySummary)
|
||||
{
|
||||
this.activitySummary = activitySummary;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
/**
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
* /**
|
||||
* Handle collection of <RestActivityModel>
|
||||
* Example:
|
||||
{
|
||||
"list": {
|
||||
"pagination": {
|
||||
"count": 3,
|
||||
"hasMoreItems": false,
|
||||
"skipCount": 0,
|
||||
"maxItems": 100
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"entry": {
|
||||
"postedAt": "2016-09-30T12:31:55.923+0000",
|
||||
"feedPersonId": "user-vtcaquckbq",
|
||||
"postPersonId": "user-vtcaquckbq",
|
||||
"siteId": "site-mNygPRuKka",
|
||||
"activitySummary": {
|
||||
"firstName": "User-vtCaqUCKBq FirstName",
|
||||
"lastName": "LN-User-vtCaqUCKBq",
|
||||
"parentObjectId": "e982c6b7-e16e-4a25-ae77-5ed96614e871",
|
||||
"title": "file-bWbaaGycDm.txt",
|
||||
"objectId": "3a647ca9-cef9-45d0-ae4a-49cffa131154"
|
||||
},
|
||||
"id": 14692,
|
||||
"activityType": "org.alfresco.documentlibrary.file-added"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestActivityModelsCollection extends RestModels<RestActivityModel, RestActivityModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* "activitySummary": {
|
||||
"firstName": "string",
|
||||
"lastName": "string",
|
||||
"parentObjectId": "string",
|
||||
"title": "string",
|
||||
"objectId": "string"
|
||||
}
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
*/
|
||||
public class RestActivitySummaryModel extends TestModel implements IRestModel<RestActivitySummaryModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActivitySummaryModel activitySummaryModel;
|
||||
|
||||
|
||||
@Override
|
||||
public RestActivitySummaryModel onModel()
|
||||
{
|
||||
return activitySummaryModel;
|
||||
}
|
||||
|
||||
String firstName;
|
||||
String lastName;
|
||||
String parentObjectId;
|
||||
String title;
|
||||
String objectId;
|
||||
String memberFirstName;
|
||||
UserRole role;
|
||||
String memberLastName;
|
||||
String memberPersonId;
|
||||
|
||||
public String getMemberFirstName()
|
||||
{
|
||||
return memberFirstName;
|
||||
}
|
||||
public void setMemberFirstName(String memberFirstName)
|
||||
{
|
||||
this.memberFirstName = memberFirstName;
|
||||
}
|
||||
public UserRole getRole()
|
||||
{
|
||||
return role;
|
||||
}
|
||||
public void setRole(UserRole role)
|
||||
{
|
||||
this.role = role;
|
||||
}
|
||||
public String getMemberLastName()
|
||||
{
|
||||
return memberLastName;
|
||||
}
|
||||
public void setMemberLastName(String memberLastName)
|
||||
{
|
||||
this.memberLastName = memberLastName;
|
||||
}
|
||||
public String getMemberPersonId()
|
||||
{
|
||||
return memberPersonId;
|
||||
}
|
||||
public void setMemberPersonId(String memberPersonId)
|
||||
{
|
||||
this.memberPersonId = memberPersonId;
|
||||
}
|
||||
|
||||
public String getFirstName()
|
||||
{
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName)
|
||||
{
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName()
|
||||
{
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName)
|
||||
{
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getParentObjectId()
|
||||
{
|
||||
return parentObjectId;
|
||||
}
|
||||
public void setParentObjectId(String parentObjectId)
|
||||
{
|
||||
this.parentObjectId = parentObjectId;
|
||||
}
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
public String getObjectId()
|
||||
{
|
||||
return objectId;
|
||||
}
|
||||
public void setObjectId(String objectId)
|
||||
{
|
||||
this.objectId = objectId;
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
public class RestAggregateModel extends TestModel implements IRestModel<RestAggregateModel>
|
||||
{
|
||||
@JsonProperty(value = "aggregate")
|
||||
RestAggregateModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private int numberOfRatings;
|
||||
private String average;
|
||||
|
||||
@Override
|
||||
public RestAggregateModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public int getNumberOfRatings()
|
||||
{
|
||||
return numberOfRatings;
|
||||
}
|
||||
|
||||
public void setNumberOfRatings(int numberOfRatings)
|
||||
{
|
||||
this.numberOfRatings = numberOfRatings;
|
||||
}
|
||||
|
||||
public String getAverage()
|
||||
{
|
||||
return average;
|
||||
}
|
||||
|
||||
public void setAverage(String average)
|
||||
{
|
||||
this.average = average;
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* Copyright 2021 Alfresco Software, Ltd. All rights reserved.
|
||||
* License rights for this program may be obtained from Alfresco Software, Ltd.
|
||||
* pursuant to a written agreement and any use of this program without such an
|
||||
* agreement is prohibited.
|
||||
*/
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Generated by 'dedwards' on '2021-12-16 08:32' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestArchiveContentRequestModel extends TestModel implements IRestModel<RestArchiveContentRequestModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestArchiveContentRequestModel model;
|
||||
|
||||
@Override
|
||||
public RestArchiveContentRequestModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
A map (String-String) of archive request properties for given content.
|
||||
|
||||
*/
|
||||
|
||||
private Object archiveProperties;
|
||||
|
||||
public Object getArchiveProperties()
|
||||
{
|
||||
return this.archiveProperties;
|
||||
}
|
||||
|
||||
public void setArchiveProperties(Object archiveProperties)
|
||||
{
|
||||
this.archiveProperties = archiveProperties;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
public class RestAspectModel extends RestAbstractClassModel
|
||||
{
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestAspectsCollection extends RestModels<RestAspectModel, RestAspectsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Generated by 'aepure' on '2017-06-29 15:31' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestAuditAppModel extends TestModel implements IRestModel<RestAuditAppModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestAuditAppModel model;
|
||||
|
||||
@Override
|
||||
public RestAuditAppModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean isEnabled;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getIsEnabled()
|
||||
{
|
||||
return this.isEnabled;
|
||||
}
|
||||
|
||||
public void setIsEnabled(boolean isEnabled)
|
||||
{
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
/*-
|
||||
* #%L
|
||||
* alfresco-tas-restapi
|
||||
* %%
|
||||
* 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.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestAuditAppModelsCollection extends RestModels<RestAuditAppModel, RestAuditAppModelsCollection>
|
||||
{
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user