mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-11-05 15:32:21 +00:00
Compare commits
168 Commits
23.5.0.1
...
fix/MNT-25
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b43fe572d | ||
|
|
1ce760f8f9 | ||
|
|
bf97fbaaca | ||
|
|
4e9c42c903 | ||
|
|
4bf1156a53 | ||
|
|
e55dd7945e | ||
|
|
aa41cfe776 | ||
|
|
d8450175a0 | ||
|
|
be1dfe39e7 | ||
|
|
b5cf107ae7 | ||
|
|
b91aeff68f | ||
|
|
557ed27667 | ||
|
|
a4184cafed | ||
|
|
df5648c86b | ||
|
|
8ad373f1fc | ||
|
|
6d95811423 | ||
|
|
b7ac5c26ef | ||
|
|
58e1c0c13b | ||
|
|
49c610cd66 | ||
|
|
e9a01e2ca0 | ||
|
|
fe3b26552d | ||
|
|
ea29639d6f | ||
|
|
36e11c3e08 | ||
|
|
93d42ad2de | ||
|
|
6970ef0d1e | ||
|
|
115c384be0 | ||
|
|
384ec9c364 | ||
|
|
d9ff7ef1d0 | ||
|
|
8bc7937e98 | ||
|
|
0b021f947b | ||
|
|
d798500b6a | ||
|
|
2e95e97bdc | ||
|
|
f84d6e49cf | ||
|
|
09f39df9e6 | ||
|
|
f574e5db05 | ||
|
|
3a37310262 | ||
|
|
061ccc48ff | ||
|
|
9d56d3a8db | ||
|
|
1c1790b66a | ||
|
|
dd812bca89 | ||
|
|
5dcc54cf0e | ||
|
|
69c1700d94 | ||
|
|
fe4c3ad171 | ||
|
|
95e64015a2 | ||
|
|
8e4c6d8cf3 | ||
|
|
9c99d98a68 | ||
|
|
ad39812999 | ||
|
|
fc66dfcc56 | ||
|
|
5018e627dd | ||
|
|
6de69ad298 | ||
|
|
53a3a22aff | ||
|
|
5252a98619 | ||
|
|
df5be66e3f | ||
|
|
269fa78155 | ||
|
|
ca41856d9b | ||
|
|
9e8958072a | ||
|
|
e26da101da | ||
|
|
d9ea31b2b6 | ||
|
|
5190bf016c | ||
|
|
ef326fb6c7 | ||
|
|
8b1139e600 | ||
|
|
2c7833f4be | ||
|
|
db7571cba0 | ||
|
|
690a1be4fa | ||
|
|
bf5518f786 | ||
|
|
481c1e221b | ||
|
|
56894f18e3 | ||
|
|
b46679eedc | ||
|
|
271bffaa06 | ||
|
|
4f8d8e605e | ||
|
|
a05ff0c537 | ||
|
|
00cb1190ed | ||
|
|
b9f4eb2c2a | ||
|
|
ad56443b23 | ||
|
|
0909616b76 | ||
|
|
1431eaaa4e | ||
|
|
ed6526587e | ||
|
|
d2ec56ad80 | ||
|
|
e81f17a5a3 | ||
|
|
0aff869ee6 | ||
|
|
639fec6cbb | ||
|
|
49b8798cfe | ||
|
|
3ccde8596a | ||
|
|
d77fede9d2 | ||
|
|
b82cf7fa49 | ||
|
|
e8b4d0b5ff | ||
|
|
e14cb0b314 | ||
|
|
abe5a72481 | ||
|
|
10721c9921 | ||
|
|
5451bf7144 | ||
|
|
8887639abe | ||
|
|
94b80c057e | ||
|
|
d9e7007b0a | ||
|
|
ed026d08ad | ||
|
|
bd2cc5497b | ||
|
|
5a7116e9ef | ||
|
|
8c7c8a69b4 | ||
|
|
427183d31c | ||
|
|
5f38888559 | ||
|
|
c35e94ba74 | ||
|
|
165de60f00 | ||
|
|
7e179d0e5c | ||
|
|
7f7444813e | ||
|
|
0dba988ff7 | ||
|
|
b002cbabc4 | ||
|
|
7fb09e2b18 | ||
|
|
6a9ab0f089 | ||
|
|
3fecdc75bd | ||
|
|
4373aa8f97 | ||
|
|
b2239eac6f | ||
|
|
ca44e805f2 | ||
|
|
705861084a | ||
|
|
7a303cef49 | ||
|
|
f7b864d35f | ||
|
|
e61991bc7d | ||
|
|
9a9665fb98 | ||
|
|
8a405f7ba3 | ||
|
|
e02722af37 | ||
|
|
3d1f95bcc8 | ||
|
|
868bf5db7e | ||
|
|
e4c2bc7740 | ||
|
|
3d651b97b6 | ||
|
|
9ee0f4a234 | ||
|
|
8f8743f4b5 | ||
|
|
d9489cedc4 | ||
|
|
c4e4c43668 | ||
|
|
b0fa6b3736 | ||
|
|
4d801ed962 | ||
|
|
138947af7f | ||
|
|
2ba28bae10 | ||
|
|
9ebcd0193a | ||
|
|
afbf52413f | ||
|
|
ad67088017 | ||
|
|
4c29d23ac0 | ||
|
|
ed8b18c576 | ||
|
|
c9b49789c7 | ||
|
|
d28d4873be | ||
|
|
44d7c2328c | ||
|
|
073338afa7 | ||
|
|
3e53467ac8 | ||
|
|
0d5ffdac2e | ||
|
|
ac03eb7642 | ||
|
|
2ff5b7dd0a | ||
|
|
b0d7e6dfba | ||
|
|
3304a62a35 | ||
|
|
763591c1a3 | ||
|
|
6de5a507fe | ||
|
|
3990bc9db4 | ||
|
|
f2207fe43e | ||
|
|
f48db84334 | ||
|
|
98d73b7200 | ||
|
|
acd4b1efcb | ||
|
|
4433dd009a | ||
|
|
d1a9794ec8 | ||
|
|
bf848ff882 | ||
|
|
69ebccfc20 | ||
|
|
600b50fce1 | ||
|
|
37e8586658 | ||
|
|
4b12ed5a51 | ||
|
|
e379b7704d | ||
|
|
297be122a6 | ||
|
|
ca28024ad8 | ||
|
|
cfd3255aa7 | ||
|
|
4e436160cc | ||
|
|
bf0ca4ca83 | ||
|
|
e23a97960f | ||
|
|
2d2371a792 | ||
|
|
0ea69dd4ef |
124
.github/dependabot.yml
vendored
124
.github/dependabot.yml
vendored
@@ -14,6 +14,15 @@ updates:
|
|||||||
timezone: Africa/Abidjan
|
timezone: Africa/Abidjan
|
||||||
open-pull-requests-limit: 99
|
open-pull-requests-limit: 99
|
||||||
ignore:
|
ignore:
|
||||||
|
- dependency-name: com.google.code.gson:gson
|
||||||
|
versions:
|
||||||
|
- "> 2.8.6"
|
||||||
|
- dependency-name: io.fabric8:fabric8-maven-plugin
|
||||||
|
versions:
|
||||||
|
- "> 4.4.0"
|
||||||
|
- dependency-name: javax.servlet:javax.servlet-api
|
||||||
|
versions:
|
||||||
|
- "> 3.0.1"
|
||||||
- dependency-name: org.acegisecurity:acegi-security
|
- dependency-name: org.acegisecurity:acegi-security
|
||||||
versions:
|
versions:
|
||||||
- "> 0.8.2_patched"
|
- "> 0.8.2_patched"
|
||||||
@@ -43,16 +52,109 @@ updates:
|
|||||||
- "> 1.0.0"
|
- "> 1.0.0"
|
||||||
- dependency-name: org.freemarker:freemarker
|
- dependency-name: org.freemarker:freemarker
|
||||||
versions:
|
versions:
|
||||||
- "> 2.3.31-alfresco-patched"
|
- "> 2.3.20-alfresco-patched-20200421"
|
||||||
|
- dependency-name: org.keycloak:keycloak-adapter-core
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.keycloak:keycloak-adapter-spi
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.keycloak:keycloak-authz-client
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.keycloak:keycloak-common
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.keycloak:keycloak-core
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.keycloak:keycloak-servlet-adapter-spi
|
||||||
|
versions:
|
||||||
|
- "> 12.0.2"
|
||||||
|
- dependency-name: org.eclipse.jetty:jetty-server
|
||||||
|
versions:
|
||||||
|
- 9.4.38.v20210224
|
||||||
|
- dependency-name: org.alfresco.tas:cmis
|
||||||
|
versions:
|
||||||
|
- "1.28"
|
||||||
|
- dependency-name: org.springframework:spring-webmvc
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-web
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-tx
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-orm
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-test
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-jms
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-jdbc
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-expression
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-core
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-context-support
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-context
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-beans
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.springframework:spring-aop
|
||||||
|
versions:
|
||||||
|
- 5.3.4
|
||||||
|
- 5.3.5
|
||||||
|
- dependency-name: org.alfresco.tas:restapi
|
||||||
|
versions:
|
||||||
|
- "1.55"
|
||||||
|
- dependency-name: org.eclipse.jetty:jetty-security
|
||||||
|
versions:
|
||||||
|
- 11.0.1
|
||||||
|
- dependency-name: org.alfresco.aos-module:alfresco-vti-bin
|
||||||
|
versions:
|
||||||
|
- 1.4.0-M1
|
||||||
|
- dependency-name: org.alfresco.aos-module:alfresco-aos-module-distributionzip
|
||||||
|
versions:
|
||||||
|
- 1.4.0-M1
|
||||||
|
- dependency-name: org.alfresco.aos-module:alfresco-aos-module
|
||||||
|
versions:
|
||||||
|
- 1.4.0-M1
|
||||||
|
- dependency-name: org.alfresco.surf:spring-webscripts-api
|
||||||
|
versions:
|
||||||
|
- "8.16"
|
||||||
|
- dependency-name: org.alfresco.surf:spring-webscripts:tests
|
||||||
|
versions:
|
||||||
|
- "8.16"
|
||||||
|
- dependency-name: org.alfresco.surf:spring-webscripts
|
||||||
|
versions:
|
||||||
|
- "8.16"
|
||||||
|
- dependency-name: org.alfresco.surf:spring-surf-core-configservice
|
||||||
|
versions:
|
||||||
|
- "8.16"
|
||||||
registries:
|
registries:
|
||||||
- maven-repository-artifacts-alfresco-com-nexus-content-groups-int
|
- maven-repository-artifacts-alfresco-com-nexus-content-groups-int
|
||||||
- package-ecosystem: "docker"
|
|
||||||
directory: "packaging/docker-alfresco/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
time: "22:00"
|
|
||||||
timezone: Africa/Abidjan
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
|
|||||||
1014
.github/workflows/ci.yml
vendored
1014
.github/workflows/ci.yml
vendored
File diff suppressed because it is too large
Load Diff
18
.github/workflows/master_release.yml
vendored
18
.github/workflows/master_release.yml
vendored
@@ -27,19 +27,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [run_ci]
|
needs: [run_ci]
|
||||||
if: >
|
if: >
|
||||||
!(failure() || cancelled()) &&
|
!failure() &&
|
||||||
!contains(github.event.head_commit.message, '[no release]') &&
|
!contains(github.event.head_commit.message, '[no release]') &&
|
||||||
github.event_name != 'pull_request'
|
github.event_name != 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v8.13.0
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v8.13.0
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.1.0
|
|
||||||
- name: "Init"
|
- name: "Init"
|
||||||
run: bash ./scripts/ci/init.sh
|
run: bash ./scripts/ci/init.sh
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v8.13.0
|
||||||
with:
|
with:
|
||||||
username: ${{ env.GIT_USERNAME }}
|
username: ${{ env.GIT_USERNAME }}
|
||||||
email: ${{ env.GIT_EMAIL }}
|
email: ${{ env.GIT_EMAIL }}
|
||||||
@@ -56,19 +55,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [push_to_nexus]
|
needs: [push_to_nexus]
|
||||||
if: >
|
if: >
|
||||||
!(failure() || cancelled()) &&
|
!failure() &&
|
||||||
!contains(github.event.head_commit.message, '[no downstream]') &&
|
!contains(github.event.head_commit.message, '[no downstream]') &&
|
||||||
github.event_name != 'pull_request'
|
github.event_name != 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v8.13.0
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v8.13.0
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.1.0
|
|
||||||
- name: "Init"
|
- name: "Init"
|
||||||
run: bash ./scripts/ci/init.sh
|
run: bash ./scripts/ci/init.sh
|
||||||
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v7.1.0
|
- uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v8.13.0
|
||||||
with:
|
with:
|
||||||
username: ${{ env.GIT_USERNAME }}
|
username: ${{ env.GIT_USERNAME }}
|
||||||
email: ${{ env.GIT_EMAIL }}
|
email: ${{ env.GIT_EMAIL }}
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -39,9 +39,6 @@ dependency-reduced-pom.xml
|
|||||||
|
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
# Development
|
|
||||||
repository/scripts/hazelcast-init/alfresco-hazelcast-config.xml
|
|
||||||
|
|
||||||
# Alfresco runtime
|
# Alfresco runtime
|
||||||
alf_data
|
alf_data
|
||||||
|
|
||||||
|
|||||||
@@ -131,23 +131,23 @@
|
|||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
"filename": ".github/workflows/ci.yml",
|
"filename": ".github/workflows/ci.yml",
|
||||||
"hashed_secret": "b86dc2f033a63f2b7b9e7d270ab806d2910d7572",
|
"hashed_secret": "a4a747bd4ba5e3a5049cad116881867c71fb625b",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 293
|
"line_number": 142
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
"filename": ".github/workflows/ci.yml",
|
"filename": ".github/workflows/ci.yml",
|
||||||
"hashed_secret": "1bfb0e20f886150ba59b853bcd49dea893e00966",
|
"hashed_secret": "3eaefff58bb411413fcbd76dc410d392529627e7",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 368
|
"line_number": 174
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
"filename": ".github/workflows/ci.yml",
|
"filename": ".github/workflows/ci.yml",
|
||||||
"hashed_secret": "128f14373ccfaff49e3664045d3a11b50cbb7b39",
|
"hashed_secret": "21b46dc06a4681d07e88157fec3a477484fd314b",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 902
|
"line_number": 391
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
".github/workflows/master_release.yml": [
|
".github/workflows/master_release.yml": [
|
||||||
@@ -170,16 +170,6 @@
|
|||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/retentionschedule/RetentionScheduleStepTests.java": [
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/retentionschedule/RetentionScheduleStepTests.java",
|
|
||||||
"hashed_secret": "e3557f3b0f2189660980d213f75d1a7828d56af1",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 83,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"amps/ags/rm-automation/rm-automation-community-rest-api/src/test/resources/default.properties": [
|
"amps/ags/rm-automation/rm-automation-community-rest-api/src/test/resources/default.properties": [
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
@@ -218,7 +208,7 @@
|
|||||||
"filename": "amps/ags/rm-community/rm-community-repo/docker-compose.yml",
|
"filename": "amps/ags/rm-community/rm-community-repo/docker-compose.yml",
|
||||||
"hashed_secret": "d1ebbc78705ad98aa2c8fb357d2e30c8f001673a",
|
"hashed_secret": "d1ebbc78705ad98aa2c8fb357d2e30c8f001673a",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 76
|
"line_number": 74
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"amps/ags/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java": [
|
"amps/ags/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/capability/RMPermissionModel.java": [
|
||||||
@@ -407,52 +397,6 @@
|
|||||||
"line_number": 79
|
"line_number": 79
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packaging/tests/scripts/wait-for-alfresco-start.sh": [
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "packaging/tests/scripts/wait-for-alfresco-start.sh",
|
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 15,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-cmis/src/main/java/org/alfresco/cmis/AuthParameterProviderFactory.java": [
|
|
||||||
{
|
|
||||||
"type": "JSON Web Token",
|
|
||||||
"filename": "packaging/tests/tas-cmis/src/main/java/org/alfresco/cmis/AuthParameterProviderFactory.java",
|
|
||||||
"hashed_secret": "a28cecdb5056cf30135809b921e38a84deb6c345",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 102,
|
|
||||||
"is_secret": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "JSON Web Token",
|
|
||||||
"filename": "packaging/tests/tas-cmis/src/main/java/org/alfresco/cmis/AuthParameterProviderFactory.java",
|
|
||||||
"hashed_secret": "5e39d8e2991ef9705998de26b33f11be0f3cdcde",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 103,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-cmis/src/main/resources/default.properties": [
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "packaging/tests/tas-cmis/src/main/resources/default.properties",
|
|
||||||
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 8,
|
|
||||||
"is_secret": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "packaging/tests/tas-cmis/src/main/resources/default.properties",
|
|
||||||
"hashed_secret": "a4a747bd4ba5e3a5049cad116881867c71fb625b",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 76,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-cmis/src/test/resources/default.properties": [
|
"packaging/tests/tas-cmis/src/test/resources/default.properties": [
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
@@ -515,52 +459,6 @@
|
|||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java": [
|
|
||||||
{
|
|
||||||
"type": "JSON Web Token",
|
|
||||||
"filename": "packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java",
|
|
||||||
"hashed_secret": "a28cecdb5056cf30135809b921e38a84deb6c345",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 79,
|
|
||||||
"is_secret": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "JSON Web Token",
|
|
||||||
"filename": "packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java",
|
|
||||||
"hashed_secret": "5e39d8e2991ef9705998de26b33f11be0f3cdcde",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 80,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModelsCollection.java": [
|
|
||||||
{
|
|
||||||
"type": "Base64 High Entropy String",
|
|
||||||
"filename": "packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModelsCollection.java",
|
|
||||||
"hashed_secret": "8b30a14989d7b8093ac29462fe29423d836625b4",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 39,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-restapi/src/main/resources/default.properties": [
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "packaging/tests/tas-restapi/src/main/resources/default.properties",
|
|
||||||
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 21,
|
|
||||||
"is_secret": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "packaging/tests/tas-restapi/src/main/resources/default.properties",
|
|
||||||
"hashed_secret": "a4a747bd4ba5e3a5049cad116881867c71fb625b",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 87,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"packaging/tests/tas-restapi/src/test/resources/default.properties": [
|
"packaging/tests/tas-restapi/src/test/resources/default.properties": [
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
@@ -691,7 +589,7 @@
|
|||||||
"filename": "remote-api/src/test/java/org/alfresco/repo/web/scripts/servlet/RemoteAuthenticatorFactoryAdminConsoleAccessTest.java",
|
"filename": "remote-api/src/test/java/org/alfresco/repo/web/scripts/servlet/RemoteAuthenticatorFactoryAdminConsoleAccessTest.java",
|
||||||
"hashed_secret": "4ffa743f28fc949c19e65ab045d7906d0609a2c2",
|
"hashed_secret": "4ffa743f28fc949c19e65ab045d7906d0609a2c2",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 269,
|
"line_number": 264,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -731,7 +629,7 @@
|
|||||||
"filename": "remote-api/src/test/java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java",
|
"filename": "remote-api/src/test/java/org/alfresco/rest/api/tests/AbstractBaseApiTest.java",
|
||||||
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 111,
|
"line_number": 120,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -963,6 +861,15 @@
|
|||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"repository/src/main/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceConfig.java": [
|
||||||
|
{
|
||||||
|
"type": "Secret Keyword",
|
||||||
|
"filename": "repository/src/main/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceConfig.java",
|
||||||
|
"hashed_secret": "fa8659c24b2b5da9a1e142348ada4c8f12493917",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 46
|
||||||
|
}
|
||||||
|
],
|
||||||
"repository/src/main/java/org/alfresco/repo/transfer/TransferServiceImpl2.java": [
|
"repository/src/main/java/org/alfresco/repo/transfer/TransferServiceImpl2.java": [
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Secret Keyword",
|
||||||
@@ -1257,7 +1164,7 @@
|
|||||||
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
||||||
"hashed_secret": "a4a747bd4ba5e3a5049cad116881867c71fb625b",
|
"hashed_secret": "a4a747bd4ba5e3a5049cad116881867c71fb625b",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 245,
|
"line_number": 244,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1265,7 +1172,7 @@
|
|||||||
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
||||||
"hashed_secret": "1459a56410378e4d3ab470eff570e5eae1742762",
|
"hashed_secret": "1459a56410378e4d3ab470eff570e5eae1742762",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 312,
|
"line_number": 311,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1273,7 +1180,7 @@
|
|||||||
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
"filename": "repository/src/main/resources/alfresco/repository.properties",
|
||||||
"hashed_secret": "84551ae5442affc9f1a2d3b4c86ae8b24860149d",
|
"hashed_secret": "84551ae5442affc9f1a2d3b4c86ae8b24860149d",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 770,
|
"line_number": 763,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1303,7 +1210,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
||||||
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 88,
|
"line_number": 82,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1311,7 +1218,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
||||||
"hashed_secret": "c464af817287343305cbd6493c593885695df531",
|
"hashed_secret": "c464af817287343305cbd6493c593885695df531",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 92,
|
"line_number": 86,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1319,7 +1226,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
||||||
"hashed_secret": "8ad8572a0b3fc4cb3afc1baaebc97a2cae58eb8c",
|
"hashed_secret": "8ad8572a0b3fc4cb3afc1baaebc97a2cae58eb8c",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 93,
|
"line_number": 87,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1327,7 +1234,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
"filename": "repository/src/test/java/org/alfresco/filesys/FTPServerTest.java",
|
||||||
"hashed_secret": "915692b4d7465b0084354173d552ac90145dc315",
|
"hashed_secret": "915692b4d7465b0084354173d552ac90145dc315",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 94,
|
"line_number": 88,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1337,7 +1244,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/filesys/repo/ContentDiskDriverTest.java",
|
"filename": "repository/src/test/java/org/alfresco/filesys/repo/ContentDiskDriverTest.java",
|
||||||
"hashed_secret": "8c85434f6f339a24b808810bd95629d0f5856355",
|
"hashed_secret": "8c85434f6f339a24b808810bd95629d0f5856355",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 1280,
|
"line_number": 1281,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1447,7 +1354,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java",
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 103,
|
"line_number": 109,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1539,7 +1446,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/rendition2/AbstractRenditionIntegrationTest.java",
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 127,
|
"line_number": 130,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1569,7 +1476,7 @@
|
|||||||
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java",
|
||||||
"hashed_secret": "607e729c2f77c4e821e68e26b4c1f5a4398624e9",
|
"hashed_secret": "607e729c2f77c4e821e68e26b4c1f5a4398624e9",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 2129,
|
"line_number": 2124,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1593,42 +1500,48 @@
|
|||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceFacadeFactoryBeanTest.java": [
|
"repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java": [
|
||||||
{
|
{
|
||||||
"type": "Base64 High Entropy String",
|
"type": "Base64 High Entropy String",
|
||||||
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceFacadeFactoryBeanTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
"hashed_secret": "c4b66dbe168ad1d2b19119494a0da063801bc3bb",
|
"hashed_secret": "00fda15183ba9ba9e6c2e364ea40c3928bd52f92",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 83,
|
"line_number": 131
|
||||||
"is_secret": false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "JSON Web Token",
|
"type": "Base64 High Entropy String",
|
||||||
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceFacadeFactoryBeanTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
"hashed_secret": "c5aad1895e1dcff195992938f1bcc9954d575ac9",
|
"hashed_secret": "b83ad0214090e5d0414a93638a9a53f72c61b549",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 92,
|
"line_number": 132
|
||||||
"is_secret": false
|
},
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/LazyInstantiatingIdentityServiceFacadeUnitTest.java": [
|
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Base64 High Entropy String",
|
||||||
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/LazyInstantiatingIdentityServiceFacadeUnitTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
"hashed_secret": "12e59296b0d17c1ceb345a7adca98574c835ba24",
|
"hashed_secret": "e16209d11bbd258c6b81680caae78cdacc632fe1",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 45,
|
"line_number": 133
|
||||||
"is_secret": false
|
},
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/SpringBasedIdentityServiceFacadeUnitTest.java": [
|
|
||||||
{
|
{
|
||||||
"type": "Secret Keyword",
|
"type": "Base64 High Entropy String",
|
||||||
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/SpringBasedIdentityServiceFacadeUnitTest.java",
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
"hashed_secret": "bf495f339a303c35da0bfd54c34f0a25498ac14a",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 46,
|
"line_number": 134
|
||||||
"is_secret": false
|
},
|
||||||
|
{
|
||||||
|
"type": "Base64 High Entropy String",
|
||||||
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
|
"hashed_secret": "6a9c25a83c51b2d802241c94f128938e2647039f",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 135
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Base64 High Entropy String",
|
||||||
|
"filename": "repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java",
|
||||||
|
"hashed_secret": "34c5cdcf8c7f163ff1935131fa9f6ddd4cfd35b7",
|
||||||
|
"is_verified": false,
|
||||||
|
"line_number": 136
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"repository/src/test/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java": [
|
"repository/src/test/java/org/alfresco/repo/tenant/MultiTNodeServiceInterceptorTest.java": [
|
||||||
@@ -1781,7 +1694,7 @@
|
|||||||
"filename": "repository/src/test/resources/alfresco-global.properties",
|
"filename": "repository/src/test/resources/alfresco-global.properties",
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
||||||
"is_verified": false,
|
"is_verified": false,
|
||||||
"line_number": 21,
|
"line_number": 28,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1868,25 +1781,7 @@
|
|||||||
"line_number": 1843,
|
"line_number": 1843,
|
||||||
"is_secret": false
|
"is_secret": false
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"scripts/ci/docker-compose/docker-compose.yaml": [
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "scripts/ci/docker-compose/docker-compose.yaml",
|
|
||||||
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 39,
|
|
||||||
"is_secret": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "Secret Keyword",
|
|
||||||
"filename": "scripts/ci/docker-compose/docker-compose.yaml",
|
|
||||||
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
|
|
||||||
"is_verified": false,
|
|
||||||
"line_number": 43,
|
|
||||||
"is_secret": false
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"generated_at": "2024-10-09T09:32:52Z"
|
"generated_at": "2025-03-29T00:03:53Z"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ Because this project forms a part of Alfresco Content Services, the guidelines a
|
|||||||
|
|
||||||
You can report an issue in the ALF project of the [Alfresco issue tracker](http://issues.alfresco.com).
|
You can report an issue in the ALF project of the [Alfresco issue tracker](http://issues.alfresco.com).
|
||||||
|
|
||||||
Read [instructions for a good issue report](https://hub.alfresco.com/t5/alfresco-content-services-hub/reporting-an-issue/ba-p/289727).
|
Read [instructions for a good issue report](https://community.alfresco.com/docs/DOC-6263-reporting-an-issue).
|
||||||
|
|
||||||
Read [instructions for making a contribution](https://hub.alfresco.com/t5/alfresco-content-services-hub/alfresco-contribution-agreement/ba-p/293276).
|
Read [instructions for making a contribution](https://community.alfresco.com/docs/DOC-6269-submitting-contributions).
|
||||||
|
|
||||||
Please follow [the coding standards](https://hub.alfresco.com/t5/alfresco-content-services-hub/coding-standards-for-alfresco-content-services/ba-p/290457).
|
Please follow [the coding standards](https://community.alfresco.com/docs/DOC-4658-coding-standards).
|
||||||
|
|||||||
79
README.md
79
README.md
@@ -1,58 +1,39 @@
|
|||||||
# alfresco-community-repo
|
# alfresco-community-repo
|
||||||
|
|
||||||
[](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml)
|
[](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml)
|
||||||
|
|
||||||
## Table of Contents
|
#### Alfresco Core
|
||||||
1. [Content](#content)
|
|
||||||
2. [Artifacts](#artifacts)
|
|
||||||
3. [Setup](#setting-up-and-building-your-development-environment)
|
|
||||||
4. [Branches](#branches)
|
|
||||||
5. [Contributing](#contributing-guide)
|
|
||||||
6. [Helpful links](#helpful-links)
|
|
||||||
|
|
||||||
|
|
||||||
## Content
|
|
||||||
Alfresco Community Repository contains following libraries:
|
|
||||||
|
|
||||||
### Alfresco Core
|
|
||||||
Core is a library packaged as a jar file which contains the following:
|
|
||||||
|
|
||||||
|
Alfresco Core is a library packaged as a jar file which contains the following:
|
||||||
* Various helpers and utils
|
* Various helpers and utils
|
||||||
* Canned queries interface and supporting classes
|
* Canned queries interface and supporting classes
|
||||||
* Generic encryption supporting classes
|
* Generic encryption supporting classes
|
||||||
|
|
||||||
### Alfresco Data Model
|
#### Alfresco Data Model
|
||||||
|
Data model is a library packaged as a jar file which contains the following:
|
||||||
Data Model is a library packaged as a jar file which contains the following:
|
|
||||||
|
|
||||||
* Dictionary, Repository and Search Services interfaces
|
* Dictionary, Repository and Search Services interfaces
|
||||||
* Models for data types and Dictionary implementation
|
* Models for data types and Dictionary implementation
|
||||||
* Parsers
|
* Parsers
|
||||||
|
|
||||||
### Alfresco Repository
|
#### Alfresco Repository
|
||||||
|
|
||||||
Repository is a library packaged as a jar file which contains the following:
|
Repository is a library packaged as a jar file which contains the following:
|
||||||
|
|
||||||
* DAOs and SQL scripts
|
* DAOs and SQL scripts
|
||||||
* Various Service implementations
|
* Various Service implementations
|
||||||
* Utility classes
|
* Utility classes
|
||||||
|
|
||||||
### Alfresco Remote API
|
#### Alfresco Remote API
|
||||||
|
|
||||||
Remote API is a library packaged as a jar file which contains the following:
|
Remote API is a library packaged as a jar file which contains the following:
|
||||||
|
|
||||||
* REST API framework
|
* REST API framework
|
||||||
* WebScript implementations including [V1 REST APIs](https://hub.alfresco.com/t5/alfresco-content-services-blog/v1-rest-api-10-things-you-should-know/ba-p/287692)
|
* WebScript implementations including [V1 REST APIs](https://community.alfresco.com/community/ecm/blog/2017/05/02/v1-rest-api-10-things-you-should-know)
|
||||||
* [OpenCMIS](https://chemistry.apache.org/java/opencmis.html) implementations
|
* [OpenCMIS](https://chemistry.apache.org/java/opencmis.html) implementations
|
||||||
|
|
||||||
## Artifacts
|
#### Artifacts
|
||||||
|
|
||||||
The artifacts can be obtained by:
|
The artifacts can be obtained by:
|
||||||
* downloading from [Alfresco maven repository](https://artifacts.alfresco.com/nexus/#browse/browse:public)
|
* downloading from [Alfresco maven repository](https://artifacts.alfresco.com/nexus/content/groups/public)
|
||||||
* as Maven dependency by adding the dependency to your pom file:
|
* as Maven dependency by adding the dependency to your pom file:
|
||||||
|
~~~
|
||||||
~~~xml
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-core</artifactId>
|
<artifactId>alfresco-core</artifactId>
|
||||||
@@ -83,46 +64,34 @@ The artifacts can be obtained by:
|
|||||||
<version>version</version>
|
<version>version</version>
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
and Alfresco maven repository:
|
and Alfresco maven repository:
|
||||||
|
~~~
|
||||||
~~~xml
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>alfresco-maven-repo</id>
|
<id>alfresco-maven-repo</id>
|
||||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
The SNAPSHOT versions of the artifact are not published.
|
The SNAPSHOT versions of the artifact are not published.
|
||||||
|
|
||||||
## Setting up and building your development environment
|
## Setting up and building your development environment
|
||||||
|
See the [Development Tomcat Environment](https://github.com/Alfresco/acs-community-packaging/tree/master/dev/README.md)
|
||||||
See the [**Development Tomcat Environment**](https://github.com/Alfresco/acs-community-packaging/tree/master/dev/README.md)
|
page which will show you how to try out your repository changes in a local tomcat instance.
|
||||||
page which will show you how to try out your repository changes in a local Tomcat instance or using Docker containers.
|
If you wish to use Docker images, take a look at the aliases ending in `D` and the docker-compose files in this
|
||||||
|
project's test modules.
|
||||||
|
|
||||||
## Branches
|
## Branches
|
||||||
|
This project has a branch for each ACS release. For example the code in ACS 6.2.1 is a
|
||||||
This project has a branch for each ACS release. For example the code in ACS 6.2.2 is a
|
branch called `releases/6.2.2`. In addition to the original 6.2.2 release it will also contain Hot Fixes
|
||||||
branch called **`release/6.2.2`**. In addition to the original 6.2.2 release it will also contain Hot Fixes
|
added later. The latest unreleased code is on the `master` branch. There are also `.N` branches, such as
|
||||||
added later. The latest unreleased code is on the **`master`** branch. There are also **`.N`** branches, such as
|
`releases/7.1.N` on which we gather unreleased fixes for future service pack releases. They do not indicate
|
||||||
**`release/7.1.N`** on which we gather unreleased fixes for future service pack releases. They do not indicate
|
|
||||||
that one is planned.
|
that one is planned.
|
||||||
|
|
||||||
For historic reasons the version of artifacts created on each branch do not match the ACS version.
|
For historic reasons the version of artifacts created on each branch do not match the ACS version.
|
||||||
For example artifact in ACS 7.2.0 will be **`14.<something>`**.
|
For example artifact in ACS 7.2.0 will be `14.<something>`.
|
||||||
|
|
||||||
The enterprise projects which extend the **`alfresco-community-repo`** use the same branch names and leading
|
The enterprise projects which extend the `alfresco-community-repo` use the same branch names and leading
|
||||||
artifact version number.
|
artifact version number.
|
||||||
|
|
||||||
## Contributing guide
|
### Contributing guide
|
||||||
|
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.
|
||||||
Please use [**this guide**](CONTRIBUTING.md) to make a contribution to the project.
|
|
||||||
|
|
||||||
## Helpful links
|
|
||||||
|
|
||||||
- [Alfresco Content Services Documentation](https://docs.alfresco.com/content-services/latest/)
|
|
||||||
- [Alfresco Platform](https://www.hyland.com/en/products/alfresco-platform)
|
|
||||||
0
amps/ags/ci/scripts/getLogs.sh
Normal file → Executable file
0
amps/ags/ci/scripts/getLogs.sh
Normal file → Executable file
@@ -7,22 +7,14 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||||
<version>23.5.0.1</version>
|
<version>16.35-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>rm-community</module>
|
<module>rm-community</module>
|
||||||
|
<module>rm-automation</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>all-tas-tests</id>
|
|
||||||
<modules>
|
|
||||||
<module>rm-automation</module>
|
|
||||||
</modules>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
@@ -38,20 +30,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- Keeping illegal-access=permit for Java 11 compatibility, even though it has no effect on JDK 17 -->
|
|
||||||
<argLine>
|
<argLine>
|
||||||
--illegal-access=permit
|
--illegal-access=permit
|
||||||
--add-opens=java.base/java.lang=ALL-UNNAMED
|
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<!-- Keeping illegal-access=permit for Java 11 compatibility, even though it has no effect on JDK 17 -->
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
--illegal-access=permit
|
--illegal-access=permit
|
||||||
--add-opens=java.base/java.lang=ALL-UNNAMED
|
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||||
<version>23.5.0.1</version>
|
<version>16.35-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||||
<version>23.5.0.1</version>
|
<version>16.35-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -42,10 +42,15 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-reload4j</artifactId>
|
||||||
|
<version>1.7.35</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.alfresco.tas</groupId>
|
<groupId>org.alfresco.tas</groupId>
|
||||||
<artifactId>restapi</artifactId>
|
<artifactId>restapi</artifactId>
|
||||||
<version>${project.version}</version>
|
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.alfresco.tas</groupId>
|
<groupId>org.alfresco.tas</groupId>
|
||||||
@@ -74,22 +79,6 @@
|
|||||||
<artifactId>alfresco-testng</artifactId>
|
<artifactId>alfresco-testng</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.epam.reportportal</groupId>
|
|
||||||
<artifactId>agent-java-testng</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.awaitility</groupId>
|
|
||||||
<artifactId>awaitility</artifactId>
|
|
||||||
<version>${dependency.awaitility.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
@@ -98,25 +87,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.docker-java</groupId>
|
<groupId>com.github.docker-java</groupId>
|
||||||
<artifactId>docker-java</artifactId>
|
<artifactId>docker-java</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.2.12</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcpkix-jdk15on</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcprov-jdk18on</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bouncycastle</groupId>
|
|
||||||
<artifactId>bcpkix-jdk18on</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ package org.alfresco.rest.core;
|
|||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
import static lombok.AccessLevel.PROTECTED;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -39,7 +39,6 @@ import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
|||||||
import org.alfresco.rest.rm.community.requests.gscore.api.ActionsExecutionAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.ActionsExecutionAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.HoldsAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMUserAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RMUserAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
@@ -49,7 +48,6 @@ import org.alfresco.rest.rm.community.requests.gscore.api.TransferAPI;
|
|||||||
import org.alfresco.rest.rm.community.requests.gscore.api.TransferContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.TransferContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RetentionScheduleAPI;
|
|
||||||
import org.alfresco.utility.data.DataUserAIS;
|
import org.alfresco.utility.data.DataUserAIS;
|
||||||
import org.alfresco.utility.model.RepoTestModel;
|
import org.alfresco.utility.model.RepoTestModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -245,24 +243,4 @@ public class RestAPIFactory
|
|||||||
{
|
{
|
||||||
return getGSCoreAPI(null).usingActionsExecutionsAPI();
|
return getGSCoreAPI(null).usingActionsExecutionsAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HoldsAPI getHoldsAPI()
|
|
||||||
{
|
|
||||||
return getGSCoreAPI(null).usingHoldsAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HoldsAPI getHoldsAPI(UserModel userModel)
|
|
||||||
{
|
|
||||||
return getGSCoreAPI(userModel).usingHoldsAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RetentionScheduleAPI getRetentionScheduleAPI()
|
|
||||||
{
|
|
||||||
return getGSCoreAPI(null).usingRetentionScheduleAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public RetentionScheduleAPI getRetentionScheduleAPI(UserModel userModel)
|
|
||||||
{
|
|
||||||
return getGSCoreAPI(userModel).usingRetentionScheduleAPI();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.core.v0;
|
package org.alfresco.rest.core.v0;
|
||||||
|
|
||||||
import jakarta.json.Json;
|
import javax.json.Json;
|
||||||
import jakarta.json.JsonReader;
|
import javax.json.JsonReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public abstract class BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract the property value for the given nodeRef and property name
|
* Helper method to extract the property value for the given nodeRef and property name
|
||||||
*
|
*
|
||||||
* @param result
|
* @param result
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
* @param propertyName
|
* @param propertyName
|
||||||
@@ -152,7 +152,7 @@ public abstract class BaseAPI
|
|||||||
|
|
||||||
return propertyValue;
|
return propertyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.
|
* Helper method to extract property values from request result and put them in map as a list that corresponds to a unique property value.
|
||||||
*
|
*
|
||||||
@@ -512,12 +512,7 @@ public abstract class BaseAPI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpResponse httpResponse = doRequestJson(HttpPost.class, requestUrl, adminUser, adminPassword, requestParams);
|
HttpResponse httpResponse = doRequestJson(HttpPost.class, requestUrl, adminUser, adminPassword, requestParams);
|
||||||
if (httpResponse.getStatusLine().getStatusCode() != expectedStatusCode)
|
assertEquals("POST request to " + requestUrl + " was not successful.", expectedStatusCode, httpResponse.getStatusLine().getStatusCode());
|
||||||
{
|
|
||||||
// It's only possible to stream the response body once, so ensure we only do this if the test has failed.
|
|
||||||
JSONObject responseJson = responseBodyToJson(httpResponse);
|
|
||||||
assertEquals("POST request to " + requestUrl + " was not successful. Response: " + responseJson, expectedStatusCode, httpResponse.getStatusLine().getStatusCode());
|
|
||||||
}
|
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException error)
|
catch (InstantiationException | IllegalAccessException error)
|
||||||
@@ -526,32 +521,6 @@ public abstract class BaseAPI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to convert the response body to a JSON object.
|
|
||||||
*
|
|
||||||
* @param response The response.
|
|
||||||
* @return The JSON object or null if it was not possible to convert the response.
|
|
||||||
*/
|
|
||||||
private JSONObject responseBodyToJson(HttpResponse response)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return new JSONObject(EntityUtils.toString(response.getEntity()));
|
|
||||||
}
|
|
||||||
catch (JSONException error)
|
|
||||||
{
|
|
||||||
LOGGER.error("Converting message body to JSON failed. Body: {}", response.getEntity().getContent(), error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ParseException | IOException error)
|
|
||||||
{
|
|
||||||
LOGGER.error("Parsing message body failed.", error);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for handling generic HTTP requests
|
* Helper method for handling generic HTTP requests
|
||||||
* @param requestType request type (a subclass of {@link HttpRequestBase})
|
* @param requestType request type (a subclass of {@link HttpRequestBase})
|
||||||
@@ -589,7 +558,18 @@ public abstract class BaseAPI
|
|||||||
HttpResponse response = client.execute(adminUser, adminPassword, request);
|
HttpResponse response = client.execute(adminUser, adminPassword, request);
|
||||||
LOGGER.info("Response: {}", response.getStatusLine());
|
LOGGER.info("Response: {}", response.getStatusLine());
|
||||||
|
|
||||||
responseBody = responseBodyToJson(response);
|
try
|
||||||
|
{
|
||||||
|
responseBody = new JSONObject(EntityUtils.toString(response.getEntity()));
|
||||||
|
}
|
||||||
|
catch (JSONException error)
|
||||||
|
{
|
||||||
|
LOGGER.error("Converting message body to JSON failed. Body: {}", responseBody, error);
|
||||||
|
}
|
||||||
|
catch (ParseException | IOException error)
|
||||||
|
{
|
||||||
|
LOGGER.error("Parsing message body failed.", error);
|
||||||
|
}
|
||||||
|
|
||||||
switch (response.getStatusLine().getStatusCode())
|
switch (response.getStatusLine().getStatusCode())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class FilePlanComponentFields
|
|||||||
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS = "rma:recordSearchDispositionEvents";
|
public static final String PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS = "rma:recordSearchDispositionEvents";
|
||||||
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_BY = "rma:declassificationReviewCompletedBy";
|
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_BY = "rma:declassificationReviewCompletedBy";
|
||||||
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_AT = "rma:declassificationReviewCompletedAt";
|
public static final String PROPERTIES_DECLASSIFICATION_REVIEW_COMPLETED_AT = "rma:declassificationReviewCompletedAt";
|
||||||
|
|
||||||
|
|
||||||
/** File plan properties */
|
/** File plan properties */
|
||||||
public static final String PROPERTIES_COMPONENT_ID = "st:componentId";
|
public static final String PROPERTIES_COMPONENT_ID = "st:componentId";
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BulkBodyCancel
|
|
||||||
{
|
|
||||||
private String reason;
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Hold extends TestModel
|
|
||||||
{
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private String reason;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
if (this == o)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Hold hold = (Hold) o;
|
|
||||||
return Objects.equals(id, hold.id) && Objects.equals(name, hold.name)
|
|
||||||
&& Objects.equals(description, hold.description) && Objects.equals(reason, hold.reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return Objects.hash(id, name, description, reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold bulk request
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldBulkOperation extends TestModel
|
|
||||||
{
|
|
||||||
public enum HoldBulkOperationType
|
|
||||||
{
|
|
||||||
ADD
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private RestRequestQueryModel query;
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private HoldBulkOperationType op;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold bulk request entry
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldBulkOperationEntry
|
|
||||||
{
|
|
||||||
private String bulkStatusId;
|
|
||||||
|
|
||||||
private long totalItems;
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold bulk request
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldBulkStatus extends TestModel
|
|
||||||
{
|
|
||||||
private String bulkStatusId;
|
|
||||||
|
|
||||||
private String startTime;
|
|
||||||
|
|
||||||
private String endTime;
|
|
||||||
|
|
||||||
private long processedItems;
|
|
||||||
|
|
||||||
private long errorsCount;
|
|
||||||
|
|
||||||
private long totalItems;
|
|
||||||
|
|
||||||
private String lastError;
|
|
||||||
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
private String cancellationReason;
|
|
||||||
|
|
||||||
private HoldBulkOperation holdBulkOperation;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle collection of {@link HoldBulkStatusEntry}
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class HoldBulkStatusCollection extends RestModels<HoldBulkStatusEntry, HoldBulkStatusCollection>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldBulkStatusEntry extends RestModels<HoldBulkStatus, HoldBulkStatusEntry>
|
|
||||||
{
|
|
||||||
private HoldBulkStatus entry;
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold child
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldChild extends TestModel
|
|
||||||
{
|
|
||||||
@JsonProperty(required = true)
|
|
||||||
private String id;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle collection of {@link HoldChildEntry}
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class HoldChildCollection extends RestModels<HoldChildEntry, HoldChildCollection>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold child entry
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldChildEntry extends RestModels<Hold, HoldChildEntry>
|
|
||||||
{
|
|
||||||
@JsonProperty
|
|
||||||
private HoldChild entry;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle collection of {@link HoldEntry}
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class HoldCollection extends RestModels<HoldEntry, HoldCollection>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold deletion reason
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldDeletionReason extends TestModel
|
|
||||||
{
|
|
||||||
@JsonProperty
|
|
||||||
private String reason;
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold child entry
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class HoldDeletionReasonEntry extends RestModels<HoldDeletionReason, HoldDeletionReasonEntry>
|
|
||||||
{
|
|
||||||
@JsonProperty
|
|
||||||
private HoldDeletionReason entry;
|
|
||||||
}
|
|
||||||
@@ -26,27 +26,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rm.community.model.hold;
|
package org.alfresco.rest.rm.community.model.hold;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.alfresco.rest.core.RestModels;
|
import org.alfresco.utility.model.TestModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POJO for hold entry
|
* POJO for hold entry
|
||||||
*
|
*
|
||||||
* @author Damian Ujma
|
* @author Rodica Sutu
|
||||||
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class HoldEntry extends RestModels<Hold, HoldEntry>
|
@JsonIgnoreProperties (ignoreUnknown = true)
|
||||||
|
public class HoldEntry extends TestModel
|
||||||
{
|
{
|
||||||
@JsonProperty
|
@JsonProperty (required = true)
|
||||||
private Hold entry;
|
private String name;
|
||||||
|
|
||||||
|
@JsonProperty (required = true)
|
||||||
|
private String nodeRef;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.hold.v0;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* POJO for hold entry
|
|
||||||
*
|
|
||||||
* @author Rodica Sutu
|
|
||||||
* @since 3.2
|
|
||||||
*/
|
|
||||||
@Builder
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@JsonIgnoreProperties (ignoreUnknown = true)
|
|
||||||
public class HoldEntry extends TestModel
|
|
||||||
{
|
|
||||||
@JsonProperty (required = true)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@JsonProperty (required = true)
|
|
||||||
private String nodeRef;
|
|
||||||
}
|
|
||||||
@@ -125,7 +125,7 @@ public class RecordProperties extends TestModel
|
|||||||
|
|
||||||
@JsonProperty (required = true, value = PROPERTIES_ORIGINAL_NAME)
|
@JsonProperty (required = true, value = PROPERTIES_ORIGINAL_NAME)
|
||||||
private String originalName;
|
private String originalName;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_CLASSIFICATION)
|
@JsonProperty (PROPERTIES_CLASSIFICATION)
|
||||||
private List<String> classification;
|
private List<String> classification;
|
||||||
|
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ public class RecordCategoryChildProperties extends TestModel
|
|||||||
|
|
||||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
|
@JsonProperty (PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE)
|
||||||
private Boolean recordSearchHasDispositionSchedule;
|
private Boolean recordSearchHasDispositionSchedule;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
|
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION)
|
||||||
private String recordSearchDispositionPeriodExpression;
|
private String recordSearchDispositionPeriodExpression;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
|
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY)
|
||||||
private String recordSearchDispositionAuthority;
|
private String recordSearchDispositionAuthority;
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class RecordCategoryChildProperties extends TestModel
|
|||||||
|
|
||||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
|
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
|
||||||
private List<String> recordSearchDispositionEvents;
|
private List<String> recordSearchDispositionEvents;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_OWNER)
|
@JsonProperty (PROPERTIES_OWNER)
|
||||||
private Owner owner;
|
private Owner owner;
|
||||||
|
|
||||||
|
|||||||
@@ -112,13 +112,13 @@ public class RecordFolderProperties extends TestModel
|
|||||||
|
|
||||||
@JsonProperty (PROPERTIES_CLASSIFICATION)
|
@JsonProperty (PROPERTIES_CLASSIFICATION)
|
||||||
private List<String> classification;
|
private List<String> classification;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_DESCRIPTION)
|
@JsonProperty (PROPERTIES_DESCRIPTION)
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_OWNER)
|
@JsonProperty (PROPERTIES_OWNER)
|
||||||
private Owner owner;
|
private Owner owner;
|
||||||
|
|
||||||
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
|
@JsonProperty (PROPERTIES_RECORD_SEARCH_VITAL_RECORD_REVIEW_PERIOD)
|
||||||
private String recordSearchVitalRecordReviewPeriod;
|
private String recordSearchVitalRecordReviewPeriod;
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.alfresco.utility.model.TestModel;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* retention schedule
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class RetentionSchedule extends TestModel
|
|
||||||
{
|
|
||||||
private String id ;
|
|
||||||
private String parentId;
|
|
||||||
private String authority;
|
|
||||||
private String instructions;
|
|
||||||
private boolean isRecordLevel;
|
|
||||||
private boolean isUnpublishedUpdates;
|
|
||||||
private List<RetentionScheduleActionDefinition> actions;
|
|
||||||
|
|
||||||
public boolean getIsRecordLevel()
|
|
||||||
{
|
|
||||||
return isRecordLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsRecordLevel(boolean recordLevel) {
|
|
||||||
isRecordLevel = recordLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* retention schedule action definition
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class RetentionScheduleActionDefinition
|
|
||||||
{
|
|
||||||
private String id;
|
|
||||||
private String name;
|
|
||||||
private int periodAmount;
|
|
||||||
private String period;
|
|
||||||
private String periodProperty;
|
|
||||||
private boolean combineRetentionStepConditions;
|
|
||||||
private List<String> events;
|
|
||||||
private boolean eligibleOnFirstCompleteEvent;
|
|
||||||
private String description;
|
|
||||||
private boolean retainRecordMetadataAfterDestruction;
|
|
||||||
private String location;
|
|
||||||
private int index;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
public class RetentionScheduleCollection extends RestModels<RetentionScheduleEntry, RetentionScheduleCollection>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
@Data
|
|
||||||
public class RetentionScheduleEntry extends RestModels<RetentionSchedule, RetentionScheduleEntry>
|
|
||||||
{
|
|
||||||
@JsonProperty
|
|
||||||
private RetentionSchedule entry;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
public class RetentionScheduleStepCollection extends RestModels<RetentionScheduleStepEntry, RetentionScheduleStepCollection>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.model.retentionschedule;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.alfresco.rest.core.RestModels;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class RetentionScheduleStepEntry extends RestModels<RetentionScheduleActionDefinition, RetentionScheduleStepEntry>
|
|
||||||
{
|
|
||||||
@JsonProperty
|
|
||||||
private RetentionScheduleActionDefinition entry;
|
|
||||||
}
|
|
||||||
@@ -28,7 +28,7 @@ package org.alfresco.rest.rm.community.model.user;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for RM user capabilities
|
* Constants for RM user capabilities
|
||||||
*
|
*
|
||||||
* @author Kristijan Conkas
|
* @author Kristijan Conkas
|
||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import org.alfresco.rest.rm.community.requests.gscore.api.ActionsExecutionAPI;
|
|||||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.HoldsAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RMUserAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RMUserAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
@@ -47,7 +46,6 @@ import org.alfresco.rest.rm.community.requests.gscore.api.TransferAPI;
|
|||||||
import org.alfresco.rest.rm.community.requests.gscore.api.TransferContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.TransferContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RetentionScheduleAPI;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the entire GS Core API
|
* Defines the entire GS Core API
|
||||||
@@ -192,11 +190,4 @@ public class GSCoreAPI extends RMModelRequest
|
|||||||
{
|
{
|
||||||
return new ActionsExecutionAPI(getRmRestWrapper());
|
return new ActionsExecutionAPI(getRmRestWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HoldsAPI usingHoldsAPI() { return new HoldsAPI(getRmRestWrapper()); }
|
|
||||||
|
|
||||||
public RetentionScheduleAPI usingRetentionScheduleAPI()
|
|
||||||
{
|
|
||||||
return new RetentionScheduleAPI(getRmRestWrapper());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ import static org.springframework.http.HttpMethod.PUT;
|
|||||||
|
|
||||||
import org.alfresco.rest.core.RMRestWrapper;
|
import org.alfresco.rest.core.RMRestWrapper;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
|
||||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||||
@@ -215,74 +213,4 @@ public class FilePlanAPI extends RMModelRequest
|
|||||||
parameters));
|
parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a hold.
|
|
||||||
*
|
|
||||||
* @param holdModel The hold model
|
|
||||||
* @param filePlanId The identifier of a file plan
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The created {@link Hold}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code filePlanId} is not a valid format or {@code filePlanId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to add children to {@code filePlanId}</li>
|
|
||||||
* <li>{@code filePlanIds} does not exist</li>
|
|
||||||
* <li>new name clashes with an existing node in the current parent container</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public Hold createHold(Hold holdModel, String filePlanId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("filePlanId", filePlanId);
|
|
||||||
mandatoryObject("holdModel", holdModel);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(Hold.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(holdModel),
|
|
||||||
"file-plans/{filePlanId}/holds",
|
|
||||||
filePlanId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #createHold(Hold, String, String)}
|
|
||||||
*/
|
|
||||||
public Hold createHold(Hold holdModel, String filePlanId)
|
|
||||||
{
|
|
||||||
return createHold(holdModel, filePlanId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the holds of a file plan.
|
|
||||||
*
|
|
||||||
* @param filePlanId The identifier of a file plan
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link HoldCollection} for the given {@code filePlanId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to read {@code filePlanId}</li>
|
|
||||||
* <li>{@code filePlanId} does not exist</li>
|
|
||||||
*</ul>
|
|
||||||
*/
|
|
||||||
public HoldCollection getHolds(String filePlanId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("filePlanId", filePlanId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModels(HoldCollection.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"file-plans/{filePlanId}/holds?{parameters}",
|
|
||||||
filePlanId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getHolds(String, String)}
|
|
||||||
*/
|
|
||||||
public HoldCollection getHolds(String filePlanId)
|
|
||||||
{
|
|
||||||
return getHolds(filePlanId, EMPTY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,446 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.requests.gscore.api;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
|
||||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
|
||||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
|
||||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
|
||||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
|
||||||
import static org.springframework.http.HttpMethod.DELETE;
|
|
||||||
import static org.springframework.http.HttpMethod.GET;
|
|
||||||
import static org.springframework.http.HttpMethod.POST;
|
|
||||||
import static org.springframework.http.HttpMethod.PUT;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RMRestWrapper;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.BulkBodyCancel;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperation;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperationEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatus;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatusCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChildCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldDeletionReason;
|
|
||||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds REST API Wrapper
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class HoldsAPI extends RMModelRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rmRestWrapper
|
|
||||||
*/
|
|
||||||
public HoldsAPI(RMRestWrapper rmRestWrapper)
|
|
||||||
{
|
|
||||||
super(rmRestWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link Hold} for the given {@code holdId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} is not a valid format</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to read {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public Hold getHold(String holdId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(Hold.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"holds/{holdId}?{parameters}",
|
|
||||||
holdId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getHold(String, String)}
|
|
||||||
*/
|
|
||||||
public Hold getHold(String holdId)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getHold(holdId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates a hold.
|
|
||||||
*
|
|
||||||
* @param holdModel The hold model which holds the information
|
|
||||||
* @param holdId The identifier of the hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>the update request is invalid or {@code holdId} is not a valid format or {@code holdModel} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to update {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public Hold updateHold(Hold holdModel, String holdId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryObject("holdModel", holdModel);
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(Hold.class, requestWithBody(
|
|
||||||
PUT,
|
|
||||||
toJson(holdModel),
|
|
||||||
"holds/{holdId}?{parameters}",
|
|
||||||
holdId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #updateHold(Hold, String, String)}
|
|
||||||
*/
|
|
||||||
public Hold updateHold(Hold holdModel, String holdId)
|
|
||||||
{
|
|
||||||
mandatoryObject("holdModel", holdModel);
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return updateHold(holdModel, holdId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} is not a valid format</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to delete {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public void deleteHold(String holdId)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
getRmRestWrapper().processEmptyModel(simpleRequest(
|
|
||||||
DELETE,
|
|
||||||
"holds/{holdId}",
|
|
||||||
holdId
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a hold and stores a reason for deletion in the audit log.
|
|
||||||
*
|
|
||||||
* @param reason The reason for hold deletion
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} is not a valid format or {@code reason} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to delete {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public HoldDeletionReason deleteHoldWithReason(HoldDeletionReason reason, String holdId)
|
|
||||||
{
|
|
||||||
mandatoryObject("reason", reason);
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(HoldDeletionReason.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(reason),
|
|
||||||
"holds/{holdId}/delete",
|
|
||||||
holdId
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the relationship between a child and a parent hold.
|
|
||||||
*
|
|
||||||
* @param holdChild The hold child model
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The created {@link Hold}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} is not a valid format or {@code holdId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to add children to {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public HoldChild addChildToHold(HoldChild holdChild, String holdId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryObject("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(HoldChild.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(holdChild),
|
|
||||||
"holds/{holdId}/children",
|
|
||||||
holdId,
|
|
||||||
parameters));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #addChildToHold(HoldChild, String, String)}
|
|
||||||
*/
|
|
||||||
public HoldChild addChildToHold(HoldChild holdChild, String holdId)
|
|
||||||
{
|
|
||||||
return addChildToHold(holdChild, holdId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the children of a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link HoldChildCollection} for the given {@code holdId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to read {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
*</ul>
|
|
||||||
*/
|
|
||||||
public HoldChildCollection getChildren(String holdId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModels(HoldChildCollection.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"holds/{holdId}/children",
|
|
||||||
holdId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getChildren(String, String)}
|
|
||||||
*/
|
|
||||||
public HoldChildCollection getChildren(String holdId)
|
|
||||||
{
|
|
||||||
return getChildren(holdId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the relationship between a child and a parent hold.
|
|
||||||
*
|
|
||||||
* @param holdChildId The identifier of hold child
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} or {@code holdChildId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to delete children from {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public void deleteHoldChild(String holdId, String holdChildId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
mandatoryString("holdChildId", holdChildId);
|
|
||||||
|
|
||||||
getRmRestWrapper().processEmptyModel(simpleRequest(
|
|
||||||
DELETE,
|
|
||||||
"holds/{holdId}/children/{holdChildId}",
|
|
||||||
holdId,
|
|
||||||
holdChildId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #deleteHoldChild(String, String, String)}
|
|
||||||
*/
|
|
||||||
public void deleteHoldChild(String holdId, String holdChildId)
|
|
||||||
{
|
|
||||||
deleteHoldChild(holdId, holdChildId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a bulk process for a hold.
|
|
||||||
*
|
|
||||||
* @param holdBulkOperation The bulk operation details
|
|
||||||
* @param hold The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link HoldBulkOperationEntry} for the started bulk process
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code hold} or {@code holdBulkOperation} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to start a bulk process for {@code hold}</li>
|
|
||||||
* <li>{@code hold} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public HoldBulkOperationEntry startBulkProcess(HoldBulkOperation holdBulkOperation, String hold, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryObject("holdBulkOperation", holdBulkOperation);
|
|
||||||
mandatoryString("hold", hold);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(HoldBulkOperationEntry.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(holdBulkOperation),
|
|
||||||
"holds/{hold}/bulk",
|
|
||||||
hold,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #startBulkProcess(HoldBulkOperation, String, String)}
|
|
||||||
*/
|
|
||||||
public HoldBulkOperationEntry startBulkProcess(HoldBulkOperation holdBulkOperation, String hold)
|
|
||||||
{
|
|
||||||
return startBulkProcess(holdBulkOperation, hold, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the status of a bulk process for a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param holdBulkStatusId The identifier of a bulk status operation
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link HoldBulkStatus} for the given {@code holdId} and {@code holdBulkStatusId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} or {@code holdBulkStatusId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to get the bulk status for {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} or {@code holdBulkStatusId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public HoldBulkStatus getBulkStatus(String holdId, String holdBulkStatusId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
mandatoryString("holdBulkStatusId", holdBulkStatusId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(HoldBulkStatus.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"holds/{holdId}/bulk-statuses/{holdBulkStatusId}",
|
|
||||||
holdId,
|
|
||||||
holdBulkStatusId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getBulkStatus(String, String, String)}
|
|
||||||
*/
|
|
||||||
public HoldBulkStatus getBulkStatus(String holdId, String holdBulkStatusId)
|
|
||||||
{
|
|
||||||
return getBulkStatus(holdId, holdBulkStatusId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the statuses of all bulk processes for a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link HoldBulkStatusCollection} for the given {@code holdId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to get the bulk statuses for {@code holdId}</li>
|
|
||||||
* <li>{@code holdId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public HoldBulkStatusCollection getBulkStatuses(String holdId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModels(HoldBulkStatusCollection.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"holds/{holdId}/bulk-statuses",
|
|
||||||
holdId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getBulkStatuses(String, String)}
|
|
||||||
*/
|
|
||||||
public HoldBulkStatusCollection getBulkStatuses(String holdId)
|
|
||||||
{
|
|
||||||
return getBulkStatuses(holdId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels a bulk operation for a hold.
|
|
||||||
*
|
|
||||||
* @param holdId The identifier of a hold
|
|
||||||
* @param bulkStatusId The identifier of a bulk status operation
|
|
||||||
* @param bulkBodyCancel The bulk body cancel model
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code holdId}, {@code bulkStatusId} or {@code bulkBodyCancel} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to cancel the bulk operation for {@code bulkStatusId}</li>
|
|
||||||
* <li>{@code holdId} or {@code bulkStatusId} does not exist</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public void cancelBulkOperation(String holdId, String bulkStatusId, BulkBodyCancel bulkBodyCancel, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
mandatoryString("bulkStatusId", bulkStatusId);
|
|
||||||
mandatoryObject("bulkBodyCancel", bulkBodyCancel);
|
|
||||||
|
|
||||||
getRmRestWrapper().processEmptyModel(requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(bulkBodyCancel),
|
|
||||||
"holds/{holdId}/bulk-statuses/{bulkStatusId}/cancel",
|
|
||||||
holdId,
|
|
||||||
bulkStatusId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #cancelBulkOperation(String, String, BulkBodyCancel, String)}
|
|
||||||
*/
|
|
||||||
public void cancelBulkOperation(String holdId, String bulkStatusId, BulkBodyCancel bulkBodyCancel)
|
|
||||||
{
|
|
||||||
mandatoryString("holdId", holdId);
|
|
||||||
mandatoryString("bulkStatusId", bulkStatusId);
|
|
||||||
mandatoryObject("bulkBodyCancel", bulkBodyCancel);
|
|
||||||
|
|
||||||
cancelBulkOperation(holdId, bulkStatusId, bulkBodyCancel, EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.requests.gscore.api;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.RMRestWrapper;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionSchedule;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleActionDefinition;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleStepCollection;
|
|
||||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
|
||||||
import static org.alfresco.rest.core.RestRequest.simpleRequest;
|
|
||||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject;
|
|
||||||
import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString;
|
|
||||||
import static org.alfresco.rest.rm.community.util.PojoUtility.toJson;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.EMPTY;
|
|
||||||
import static org.springframework.http.HttpMethod.GET;
|
|
||||||
import static org.springframework.http.HttpMethod.POST;
|
|
||||||
|
|
||||||
public class RetentionScheduleAPI extends RMModelRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rmRestWrapper
|
|
||||||
*/
|
|
||||||
public RetentionScheduleAPI(RMRestWrapper rmRestWrapper)
|
|
||||||
{
|
|
||||||
super(rmRestWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a retention schedule.
|
|
||||||
*
|
|
||||||
* @param retentionScheduleModel The retentionSchedule model
|
|
||||||
* @param recordCategoryId The identifier of a record category
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The created {@link RetentionSchedule}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code recordCategoryId} is not a valid format or {@code recordCategoryId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to add children to {@code recordCategoryId}</li>
|
|
||||||
* <li>{@code recordCategoryId} does not exist</li>
|
|
||||||
* <li>new name clashes with an existing node in the current parent container</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public RetentionSchedule createRetentionSchedule(RetentionSchedule retentionScheduleModel, String recordCategoryId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("recordCategoryId", recordCategoryId);
|
|
||||||
mandatoryObject("retentionScheduleModel", retentionScheduleModel);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(RetentionSchedule.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(retentionScheduleModel),
|
|
||||||
"record-categories/{recordCategoryId}/retention-schedules",
|
|
||||||
recordCategoryId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #createRetentionSchedule(RetentionSchedule, String, String)}
|
|
||||||
*/
|
|
||||||
public RetentionSchedule createRetentionSchedule(RetentionSchedule retentionScheduleModel, String recordCategoryId)
|
|
||||||
{
|
|
||||||
return createRetentionSchedule(retentionScheduleModel, recordCategoryId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the retentionSchedule of a record category.
|
|
||||||
*
|
|
||||||
* @param recordCategoryId The identifier of a record category
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link RetentionSchedule} for the given {@code recordCategoryId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to read {@code recordCategoryId}</li>
|
|
||||||
* <li>{@code recordCategoryId} does not exist</li>
|
|
||||||
*</ul>
|
|
||||||
*/
|
|
||||||
public RetentionScheduleCollection getRetentionSchedule(String recordCategoryId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("recordCategoryId", recordCategoryId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModels(RetentionScheduleCollection.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"record-categories/{recordCategoryId}/retention-schedules?{parameters}",
|
|
||||||
recordCategoryId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getRetentionSchedule(String, String)}
|
|
||||||
*/
|
|
||||||
public RetentionScheduleCollection getRetentionSchedule(String recordCategoryId)
|
|
||||||
{
|
|
||||||
return getRetentionSchedule(recordCategoryId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a step in the retention schedule.
|
|
||||||
*
|
|
||||||
* @param retentionScheduleActionDefinition The retentionScheduleActionDefinition model
|
|
||||||
* @param retentionScheduleId The identifier of a retention schedule id
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The created {@link RetentionScheduleActionDefinition}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code retentionScheduleId} is not a valid format or {@code retentionScheduleId} is invalid</li>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to add children to {@code retentionScheduleId}</li>
|
|
||||||
* <li>{@code retentionScheduleId} does not exist</li>
|
|
||||||
* <li>new name clashes with an existing node in the current parent container</li>
|
|
||||||
* </ul>
|
|
||||||
*/
|
|
||||||
public RetentionScheduleActionDefinition createRetentionScheduleStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition, String retentionScheduleId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("retentionScheduleId", retentionScheduleId);
|
|
||||||
mandatoryObject("retentionScheduleActionDefinition", retentionScheduleActionDefinition);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModel(RetentionScheduleActionDefinition.class, requestWithBody(
|
|
||||||
POST,
|
|
||||||
toJson(retentionScheduleActionDefinition),
|
|
||||||
"retention-schedules/{retentionScheduleId}/retention-steps",
|
|
||||||
retentionScheduleId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #createRetentionScheduleStep(RetentionScheduleActionDefinition, String)} (RetentionSchedule, String, String)}
|
|
||||||
*/
|
|
||||||
public RetentionScheduleActionDefinition createRetentionScheduleStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition, String retentionScheduleId)
|
|
||||||
{
|
|
||||||
return createRetentionScheduleStep(retentionScheduleActionDefinition, retentionScheduleId, EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the retentionSchedule of a record category.
|
|
||||||
*
|
|
||||||
* @param retentionScheduleId The identifier of a record category
|
|
||||||
* @param parameters The URL parameters to add
|
|
||||||
* @return The {@link RetentionScheduleActionDefinition} for the given {@code recordCategoryId}
|
|
||||||
* @throws RuntimeException for the following cases:
|
|
||||||
* <ul>
|
|
||||||
* <li>authentication fails</li>
|
|
||||||
* <li>current user does not have permission to read {@code recordCategoryId}</li>
|
|
||||||
* <li>{@code recordCategoryId} does not exist</li>
|
|
||||||
*</ul>
|
|
||||||
*/
|
|
||||||
public RetentionScheduleStepCollection getRetentionScheduleStep(String retentionScheduleId, String parameters)
|
|
||||||
{
|
|
||||||
mandatoryString("retentionScheduleId", retentionScheduleId);
|
|
||||||
|
|
||||||
return getRmRestWrapper().processModels(RetentionScheduleStepCollection.class, simpleRequest(
|
|
||||||
GET,
|
|
||||||
"retention-schedules/{retentionScheduleId}/retention-steps?{parameters}",
|
|
||||||
retentionScheduleId,
|
|
||||||
parameters
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* See {@link #getRetentionScheduleStep(String, String)}
|
|
||||||
*/
|
|
||||||
public RetentionScheduleStepCollection getRetentionScheduleStep(String recordCategoryId)
|
|
||||||
{
|
|
||||||
return getRetentionScheduleStep(recordCategoryId, EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.v0;
|
package org.alfresco.rest.v0;
|
||||||
|
|
||||||
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
import org.alfresco.rest.core.v0.BaseAPI;
|
||||||
@@ -36,9 +38,7 @@ import org.json.JSONObject;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
|
||||||
import static org.testng.AssertJUnit.assertNotNull;
|
|
||||||
/**
|
/**
|
||||||
* Methods to make API requests using v0 API on Records Management Custom Model Reference Definitions
|
* Methods to make API requests using v0 API on Records Management Custom Model Reference Definitions
|
||||||
*
|
*
|
||||||
@@ -57,8 +57,6 @@ public class CustomDefinitionsAPI extends BaseAPI
|
|||||||
* create reference endpoint
|
* create reference endpoint
|
||||||
*/
|
*/
|
||||||
private static final String CREATE_RELATIONSHIP_API_ENDPOINT = "{0}node/{1}/customreferences";
|
private static final String CREATE_RELATIONSHIP_API_ENDPOINT = "{0}node/{1}/customreferences";
|
||||||
private static final String GET_RELATIONSHIP_API_ENDPOINT = "{0}node/{1}/relationships";
|
|
||||||
private static final String DELETE_RELATIONSHIP_API_ENDPOINT = "{0}node/{1}/targetnode/{2}/uniqueName/{3}";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logger
|
* logger
|
||||||
@@ -143,48 +141,4 @@ public class CustomDefinitionsAPI extends BaseAPI
|
|||||||
assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
|
assertTrue("Creating relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createRelationship(
|
|
||||||
String adminUser,
|
|
||||||
String adminPassword,
|
|
||||||
int expectedStatus,
|
|
||||||
String recordNodeIdFrom,
|
|
||||||
String recordNodeIdTo,
|
|
||||||
CustomDefinitions relationshipType) {
|
|
||||||
//create the request body
|
|
||||||
JSONObject requestParams = new JSONObject();
|
|
||||||
requestParams.put("toNode", NODE_REF_WORKSPACE_SPACES_STORE + recordNodeIdTo);
|
|
||||||
requestParams.put("refId", getCustomReferenceId(adminUser, adminPassword, relationshipType
|
|
||||||
.getDefinition()));
|
|
||||||
//send the API request to create the relationship
|
|
||||||
JSONObject setRelationshipStatus = doPostRequest(adminUser, adminPassword, requestParams,
|
|
||||||
MessageFormat.format(CREATE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom));
|
|
||||||
//check the response
|
|
||||||
assertEquals("POST request for createRelationship was not successful.", expectedStatus, setRelationshipStatus.getJSONObject("status").get("code"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject getRelationshipDetails(
|
|
||||||
String adminUser,
|
|
||||||
String adminPassword,
|
|
||||||
String nodeRef) {
|
|
||||||
//send the API request to create the relationship
|
|
||||||
JSONObject relationshipDetails = doGetRequest(adminUser, adminPassword,
|
|
||||||
MessageFormat.format(GET_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + nodeRef));
|
|
||||||
//check the response
|
|
||||||
assertNotNull("The Relationship detail is not found for the Noderef " + nodeRef, relationshipDetails);
|
|
||||||
return relationshipDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteRelationship(
|
|
||||||
String adminUser,
|
|
||||||
String adminPassword,
|
|
||||||
String recordNodeIdFrom,
|
|
||||||
String recordNodeIdTo,
|
|
||||||
String relationshipUniqueName) {
|
|
||||||
//send the API request to create the relationship
|
|
||||||
JSONObject setRelationshipStatus = doDeleteRequest(adminUser, adminPassword,
|
|
||||||
MessageFormat.format(DELETE_RELATIONSHIP_API_ENDPOINT, "{0}", NODE_PREFIX + recordNodeIdFrom,NODE_PREFIX + recordNodeIdTo,relationshipUniqueName));
|
|
||||||
//check the response
|
|
||||||
boolean success = (setRelationshipStatus != null) && setRelationshipStatus.getBoolean("success");
|
|
||||||
assertTrue("Deleting relationship from " + recordNodeIdFrom + " to " + recordNodeIdTo + " failed.", success);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.alfresco.rest.core.v0.APIUtils;
|
import org.alfresco.rest.core.v0.APIUtils;
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
import org.alfresco.rest.core.v0.BaseAPI;
|
||||||
import org.alfresco.rest.rm.community.model.hold.v0.HoldEntry;
|
import org.alfresco.rest.rm.community.model.hold.HoldEntry;
|
||||||
import org.alfresco.rest.rm.community.util.PojoUtility;
|
import org.alfresco.rest.rm.community.util.PojoUtility;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.v0;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Methods to make API requests using v0 API for Linking Records
|
|
||||||
*
|
|
||||||
* @author Kavit Shah
|
|
||||||
* @since 3.2
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class LinksAPI extends BaseAPI {
|
|
||||||
|
|
||||||
private static final String LINK_API = "{0}doclib/action/rm-link/site/rm/documentLibrary/{1}";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the Link
|
|
||||||
*
|
|
||||||
* @param user The username of the user to use.
|
|
||||||
* @param password The password of the user.
|
|
||||||
* @param expectedStatusCode The expected return status code.
|
|
||||||
* @param sourcePath The Source of link the record. This should be in the format
|
|
||||||
* "{site}/{container}/{path}", "{site}/{container}", "{store_type}/{store_id}/{id}/{path}",
|
|
||||||
* "{store_type}/{store_id}/{id}" or "{store_type}/{store_id}".
|
|
||||||
* @param nodeRefs The Node that needs to be linked.
|
|
||||||
* @return The HTTP Response.
|
|
||||||
* @throws AssertionError If the API didn't return the expected status code.
|
|
||||||
*/
|
|
||||||
public HttpResponse linkRecord(String user, String password, int expectedStatusCode, String sourcePath, List<String> nodeRefs) throws UnsupportedEncodingException {
|
|
||||||
JSONObject requestParams = new JSONObject();
|
|
||||||
requestParams.put("nodeRefs", new JSONArray(nodeRefs));
|
|
||||||
|
|
||||||
return doSlingshotPostJsonRequest(user, password, expectedStatusCode, requestParams,
|
|
||||||
MessageFormat.format(LINK_API, "{0}", sourcePath));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -38,7 +38,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The v0 REST API for nodes
|
* The v0 REST API for nodes
|
||||||
*
|
*
|
||||||
* @author jcule
|
* @author jcule
|
||||||
* @since 2.7EA1
|
* @since 2.7EA1
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +56,7 @@ public class NodeAPI extends BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the node metadata using the using the node data webscript: Document List v2 Component
|
* Get the node metadata using the using the node data webscript: Document List v2 Component
|
||||||
*
|
*
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @param nodeId
|
* @param nodeId
|
||||||
@@ -70,5 +70,5 @@ public class NodeAPI extends BaseAPI
|
|||||||
client.close();
|
client.close();
|
||||||
return doGetRequest(username, password, requestURL);
|
return doGetRequest(username, password, requestURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.v0;
|
package org.alfresco.rest.v0;
|
||||||
|
|
||||||
import static org.apache.http.HttpStatus.SC_OK;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@@ -37,7 +36,6 @@ import java.util.List;
|
|||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
import org.alfresco.rest.core.v0.BaseAPI;
|
||||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
||||||
import org.alfresco.rest.rm.community.util.PojoUtility;
|
import org.alfresco.rest.rm.community.util.PojoUtility;
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -60,8 +58,6 @@ public class RMAuditAPI extends BaseAPI
|
|||||||
private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog";
|
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_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 .
|
* Returns a list of rm audit entries .
|
||||||
*
|
*
|
||||||
@@ -88,21 +84,6 @@ public class RMAuditAPI extends BaseAPI
|
|||||||
return PojoUtility.jsonToObject(auditEntries, AuditEntry.class);
|
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.
|
* Clear the list of audit entries.
|
||||||
*
|
*
|
||||||
@@ -119,19 +100,5 @@ public class RMAuditAPI extends BaseAPI
|
|||||||
&& getRMAuditLog(username, password, 100, null).size() == 2);
|
&& 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class RecordCategoriesAPI extends BaseAPI
|
|||||||
private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
|
private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
|
||||||
private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions";
|
private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions";
|
||||||
private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule";
|
private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule";
|
||||||
private static final String NEXT_DISPOSITION_ACTIONS_API = "{0}node/{1}/nextdispositionaction";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a retention schedule for the category given as parameter
|
* Creates a retention schedule for the category given as parameter
|
||||||
@@ -191,19 +191,4 @@ public class RecordCategoriesAPI extends BaseAPI
|
|||||||
retentionProperties.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, instructions);
|
retentionProperties.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, instructions);
|
||||||
return retentionProperties;
|
return retentionProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Next Disposition Action
|
|
||||||
*
|
|
||||||
* @param user
|
|
||||||
* @param password
|
|
||||||
* @param recordId
|
|
||||||
* @return the next disposition schedule action
|
|
||||||
*/
|
|
||||||
public JSONObject getNextDispositionAction(String user, String password, String recordId)
|
|
||||||
{
|
|
||||||
String nodeRef = NODE_PREFIX + recordId;
|
|
||||||
JSONObject nextDispositionAction = doGetRequest(user, password, MessageFormat.format(NEXT_DISPOSITION_ACTIONS_API, "{0}", nodeRef));
|
|
||||||
return nextDispositionAction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,39 +74,4 @@ public class RecordFoldersAPI extends BaseAPI
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpResponse postFolderAction(String user, String password, JSONObject requestParams, String recordFolder) {
|
|
||||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordFolder);
|
|
||||||
try {
|
|
||||||
requestParams.put("nodeRef", recNodeRef);
|
|
||||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
|
||||||
}
|
|
||||||
catch (Exception error) {
|
|
||||||
LOGGER.error("Unable to extract response parameter", error);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpResponse postRecordAction(String user, String password, JSONObject requestParams, String recordId) {
|
|
||||||
try {
|
|
||||||
requestParams.put("nodeRef", recordId);
|
|
||||||
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
|
|
||||||
}
|
|
||||||
catch (JSONException error) {
|
|
||||||
LOGGER.error("Unable to extract response parameter", error);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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,25 +360,4 @@ public class RecordsAPI extends BaseAPI
|
|||||||
{
|
{
|
||||||
return getNodeRefSpacesStore() + getItemNodeRef(username, password, recordPath + "/" + recordName);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class SearchAPI extends BaseAPI
|
|||||||
/**
|
/**
|
||||||
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
|
* Search as a user for nodes on site "rm" matching query, using SearchAPI.RM_DEFAULT_RECORD_FILTERS and sorted
|
||||||
* by sortby and returns the property value for the given nodeRef and property name
|
* by sortby and returns the property value for the given nodeRef and property name
|
||||||
*
|
*
|
||||||
* @param username
|
* @param username
|
||||||
* @param password
|
* @param password
|
||||||
* @param query
|
* @param query
|
||||||
@@ -157,9 +157,9 @@ public class SearchAPI extends BaseAPI
|
|||||||
{
|
{
|
||||||
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
|
String searchFilterParamaters = MessageFormat.format(RM_DEFAULT_NODES_FILTERS, Boolean.toString(includeFolders),
|
||||||
Boolean.toString(includeCategories));
|
Boolean.toString(includeCategories));
|
||||||
return getItemProperty(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby), nodeRef, propertyName);
|
return getItemProperty(rmSearch(username, password, "rm", query, searchFilterParamaters, sortby), nodeRef, propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic faceted search.
|
* Generic faceted search.
|
||||||
* @param username
|
* @param username
|
||||||
@@ -229,17 +229,17 @@ public class SearchAPI extends BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract list of names from search result.
|
* Helper method to extract list of names from search result.
|
||||||
*
|
*
|
||||||
* @param searchResult
|
* @param searchResult
|
||||||
* @return list of document or record names in search result
|
* @return list of document or record names in search result
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
* @throws JsonSyntaxException
|
* @throws JsonSyntaxException
|
||||||
* @throws JsonIOException
|
* @throws JsonIOException
|
||||||
* @throws RuntimeException for malformed search response
|
* @throws RuntimeException for malformed search response
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Helper method to extract list of names from search result.
|
* Helper method to extract list of names from search result.
|
||||||
*
|
*
|
||||||
* @param searchResult
|
* @param searchResult
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -247,10 +247,10 @@ public class SearchAPI extends BaseAPI
|
|||||||
{
|
{
|
||||||
return getPropertyValues(searchResult, "name");
|
return getPropertyValues(searchResult, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to extract list of property values from search result for the given nodeRef.
|
* Helper method to extract list of property values from search result for the given nodeRef.
|
||||||
*
|
*
|
||||||
* @param searchResult
|
* @param searchResult
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
* @param propertyName
|
* @param propertyName
|
||||||
|
|||||||
@@ -31,18 +31,18 @@ import static java.util.Arrays.asList;
|
|||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD;
|
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.ADD_TO_HOLD;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH;
|
||||||
import static org.alfresco.utility.Utility.buildPath;
|
import static org.alfresco.utility.Utility.buildPath;
|
||||||
import static org.alfresco.utility.Utility.removeLastSlash;
|
import static org.alfresco.utility.Utility.removeLastSlash;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -50,13 +50,12 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
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.AuditEntry;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
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.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
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.RMAuditService;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
@@ -86,6 +85,8 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RMAuditService rmAuditService;
|
private RMAuditService rmAuditService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private HoldsAPI holdsAPI;
|
||||||
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
private UserModel rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode;
|
private UserModel rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode;
|
||||||
@@ -93,22 +94,17 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
private RecordCategory recordCategory;
|
private RecordCategory recordCategory;
|
||||||
private RecordCategoryChild recordFolder;
|
private RecordCategoryChild recordFolder;
|
||||||
private List<AuditEntry> auditEntries;
|
private List<AuditEntry> auditEntries;
|
||||||
|
private final List<String> holdsList = asList(HOLD1, HOLD2);
|
||||||
private List<String> holdsListRef = new ArrayList<>();
|
private List<String> holdsListRef = new ArrayList<>();
|
||||||
private String hold1NodeRef;
|
private String hold1NodeRef;
|
||||||
private String hold2NodeRef;
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
@BeforeClass (alwaysRun = true)
|
||||||
public void preconditionForAuditAddToHoldTests()
|
public void preconditionForAuditAddToHoldTests()
|
||||||
{
|
{
|
||||||
STEP("Create 2 holds.");
|
STEP("Create 2 holds.");
|
||||||
hold1NodeRef = getRestAPIFactory()
|
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(),
|
||||||
.getFilePlansAPI(rmAdmin)
|
getAdminUser().getPassword(), HOLD1, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(HOLD1).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.getId();
|
|
||||||
hold2NodeRef = getRestAPIFactory()
|
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(HOLD2).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
holdsListRef = asList(hold1NodeRef, hold2NodeRef);
|
holdsListRef = asList(hold1NodeRef, hold2NodeRef);
|
||||||
|
|
||||||
STEP("Create a new record category with a record folder.");
|
STEP("Create a new record category with a record folder.");
|
||||||
@@ -173,8 +169,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Add node to hold.");
|
STEP("Add node to hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(nodeId).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD1);
|
||||||
|
|
||||||
|
|
||||||
STEP("Check the audit log contains the entry for the add to hold event.");
|
STEP("Check the audit log contains the entry for the add to hold event.");
|
||||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, nodeName, nodePath,
|
rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, nodeName, nodePath,
|
||||||
@@ -196,8 +191,9 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Try to add the record to a hold by an user with no rights.");
|
STEP("Try to add the record to a hold by an user with no rights.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmManagerNoReadOnHold).addChildToHold(HoldChild.builder().id(recordToBeAdded.getId()).build(), hold1NodeRef);
|
holdsAPI.addItemsToHolds(rmManagerNoReadOnHold.getUsername(), rmManagerNoReadOnHold.getPassword(),
|
||||||
assertStatusCode(FORBIDDEN);
|
SC_INTERNAL_SERVER_ERROR, Collections.singletonList(recordToBeAdded.getId()),
|
||||||
|
Collections.singletonList(hold1NodeRef));
|
||||||
|
|
||||||
STEP("Check the audit log doesn't contain the entry for the unsuccessful add to hold.");
|
STEP("Check the audit log doesn't contain the entry for the unsuccessful add to hold.");
|
||||||
assertTrue("The list of events should not contain Add to Hold entry ",
|
assertTrue("The list of events should not contain Add to Hold entry ",
|
||||||
@@ -219,7 +215,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Add record folder to hold.");
|
STEP("Add record folder to hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(notEmptyRecFolder.getId()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), notEmptyRecFolder.getId(), HOLD1);
|
||||||
|
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), ADD_TO_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), ADD_TO_HOLD);
|
||||||
|
|
||||||
@@ -243,9 +239,8 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Add record to multiple holds.");
|
STEP("Add record to multiple holds.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(recordToBeAdded.getId()).build(), hold1NodeRef);
|
holdsAPI.addItemsToHolds(rmAdmin.getUsername(), rmAdmin.getPassword(),
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(recordToBeAdded.getId()).build(), hold2NodeRef);
|
Collections.singletonList(recordToBeAdded.getId()), holdsList);
|
||||||
|
|
||||||
|
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), ADD_TO_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), ADD_TO_HOLD);
|
||||||
|
|
||||||
@@ -273,7 +268,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Add file to hold.");
|
STEP("Add file to hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(contentToBeAdded.getNodeRefWithoutVersion()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), contentToBeAdded.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
STEP("Check that an user with no Read permissions can't see the entry for the add to hold event.");
|
STEP("Check that an user with no Read permissions can't see the entry for the add to hold event.");
|
||||||
assertTrue("The list of events should not contain Add to Hold entry ",
|
assertTrue("The list of events should not contain Add to Hold entry ",
|
||||||
@@ -294,7 +289,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Add file to hold.");
|
STEP("Add file to hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(contentToBeAdded.getNodeRefWithoutVersion()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), contentToBeAdded.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(rmManagerNoReadOnHold, ADD_TO_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(rmManagerNoReadOnHold, ADD_TO_HOLD);
|
||||||
|
|
||||||
@@ -309,8 +304,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
|
|||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void cleanUpAuditAddToHoldTests()
|
public void cleanUpAuditAddToHoldTests()
|
||||||
{
|
{
|
||||||
holdsListRef.forEach(holdRef -> getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(holdRef));
|
holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef));
|
||||||
|
|
||||||
dataSite.usingAdmin().deleteSite(privateSite);
|
dataSite.usingAdmin().deleteSite(privateSite);
|
||||||
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
||||||
deleteRecordCategory(recordCategory.getId());
|
deleteRecordCategory(recordCategory.getId());
|
||||||
|
|||||||
@@ -31,10 +31,9 @@ import static java.util.Arrays.asList;
|
|||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.CREATE_HOLD;
|
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.CREATE_HOLD;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
@@ -45,8 +44,8 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
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.AuditEntry;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
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.RMAuditService;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
@@ -74,6 +73,8 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RMAuditService rmAuditService;
|
private RMAuditService rmAuditService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private HoldsAPI holdsAPI;
|
||||||
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
private UserModel rmAdmin, rmManager;
|
private UserModel rmAdmin, rmManager;
|
||||||
@@ -101,10 +102,8 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
String hold1NodeRef = getRestAPIFactory()
|
String hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1,
|
||||||
.getFilePlansAPI(rmAdmin)
|
HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(HOLD1).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
holdsListRef.add(hold1NodeRef);
|
holdsListRef.add(hold1NodeRef);
|
||||||
STEP("Check the audit log contains the entry for the created hold with the hold details.");
|
STEP("Check the audit log contains the entry for the created hold with the hold details.");
|
||||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), CREATE_HOLD, rmAdmin, HOLD1,
|
rmAuditService.checkAuditLogForEvent(getAdminUser(), CREATE_HOLD, rmAdmin, HOLD1,
|
||||||
@@ -121,18 +120,13 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
public void createHoldEventIsNotAuditedForExistingHold()
|
public void createHoldEventIsNotAuditedForExistingHold()
|
||||||
{
|
{
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
String hold2NodeRef = getRestAPIFactory()
|
String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(HOLD2).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
holdsListRef.add(hold2NodeRef);
|
holdsListRef.add(hold2NodeRef);
|
||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Try to create again the same hold and expect action to fail.");
|
STEP("Try to create again the same hold and expect action to fail.");
|
||||||
getRestAPIFactory()
|
holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION,
|
||||||
.getFilePlansAPI(rmAdmin)
|
SC_INTERNAL_SERVER_ERROR);
|
||||||
.createHold(Hold.builder().name(HOLD2).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
assertStatusCode(CONFLICT);
|
|
||||||
|
|
||||||
STEP("Check the audit log doesn't contain the entry for the second create hold event.");
|
STEP("Check the audit log doesn't contain the entry for the second create hold event.");
|
||||||
assertTrue("The list of events should not contain Create Hold entry ",
|
assertTrue("The list of events should not contain Create Hold entry ",
|
||||||
@@ -151,17 +145,13 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
String nodeRef = getRestAPIFactory()
|
holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), holdName, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(holdName).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS).getId();
|
|
||||||
|
|
||||||
STEP("Get the list of audit entries for the create hold event.");
|
STEP("Get the list of audit entries for the create hold event.");
|
||||||
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), CREATE_HOLD);
|
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), CREATE_HOLD);
|
||||||
|
|
||||||
STEP("Delete the created hold.");
|
STEP("Delete the created hold.");
|
||||||
getRestAPIFactory()
|
holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), holdName);
|
||||||
.getHoldsAPI(rmAdmin)
|
|
||||||
.deleteHold(nodeRef);
|
|
||||||
|
|
||||||
STEP("Get again the list of audit entries for the create hold event.");
|
STEP("Get again the list of audit entries for the create hold event.");
|
||||||
List<AuditEntry> auditEntriesAfterDelete = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), CREATE_HOLD);
|
List<AuditEntry> auditEntriesAfterDelete = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), CREATE_HOLD);
|
||||||
@@ -181,10 +171,8 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
String hold3NodeRef = getRestAPIFactory()
|
String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD3,
|
||||||
.getFilePlansAPI(rmAdmin)
|
HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(HOLD3).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS).getId();
|
|
||||||
|
|
||||||
holdsListRef.add(hold3NodeRef);
|
holdsListRef.add(hold3NodeRef);
|
||||||
|
|
||||||
STEP("Check that an user with no Read permissions over the hold can't see the entry for the create hold event");
|
STEP("Check that an user with no Read permissions over the hold can't see the entry for the create hold event");
|
||||||
@@ -195,7 +183,7 @@ public class AuditCreateHoldTests extends BaseRMRestTest
|
|||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void cleanUpAuditCreateHoldTests()
|
public void cleanUpAuditCreateHoldTests()
|
||||||
{
|
{
|
||||||
holdsListRef.forEach(holdRef -> getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHold(holdRef));
|
holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef));
|
||||||
asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,20 +31,18 @@ import static java.util.Arrays.asList;
|
|||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.DELETE_HOLD;
|
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.DELETE_HOLD;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Collections;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldDeletionReason;
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
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.RMAuditService;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
@@ -64,13 +62,14 @@ import org.testng.annotations.Test;
|
|||||||
public class AuditDeleteHoldTests extends BaseRMRestTest
|
public class AuditDeleteHoldTests extends BaseRMRestTest
|
||||||
{
|
{
|
||||||
private final String PREFIX = generateTestPrefix(AuditDeleteHoldTests.class);
|
private final String PREFIX = generateTestPrefix(AuditDeleteHoldTests.class);
|
||||||
private final String hold = PREFIX + "holdToBeDeleted";
|
private final String HOLD = PREFIX + "holdToBeDeleted";
|
||||||
private final String hold2 = PREFIX + "deleteHold";
|
private final String HOLD2 = PREFIX + "deleteHold";
|
||||||
private final String hold3 = PREFIX + "deleteHoldWithReason";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RMAuditService rmAuditService;
|
private RMAuditService rmAuditService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private HoldsAPI holdsAPI;
|
||||||
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
private UserModel rmAdmin, rmManager;
|
private UserModel rmAdmin, rmManager;
|
||||||
@@ -80,10 +79,8 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
|||||||
public void preconditionForAuditDeleteHoldTests()
|
public void preconditionForAuditDeleteHoldTests()
|
||||||
{
|
{
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
holdNodeRef = getRestAPIFactory()
|
holdNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD,
|
||||||
.getFilePlansAPI(rmAdmin)
|
HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(hold).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
|
|
||||||
STEP("Create 2 users with different permissions for the created hold.");
|
STEP("Create 2 users with different permissions for the created hold.");
|
||||||
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
|
||||||
@@ -102,51 +99,17 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
|||||||
public void deleteHoldEventIsAudited()
|
public void deleteHoldEventIsAudited()
|
||||||
{
|
{
|
||||||
STEP("Create a new hold.");
|
STEP("Create a new hold.");
|
||||||
String holdRef = getRestAPIFactory()
|
String holdRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2,
|
||||||
.getFilePlansAPI(rmAdmin)
|
HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(hold2).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
|
|
||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Delete the created hold.");
|
STEP("Delete the created hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHold(holdRef);
|
holdsAPI.deleteHold(rmAdmin, holdRef);
|
||||||
|
|
||||||
STEP("Check the audit log contains the entry for the deleted hold with the hold details.");
|
STEP("Check the audit log contains the entry for the deleted hold with the hold details.");
|
||||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, hold2,
|
rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, HOLD2,
|
||||||
List.of(ImmutableMap.of("new", "", "previous", hold2, "name", "Hold Name"),
|
Collections.singletonList(ImmutableMap.of("new", "", "previous", HOLD2, "name", "Hold Name")));
|
||||||
ImmutableMap.of("new", "", "previous", "", "name", "Hold deletion reason")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a hold is deleted with a reason
|
|
||||||
* When I view the audit log
|
|
||||||
* Then an entry has been created in the audit log which contains the following:
|
|
||||||
* name of the hold
|
|
||||||
* hold deletion reason
|
|
||||||
* user who deleted the hold
|
|
||||||
* date the delete occurred
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void deleteHoldWithReasonEventIsAudited()
|
|
||||||
{
|
|
||||||
STEP("Create a new hold.");
|
|
||||||
String holdRef = getRestAPIFactory()
|
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(hold3).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
|
|
||||||
String deletionReason = "Test reason";
|
|
||||||
|
|
||||||
rmAuditService.clearAuditLog();
|
|
||||||
|
|
||||||
STEP("Delete the created hold with a reason.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldWithReason(HoldDeletionReason.builder().reason(deletionReason).build(), holdRef);
|
|
||||||
|
|
||||||
STEP("Check the audit log contains the entry for the deleted hold with the hold details.");
|
|
||||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, hold3,
|
|
||||||
List.of(ImmutableMap.of("new", "", "previous", hold3, "name", "Hold Name"),
|
|
||||||
ImmutableMap.of("new", "", "previous", deletionReason, "name", "Hold deletion reason")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,8 +123,7 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Try to delete a hold by an user with no Read permissions over the hold.");
|
STEP("Try to delete a hold by an user with no Read permissions over the hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmManager).deleteHold(holdNodeRef);
|
holdsAPI.deleteHold(rmManager.getUsername(), rmManager.getPassword(), holdNodeRef, SC_INTERNAL_SERVER_ERROR);
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
|
|
||||||
STEP("Check the audit log doesn't contain the entry for the unsuccessful delete hold.");
|
STEP("Check the audit log doesn't contain the entry for the unsuccessful delete hold.");
|
||||||
assertTrue("The list of events should not contain Delete Hold entry ",
|
assertTrue("The list of events should not contain Delete Hold entry ",
|
||||||
@@ -171,7 +133,7 @@ public class AuditDeleteHoldTests extends BaseRMRestTest
|
|||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void cleanUpAuditDeleteHoldTests()
|
public void cleanUpAuditDeleteHoldTests()
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getHoldsAPI(rmManager).deleteHold(holdNodeRef);
|
holdsAPI.deleteHold(getAdminUser(), holdNodeRef);
|
||||||
asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
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.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
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.assertFalse;
|
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
|
||||||
|
|
||||||
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.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
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.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 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 = getRestAPIFactory()
|
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(HOLD1).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
|
|
||||||
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());
|
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(recordToBeAdded.getId()).build(), hold1NodeRef);
|
|
||||||
for(String childId : itemsList)
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold1NodeRef, childId);
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -73,7 +73,7 @@ public class AuditLoginEventsTests extends BaseRMRestTest
|
|||||||
assertTrue("The list of events is not filtered by " + LOGIN_UNSUCCESSFUL.event,
|
assertTrue("The list of events is not filtered by " + LOGIN_UNSUCCESSFUL.event,
|
||||||
auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_UNSUCCESSFUL.eventDisplayName)));
|
auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(LOGIN_UNSUCCESSFUL.eventDisplayName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given I have tried to login using valid credentials
|
* Given I have tried to login using valid credentials
|
||||||
* When I view the RM audit filtered by Login successful event
|
* When I view the RM audit filtered by Login successful event
|
||||||
|
|||||||
@@ -31,18 +31,18 @@ import static java.util.Arrays.asList;
|
|||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD;
|
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.REMOVE_FROM_HOLD;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.FILE_PLAN_PATH;
|
||||||
import static org.alfresco.utility.Utility.buildPath;
|
import static org.alfresco.utility.Utility.buildPath;
|
||||||
import static org.alfresco.utility.Utility.removeLastSlash;
|
import static org.alfresco.utility.Utility.removeLastSlash;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -50,13 +50,12 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
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.AuditEntry;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
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.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
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.RMAuditService;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
@@ -87,6 +86,8 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RMAuditService rmAuditService;
|
private RMAuditService rmAuditService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private HoldsAPI holdsAPI;
|
||||||
|
@Autowired
|
||||||
private RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
private UserModel rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode;
|
private UserModel rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode;
|
||||||
@@ -95,11 +96,10 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
private RecordCategoryChild recordFolder, heldRecordFolder;
|
private RecordCategoryChild recordFolder, heldRecordFolder;
|
||||||
private Record heldRecord;
|
private Record heldRecord;
|
||||||
private List<AuditEntry> auditEntries;
|
private List<AuditEntry> auditEntries;
|
||||||
|
private final List<String> holdsList = asList(HOLD1, HOLD2, HOLD3);
|
||||||
private List<String> holdsListRef = new ArrayList<>();
|
private List<String> holdsListRef = new ArrayList<>();
|
||||||
private FileModel heldContent;
|
private FileModel heldContent;
|
||||||
private String hold1NodeRef;
|
private String hold1NodeRef;
|
||||||
private String hold2NodeRef;
|
|
||||||
private String hold3NodeRef;
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
@BeforeClass (alwaysRun = true)
|
||||||
public void preconditionForAuditRemoveFromHoldTests()
|
public void preconditionForAuditRemoveFromHoldTests()
|
||||||
@@ -111,18 +111,10 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
privateSite = dataSite.usingUser(rmAdmin).createPrivateRandomSite();
|
privateSite = dataSite.usingUser(rmAdmin).createPrivateRandomSite();
|
||||||
|
|
||||||
STEP("Create new holds.");
|
STEP("Create new holds.");
|
||||||
hold1NodeRef = getRestAPIFactory()
|
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
||||||
.getFilePlansAPI(rmAdmin)
|
HOLD1, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.createHold(Hold.builder().name(HOLD1).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
.getId();
|
String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION);
|
||||||
hold2NodeRef = getRestAPIFactory()
|
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(HOLD2).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
hold3NodeRef = getRestAPIFactory()
|
|
||||||
.getFilePlansAPI(rmAdmin)
|
|
||||||
.createHold(Hold.builder().name(HOLD3).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), FILE_PLAN_ALIAS)
|
|
||||||
.getId();
|
|
||||||
holdsListRef = asList(hold1NodeRef, hold2NodeRef, hold3NodeRef);
|
holdsListRef = asList(hold1NodeRef, hold2NodeRef, hold3NodeRef);
|
||||||
|
|
||||||
STEP("Create a new record category with a record folder.");
|
STEP("Create a new record category with a record folder.");
|
||||||
@@ -135,12 +127,9 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
heldRecordFolder = createRecordFolder(recordCategory.getId(), PREFIX + "heldRecFolder");
|
heldRecordFolder = createRecordFolder(recordCategory.getId(), PREFIX + "heldRecFolder");
|
||||||
heldRecord = createElectronicRecord(recordFolder.getId(), PREFIX + "record");
|
heldRecord = createElectronicRecord(recordFolder.getId(), PREFIX + "record");
|
||||||
|
|
||||||
holdsListRef.forEach(holdRef ->
|
holdsAPI.addItemsToHolds(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
||||||
{
|
asList(heldContent.getNodeRefWithoutVersion(), heldRecordFolder.getId(), heldRecord.getId()),
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(heldContent.getNodeRefWithoutVersion()).build(), holdRef);
|
holdsList);
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(heldRecordFolder.getId()).build(), holdRef);
|
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(heldRecord.getId()).build(), holdRef);
|
|
||||||
});
|
|
||||||
|
|
||||||
STEP("Create users without rights to remove content from a hold.");
|
STEP("Create users without rights to remove content from a hold.");
|
||||||
rmManagerNoReadOnHold = roleService.createUserWithSiteRoleRMRoleAndPermission(privateSite,
|
rmManagerNoReadOnHold = roleService.createUserWithSiteRoleRMRoleAndPermission(privateSite,
|
||||||
@@ -190,7 +179,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Remove node from hold.");
|
STEP("Remove node from hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold3NodeRef, nodeId);
|
holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD3);
|
||||||
|
|
||||||
STEP("Check the audit log contains the entry for the remove from hold event.");
|
STEP("Check the audit log contains the entry for the remove from hold event.");
|
||||||
rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, nodeName, nodePath,
|
rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, nodeName, nodePath,
|
||||||
@@ -209,8 +198,9 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Try to remove the record from a hold by an user with no rights.");
|
STEP("Try to remove the record from a hold by an user with no rights.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmManagerNoReadOnHold).deleteHoldChild(hold1NodeRef, heldRecord.getId());
|
holdsAPI.removeItemsFromHolds(rmManagerNoReadOnHold.getUsername(), rmManagerNoReadOnHold.getPassword(),
|
||||||
assertStatusCode(FORBIDDEN);
|
SC_INTERNAL_SERVER_ERROR, Collections.singletonList(heldRecord.getId()),
|
||||||
|
Collections.singletonList(hold1NodeRef));
|
||||||
|
|
||||||
STEP("Check the audit log doesn't contain the entry for the unsuccessful remove from hold.");
|
STEP("Check the audit log doesn't contain the entry for the unsuccessful remove from hold.");
|
||||||
assertTrue("The list of events should not contain remove from hold entry ",
|
assertTrue("The list of events should not contain remove from hold entry ",
|
||||||
@@ -230,12 +220,12 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
Record record = createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record");
|
Record record = createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record");
|
||||||
|
|
||||||
STEP("Add the record folder to a hold.");
|
STEP("Add the record folder to a hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(notEmptyRecFolder.getId()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), notEmptyRecFolder.getId(), HOLD1);
|
||||||
|
|
||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Remove record folder from hold.");
|
STEP("Remove record folder from hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold1NodeRef, notEmptyRecFolder.getId());
|
holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), notEmptyRecFolder.getId(), HOLD1);
|
||||||
|
|
||||||
STEP("Get the list of audit entries for the remove from hold event.");
|
STEP("Get the list of audit entries for the remove from hold event.");
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), REMOVE_FROM_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), REMOVE_FROM_HOLD);
|
||||||
@@ -257,8 +247,8 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Remove record folder from multiple holds.");
|
STEP("Remove record folder from multiple holds.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold1NodeRef, heldRecordFolder.getId());
|
holdsAPI.removeItemsFromHolds(rmAdmin.getUsername(), rmAdmin.getPassword(),
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold2NodeRef, heldRecordFolder.getId());
|
Collections.singletonList(heldRecordFolder.getId()), asList(HOLD1, HOLD2));
|
||||||
|
|
||||||
STEP("Get the list of audit entries for the remove from hold event.");
|
STEP("Get the list of audit entries for the remove from hold event.");
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), REMOVE_FROM_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), REMOVE_FROM_HOLD);
|
||||||
@@ -285,12 +275,12 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
STEP("Add content to a hold.");
|
STEP("Add content to a hold.");
|
||||||
FileModel heldFile = dataContent.usingAdmin().usingSite(privateSite)
|
FileModel heldFile = dataContent.usingAdmin().usingSite(privateSite)
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(heldFile.getNodeRefWithoutVersion()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), heldFile.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Remove held content from the hold.");
|
STEP("Remove held content from the hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold1NodeRef, heldFile.getNodeRefWithoutVersion());
|
holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), heldFile.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
STEP("Check that an user with no Read permissions can't see the entry for the remove from hold event.");
|
STEP("Check that an user with no Read permissions can't see the entry for the remove from hold event.");
|
||||||
assertTrue("The list of events should not contain Remove from Hold entry ",
|
assertTrue("The list of events should not contain Remove from Hold entry ",
|
||||||
@@ -308,12 +298,12 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
STEP("Add content to a hold.");
|
STEP("Add content to a hold.");
|
||||||
FileModel heldFile = dataContent.usingAdmin().usingSite(privateSite)
|
FileModel heldFile = dataContent.usingAdmin().usingSite(privateSite)
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).addChildToHold(HoldChild.builder().id(heldFile.getNodeRefWithoutVersion()).build(), hold1NodeRef);
|
holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), heldFile.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
rmAuditService.clearAuditLog();
|
rmAuditService.clearAuditLog();
|
||||||
|
|
||||||
STEP("Remove held content from the hold.");
|
STEP("Remove held content from the hold.");
|
||||||
getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHoldChild(hold1NodeRef, heldFile.getNodeRefWithoutVersion());
|
holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), heldFile.getNodeRefWithoutVersion(), HOLD1);
|
||||||
|
|
||||||
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(rmManagerNoReadOnHold, REMOVE_FROM_HOLD);
|
auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(rmManagerNoReadOnHold, REMOVE_FROM_HOLD);
|
||||||
|
|
||||||
@@ -328,7 +318,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
|
|||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void cleanUpAuditRemoveFromHoldTests()
|
public void cleanUpAuditRemoveFromHoldTests()
|
||||||
{
|
{
|
||||||
holdsListRef.forEach(holdRef -> getRestAPIFactory().getHoldsAPI(rmAdmin).deleteHold(holdRef));
|
holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef));
|
||||||
dataSite.usingAdmin().deleteSite(privateSite);
|
dataSite.usingAdmin().deleteSite(privateSite);
|
||||||
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
||||||
deleteRecordCategory(recordCategory.getId());
|
deleteRecordCategory(recordCategory.getId());
|
||||||
|
|||||||
@@ -1,244 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -53,12 +53,9 @@ import static org.springframework.http.HttpStatus.OK;
|
|||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -94,7 +91,6 @@ import org.alfresco.utility.model.FileModel;
|
|||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.FolderModel;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
@@ -125,8 +121,6 @@ public class BaseRMRestTest extends RestTest
|
|||||||
@Getter(value = PROTECTED)
|
@Getter(value = PROTECTED)
|
||||||
private SearchAPI searchApi;
|
private SearchAPI searchApi;
|
||||||
|
|
||||||
protected static final String iso8601_DateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts the given status code
|
* Asserts the given status code
|
||||||
*
|
*
|
||||||
@@ -167,7 +161,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass (alwaysRun = true)
|
@BeforeClass (alwaysRun = true)
|
||||||
public void checkServerHealth()
|
public void checkServerHealth() throws Exception
|
||||||
{
|
{
|
||||||
// Create RM Site if not exist
|
// Create RM Site if not exist
|
||||||
createRMSiteIfNotExists();
|
createRMSiteIfNotExists();
|
||||||
@@ -634,8 +628,8 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* Returns search results for the given search term
|
* Returns search results for the given search term
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
* @param q
|
* @param term
|
||||||
* @param queryLanguage language
|
* @param query language
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -962,34 +956,5 @@ public class BaseRMRestTest extends RestTest
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Helper method to get the Previous Date in the YYYY-MM-ddTHH:mm:ss.SSSXXX format
|
|
||||||
* @param previousDays number of previous days while calculating the date as output
|
|
||||||
* @return previousDate as String in the ISO 8601 Date Format
|
|
||||||
*/
|
|
||||||
protected String getIso8601Date(int previousDays) {
|
|
||||||
Date date = new Date(System.currentTimeMillis());
|
|
||||||
Date previousDate = new Date(date.getTime() - previousDays);
|
|
||||||
// Conversion
|
|
||||||
SimpleDateFormat sdf= new SimpleDateFormat(iso8601_DateFormat);;
|
|
||||||
sdf.setTimeZone(TimeZone.getDefault());
|
|
||||||
return sdf.format(previousDate);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Helper method to provide the Edited Disposition Date Json
|
|
||||||
* The Edited Disposition Date is modified to previous date so that CUTOFF & DESTROY Steps will be enabled
|
|
||||||
* @return JsonObject with the format {"name":"editDispositionActionAsOfDate","params":{"asOfDate":{"iso8601":"Previous Date"}}}
|
|
||||||
*/
|
|
||||||
protected JSONObject editDispositionDateJson() {
|
|
||||||
JSONObject requestParams = new JSONObject();
|
|
||||||
|
|
||||||
requestParams.put("name","editDispositionActionAsOfDate");
|
|
||||||
JSONObject params = new JSONObject();
|
|
||||||
requestParams.put("params",params);
|
|
||||||
|
|
||||||
JSONObject asOfDate = new JSONObject();
|
|
||||||
params.put("asOfDate",asOfDate);
|
|
||||||
asOfDate.put("iso8601",getIso8601Date(1));
|
|
||||||
return requestParams;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,15 +60,12 @@ import static org.testng.Assert.fail;
|
|||||||
import static org.testng.AssertJUnit.assertEquals;
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.base.DataProviderClass;
|
import org.alfresco.rest.rm.community.base.DataProviderClass;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlanProperties;
|
import org.alfresco.rest.rm.community.model.fileplan.FilePlanProperties;
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties;
|
||||||
@@ -517,97 +514,5 @@ public class FilePlanTests extends BaseRMRestTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a file plan exists
|
|
||||||
* When I ask the API to create a hold
|
|
||||||
* Then it is created
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void createHolds()
|
|
||||||
{
|
|
||||||
String holdName = "Hold" + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Description" + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
assertEquals(createdHold.getName(), holdName);
|
|
||||||
assertEquals(createdHold.getDescription(), holdDescription);
|
|
||||||
assertEquals(createdHold.getReason(), holdReason);
|
|
||||||
assertNotNull(createdHold.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void listHolds()
|
|
||||||
{
|
|
||||||
// Delete all holds
|
|
||||||
getRestAPIFactory().getFilePlansAPI().getHolds(FILE_PLAN_ALIAS).getEntries().forEach(holdEntry ->
|
|
||||||
getRestAPIFactory().getHoldsAPI().deleteHold(holdEntry.getEntry().getId()));
|
|
||||||
|
|
||||||
// Add holds
|
|
||||||
List<Hold> filePlanHolds = new ArrayList<>();
|
|
||||||
for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
|
|
||||||
{
|
|
||||||
String holdName = "Hold name " + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Hold Description " + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason " + getRandomAlphanumeric();
|
|
||||||
// Create a hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
assertNotNull(createdHold.getId());
|
|
||||||
filePlanHolds.add(createdHold);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get holds of a file plan
|
|
||||||
HoldCollection holdCollection = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.getHolds(FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// Check status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Check holds against created list
|
|
||||||
holdCollection.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
Hold hold = c.getEntry();
|
|
||||||
String holdId = hold.getId();
|
|
||||||
assertNotNull(holdId);
|
|
||||||
logger.info("Checking hold " + holdId);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Find this hold in created holds list
|
|
||||||
Hold createdHold = filePlanHolds.stream()
|
|
||||||
.filter(child -> child.getId().equals(holdId))
|
|
||||||
.findFirst()
|
|
||||||
.orElseThrow();
|
|
||||||
|
|
||||||
assertEquals(createdHold.getName(), hold.getName());
|
|
||||||
assertEquals(createdHold.getDescription(), hold.getDescription());
|
|
||||||
assertEquals(createdHold.getReason(), hold.getReason());
|
|
||||||
}
|
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
fail("No child element for " + hold);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,7 @@ import org.testng.annotations.AfterClass;
|
|||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Ignore;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.alfresco.utility.model.TestGroup;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API tests for declaring document as record and filing it immediately to a record folder location within the file plan
|
* API tests for declaring document as record and filing it immediately to a record folder location within the file plan
|
||||||
@@ -259,8 +257,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
|
|||||||
* Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
|
* Then I receive an error indicating that I have attempted to declare and file a document into an invalid record folder
|
||||||
* And the document is not declared as a record
|
* And the document is not declared as a record
|
||||||
*/
|
*/
|
||||||
@Test (dataProvider = "invalidDestinationPaths",groups = { TestGroup.NOT_SUPPORTED_ON_SINGLE_PIPELINE })
|
@Test (dataProvider = "invalidDestinationPaths")
|
||||||
@Ignore
|
|
||||||
public void declareAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
|
public void declareAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
|
||||||
{
|
{
|
||||||
STEP("Declare document as record with an invalid location parameter value");
|
STEP("Declare document as record with an invalid location parameter value");
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ import org.testng.annotations.AfterClass;
|
|||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Ignore;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.alfresco.utility.model.TestGroup;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API tests for declaring a document version as record and filing to a record folder location within the file plan
|
* API tests for declaring a document version as record and filing to a record folder location within the file plan
|
||||||
@@ -209,8 +207,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest
|
|||||||
* record folder
|
* record folder
|
||||||
* And the document is not declared as a version record
|
* And the document is not declared as a version record
|
||||||
*/
|
*/
|
||||||
@Test (dataProvider = "invalidDestinationPaths", groups = { TestGroup.NOT_SUPPORTED_ON_SINGLE_PIPELINE })
|
@Test (dataProvider = "invalidDestinationPaths")
|
||||||
@Ignore
|
|
||||||
public void declareVersionAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
|
public void declareVersionAndFileToInvalidLocationUsingActionsAPI(String containerPath, String expectedException) throws Exception
|
||||||
{
|
{
|
||||||
STEP("Declare document as record version with an invalid location parameter value");
|
STEP("Declare document as record version with an invalid location parameter value");
|
||||||
|
|||||||
@@ -1,614 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.hold;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.awaitility.Awaitility.await;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.springframework.http.HttpStatus.ACCEPTED;
|
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.dataprep.ContentActions;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.BulkBodyCancel;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperation;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperation.HoldBulkOperationType;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkOperationEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatus;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatusCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldBulkStatusEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChildEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
|
||||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
|
||||||
import org.alfresco.rest.search.SearchRequest;
|
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API tests for adding items to holds via the bulk process
|
|
||||||
*/
|
|
||||||
public class AddToHoldsBulkV1Tests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static final String ACCESS_DENIED_ERROR_MESSAGE = "Access Denied. You do not have the appropriate " +
|
|
||||||
"permissions to perform this operation.";
|
|
||||||
private static final int NUMBER_OF_FILES = 5;
|
|
||||||
private final List<FileModel> addedFiles = new ArrayList<>();
|
|
||||||
private final List<UserModel> users = new ArrayList<>();
|
|
||||||
private final List<Hold> holds = new ArrayList<>();
|
|
||||||
private Hold hold;
|
|
||||||
private Hold hold2;
|
|
||||||
private Hold hold3;
|
|
||||||
private FolderModel rootFolder;
|
|
||||||
private HoldBulkOperation holdBulkOperation;
|
|
||||||
@Autowired
|
|
||||||
private RoleService roleService;
|
|
||||||
@Autowired
|
|
||||||
private ContentActions contentActions;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForAddContentToHold()
|
|
||||||
{
|
|
||||||
STEP("Create a hold.");
|
|
||||||
hold = getRestAPIFactory().getFilePlansAPI(getAdminUser()).createHold(
|
|
||||||
Hold.builder().name("HOLD" + generateTestPrefix(AddToHoldsV1Tests.class)).description(HOLD_DESCRIPTION)
|
|
||||||
.reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
holds.add(hold);
|
|
||||||
|
|
||||||
STEP("Create test files.");
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
|
|
||||||
rootFolder = dataContent.usingAdmin().usingSite(testSite).createFolder();
|
|
||||||
FolderModel folder1 = dataContent.usingAdmin().usingResource(rootFolder).createFolder();
|
|
||||||
FolderModel folder2 = dataContent.usingAdmin().usingResource(folder1).createFolder();
|
|
||||||
|
|
||||||
// Add files to subfolders in the site
|
|
||||||
for (int i = 0; i < NUMBER_OF_FILES; i++)
|
|
||||||
{
|
|
||||||
FileModel documentHeld = dataContent.usingAdmin()
|
|
||||||
.usingResource(i % 2 == 0 ? folder1 : folder2)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
addedFiles.add(documentHeld);
|
|
||||||
}
|
|
||||||
|
|
||||||
RestRequestQueryModel queryReq = getContentFromSiteQuery(testSite.getId());
|
|
||||||
SearchRequest searchRequest = new SearchRequest();
|
|
||||||
searchRequest.setQuery(queryReq);
|
|
||||||
|
|
||||||
STEP("Wait until all files are searchable.");
|
|
||||||
await().atMost(30, TimeUnit.SECONDS)
|
|
||||||
.until(() -> getRestAPIFactory().getSearchAPI(null).search(searchRequest).getPagination()
|
|
||||||
.getTotalItems() == NUMBER_OF_FILES);
|
|
||||||
|
|
||||||
holdBulkOperation = HoldBulkOperation.builder()
|
|
||||||
.query(queryReq)
|
|
||||||
.op(HoldBulkOperationType.ADD).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then the content is added to the hold and the status of the bulk operation is DONE
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void addContentFromTestSiteToHoldUsingBulkAPI()
|
|
||||||
{
|
|
||||||
UserModel userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
assertEquals(NUMBER_OF_FILES, bulkOperationEntry.getTotalItems());
|
|
||||||
|
|
||||||
STEP("Wait until all files are added to the hold.");
|
|
||||||
await().atMost(20, TimeUnit.SECONDS).until(
|
|
||||||
() -> getRestAPIFactory().getHoldsAPI(getAdminUser()).getChildren(hold.getId()).getEntries().size()
|
|
||||||
== NUMBER_OF_FILES);
|
|
||||||
List<String> holdChildrenNodeRefs = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getChildren(hold.getId()).getEntries().stream().map(HoldChildEntry::getEntry).map(
|
|
||||||
HoldChild::getId).toList();
|
|
||||||
assertEquals(addedFiles.stream().map(FileModel::getNodeRefWithoutVersion).sorted().toList(),
|
|
||||||
holdChildrenNodeRefs.stream().sorted().toList());
|
|
||||||
|
|
||||||
STEP("Check the bulk status.");
|
|
||||||
HoldBulkStatus holdBulkStatus = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatus(hold.getId(), bulkOperationEntry.getBulkStatusId());
|
|
||||||
assertBulkProcessStatus(holdBulkStatus, NUMBER_OF_FILES, 0, null, holdBulkOperation);
|
|
||||||
|
|
||||||
STEP("Check the bulk statuses.");
|
|
||||||
HoldBulkStatusCollection holdBulkStatusCollection = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatuses(hold.getId());
|
|
||||||
assertEquals(Arrays.asList(holdBulkStatus),
|
|
||||||
holdBulkStatusCollection.getEntries().stream().map(HoldBulkStatusEntry::getEntry).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a folder and all subfolders to a hold using the bulk API
|
|
||||||
* Then the content is added to the hold and the status of the bulk operation is DONE
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void addContentFromFolderAndAllSubfoldersToHoldUsingBulkAPI()
|
|
||||||
{
|
|
||||||
hold3 = getRestAPIFactory().getFilePlansAPI(getAdminUser()).createHold(
|
|
||||||
Hold.builder().name("HOLD" + generateTestPrefix(AddToHoldsV1Tests.class)).description(HOLD_DESCRIPTION)
|
|
||||||
.reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
holds.add(hold3);
|
|
||||||
|
|
||||||
UserModel userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold3.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
// Get content from folder and all subfolders of the root folder
|
|
||||||
HoldBulkOperation bulkOperation = HoldBulkOperation.builder()
|
|
||||||
.query(getContentFromFolderAndAllSubfoldersQuery(rootFolder.getNodeRefWithoutVersion()))
|
|
||||||
.op(HoldBulkOperationType.ADD).build();
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.startBulkProcess(bulkOperation, hold3.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
assertEquals(NUMBER_OF_FILES, bulkOperationEntry.getTotalItems());
|
|
||||||
|
|
||||||
STEP("Wait until all files are added to the hold.");
|
|
||||||
await().atMost(20, TimeUnit.SECONDS).until(
|
|
||||||
() -> getRestAPIFactory().getHoldsAPI(getAdminUser()).getChildren(hold3.getId()).getEntries().size()
|
|
||||||
== NUMBER_OF_FILES);
|
|
||||||
List<String> holdChildrenNodeRefs = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getChildren(hold3.getId()).getEntries().stream().map(HoldChildEntry::getEntry).map(
|
|
||||||
HoldChild::getId).toList();
|
|
||||||
assertEquals(addedFiles.stream().map(FileModel::getNodeRefWithoutVersion).sorted().toList(),
|
|
||||||
holdChildrenNodeRefs.stream().sorted().toList());
|
|
||||||
|
|
||||||
STEP("Check the bulk status.");
|
|
||||||
HoldBulkStatus holdBulkStatus = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatus(hold3.getId(), bulkOperationEntry.getBulkStatusId());
|
|
||||||
assertBulkProcessStatus(holdBulkStatus, NUMBER_OF_FILES, 0, null, bulkOperation);
|
|
||||||
|
|
||||||
STEP("Check the bulk statuses.");
|
|
||||||
HoldBulkStatusCollection holdBulkStatusCollection = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatuses(hold3.getId());
|
|
||||||
assertEquals(List.of(holdBulkStatus),
|
|
||||||
holdBulkStatusCollection.getEntries().stream().map(HoldBulkStatusEntry::getEntry).toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user without the add to hold capability
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then the user receives access denied error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessWithUserWithoutAddToHoldCapability()
|
|
||||||
{
|
|
||||||
UserModel userWithoutAddToHoldCapability = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole
|
|
||||||
.SiteCollaborator,
|
|
||||||
hold.getId(), UserRoles.ROLE_RM_POWER_USER, PERMISSION_FILING);
|
|
||||||
users.add(userWithoutAddToHoldCapability);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userWithoutAddToHoldCapability)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response status code and the error message.");
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(ACCESS_DENIED_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user without the filing permission on a hold
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then the user receives access denied error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessWithUserWithoutFilingPermissionOnAHold()
|
|
||||||
{
|
|
||||||
// User without filing permission on a hold
|
|
||||||
UserModel userWithoutPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_READ_RECORDS);
|
|
||||||
users.add(userWithoutPermission);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userWithoutPermission)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response status code and the error message.");
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(ACCESS_DENIED_ERROR_MESSAGE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user without the write permission on all the content
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then all processed items are marked as errors and the last error message contains access denied error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessWithUserWithoutWritePermissionOnTheContent()
|
|
||||||
{
|
|
||||||
// User without write permission on the content
|
|
||||||
UserModel userWithoutPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(
|
|
||||||
testSite, UserRole.SiteConsumer,
|
|
||||||
hold.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userWithoutPermission);
|
|
||||||
|
|
||||||
// Wait until permissions are reverted
|
|
||||||
SearchRequest searchRequest = new SearchRequest();
|
|
||||||
searchRequest.setQuery(holdBulkOperation.getQuery());
|
|
||||||
await().atMost(30, TimeUnit.SECONDS)
|
|
||||||
.until(() -> getRestAPIFactory().getSearchAPI(userWithoutPermission).search(searchRequest).getPagination()
|
|
||||||
.getTotalItems() == NUMBER_OF_FILES);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(
|
|
||||||
userWithoutPermission).startBulkProcess(holdBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response.");
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
|
|
||||||
await().atMost(20, TimeUnit.SECONDS).until(() ->
|
|
||||||
Objects.equals(getRestAPIFactory().getHoldsAPI(userWithoutPermission)
|
|
||||||
.getBulkStatus(hold.getId(), bulkOperationEntry.getBulkStatusId()).getStatus(), "DONE"));
|
|
||||||
|
|
||||||
HoldBulkStatus holdBulkStatus = getRestAPIFactory().getHoldsAPI(userWithoutPermission)
|
|
||||||
.getBulkStatus(hold.getId(), bulkOperationEntry.getBulkStatusId());
|
|
||||||
assertBulkProcessStatus(holdBulkStatus, NUMBER_OF_FILES, NUMBER_OF_FILES, ACCESS_DENIED_ERROR_MESSAGE,
|
|
||||||
holdBulkOperation);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user without the write permission on one file
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then all processed items are added to the hold except the one that the user does not have write permission
|
|
||||||
* And the status of the bulk operation is DONE, contains the error message and the number of errors is 1
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessWithUserWithoutWritePermissionOnOneFile()
|
|
||||||
{
|
|
||||||
hold2 = getRestAPIFactory().getFilePlansAPI(getAdminUser()).createHold(
|
|
||||||
Hold.builder().name("HOLD" + generateTestPrefix(AddToHoldsV1Tests.class)).description(HOLD_DESCRIPTION)
|
|
||||||
.reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
holds.add(hold2);
|
|
||||||
|
|
||||||
UserModel userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold2.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
|
|
||||||
contentActions.setPermissionForUser(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
|
||||||
testSite.getId(), addedFiles.get(0).getName(), userAddHoldPermission.getUsername(),
|
|
||||||
UserRole.SiteConsumer.getRoleId(), false);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold2.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
assertEquals(NUMBER_OF_FILES, bulkOperationEntry.getTotalItems());
|
|
||||||
|
|
||||||
STEP("Wait until all files are added to the hold.");
|
|
||||||
await().atMost(30, TimeUnit.SECONDS).until(
|
|
||||||
() -> getRestAPIFactory().getHoldsAPI(getAdminUser()).getChildren(hold2.getId()).getEntries().size()
|
|
||||||
== NUMBER_OF_FILES - 1);
|
|
||||||
await().atMost(30, TimeUnit.SECONDS).until(
|
|
||||||
() -> getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatus(hold2.getId(), bulkOperationEntry.getBulkStatusId()).getProcessedItems()
|
|
||||||
== NUMBER_OF_FILES);
|
|
||||||
List<String> holdChildrenNodeRefs = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getChildren(hold2.getId()).getEntries().stream().map(HoldChildEntry::getEntry).map(
|
|
||||||
HoldChild::getId).toList();
|
|
||||||
assertEquals(addedFiles.stream().skip(1).map(FileModel::getNodeRefWithoutVersion).sorted().toList(),
|
|
||||||
holdChildrenNodeRefs.stream().sorted().toList());
|
|
||||||
|
|
||||||
STEP("Check the bulk status.");
|
|
||||||
HoldBulkStatus holdBulkStatus = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatus(hold2.getId(), bulkOperationEntry.getBulkStatusId());
|
|
||||||
assertBulkProcessStatus(holdBulkStatus, NUMBER_OF_FILES, 1, ACCESS_DENIED_ERROR_MESSAGE, holdBulkOperation);
|
|
||||||
|
|
||||||
STEP("Check the bulk statuses.");
|
|
||||||
HoldBulkStatusCollection holdBulkStatusCollection = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.getBulkStatuses(hold2.getId());
|
|
||||||
assertEquals(List.of(holdBulkStatus),
|
|
||||||
holdBulkStatusCollection.getEntries().stream().map(HoldBulkStatusEntry::getEntry).toList());
|
|
||||||
|
|
||||||
// Revert the permissions
|
|
||||||
contentActions.setPermissionForUser(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
|
||||||
testSite.getId(), addedFiles.get(0).getName(), userAddHoldPermission.getUsername(),
|
|
||||||
UserRole.SiteCollaborator.getRoleId(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an unauthenticated user
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* Then the user receives unauthorized error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessAsUnauthenticatedUser()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process as unauthenticated user");
|
|
||||||
getRestAPIFactory().getHoldsAPI(new UserModel(getAdminUser().getUsername(), "wrongPassword"))
|
|
||||||
.startBulkProcess(holdBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And the hold does not exist
|
|
||||||
* Then the user receives not found error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessForNonExistentHold()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process for non existent hold");
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).startBulkProcess(holdBulkOperation, "nonExistentHoldId");
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* and the bulk operation is invalid
|
|
||||||
* Then the user receives bad request error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetBulkStatusesForInvalidOperation()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process for non existent hold");
|
|
||||||
|
|
||||||
HoldBulkOperation invalidHoldBulkOperation = HoldBulkOperation.builder().op(null)
|
|
||||||
.query(holdBulkOperation.getQuery()).build();
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).startBulkProcess(invalidHoldBulkOperation, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And the hold does not exist
|
|
||||||
* Then the user receives not found error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetBulkStatusForNonExistentHold()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process for non existent hold");
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).getBulkStatus("nonExistentHoldId", "nonExistenBulkStatusId");
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And the bulk status does not exist
|
|
||||||
* Then the user receives not found error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetBulkStatusForNonExistentBulkStatus()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process for non bulk status");
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).getBulkStatus(hold.getId(), "nonExistenBulkStatusId");
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And the hold does not exist
|
|
||||||
* Then the user receives not found error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetBulkStatusesForNonExistentHold()
|
|
||||||
{
|
|
||||||
STEP("Start bulk process for non existent hold");
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).getBulkStatuses("nonExistentHoldId");
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from all sites to a hold using the bulk API to exceed the limit (30 items)
|
|
||||||
* Then the user receives bad request error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testExceedingBulkOperationLimit()
|
|
||||||
{
|
|
||||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
|
||||||
queryReq.setQuery("TYPE:content");
|
|
||||||
queryReq.setLanguage("afts");
|
|
||||||
|
|
||||||
HoldBulkOperation exceedLimitOp = HoldBulkOperation.builder()
|
|
||||||
.query(queryReq)
|
|
||||||
.op(HoldBulkOperationType.ADD).build();
|
|
||||||
|
|
||||||
STEP("Start bulk process to exceed the limit");
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).startBulkProcess(exceedLimitOp, hold.getId());
|
|
||||||
|
|
||||||
STEP("Verify the response status code.");
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And then the user cancels the bulk operation
|
|
||||||
* Then the user receives OK status code
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessCancellationWithAllowedUser()
|
|
||||||
{
|
|
||||||
Hold hold4 = getRestAPIFactory().getFilePlansAPI(getAdminUser()).createHold(
|
|
||||||
Hold.builder().name("HOLD" + generateTestPrefix(AddToHoldsV1Tests.class)).description(HOLD_DESCRIPTION)
|
|
||||||
.reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
holds.add(hold4);
|
|
||||||
|
|
||||||
UserModel userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold4.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold4.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
assertEquals(NUMBER_OF_FILES, bulkOperationEntry.getTotalItems());
|
|
||||||
|
|
||||||
STEP("Cancel the bulk operation.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.cancelBulkOperation(hold4.getId(), bulkOperationEntry.getBulkStatusId(), new BulkBodyCancel());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a user with the add to hold capability and hold filing permission
|
|
||||||
* When the user adds content from a site to a hold using the bulk API
|
|
||||||
* And a 2nd user without the add to hold capability cancels the bulk operation
|
|
||||||
* Then the 2nd user receives access denied error
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testBulkProcessCancellationWithUserWithoutAddToHoldCapability()
|
|
||||||
{
|
|
||||||
Hold hold5 = getRestAPIFactory().getFilePlansAPI(getAdminUser()).createHold(
|
|
||||||
Hold.builder().name("HOLD" + generateTestPrefix(AddToHoldsV1Tests.class)).description(HOLD_DESCRIPTION)
|
|
||||||
.reason(HOLD_REASON).build(), FILE_PLAN_ALIAS);
|
|
||||||
holds.add(hold5);
|
|
||||||
|
|
||||||
UserModel userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, hold5.getId(), UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
|
|
||||||
STEP("Add content from the site to the hold using the bulk API.");
|
|
||||||
HoldBulkOperationEntry bulkOperationEntry = getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.startBulkProcess(holdBulkOperation, hold5.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(ACCEPTED);
|
|
||||||
assertEquals(NUMBER_OF_FILES, bulkOperationEntry.getTotalItems());
|
|
||||||
|
|
||||||
UserModel userWithoutAddToHoldCapability = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole
|
|
||||||
.SiteCollaborator,
|
|
||||||
hold5.getId(), UserRoles.ROLE_RM_POWER_USER, PERMISSION_FILING);
|
|
||||||
users.add(userWithoutAddToHoldCapability);
|
|
||||||
|
|
||||||
STEP("Cancel the bulk operation.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userWithoutAddToHoldCapability)
|
|
||||||
.cancelBulkOperation(hold5.getId(), bulkOperationEntry.getBulkStatusId(), new BulkBodyCancel());
|
|
||||||
|
|
||||||
STEP("Verify the response status code and the error message.");
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(ACCESS_DENIED_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertBulkProcessStatus(HoldBulkStatus holdBulkStatus, long expectedProcessedItems,
|
|
||||||
int expectedErrorsCount, String expectedErrorMessage, HoldBulkOperation holdBulkOperation)
|
|
||||||
{
|
|
||||||
assertEquals("DONE", holdBulkStatus.getStatus());
|
|
||||||
assertEquals(expectedProcessedItems, holdBulkStatus.getTotalItems());
|
|
||||||
assertEquals(expectedProcessedItems, holdBulkStatus.getProcessedItems());
|
|
||||||
assertEquals(expectedErrorsCount, holdBulkStatus.getErrorsCount());
|
|
||||||
assertEquals(holdBulkStatus.getHoldBulkOperation(), holdBulkOperation);
|
|
||||||
assertNotNull(holdBulkStatus.getStartTime());
|
|
||||||
assertNotNull(holdBulkStatus.getEndTime());
|
|
||||||
|
|
||||||
if (expectedErrorMessage != null)
|
|
||||||
{
|
|
||||||
assertTrue(holdBulkStatus.getLastError().contains(expectedErrorMessage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestRequestQueryModel getContentFromSiteQuery(String siteId)
|
|
||||||
{
|
|
||||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
|
||||||
queryReq.setQuery("SITE:\"" + siteId + "\" and TYPE:content");
|
|
||||||
queryReq.setLanguage("afts");
|
|
||||||
return queryReq;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestRequestQueryModel getContentFromFolderAndAllSubfoldersQuery(String folderId)
|
|
||||||
{
|
|
||||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
|
||||||
queryReq.setQuery("ANCESTOR:\"workspace://SpacesStore/" + folderId + "\" and TYPE:content");
|
|
||||||
queryReq.setLanguage("afts");
|
|
||||||
return queryReq;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanupAddToHoldsBulkV1Tests()
|
|
||||||
{
|
|
||||||
dataSite.usingAdmin().deleteSite(testSite);
|
|
||||||
users.forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
|
||||||
holds.forEach(hold -> getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(hold.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -60,7 +60,7 @@ import org.alfresco.dataprep.CMISUtil;
|
|||||||
import org.alfresco.dataprep.ContentActions;
|
import org.alfresco.dataprep.ContentActions;
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
import org.alfresco.rest.model.RestNodeModel;
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.hold.v0.HoldEntry;
|
import org.alfresco.rest.rm.community.model.hold.HoldEntry;
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
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.RecordCategory;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
|
|||||||
@@ -1,386 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.hold;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.apache.commons.httpclient.HttpStatus.SC_BAD_REQUEST;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
import static org.testng.AssertJUnit.assertFalse;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.dataprep.ContentActions;
|
|
||||||
import org.alfresco.rest.model.RestNodeAssociationModelCollection;
|
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
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.user.UserRoles;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
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.springframework.http.HttpStatus;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.DataProvider;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* V1 API tests for adding content/record folder/records to holds
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class AddToHoldsV1Tests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static final String ACCESS_DENIED_ERROR_MESSAGE = "Access Denied. You do not have the appropriate " +
|
|
||||||
"permissions to perform this operation.";
|
|
||||||
private static final String INVALID_TYPE_ERROR_MESSAGE = "Only records, record folders or content can be added to a hold.";
|
|
||||||
private static final String LOCKED_FILE_ERROR_MESSAGE = "Locked content can't be added to a hold.";
|
|
||||||
|
|
||||||
private static final String HOLD = "HOLD" + generateTestPrefix(AddToHoldsV1Tests.class);
|
|
||||||
private String holdNodeRef;
|
|
||||||
private SiteModel testSite;
|
|
||||||
private FileModel documentHeld;
|
|
||||||
private FileModel contentToAddToHold;
|
|
||||||
private FileModel contentAddToHoldNoPermission;
|
|
||||||
private Hold hold;
|
|
||||||
|
|
||||||
private UserModel userAddHoldPermission;
|
|
||||||
private final List<UserModel> users = new ArrayList<>();
|
|
||||||
private final List<String> nodesToBeClean = new ArrayList<>();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleService roleService;
|
|
||||||
@Autowired
|
|
||||||
private ContentActions contentActions;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForAddContentToHold()
|
|
||||||
{
|
|
||||||
STEP("Create a hold.");
|
|
||||||
hold = createHold(FILE_PLAN_ALIAS,
|
|
||||||
Hold.builder().name(HOLD).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), getAdminUser());
|
|
||||||
holdNodeRef = hold.getId();
|
|
||||||
STEP("Create test files.");
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
documentHeld = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
contentToAddToHold = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
contentAddToHoldNoPermission = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
STEP("Add the content to the hold.");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(documentHeld.getNodeRefWithoutVersion()).build(), hold.getId());
|
|
||||||
|
|
||||||
STEP("Create users");
|
|
||||||
userAddHoldPermission = roleService.createUserWithSiteRoleRMRoleAndPermission(testSite,
|
|
||||||
UserRole.SiteCollaborator, holdNodeRef, UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
users.add(userAddHoldPermission);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a hold that contains at least one active content
|
|
||||||
* When I use the existing REST API to retrieve the contents of the hold
|
|
||||||
* Then I should see all the active content on hold
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void retrieveTheContentOfTheHoldUsingV1API()
|
|
||||||
{
|
|
||||||
STEP("Retrieve the list of children from the hold and collect the entries that have the name of the active " +
|
|
||||||
"content held");
|
|
||||||
List<String> documentNames = restClient.authenticateUser(getAdminUser()).withCoreAPI()
|
|
||||||
.usingNode(toContentModel(holdNodeRef))
|
|
||||||
.listChildren().getEntries().stream()
|
|
||||||
.map(RestNodeModel::onModel)
|
|
||||||
.map(RestNodeModel::getName)
|
|
||||||
.filter(documentName -> documentName.equals(documentHeld.getName()))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
STEP("Check the list of active content");
|
|
||||||
assertEquals(documentNames, Set.of(documentHeld.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a hold that contains at least one active content
|
|
||||||
* When I use the existing REST API to retrieve the holds the content is added
|
|
||||||
* Then the hold where the content held is returned
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void retrieveTheHoldWhereTheContentIsAdded()
|
|
||||||
{
|
|
||||||
RestNodeAssociationModelCollection holdsEntries = getRestAPIFactory()
|
|
||||||
.getNodeAPI(documentHeld).usingParams("where=(assocType='rma:frozenContent')").getParents();
|
|
||||||
Hold retrievedHold = getRestAPIFactory().getHoldsAPI(getAdminUser())
|
|
||||||
.getHold(holdsEntries.getEntries().get(0).getModel().getId());
|
|
||||||
assertEquals(retrievedHold, hold, "Holds are not equal");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valid nodes to be added to hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "validNodesForAddToHold")
|
|
||||||
public Object[][] getValidNodesForAddToHold()
|
|
||||||
{
|
|
||||||
//create electronic and nonElectronic record in record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
nodesToBeClean.add(recordFolder.getParentId());
|
|
||||||
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder.getId(),
|
|
||||||
getFile
|
|
||||||
(IMAGE_FILE));
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(),
|
|
||||||
recordFolder.getId());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(recordFolder.getId(), userAddHoldPermission,
|
|
||||||
PERMISSION_FILING);
|
|
||||||
|
|
||||||
RecordCategoryChild folderToHold = createCategoryFolderInFilePlan();
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(folderToHold.getId(), userAddHoldPermission,
|
|
||||||
PERMISSION_FILING);
|
|
||||||
nodesToBeClean.add(folderToHold.getParentId());
|
|
||||||
|
|
||||||
return new String[][]
|
|
||||||
{ // record folder
|
|
||||||
{ folderToHold.getId() },
|
|
||||||
//electronic record
|
|
||||||
{ electronicRecord.getId() },
|
|
||||||
// non electronic record
|
|
||||||
{ nonElectronicRecord.getId() },
|
|
||||||
// document from collaboration site
|
|
||||||
{ contentToAddToHold.getNodeRefWithoutVersion() },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given record folder/record/document not on hold
|
|
||||||
* And a hold
|
|
||||||
* And file permission on the hold
|
|
||||||
* And the appropriate capability to add to hold
|
|
||||||
* When I use the existing REST API to add the node to the hold
|
|
||||||
* Then the record folder/record/document is added to the hold
|
|
||||||
* And the item is frozen
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Test(dataProvider = "validNodesForAddToHold")
|
|
||||||
public void addValidNodesToHoldWithAllowedUser(String nodeId) throws Exception
|
|
||||||
{
|
|
||||||
STEP("Add node to hold with user with permission.");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userAddHoldPermission)
|
|
||||||
.addChildToHold(HoldChild.builder().id(nodeId).build(), hold.getId());
|
|
||||||
|
|
||||||
STEP("Check the node is frozen.");
|
|
||||||
assertTrue(hasAspect(nodeId, FROZEN_ASPECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data provider with user without correct permission to add to hold and the node ref to be added to hold
|
|
||||||
*
|
|
||||||
* @return object with user model and the node ref to be added to hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "userWithoutPermissionForAddToHold")
|
|
||||||
public Object[][] getUserWithoutPermissionForAddToHold()
|
|
||||||
{
|
|
||||||
//create record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
//create a rm manager and grant read permission over the record folder created
|
|
||||||
UserModel user = roleService.createUserWithRMRoleAndRMNodePermission(ROLE_RM_MANAGER.roleId,
|
|
||||||
recordFolder.getId(),
|
|
||||||
PERMISSION_READ_RECORDS);
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(holdNodeRef, user, PERMISSION_FILING);
|
|
||||||
nodesToBeClean.add(recordFolder.getParentId());
|
|
||||||
return new Object[][]
|
|
||||||
{ // user without write permission on the content
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole.SiteConsumer,
|
|
||||||
holdNodeRef, UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING),
|
|
||||||
contentAddToHoldNoPermission.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
// user with write permission on the content and without filling permission on a hold
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole
|
|
||||||
.SiteCollaborator,
|
|
||||||
holdNodeRef, UserRoles.ROLE_RM_MANAGER, PERMISSION_READ_RECORDS),
|
|
||||||
contentAddToHoldNoPermission.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
// user with write permission on the content, filling permission on a hold without add to
|
|
||||||
// hold capability
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole
|
|
||||||
.SiteCollaborator,
|
|
||||||
holdNodeRef, UserRoles.ROLE_RM_POWER_USER, PERMISSION_READ_RECORDS),
|
|
||||||
contentAddToHoldNoPermission.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
//user without write permission on RM record folder
|
|
||||||
{
|
|
||||||
user, recordFolder.getId()
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a node not on hold
|
|
||||||
* And a hold
|
|
||||||
* And user without right permission to add to hold
|
|
||||||
* When I use the existing REST API to add the node to the hold
|
|
||||||
* Then the node is not added to the hold
|
|
||||||
* And the node is not frozen
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Test(dataProvider = "userWithoutPermissionForAddToHold")
|
|
||||||
public void addContentToHoldWithUserWithoutHoldPermission(UserModel userModel, String nodeToBeAddedToHold)
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
users.add(userModel);
|
|
||||||
STEP("Add the node to the hold with user without permission.");
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(userModel)
|
|
||||||
.addChildToHold(HoldChild.builder().id(nodeToBeAddedToHold).build(), holdNodeRef);
|
|
||||||
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(ACCESS_DENIED_ERROR_MESSAGE);
|
|
||||||
|
|
||||||
STEP("Check the node is not frozen.");
|
|
||||||
assertFalse(hasAspect(nodeToBeAddedToHold, FROZEN_ASPECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data provider with invalid node types that can be added to a hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "invalidNodesForAddToHold")
|
|
||||||
public Object[][] getInvalidNodesForAddToHold()
|
|
||||||
{
|
|
||||||
//create locked file
|
|
||||||
FileModel contentLocked = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
contentActions.checkOut(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
|
||||||
testSite.getId(), contentLocked.getName());
|
|
||||||
RecordCategory category = createRootCategory(getRandomAlphanumeric());
|
|
||||||
nodesToBeClean.add(category.getId());
|
|
||||||
return new Object[][]
|
|
||||||
{ // file plan node id
|
|
||||||
{ getFilePlan(FILE_PLAN_ALIAS).getId(), SC_BAD_REQUEST, INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
//transfer container
|
|
||||||
{ getTransferContainer(TRANSFERS_ALIAS).getId(), SC_BAD_REQUEST, INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
// a record category
|
|
||||||
{ category.getId(), SC_BAD_REQUEST, INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
// unfiled records root
|
|
||||||
{ getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId(), SC_BAD_REQUEST,
|
|
||||||
INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
// an arbitrary unfiled records folder
|
|
||||||
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " +
|
|
||||||
getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(), SC_BAD_REQUEST,
|
|
||||||
INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
//folder,
|
|
||||||
{ dataContent.usingAdmin().usingSite(testSite).createFolder().getNodeRef(), SC_BAD_REQUEST,
|
|
||||||
INVALID_TYPE_ERROR_MESSAGE },
|
|
||||||
//document locked
|
|
||||||
{ contentLocked.getNodeRefWithoutVersion(), SC_BAD_REQUEST, LOCKED_FILE_ERROR_MESSAGE }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a node that is not a document/record/ record folder ( a valid node type to be added to hold)
|
|
||||||
* And a hold
|
|
||||||
* And user without right permission to add to hold
|
|
||||||
* When I use the existing REST API to add the node to the hold
|
|
||||||
* Then the node is not added to the hold
|
|
||||||
* And the node is not frozen
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Test(dataProvider = "invalidNodesForAddToHold")
|
|
||||||
public void addInvalidNodesToHold(String itemNodeRef, int responseCode, String errorMessage) throws Exception
|
|
||||||
{
|
|
||||||
STEP("Add the node to the hold ");
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(itemNodeRef).build(), holdNodeRef);
|
|
||||||
|
|
||||||
assertStatusCode(HttpStatus.valueOf(responseCode));
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(errorMessage);
|
|
||||||
|
|
||||||
STEP("Check node is not frozen.");
|
|
||||||
assertFalse(hasAspect(itemNodeRef, FROZEN_ASPECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Hold createHold(String parentId, Hold hold, UserModel user)
|
|
||||||
{
|
|
||||||
FilePlanAPI filePlanAPI = getRestAPIFactory().getFilePlansAPI(user);
|
|
||||||
return filePlanAPI.createHold(hold, parentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpAddContentToHold()
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(holdNodeRef);
|
|
||||||
dataSite.usingAdmin().deleteSite(testSite);
|
|
||||||
users.forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
|
||||||
nodesToBeClean.forEach(this::deleteRecordCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.hold;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldDeletionReason;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the tests for the Holds CRUD V1 API
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class HoldsTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
|
|
||||||
private final List<String> nodeRefs = new ArrayList<>();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetHold()
|
|
||||||
{
|
|
||||||
String holdName = "Hold" + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Description" + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// Get the hold
|
|
||||||
Hold receivedHold = getRestAPIFactory().getHoldsAPI().getHold(createdHold.getId());
|
|
||||||
nodeRefs.add(receivedHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
assertEquals(receivedHold.getName(), holdName);
|
|
||||||
assertEquals(receivedHold.getDescription(), holdDescription);
|
|
||||||
assertEquals(receivedHold.getReason(), holdReason);
|
|
||||||
assertNotNull(receivedHold.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateHold()
|
|
||||||
{
|
|
||||||
String holdName = "Hold" + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Description" + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
nodeRefs.add(createdHold.getId());
|
|
||||||
|
|
||||||
Hold holdModel = Hold.builder()
|
|
||||||
.name("Updated" + holdName)
|
|
||||||
.description("Updated" + holdDescription)
|
|
||||||
.reason("Updated" + holdReason)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Update the hold
|
|
||||||
Hold updatedHold = getRestAPIFactory().getHoldsAPI().updateHold(holdModel, createdHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
assertEquals(updatedHold.getName(), "Updated" + holdName);
|
|
||||||
assertEquals(updatedHold.getDescription(), "Updated" + holdDescription);
|
|
||||||
assertEquals(updatedHold.getReason(), "Updated" + holdReason);
|
|
||||||
assertNotNull(updatedHold.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeleteHold()
|
|
||||||
{
|
|
||||||
String holdName = "Hold" + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Description" + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
nodeRefs.add(createdHold.getId());
|
|
||||||
|
|
||||||
// Delete the hold
|
|
||||||
getRestAPIFactory().getHoldsAPI().deleteHold(createdHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
|
|
||||||
// Try to get the hold
|
|
||||||
getRestAPIFactory().getHoldsAPI().getHold(createdHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeleteHoldWithReason()
|
|
||||||
{
|
|
||||||
String holdName = "Hold" + getRandomAlphanumeric();
|
|
||||||
String holdDescription = "Description" + getRandomAlphanumeric();
|
|
||||||
String holdReason = "Reason" + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the hold
|
|
||||||
Hold hold = Hold.builder()
|
|
||||||
.name(holdName)
|
|
||||||
.description(holdDescription)
|
|
||||||
.reason(holdReason)
|
|
||||||
.build();
|
|
||||||
Hold createdHold = getRestAPIFactory().getFilePlansAPI()
|
|
||||||
.createHold(hold, FILE_PLAN_ALIAS);
|
|
||||||
nodeRefs.add(createdHold.getId());
|
|
||||||
|
|
||||||
// Delete the hold with the reason
|
|
||||||
getRestAPIFactory().getHoldsAPI()
|
|
||||||
.deleteHoldWithReason(HoldDeletionReason.builder().reason("Example reason").build(), createdHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Try to get the hold
|
|
||||||
getRestAPIFactory().getHoldsAPI().getHold(createdHold.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpHoldsTests()
|
|
||||||
{
|
|
||||||
nodeRefs.forEach(nodeRef -> getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(nodeRef));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,8 +42,8 @@ import static org.testng.Assert.assertNotNull;
|
|||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
import static org.testng.AssertJUnit.assertFalse;
|
import static org.testng.AssertJUnit.assertFalse;
|
||||||
|
|
||||||
import jakarta.json.Json;
|
import javax.json.Json;
|
||||||
import jakarta.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
|
|||||||
@@ -1,337 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.hold;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_VITAL_RECORD;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_VITAL_RECORD_DEFINITION;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
import static org.testng.AssertJUnit.assertFalse;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import jakarta.json.Json;
|
|
||||||
import jakarta.json.JsonObject;
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.core.JsonBodyGenerator;
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI.RM_ACTIONS;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
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.recordfolder.RecordFolderProperties;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
|
||||||
import org.alfresco.utility.Utility;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* V1 API tests to check actions on frozen content
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class PreventActionsOnFrozenContentV1Tests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static String holdNodeRef;
|
|
||||||
private static FileModel contentHeld;
|
|
||||||
private static File updatedFile;
|
|
||||||
private static FolderModel folderModel;
|
|
||||||
private static RecordCategoryChild recordFolder;
|
|
||||||
private static Record recordFrozen;
|
|
||||||
private static Record recordNotHeld;
|
|
||||||
private static RecordCategory categoryWithRS;
|
|
||||||
|
|
||||||
private Hold hold;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DispositionScheduleService dispositionScheduleService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForPreventActionsOnFrozenContent()
|
|
||||||
{
|
|
||||||
String holdOne = "HOLD" + generateTestPrefix(PreventActionsOnFrozenContentV1Tests.class);
|
|
||||||
|
|
||||||
STEP("Create a hold.");
|
|
||||||
hold = createHold(FILE_PLAN_ALIAS,
|
|
||||||
Hold.builder().name(holdOne).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(), getAdminUser());
|
|
||||||
holdNodeRef = hold.getId();
|
|
||||||
|
|
||||||
STEP("Create a test file.");
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
contentHeld = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
STEP("Add the file to the hold.");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(contentHeld.getNodeRefWithoutVersion()).build(), hold.getId());
|
|
||||||
|
|
||||||
STEP("Get a file resource.");
|
|
||||||
updatedFile = Utility.getResourceTestDataFile("SampleTextFile_10kb.txt");
|
|
||||||
|
|
||||||
STEP("Create a folder withing the test site .");
|
|
||||||
folderModel = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createFolder();
|
|
||||||
|
|
||||||
STEP("Create a record folder with some records");
|
|
||||||
recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
recordFrozen = createElectronicRecord(recordFolder.getId(), getRandomName("elRecordFrozen"));
|
|
||||||
recordNotHeld = createElectronicRecord(recordFolder.getId(), getRandomName("elRecordNotHeld"));
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
STEP("Add the record to the hold.");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(recordFrozen.getId()).build(), hold.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given active content on hold
|
|
||||||
* When I try to edit the properties
|
|
||||||
* Or perform an action that edits the properties
|
|
||||||
* Then I am not successful
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void editPropertiesForContentHeld() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Update name property of the held content");
|
|
||||||
JsonObject nameUpdated = Json.createObjectBuilder().add("name", "HeldNameUpdated").build();
|
|
||||||
restClient.authenticateUser(getAdminUser()).withCoreAPI().usingNode(contentHeld)
|
|
||||||
.updateNode(nameUpdated.toString());
|
|
||||||
|
|
||||||
STEP("Check the request failed.");
|
|
||||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
|
||||||
restClient.assertLastError().containsSummary("Frozen content can't be updated.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Given active content on hold
|
|
||||||
* When I try to update the content
|
|
||||||
* Then I am not successful
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void updateContentForFrozenFile() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Update content of the held file");
|
|
||||||
restClient.authenticateUser(getAdminUser()).withCoreAPI().usingNode(contentHeld).updateNodeContent(updatedFile);
|
|
||||||
|
|
||||||
STEP("Check the request failed.");
|
|
||||||
restClient.assertStatusCodeIs(INTERNAL_SERVER_ERROR);
|
|
||||||
restClient.assertLastError().containsSummary("Frozen content can't be updated.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Given active content on hold
|
|
||||||
* When I try to delete the content
|
|
||||||
* Then I am not successful
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void deleteFrozenFile() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Delete frozen file");
|
|
||||||
restClient.authenticateUser(getAdminUser()).withCoreAPI().usingNode(contentHeld)
|
|
||||||
.deleteNode(contentHeld.getNodeRefWithoutVersion());
|
|
||||||
|
|
||||||
STEP("Check the request failed.");
|
|
||||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
|
||||||
restClient.assertLastError().containsSummary("Frozen content can't be deleted.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given active content on hold
|
|
||||||
* When I try to copy the content
|
|
||||||
* Then I am not successful
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void copyFrozenFile()
|
|
||||||
{
|
|
||||||
STEP("Copy frozen file");
|
|
||||||
String postBody = JsonBodyGenerator.keyValueJson("targetParentId", folderModel.getNodeRef());
|
|
||||||
getRestAPIFactory().getNodeAPI(contentHeld).copyNode(postBody);
|
|
||||||
|
|
||||||
STEP("Check the request failed.");
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary("Permission was denied");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given active content on hold
|
|
||||||
* When I try to move the content
|
|
||||||
* Then I am not successful
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void moveFrozenFile() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Move frozen file");
|
|
||||||
getRestAPIFactory().getNodeAPI(contentHeld).move(createBodyForMoveCopy(folderModel.getNodeRef()));
|
|
||||||
|
|
||||||
STEP("Check the request failed.");
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary("Frozen content can't be moved.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a record folder with a frozen record and another record not held
|
|
||||||
* When I update the record folder and make the records as vital
|
|
||||||
* Then I am successful and the records not held are marked as vital
|
|
||||||
* And the frozen nodes have the vital record search properties updated
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void updateRecordFolderVitalProperties()
|
|
||||||
{
|
|
||||||
STEP("Update the vital record properties for the record folder");
|
|
||||||
// Create the record folder properties to update
|
|
||||||
RecordFolder recordFolderToUpdate = RecordFolder.builder()
|
|
||||||
.properties(RecordFolderProperties.builder()
|
|
||||||
.vitalRecordIndicator(true)
|
|
||||||
.reviewPeriod(new ReviewPeriod("month", "1"))
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Update the record folder
|
|
||||||
RecordFolder updatedRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder
|
|
||||||
(recordFolderToUpdate,
|
|
||||||
recordFolder.getId());
|
|
||||||
assertStatusCode(OK);
|
|
||||||
assertTrue(updatedRecordFolder.getAspectNames().contains(ASPECTS_VITAL_RECORD_DEFINITION));
|
|
||||||
|
|
||||||
STEP("Check the frozen record was not marked as vital");
|
|
||||||
recordFrozen = getRestAPIFactory().getRecordsAPI().getRecord(recordFrozen.getId());
|
|
||||||
assertFalse(recordFrozen.getAspectNames().contains(ASPECTS_VITAL_RECORD));
|
|
||||||
assertTrue(recordFrozen.getProperties().getRecordSearchVitalRecordReviewPeriod().contains("month"));
|
|
||||||
assertTrue(recordFrozen.getProperties().getRecordSearchVitalRecordReviewPeriodExpression().contains("1"));
|
|
||||||
|
|
||||||
STEP("Check the record not held was marked as vital");
|
|
||||||
recordNotHeld = getRestAPIFactory().getRecordsAPI().getRecord(recordNotHeld.getId());
|
|
||||||
assertTrue(recordNotHeld.getAspectNames().contains(ASPECTS_VITAL_RECORD));
|
|
||||||
assertNotNull(recordNotHeld.getProperties().getReviewAsOf());
|
|
||||||
assertTrue(recordNotHeld.getProperties().getRecordSearchVitalRecordReviewPeriod().contains("month"));
|
|
||||||
assertTrue(recordNotHeld.getProperties().getRecordSearchVitalRecordReviewPeriodExpression().contains("1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a record folder with a frozen record and another record not held
|
|
||||||
* When I add a disposition schedule
|
|
||||||
* Then I am successful
|
|
||||||
* And the record search disposition schedule properties are updated
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void createDispositionScheduleOnCategoryWithHeldChildren()
|
|
||||||
{
|
|
||||||
STEP("Create a retention schedule on the category with frozen children");
|
|
||||||
RecordCategory categoryWithRS = getRestAPIFactory().getRecordCategoryAPI()
|
|
||||||
.getRecordCategory(recordFolder.getParentId());
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(categoryWithRS.getName(), false);
|
|
||||||
dispositionScheduleService.addCutOffImmediatelyStep(categoryWithRS.getName());
|
|
||||||
dispositionScheduleService.addDestroyWithGhostingImmediatelyAfterCutOff(categoryWithRS.getName());
|
|
||||||
|
|
||||||
STEP("Check the record folder has a disposition schedule");
|
|
||||||
RecordFolder folderWithRS = getRestAPIFactory().getRecordFolderAPI().getRecordFolder(recordFolder.getId());
|
|
||||||
assertNotNull(folderWithRS.getProperties().getRecordSearchDispositionAuthority());
|
|
||||||
assertNotNull(folderWithRS.getProperties().getRecordSearchDispositionInstructions());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a record category with a disposition schedule applied to records
|
|
||||||
* And the disposition schedule has a retain step immediately and destroy step immediately
|
|
||||||
* And a complete record added to one hold
|
|
||||||
* When I execute the retain action
|
|
||||||
* Then the action is executed
|
|
||||||
* And the record search disposition schedule properties are updated
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void retainActionOnFrozenHeldRecords()
|
|
||||||
{
|
|
||||||
STEP("Add a category with a disposition schedule.");
|
|
||||||
categoryWithRS = createRootCategory(getRandomName("CategoryWithRS"));
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(categoryWithRS.getName(), true);
|
|
||||||
dispositionScheduleService.addRetainAfterPeriodStep(categoryWithRS.getName(), "immediately");
|
|
||||||
dispositionScheduleService.addDestroyWithGhostingImmediatelyAfterCutOff(categoryWithRS.getName());
|
|
||||||
|
|
||||||
STEP("Create record folder with a record.");
|
|
||||||
RecordCategoryChild folder = createFolder(categoryWithRS.getId(), getRandomName("RecFolder"));
|
|
||||||
Record record = createElectronicRecord(folder.getId(), getRandomName("elRecord"));
|
|
||||||
completeRecord(record.getId());
|
|
||||||
|
|
||||||
STEP("Add the record to the hold");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(record.getId()).build(), hold.getId());
|
|
||||||
|
|
||||||
STEP("Execute the retain action");
|
|
||||||
rmRolesAndActionsAPI.executeAction(getAdminUser().getUsername(), getAdminUser().getPassword(), record.getName(),
|
|
||||||
RM_ACTIONS.END_RETENTION, null, SC_INTERNAL_SERVER_ERROR);
|
|
||||||
|
|
||||||
STEP("Check the record search disposition properties");
|
|
||||||
Record recordUpdated = getRestAPIFactory().getRecordsAPI().getRecord(record.getId());
|
|
||||||
assertTrue(recordUpdated.getProperties().getRecordSearchDispositionActionName()
|
|
||||||
.contains(RM_ACTIONS.END_RETENTION.getAction()));
|
|
||||||
assertTrue(recordUpdated.getProperties().getRecordSearchDispositionPeriod().contains("immediately"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Hold createHold(String parentId, Hold hold, UserModel user)
|
|
||||||
{
|
|
||||||
FilePlanAPI filePlanAPI = getRestAPIFactory().getFilePlansAPI(user);
|
|
||||||
return filePlanAPI.createHold(hold, parentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpPreventActionsOnFrozenContent()
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(holdNodeRef);
|
|
||||||
dataSite.usingAdmin().deleteSite(testSite);
|
|
||||||
deleteRecordCategory(recordFolder.getParentId());
|
|
||||||
deleteRecordCategory(categoryWithRS.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -52,7 +52,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.hold.v0.HoldEntry;
|
import org.alfresco.rest.rm.community.model.hold.HoldEntry;
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
import org.alfresco.rest.rm.community.model.record.Record;
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||||
|
|||||||
@@ -1,374 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.hold;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.model.RestNodeAssociationModelCollection;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.Hold;
|
|
||||||
import org.alfresco.rest.rm.community.model.hold.HoldChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.rest.rm.community.utils.CoreUtil;
|
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* V1 API tests for removing content/record folder/record from holds
|
|
||||||
*
|
|
||||||
* @author Damian Ujma
|
|
||||||
*/
|
|
||||||
public class RemoveFromHoldsV1Tests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private static final String HOLD_ONE = "HOLD_ONE" + generateTestPrefix(RemoveFromHoldsV1Tests.class);
|
|
||||||
private static final String HOLD_TWO = "HOLD_TWO" + generateTestPrefix(RemoveFromHoldsV1Tests.class);
|
|
||||||
private static final String ACCESS_DENIED_ERROR_MESSAGE = "Access Denied. You do not have the appropriate " +
|
|
||||||
"permissions to perform this operation.";
|
|
||||||
|
|
||||||
private SiteModel testSite;
|
|
||||||
private SiteModel privateSite;
|
|
||||||
private String holdNodeRefOne;
|
|
||||||
private FileModel contentHeld;
|
|
||||||
private FileModel contentAddToManyHolds;
|
|
||||||
private List<String> holdsListRef = new ArrayList<>();
|
|
||||||
private final Set<UserModel> usersToBeClean = new HashSet<>();
|
|
||||||
private final Set<String> nodesToBeClean = new HashSet<>();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleService roleService;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForRemoveContentFromHold()
|
|
||||||
{
|
|
||||||
STEP("Create two holds.");
|
|
||||||
|
|
||||||
holdNodeRefOne = createHold(FILE_PLAN_ALIAS,
|
|
||||||
Hold.builder().name(HOLD_ONE).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(),
|
|
||||||
getAdminUser()).getId();
|
|
||||||
String holdNodeRefTwo = createHold(FILE_PLAN_ALIAS,
|
|
||||||
Hold.builder().name(HOLD_TWO).description(HOLD_DESCRIPTION).reason(HOLD_REASON).build(),
|
|
||||||
getAdminUser()).getId();
|
|
||||||
holdsListRef = asList(holdNodeRefOne, holdNodeRefTwo);
|
|
||||||
|
|
||||||
STEP("Create test files.");
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
|
||||||
contentHeld = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
contentAddToManyHolds = dataContent.usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
STEP("Add content to the holds.");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(contentHeld.getNodeRefWithoutVersion()).build(), holdNodeRefOne);
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(contentAddToManyHolds.getNodeRefWithoutVersion()).build(),
|
|
||||||
holdNodeRefOne);
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(contentAddToManyHolds.getNodeRefWithoutVersion()).build(),
|
|
||||||
holdNodeRefTwo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valid nodes to be removed from hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "validNodesToRemoveFromHold")
|
|
||||||
public Object[][] getValidNodesToRemoveFromHold()
|
|
||||||
{
|
|
||||||
//create electronic and nonElectronic record in record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
nodesToBeClean.add(recordFolder.getParentId());
|
|
||||||
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder.getId(),
|
|
||||||
getFile
|
|
||||||
(IMAGE_FILE));
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(),
|
|
||||||
recordFolder.getId());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RecordCategoryChild folderToHeld = createCategoryFolderInFilePlan();
|
|
||||||
nodesToBeClean.add(folderToHeld.getParentId());
|
|
||||||
Stream.of(electronicRecord.getId(), nonElectronicRecord.getId(), folderToHeld.getId())
|
|
||||||
.forEach(id -> getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(id).build(), holdNodeRefOne));
|
|
||||||
|
|
||||||
return new String[][]
|
|
||||||
{ // record folder
|
|
||||||
{ folderToHeld.getId() },
|
|
||||||
//electronic record
|
|
||||||
{ electronicRecord.getId() },
|
|
||||||
// non electronic record
|
|
||||||
{ nonElectronicRecord.getId() },
|
|
||||||
// document from collaboration site
|
|
||||||
{ contentHeld.getNodeRefWithoutVersion() },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given content/record folder/record that is held
|
|
||||||
* And the corresponding hold
|
|
||||||
* When I use the existing REST API to remove the node from the hold
|
|
||||||
* Then the node is removed from the hold
|
|
||||||
* And is no longer frozen
|
|
||||||
*/
|
|
||||||
@Test(dataProvider = "validNodesToRemoveFromHold")
|
|
||||||
public void removeContentFromHold(String nodeId) throws Exception
|
|
||||||
{
|
|
||||||
STEP("Remove node from hold");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser()).deleteHoldChild(holdNodeRefOne, nodeId);
|
|
||||||
|
|
||||||
STEP("Check the node is not held");
|
|
||||||
assertFalse(hasAspect(nodeId, FROZEN_ASPECT));
|
|
||||||
|
|
||||||
STEP("Check node is not in any hold");
|
|
||||||
RestNodeAssociationModelCollection holdsEntries = getRestAPIFactory()
|
|
||||||
.getNodeAPI(CoreUtil.toContentModel(nodeId)).usingParams("where=(assocType='rma:frozenContent')")
|
|
||||||
.getParents();
|
|
||||||
assertTrue(holdsEntries.getEntries().isEmpty(), "Content held is still added to a hold.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given active content that is held on many holds
|
|
||||||
* When I use the existing REST API to remove the active content from one hold
|
|
||||||
* Then the active content is removed from the specific hold
|
|
||||||
* And is frozen
|
|
||||||
* And in the other holds
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void removeContentAddedToManyHolds() throws Exception
|
|
||||||
{
|
|
||||||
STEP("Remove content from hold. ");
|
|
||||||
|
|
||||||
getRestAPIFactory().getHoldsAPI(getAdminUser())
|
|
||||||
.deleteHoldChild(holdNodeRefOne, contentAddToManyHolds.getNodeRefWithoutVersion());
|
|
||||||
|
|
||||||
STEP("Check the content is held. ");
|
|
||||||
assertTrue(hasAspect(contentAddToManyHolds.getNodeRefWithoutVersion(), FROZEN_ASPECT));
|
|
||||||
|
|
||||||
STEP("Check node is in hold HOLD_TWO. ");
|
|
||||||
|
|
||||||
RestNodeAssociationModelCollection holdsEntries = getRestAPIFactory()
|
|
||||||
.getNodeAPI(CoreUtil.toContentModel(contentAddToManyHolds.getNodeRefWithoutVersion()))
|
|
||||||
.usingParams("where=(assocType='rma:frozenContent')").getParents();
|
|
||||||
assertFalse(holdsEntries.getEntries().isEmpty(), "Content held is not held after removing from one hold.");
|
|
||||||
assertTrue(holdsEntries.getEntries().stream()
|
|
||||||
.anyMatch(restNodeModel -> restNodeModel.getModel().getName().equals(HOLD_TWO)),
|
|
||||||
"Content held is not held after removing from one hold.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data provider with user without right permission or capability to remove from hold a specific node
|
|
||||||
*
|
|
||||||
* @return user model and the node ref to be removed from hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "userWithoutPermissionForRemoveFromHold")
|
|
||||||
public Object[][] getUserWithoutPermissionForAddToHold()
|
|
||||||
{
|
|
||||||
//create record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
nodesToBeClean.add(recordFolder.getParentId());
|
|
||||||
UserModel user = roleService.createUserWithRMRole(ROLE_RM_MANAGER.roleId);
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(holdNodeRefOne, user, PERMISSION_FILING);
|
|
||||||
//create files that will be removed from hold
|
|
||||||
FileModel contentNoHoldPerm = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
FileModel contentNoHoldCap = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
FileModel privateFile = dataContent.usingAdmin().usingSite(privateSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
//add files to hold
|
|
||||||
asList(recordFolder.getId(), contentNoHoldCap.getNodeRefWithoutVersion(),
|
|
||||||
contentNoHoldPerm.getNodeRefWithoutVersion(), privateFile.getNodeRefWithoutVersion())
|
|
||||||
.forEach(id -> getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(id).build(), holdNodeRefOne));
|
|
||||||
|
|
||||||
return new Object[][]
|
|
||||||
{
|
|
||||||
// user with read permission on the content, with remove from hold capability and without
|
|
||||||
// filling permission on a hold
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole.SiteCollaborator,
|
|
||||||
holdNodeRefOne, UserRoles.ROLE_RM_MANAGER, PERMISSION_READ_RECORDS),
|
|
||||||
contentNoHoldPerm.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
// user with write permission on the content, filling permission on a hold without remove from
|
|
||||||
// hold capability
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole
|
|
||||||
.SiteCollaborator,
|
|
||||||
holdNodeRefOne, UserRoles.ROLE_RM_POWER_USER, PERMISSION_FILING),
|
|
||||||
contentNoHoldCap.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
//user without read permission on RM record folder
|
|
||||||
{
|
|
||||||
user, recordFolder.getId()
|
|
||||||
},
|
|
||||||
//user without read permission over the content from the private site
|
|
||||||
{
|
|
||||||
user, privateFile.getNodeRefWithoutVersion()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given node on hold in a single hold location
|
|
||||||
* And the user does not have sufficient permissions or capabilities to remove the node from the hold
|
|
||||||
* When the user tries to remove the node from the hold
|
|
||||||
* Then it's unsuccessful
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Test(dataProvider = "userWithoutPermissionForRemoveFromHold")
|
|
||||||
public void removeFromHoldWithUserWithoutPermission(UserModel userModel, String nodeIdToBeRemoved) throws Exception
|
|
||||||
{
|
|
||||||
STEP("Update the list of users to be deleted after running the tests");
|
|
||||||
usersToBeClean.add(userModel);
|
|
||||||
|
|
||||||
STEP("Remove node from hold with user without right permission or capability");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userModel).deleteHoldChild(holdNodeRefOne, nodeIdToBeRemoved);
|
|
||||||
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertLastError().containsSummary(ACCESS_DENIED_ERROR_MESSAGE);
|
|
||||||
|
|
||||||
STEP("Check node is frozen.");
|
|
||||||
assertTrue(hasAspect(nodeIdToBeRemoved, FROZEN_ASPECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data provider with user with right permission or capability to remove from hold a specific node
|
|
||||||
*
|
|
||||||
* @return user model and the node ref to be removed from hold
|
|
||||||
*/
|
|
||||||
@DataProvider(name = "userWithPermissionForRemoveFromHold")
|
|
||||||
public Object[][] getUserWithPermissionForAddToHold()
|
|
||||||
{
|
|
||||||
//create record folder
|
|
||||||
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
|
|
||||||
nodesToBeClean.add(recordFolder.getParentId());
|
|
||||||
UserModel user = roleService.createUserWithRMRoleAndRMNodePermission(ROLE_RM_MANAGER.roleId,
|
|
||||||
recordFolder.getId(),
|
|
||||||
PERMISSION_READ_RECORDS);
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(holdNodeRefOne, user, PERMISSION_FILING);
|
|
||||||
//create file that will be removed from hold
|
|
||||||
FileModel contentPermission = dataContent.usingAdmin().usingSite(testSite)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
//add files to hold
|
|
||||||
asList(recordFolder.getId(), contentPermission.getNodeRefWithoutVersion())
|
|
||||||
.forEach(id -> getRestAPIFactory()
|
|
||||||
.getHoldsAPI(getAdminUser())
|
|
||||||
.addChildToHold(HoldChild.builder().id(id).build(), holdNodeRefOne));
|
|
||||||
|
|
||||||
return new Object[][]
|
|
||||||
{
|
|
||||||
// user with write permission on the content
|
|
||||||
{
|
|
||||||
roleService.createUserWithSiteRoleRMRoleAndPermission(testSite, UserRole.SiteConsumer,
|
|
||||||
holdNodeRefOne, UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING),
|
|
||||||
contentPermission.getNodeRefWithoutVersion()
|
|
||||||
},
|
|
||||||
//user with read permission on RM record folder
|
|
||||||
{
|
|
||||||
user, recordFolder.getId()
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProvider = "userWithPermissionForRemoveFromHold")
|
|
||||||
public void removeFromHoldWithUserWithPermission(UserModel userModel, String nodeIdToBeRemoved) throws Exception
|
|
||||||
{
|
|
||||||
STEP("Update the list of users to be deleted after running the tests");
|
|
||||||
usersToBeClean.add(userModel);
|
|
||||||
|
|
||||||
STEP("Remove node from hold with user with right permission and capability");
|
|
||||||
getRestAPIFactory().getHoldsAPI(userModel).deleteHoldChild(holdNodeRefOne, nodeIdToBeRemoved);
|
|
||||||
|
|
||||||
STEP("Check node is not frozen.");
|
|
||||||
assertFalse(hasAspect(nodeIdToBeRemoved, FROZEN_ASPECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
private Hold createHold(String parentId, Hold hold, UserModel user)
|
|
||||||
{
|
|
||||||
FilePlanAPI filePlanAPI = getRestAPIFactory().getFilePlansAPI(user);
|
|
||||||
return filePlanAPI.createHold(hold, parentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpRemoveContentFromHold()
|
|
||||||
{
|
|
||||||
holdsListRef.forEach(holdRef -> getRestAPIFactory().getHoldsAPI(getAdminUser()).deleteHold(holdRef));
|
|
||||||
dataSite.usingAdmin().deleteSite(testSite);
|
|
||||||
dataSite.usingAdmin().deleteSite(privateSite);
|
|
||||||
usersToBeClean.forEach(user -> getDataUser().usingAdmin().deleteUser(user));
|
|
||||||
nodesToBeClean.forEach(this::deleteRecordCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import java.util.Collections;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.custom.CustomDefinitions;
|
|
||||||
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.CustomDefinitionsAPI;
|
|
||||||
import org.alfresco.rest.v0.HoldsAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordCategoriesAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
|
||||||
import static org.apache.commons.httpclient.HttpStatus.SC_OK;
|
|
||||||
/**
|
|
||||||
* Add Relationship tests
|
|
||||||
* @author Kavit Shah
|
|
||||||
*/
|
|
||||||
public class AddRelationshipTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(AddRelationshipTests.class);
|
|
||||||
private final String CATEGORY = TEST_PREFIX + "category";
|
|
||||||
private final String HOLD1 = TEST_PREFIX + "hold1";
|
|
||||||
private final String FOLDER = TEST_PREFIX + "RM_2709_1814_FOLDER";
|
|
||||||
private final String RECORD1 = TEST_PREFIX + "RM_2709_1814_RECORD_ONE";
|
|
||||||
private final String RECORD2 = TEST_PREFIX + "RM_1814_RECORD_TWO";
|
|
||||||
private String hold1NodeRef;
|
|
||||||
@Autowired
|
|
||||||
private HoldsAPI holdsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
@Autowired
|
|
||||||
private CustomDefinitionsAPI customDefinitionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordCategoriesAPI recordCategoriesAPI;
|
|
||||||
|
|
||||||
@Test (priority = 1)
|
|
||||||
@AlfrescoTest (jira = "RM-1814")
|
|
||||||
public void addRelationshipToHoldRecord()
|
|
||||||
{
|
|
||||||
String CATEGORY_RELATIONSHIP = CATEGORY + "To Hold";
|
|
||||||
//create RM site
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
//create record category, record folder and records
|
|
||||||
RecordCategory recordCategory = createCategoryIfDoesNotExist(CATEGORY_RELATIONSHIP);
|
|
||||||
RecordCategoryChild recordCategoryChild = createRecordFolderInCategory(FOLDER, recordCategory);
|
|
||||||
|
|
||||||
createRecordItems(recordCategoryChild, RECORD1);
|
|
||||||
Record record2 = createRecordItems(recordCategoryChild, RECORD2);
|
|
||||||
|
|
||||||
//create Hold
|
|
||||||
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(), HOLD1, HOLD_REASON, HOLD_DESCRIPTION);
|
|
||||||
//add RECORD2 to holds
|
|
||||||
holdsAPI.addItemsToHolds(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
SC_OK, Collections.singletonList(record2.getId()),
|
|
||||||
Collections.singletonList(hold1NodeRef));
|
|
||||||
|
|
||||||
// get records nodeRefs
|
|
||||||
String elRecordFullName1 = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, RECORD1);
|
|
||||||
String elRecordNodeRef1 = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName1, "/" + CATEGORY_RELATIONSHIP + "/" + FOLDER);
|
|
||||||
|
|
||||||
String elRecordFullName2 = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, RECORD2);
|
|
||||||
String elRecordNodeRef2 = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName2, "/" + CATEGORY_RELATIONSHIP + "/" + FOLDER);
|
|
||||||
|
|
||||||
// create Relationship
|
|
||||||
customDefinitionsAPI.createRelationship(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
SC_INTERNAL_SERVER_ERROR,
|
|
||||||
formatNodeRef(elRecordNodeRef1),
|
|
||||||
formatNodeRef(elRecordNodeRef2),
|
|
||||||
CustomDefinitions.ATTACHMENT);
|
|
||||||
|
|
||||||
//delete preconditions
|
|
||||||
deletePrecondition();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test (priority = 2)
|
|
||||||
@AlfrescoTest (jira = "RM-1874")
|
|
||||||
public void deleteRelationship()
|
|
||||||
{
|
|
||||||
String CATEGORY_RELATIONSHIP = CATEGORY + "deleteRelationship";
|
|
||||||
// create RM site
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
// create record category, record folder and records
|
|
||||||
RecordCategory recordCategory = createCategoryIfDoesNotExist(CATEGORY_RELATIONSHIP);
|
|
||||||
RecordCategoryChild recordCategoryChild = createRecordFolderInCategory(FOLDER, recordCategory);
|
|
||||||
|
|
||||||
createRecordItems(recordCategoryChild, RECORD1);
|
|
||||||
createRecordItems(recordCategoryChild, RECORD2);
|
|
||||||
|
|
||||||
// Add Relationship
|
|
||||||
String elRecordFullName1 = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, RECORD1);
|
|
||||||
String elRecordNodeRef1 = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName1, "/" + CATEGORY_RELATIONSHIP + "/" + FOLDER);
|
|
||||||
|
|
||||||
String elRecordFullName2 = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, RECORD2);
|
|
||||||
String elRecordNodeRef2 = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName2, "/" + CATEGORY_RELATIONSHIP + "/" + FOLDER);
|
|
||||||
|
|
||||||
customDefinitionsAPI.createRelationship(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
formatNodeRef(elRecordNodeRef1),
|
|
||||||
formatNodeRef(elRecordNodeRef2),
|
|
||||||
CustomDefinitions.ATTACHMENT);
|
|
||||||
|
|
||||||
// Get RelationshipDetails
|
|
||||||
JSONObject relationshipDetails = customDefinitionsAPI.getRelationshipDetails(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
formatNodeRef(elRecordNodeRef1));
|
|
||||||
|
|
||||||
// Delete RelationshipDetails
|
|
||||||
customDefinitionsAPI.deleteRelationship(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
formatNodeRef(elRecordNodeRef1),
|
|
||||||
formatNodeRef(elRecordNodeRef2),
|
|
||||||
relationshipUniqueName(relationshipDetails));
|
|
||||||
|
|
||||||
// delete category
|
|
||||||
tearDown(CATEGORY_RELATIONSHIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deletePrecondition()
|
|
||||||
{
|
|
||||||
holdsAPI.deleteHold(getAdminUser(), hold1NodeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Record createRecordItems(RecordCategoryChild recordCategoryChild, String record) {
|
|
||||||
return createElectronicRecord(recordCategoryChild.getId(), record);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordCategory createCategoryIfDoesNotExist(String CATEGORY_ALL) {
|
|
||||||
return createRootCategory(getDataUser().usingAdmin().getAdminUser(), CATEGORY_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordCategoryChild createRecordFolderInCategory(String FOLDER_SEARCH, RecordCategory recordCategory) {
|
|
||||||
return createFolder(getDataUser().usingAdmin().getAdminUser(), recordCategory.getId(), FOLDER_SEARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatNodeRef(String nodeRef) {
|
|
||||||
return StringUtils.remove(nodeRef,"workspace://SpacesStore/");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tearDown(String category) {
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, FOLDER);
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, category);
|
|
||||||
recordCategoriesAPI.deleteCategory(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), category);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String relationshipUniqueName(JSONObject relationshipDetails) {
|
|
||||||
return relationshipDetails.getJSONObject("data").getJSONArray("items").getJSONObject(0).getJSONObject("node")
|
|
||||||
.get("relationshipUniqueName").toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
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.createElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
|
||||||
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.requests.gscore.api.RecordFolderAPI;
|
|
||||||
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 org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
/**
|
|
||||||
* This class contains the tests for
|
|
||||||
* CreateElectronicRecordsTests Action REST API
|
|
||||||
*
|
|
||||||
* @author Shishuraj Bisht
|
|
||||||
*/
|
|
||||||
public class CreateElectronicRecordsTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private RecordCategory rootCategory;
|
|
||||||
private UserModel updateUser;
|
|
||||||
/**
|
|
||||||
* data prep services
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(CreateElectronicRecordsTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
|
||||||
public void preConditions()
|
|
||||||
{
|
|
||||||
STEP("Create RM Site");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
STEP("Create root level category");
|
|
||||||
rootCategory = createRootCategory(getRandomName("Category"));
|
|
||||||
|
|
||||||
STEP("Create the record folder1 inside the rootCategory");
|
|
||||||
String recordFolder1 = createCategoryFolderInFilePlan().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test v0 methods to create and get electronic records.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest (jira = "RM-2768")
|
|
||||||
public void createElectronicRecordTest() throws Exception {
|
|
||||||
|
|
||||||
//create electronic record in record folder
|
|
||||||
String recordFolder1 = createRecordFolder(rootCategory.getId(), getRandomName("recFolder")).getId();
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
|
|
||||||
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder1, getFile(IMAGE_FILE));
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
STEP("Check the electronic record has been created");
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// Get recordsAPI instance initialised to updateUser
|
|
||||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(updateUser);
|
|
||||||
|
|
||||||
for (Record record: asList(electronicRecord)) {
|
|
||||||
recordsAPI.getRecord(record.getId());
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// Generate update metadata
|
|
||||||
String newName = getModifiedPropertyValue(record.getName());
|
|
||||||
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
|
|
||||||
String newDescription = getModifiedPropertyValue(record.getProperties().getDescription());
|
|
||||||
|
|
||||||
// Update record
|
|
||||||
recordsAPI.updateRecord(createRecordModel(newName, newDescription, newTitle), record.getId());
|
|
||||||
assertStatusCode(OK);
|
|
||||||
}
|
|
||||||
// move the record from one folder1 to folder2
|
|
||||||
STEP("Create the record folder2 inside the rootCategory");
|
|
||||||
String recordFolder2 = createCategoryFolderInFilePlan().getId();
|
|
||||||
|
|
||||||
STEP("Move record from folder1 to folder2");
|
|
||||||
RestNodeModel electronicDocRestNodeModel = getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(electronicRecord.getId()))
|
|
||||||
.move(createBodyForMoveCopy(recordFolder2));
|
|
||||||
assertStatusCode(OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getModifiedPropertyValue(String originalValue) {
|
|
||||||
/* to be used to append to modifications */
|
|
||||||
String MODIFIED_PREFIX = "modified_";
|
|
||||||
return MODIFIED_PREFIX + originalValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass (alwaysRun = true)
|
|
||||||
public void deletePreConditions() {
|
|
||||||
STEP("Delete the created rootCategory along with corresponding record folders/records present in it");
|
|
||||||
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FolderModel;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
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.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
/**
|
|
||||||
* This class contains the tests for
|
|
||||||
* Create the Document, marking them as Record, Hiding them using Site Collaborator
|
|
||||||
* The Rm_Admin user then verofy if he is able to access the documents using Rest Api
|
|
||||||
*
|
|
||||||
* @author Kavit Shah
|
|
||||||
*/
|
|
||||||
public class DeclareInPlaceRecordTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(DeclareInPlaceRecordTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
private UserModel testUser;
|
|
||||||
private UserModel RmAdminUser;
|
|
||||||
private SiteModel testSite;
|
|
||||||
private FolderModel testFolder;
|
|
||||||
/**
|
|
||||||
* data prep services
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preConditions() {
|
|
||||||
STEP("Create RM Site");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
RmAdminUser = new UserModel(RM_ADMIN,getAdminUser().getPassword());
|
|
||||||
|
|
||||||
STEP("Create collab_user user");
|
|
||||||
testUser = getDataUser().createRandomTestUser();
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
|
|
||||||
// invite collab_user to Collaboration site with Contributor role
|
|
||||||
getDataUser().addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
|
||||||
|
|
||||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-2366")
|
|
||||||
public void declareInplaceRecord() {
|
|
||||||
|
|
||||||
// Upload document in a folder in a collaboration site
|
|
||||||
FileModel uploadedDocHidden = dataContent.usingSite(testSite)
|
|
||||||
.usingUser(testUser)
|
|
||||||
.usingResource(testFolder)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
// declare uploadedDocument as record
|
|
||||||
Record uploadedRecordHidden = getRestAPIFactory().getFilesAPI(testUser).declareAsRecord(uploadedDocHidden.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
recordsAPI.hideRecord(testUser.getUsername(),testUser.getPassword(),uploadedRecordHidden.getId());
|
|
||||||
|
|
||||||
// Upload document in a folder in a collaboration site
|
|
||||||
FileModel uploadedDocWithoutHidden = dataContent.usingSite(testSite)
|
|
||||||
.usingUser(testUser)
|
|
||||||
.usingResource(testFolder)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
Record uploadedRecordWithoutHidden = getRestAPIFactory().getFilesAPI(testUser).declareAsRecord(uploadedDocWithoutHidden.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
assertTrue(isRecordChildOfUnfiledContainer(uploadedRecordHidden.getId()), uploadedRecordHidden.getId() + " doesn't exist in Unfiled Records");
|
|
||||||
assertTrue(isRecordChildOfUnfiledContainer(uploadedRecordWithoutHidden.getId()), uploadedRecordWithoutHidden.getId() + " doesn't exist in Unfiled Records");
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void deletePreConditions() {
|
|
||||||
STEP("Delete the records created in the test");
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getUnfiledContainersAPI(RmAdminUser)
|
|
||||||
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
|
||||||
.getEntries()
|
|
||||||
.stream()
|
|
||||||
.forEach(x -> getRestAPIFactory()
|
|
||||||
.getRecordsAPI()
|
|
||||||
.deleteRecord(x.getEntry().getId()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isRecordChildOfUnfiledContainer(String recordId) {
|
|
||||||
return getRestAPIFactory()
|
|
||||||
.getUnfiledContainersAPI(RmAdminUser)
|
|
||||||
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
|
||||||
.getEntries()
|
|
||||||
.stream()
|
|
||||||
.anyMatch(c -> c.getEntry().getId().equals(recordId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
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.model.unfiledcontainer.UnfiledContainer;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.rest.v0.RulesAPI;
|
|
||||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FolderModel;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
|
|
||||||
import static org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI.PARENT_ID_PARAM;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
|
|
||||||
public class DeclareInPlaceRecordsTestLevel2 extends BaseRMRestTest {
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(DeclareInPlaceRecordsTestLevel2.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
private final String RECORDS_CATEGORY_ONE = TEST_PREFIX + "category";
|
|
||||||
public static final String RECORD_FOLDER_ONE = "record-folder-one";
|
|
||||||
public static final String RECORD_CATEGORY_TWO = "record-category-two" + System.currentTimeMillis();
|
|
||||||
public static final String RECORD_FOLDER_TWO = "record-folder-two";
|
|
||||||
private final String RULE_NAME = TEST_PREFIX + "rule unfiled";
|
|
||||||
private String unfiledRecordsNodeRef;
|
|
||||||
private RecordCategory RecordCategoryOne, RecordCategoryTwo;
|
|
||||||
private RecordCategoryChild recordFolder;
|
|
||||||
private UnfiledContainer unfiledContainer;
|
|
||||||
private FolderModel testFolder;
|
|
||||||
private SiteModel testSite;
|
|
||||||
private SiteModel privateSite;
|
|
||||||
private UserModel testUser;
|
|
||||||
@Autowired
|
|
||||||
private DispositionScheduleService dispositionScheduleService;
|
|
||||||
@Autowired
|
|
||||||
private RulesAPI rulesAPI;
|
|
||||||
/**
|
|
||||||
* data prep services
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preConditions() {
|
|
||||||
STEP("Create RM Site");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given that a user is the owner of a document
|
|
||||||
* And that user has been deleted
|
|
||||||
* When admin tries to declare the document as a record
|
|
||||||
* Then the document becomes an inplace record
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira="RM-2584")
|
|
||||||
public void DeclareRecordOwnerDeleted() throws Exception {
|
|
||||||
|
|
||||||
createTestPrecondition();
|
|
||||||
|
|
||||||
// Upload document in a folder in a collaboration site
|
|
||||||
FileModel uploadedDoc = dataContent.usingSite(testSite)
|
|
||||||
.usingUser(testUser)
|
|
||||||
.usingResource(testFolder)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
// delete the test user
|
|
||||||
dataUser.deleteUser(testUser);
|
|
||||||
|
|
||||||
// declare uploadedDocument as record
|
|
||||||
getRestAPIFactory().getFilesAPI(getDataUser().getAdminUser()).declareAsRecord(uploadedDoc.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
// assert that the document is now a record
|
|
||||||
assertTrue(hasRecordAspect(uploadedDoc));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Given that a user is the owner of a document
|
|
||||||
* And that user declare the document as a record
|
|
||||||
* When admin files the record to a category that has a disposition schedule applied on records and a cut off step
|
|
||||||
* And admin completes the record so the pending record action is now Cut off
|
|
||||||
* Then user is still able to see the in place record in original share site location
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira="MNT-18558")
|
|
||||||
public void inPlaceRecordVisibilityAfterFilingToCategoryWithCutOffStep() throws Exception {
|
|
||||||
|
|
||||||
// create test precondition
|
|
||||||
createTestPrecondition(RECORDS_CATEGORY_ONE);
|
|
||||||
|
|
||||||
//create a disposition schedule on Records level with a cut off step
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(RECORDS_CATEGORY_ONE, true);
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(RECORDS_CATEGORY_ONE, "day|2", CREATED_DATE);
|
|
||||||
|
|
||||||
//create a folder in category
|
|
||||||
recordFolder = createFolder(getAdminUser(),RecordCategoryOne.getId(),RECORD_FOLDER_ONE);
|
|
||||||
|
|
||||||
// create a File to record folder rule applied on Unfiled Records container
|
|
||||||
fileToRuleAppliedOnUnfiledRecords();
|
|
||||||
|
|
||||||
//create a new test user
|
|
||||||
UserModel testUser = createSiteManager();
|
|
||||||
|
|
||||||
// upload a new document as the user and declare the document as record
|
|
||||||
FileModel uploadedDoc = dataContent.usingSite(privateSite)
|
|
||||||
.usingUser(testUser)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
Record uploadedRecord = getRestAPIFactory().getFilesAPI(getDataUser().getAdminUser()).declareAsRecord(uploadedDoc.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
//Complete the record as admin to be sure that pending action is now Cut off
|
|
||||||
recordsAPI.completeRecord(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), uploadedRecord.getName());
|
|
||||||
|
|
||||||
// As test user navigate to collaboration site documents library and check that the record is still visible
|
|
||||||
dataContent.usingAdmin().usingSite(privateSite).assertContentExist();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Create a user called test
|
|
||||||
* Create a collaboration site
|
|
||||||
* Add the user to the collaboration site as consumer
|
|
||||||
* Create an RM site
|
|
||||||
* In RM, create a new categories under file plan with a cut off step set after an event happens
|
|
||||||
* Under the previously created category create a folder
|
|
||||||
* Set READ-ONLY permission for test user for the folder previously created (the user does not have Read
|
|
||||||
* permissions to the category containing the folder)
|
|
||||||
* In the collaboration site create two files
|
|
||||||
* File as record the first file
|
|
||||||
* Log in with test user and check if he can still see the two files in the collaboration site
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest (jira = "MNT-22138")
|
|
||||||
public void filesVisibilityAfterFilingToCategoryWithCutOffAfterEventStep() throws Exception {
|
|
||||||
|
|
||||||
//create a category
|
|
||||||
RecordCategoryTwo = createRootCategory(RECORD_CATEGORY_TWO);
|
|
||||||
|
|
||||||
//create a disposition schedule on Records level with a cut off step
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(RECORD_CATEGORY_TWO, true);
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(RECORD_CATEGORY_TWO, "day|2", CREATED_DATE);
|
|
||||||
|
|
||||||
//create a folder in category
|
|
||||||
recordFolder = createFolder(getAdminUser(),RecordCategoryTwo.getId(),RECORD_FOLDER_TWO);
|
|
||||||
|
|
||||||
//create a new test user
|
|
||||||
UserModel siteConsumer = getDataUser().createRandomTestUser();
|
|
||||||
getDataUser().addUserToSite(siteConsumer,privateSite,UserRole.SiteConsumer);
|
|
||||||
|
|
||||||
// give read permissions to test user
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(recordFolder.getId(), siteConsumer, PERMISSION_READ_RECORDS);
|
|
||||||
|
|
||||||
// create two documents
|
|
||||||
FileModel testFile = dataContent.usingSite(new SiteModel(privateSite.getTitle()))
|
|
||||||
.usingAdmin()
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
FileModel testFileNotFiled = dataContent.usingSite(new SiteModel(privateSite.getTitle()))
|
|
||||||
.usingAdmin()
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
// file one of the documents as record
|
|
||||||
getRestAPIFactory().getFilesAPI()
|
|
||||||
.usingParams(String.format("%s=%s", PARENT_ID_PARAM, recordFolder.getId()))
|
|
||||||
.declareAsRecord(testFile.getNodeRefWithoutVersion());
|
|
||||||
getRestAPIFactory().getRmRestWrapper().assertStatusCodeIs(CREATED);
|
|
||||||
|
|
||||||
// As test user navigate to collaboration site documents library and check that both of the documents are
|
|
||||||
// visible
|
|
||||||
STEP("Verify the document in collaboration site is now a record");
|
|
||||||
Assert.assertTrue(hasRecordAspect(testFile), "File should have record aspect");
|
|
||||||
Assert.assertFalse(hasRecordAspect(testFileNotFiled), "File should not have record aspect");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTestPrecondition(String categoryName) {
|
|
||||||
|
|
||||||
// create "rm admin" user if it does not exist and assign it to RM Administrator role
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
RM_ADMIN, DEFAULT_PASSWORD, "Administrator");
|
|
||||||
|
|
||||||
// create category
|
|
||||||
STEP("Create category");
|
|
||||||
RecordCategoryOne = createRootCategory(categoryName,"Title");
|
|
||||||
|
|
||||||
unfiledContainer = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS);
|
|
||||||
|
|
||||||
unfiledRecordsNodeRef = NODE_PREFIX + unfiledContainer.getId();
|
|
||||||
}
|
|
||||||
private void createTestPrecondition() {
|
|
||||||
STEP("Create collab_user user");
|
|
||||||
testUser = getDataUser().createRandomTestUser();
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
|
|
||||||
// invite collab_user to Collaboration site with Contributor role
|
|
||||||
getDataUser().addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
|
||||||
|
|
||||||
testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
|
|
||||||
}
|
|
||||||
private void fileToRuleAppliedOnUnfiledRecords() {
|
|
||||||
unfiledRecordsRuleTeardown();
|
|
||||||
|
|
||||||
// create a rule
|
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title(RULE_NAME)
|
|
||||||
.description(RULE_NAME)
|
|
||||||
.createRecordPath(false)
|
|
||||||
.path("/" + RECORDS_CATEGORY_ONE + "/" + RECORD_FOLDER_ONE)
|
|
||||||
.runInBackground(true)
|
|
||||||
.actions(asList(ActionsOnRule.FILE_TO.getActionValue()));
|
|
||||||
|
|
||||||
// create a rule on unfiledRecords
|
|
||||||
rulesAPI.createRule(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), unfiledRecordsNodeRef, ruleDefinition);
|
|
||||||
}
|
|
||||||
private void unfiledRecordsRuleTeardown() {
|
|
||||||
rulesAPI.deleteAllRulesOnContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), unfiledRecordsNodeRef);
|
|
||||||
}
|
|
||||||
public UserModel createSiteManager() {
|
|
||||||
UserModel siteManager = getDataUser().createRandomTestUser();
|
|
||||||
getDataUser().addUserToSite(siteManager, privateSite, UserRole.SiteManager);
|
|
||||||
return siteManager;
|
|
||||||
}
|
|
||||||
@AfterClass
|
|
||||||
public void cleanupCategory() {
|
|
||||||
unfiledRecordsRuleTeardown();
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, RECORD_FOLDER_ONE);
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, RecordCategoryOne.getName());
|
|
||||||
deleteRecordCategory(RecordCategoryOne.getId());
|
|
||||||
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, RECORD_FOLDER_TWO);
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, RecordCategoryTwo.getName());
|
|
||||||
deleteRecordCategory(RecordCategoryTwo.getId());
|
|
||||||
|
|
||||||
dataSite.usingAdmin().deleteSite(privateSite);
|
|
||||||
dataSite.usingAdmin().deleteSite(testSite);
|
|
||||||
|
|
||||||
UnfiledContainerChildCollection unfiledContainerChildCollection = getRestAPIFactory()
|
|
||||||
.getUnfiledContainersAPI().getUnfiledContainerChildren(unfiledContainer.getId());
|
|
||||||
|
|
||||||
unfiledContainerChildCollection.getEntries().forEach(unfiledChild ->
|
|
||||||
{
|
|
||||||
if (unfiledChild.getEntry().getIsRecord())
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getRecordsAPI().deleteRecord(unfiledChild.getEntry().getId());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledChild.getEntry().getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -75,7 +75,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Ignore;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -291,6 +290,7 @@ public class DeleteRecordTests extends BaseRMRestTest
|
|||||||
* Then it is still possible to view the content of the copy
|
* Then it is still possible to view the content of the copy
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
@Test (description = "Destroying record doesn't delete the content for the associated copy")
|
@Test (description = "Destroying record doesn't delete the content for the associated copy")
|
||||||
@AlfrescoTest (jira = "MNT-20145")
|
@AlfrescoTest (jira = "MNT-20145")
|
||||||
public void destroyOfRecord()
|
public void destroyOfRecord()
|
||||||
@@ -332,6 +332,7 @@ public class DeleteRecordTests extends BaseRMRestTest
|
|||||||
getNodeContent(copy.getId());
|
getNodeContent(copy.getId());
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|||||||
@@ -1,226 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
|
||||||
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.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.apache.chemistry.opencmis.client.api.CmisObject;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
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.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.v0.APIUtils.convertHTTPResponseToJSON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
|
|
||||||
public class FileUnfiledRecordsTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(FileUnfiledRecordsTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
public static final String NODE_REF_WORKSPACE_SPACES_STORE = "workspace://SpacesStore/";
|
|
||||||
private UserModel testUser;
|
|
||||||
private SiteModel testSite;
|
|
||||||
private String unfiledRecordFolderId;
|
|
||||||
private UserModel RmAdminUser;
|
|
||||||
private RecordCategory rootCategory;
|
|
||||||
private RecordCategoryChild recordFolder;
|
|
||||||
private final String recordName = "RM-2790 record";
|
|
||||||
private final String recordTitle = recordName + " title";
|
|
||||||
private final String recordDescription = recordName + " description";
|
|
||||||
/**
|
|
||||||
* data prep services
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preConditions() {
|
|
||||||
|
|
||||||
STEP("Create RM Site");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
RmAdminUser = new UserModel(RM_ADMIN, getAdminUser().getPassword());
|
|
||||||
|
|
||||||
STEP("Create collab_user user");
|
|
||||||
testUser = getDataUser().createRandomTestUser();
|
|
||||||
testSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
|
|
||||||
// invite collab_user to Collaboration site with Contributor role
|
|
||||||
getDataUser().addUserToSite(testUser, testSite, UserRole.SiteContributor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-2790")
|
|
||||||
public void fileUnfiledRecords() throws Exception {
|
|
||||||
|
|
||||||
STEP("Upload the document to test site and then make it reacord");
|
|
||||||
// Upload document in a folder in a collaboration site
|
|
||||||
FileModel uploadedDocbyCollabUser = dataContent.usingSite(testSite)
|
|
||||||
.usingUser(testUser)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
// declare uploadedDocument as record
|
|
||||||
Record uploadedDocRecordbyCollabUser = getRestAPIFactory().getFilesAPI(testUser)
|
|
||||||
.declareAsRecord(uploadedDocbyCollabUser.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
STEP("Create root level category");
|
|
||||||
rootCategory = createRootCategory(RmAdminUser, getRandomName("Category"));
|
|
||||||
|
|
||||||
STEP("Create the record folder inside the rootCategory");
|
|
||||||
recordFolder = createFolder(RmAdminUser, rootCategory.getId(), getRandomName("Folder"));
|
|
||||||
|
|
||||||
STEP("Create a non-electronic record by completing some of the fields");
|
|
||||||
Map<Enum<?>, String> non_electronic_records_properties = new HashMap<>();
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.TITLE, recordTitle);
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.DESCRIPTION, recordDescription);
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.NAME, recordName);
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.PHYSICAL_SIZE, "");
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.NUMBER_OF_COPIES, "");
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.SHELF, "");
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.STORAGE_LOCATION, "");
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.BOX, "");
|
|
||||||
non_electronic_records_properties.put(BaseAPI.RMProperty.FILE, "");
|
|
||||||
|
|
||||||
HttpResponse nonElectronicRecordHttpResponse = recordsAPI.createNonElectronicRecord(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(), non_electronic_records_properties, rootCategory.getName(), recordFolder.getName());
|
|
||||||
|
|
||||||
String nonElectronicRecordId = getNodeRef(nonElectronicRecordHttpResponse);
|
|
||||||
|
|
||||||
STEP("Check the non-electronic record has been created");
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
STEP("Create a electronic record by completing some of the fields");
|
|
||||||
Map<BaseAPI.RMProperty, String> electronic_records_properties = new HashMap<>();
|
|
||||||
electronic_records_properties.put(BaseAPI.RMProperty.DESCRIPTION, recordDescription);
|
|
||||||
electronic_records_properties.put(BaseAPI.RMProperty.NAME, recordName);
|
|
||||||
|
|
||||||
recordsAPI.uploadElectronicRecord(RmAdminUser.getUsername(),
|
|
||||||
RmAdminUser.getPassword(), electronic_records_properties, recordFolder.getName(), CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
CmisObject electronicRecord = recordsAPI.getRecord(RmAdminUser.getUsername(),
|
|
||||||
RmAdminUser.getPassword(),recordFolder.getName(), electronic_records_properties.get(BaseAPI.RMProperty.NAME));
|
|
||||||
|
|
||||||
STEP("Check the electronic record has been created");
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
STEP("Create a root folder under FilePlan - Unfiled");
|
|
||||||
String unFiledFolder = createUnFileFolder();
|
|
||||||
|
|
||||||
STEP("Move all the Unfiled Records to unFiledFolder");
|
|
||||||
RestNodeModel uploadDocRestNodeModel = getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(uploadedDocRecordbyCollabUser.getId()))
|
|
||||||
.move(createBodyForMoveCopy(unFiledFolder));
|
|
||||||
|
|
||||||
RestNodeModel nonElectronicDocRestNodeModel = getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(nonElectronicRecordId))
|
|
||||||
.move(createBodyForMoveCopy(unFiledFolder));
|
|
||||||
|
|
||||||
RestNodeModel electronicDocRestNodeModel = getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(electronicRecord.getId()))
|
|
||||||
.move(createBodyForMoveCopy(unFiledFolder));
|
|
||||||
|
|
||||||
STEP("Move all the Record present in the unFiledFolder to Folder inside Root Category");
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(uploadDocRestNodeModel.getId()))
|
|
||||||
.move(createBodyForMoveCopy(recordFolder.getId()));
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(nonElectronicDocRestNodeModel.getId()))
|
|
||||||
.move(createBodyForMoveCopy(recordFolder.getId()));
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getNodeAPI(toContentModel(electronicDocRestNodeModel.getId()))
|
|
||||||
.move(createBodyForMoveCopy(recordFolder.getId()));
|
|
||||||
|
|
||||||
getRestAPIFactory().getRecordsAPI().deleteRecord(uploadDocRestNodeModel.getId());
|
|
||||||
getRestAPIFactory().getRecordsAPI().deleteRecord(nonElectronicDocRestNodeModel.getId());
|
|
||||||
getRestAPIFactory().getRecordsAPI().deleteRecord(electronicDocRestNodeModel.getId());
|
|
||||||
|
|
||||||
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
|
|
||||||
unfiledRecordFoldersAPI.deleteUnfiledRecordFolder(unFiledFolder);
|
|
||||||
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
String recordFolderId = recordFolder.getId();
|
|
||||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass (alwaysRun = true)
|
|
||||||
public void deletePreConditions()
|
|
||||||
{
|
|
||||||
STEP("Delete the created rootCategory along with corresponding record folders/records present in it");
|
|
||||||
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private String createUnFileFolder() {
|
|
||||||
String categoryName = "RM-2790 record Category name " + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
|
|
||||||
categoryName + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
|
|
||||||
return unfiledRecordFolderId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getNodeRef(HttpResponse httpResponse) {
|
|
||||||
return convertHTTPResponseToJSON(httpResponse).getString("persistedObject")
|
|
||||||
.replace(NODE_REF_WORKSPACE_SPACES_STORE, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.utility.Utility;
|
|
||||||
import org.alfresco.utility.constants.UserRole;
|
|
||||||
import org.alfresco.utility.data.RandomData;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FileType;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
public class InplaceRecordSearchTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private UserModel siteCollaborator, siteConsumer, nonSiteMember;
|
|
||||||
private SiteModel privateSite;
|
|
||||||
private Record uploadedDocRecordbyCollabUser;
|
|
||||||
private FileModel uploadedDocbyCollabUser;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preConditions() {
|
|
||||||
|
|
||||||
STEP("Create RM Site");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
// And a private collaboration site
|
|
||||||
privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
|
||||||
|
|
||||||
// And a site collaborator
|
|
||||||
siteCollaborator = getDataUser().createRandomTestUser();
|
|
||||||
getDataUser().addUserToSite(siteCollaborator, privateSite, UserRole.SiteCollaborator);
|
|
||||||
|
|
||||||
// And a site consumer
|
|
||||||
siteConsumer = getDataUser().createRandomTestUser();
|
|
||||||
getDataUser().addUserToSite(siteConsumer, privateSite, UserRole.SiteConsumer);
|
|
||||||
|
|
||||||
nonSiteMember = getDataUser().createRandomTestUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a RM site
|
|
||||||
* And a private collaboration site
|
|
||||||
* And a site collaborator
|
|
||||||
* And a site consumer
|
|
||||||
* And a user who is not a member of the site
|
|
||||||
* And a document that isn't a record
|
|
||||||
* When the collaborator declares it as a record
|
|
||||||
* Then the collaborator can browse to the record in the document library
|
|
||||||
* And can find the record using live search
|
|
||||||
* And can find the record using advanced search
|
|
||||||
* And the consumer can browse to the record in the document library
|
|
||||||
* And can find the record using live search
|
|
||||||
* And can find the record using advanced search
|
|
||||||
* And the user who is not a member of the site can't find the record using live search
|
|
||||||
* And can't find the record using advanced search
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void searchForInplaceRecord() {
|
|
||||||
// And a document that isn't a record
|
|
||||||
final String fileName = "File" + RandomData.getRandomAlphanumeric();
|
|
||||||
uploadedDocbyCollabUser = dataContent.usingSite(privateSite)
|
|
||||||
.usingUser(siteCollaborator)
|
|
||||||
.createContent(new FileModel(fileName, FileType.fromName(fileName + "." + CMISUtil.DocumentType.TEXT_PLAIN.extention)));
|
|
||||||
|
|
||||||
assertNotNull(uploadedDocbyCollabUser.getNodeRef());
|
|
||||||
|
|
||||||
// declare uploadedDocument as record
|
|
||||||
uploadedDocRecordbyCollabUser = getRestAPIFactory().getFilesAPI(siteCollaborator)
|
|
||||||
.declareAsRecord(uploadedDocbyCollabUser.getNodeRefWithoutVersion());
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
assertNotNull(uploadedDocRecordbyCollabUser.getId());
|
|
||||||
|
|
||||||
STEP("Allow the Document to be index for it to be available");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Utility.sleep(1000, 40000, () ->
|
|
||||||
{
|
|
||||||
JSONObject siteConsumerSearchJson = getSearchApi().liveSearchForDocuments(siteConsumer.getUsername(),
|
|
||||||
siteConsumer.getPassword(),
|
|
||||||
uploadedDocbyCollabUser.getName());
|
|
||||||
assertTrue("Site Consumer not able to find the document.",siteConsumerSearchJson.getJSONArray("items").length() != 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Utility.sleep(1000, 40000, () ->
|
|
||||||
{
|
|
||||||
JSONObject siteCollaboratorSearchJson = getSearchApi().liveSearchForDocuments(siteCollaborator.getUsername(),
|
|
||||||
siteCollaborator.getPassword(),
|
|
||||||
uploadedDocbyCollabUser.getName());
|
|
||||||
assertTrue("Site Collaborator not able to find the document.",siteCollaboratorSearchJson.getJSONArray("items").length() != 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject nonSiteMemberSearchJson = getSearchApi().liveSearchForDocuments(nonSiteMember.getUsername(),
|
|
||||||
nonSiteMember.getPassword(),
|
|
||||||
uploadedDocbyCollabUser.getName());
|
|
||||||
|
|
||||||
assertTrue("Non Site Member is able to access restricted document.",nonSiteMemberSearchJson.getJSONArray("items").isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given @see {@link #searchForInplaceRecord()}
|
|
||||||
* When the collaboration user hides the record in the collaboration site
|
|
||||||
* Then the collaborator can not browse to the record in the document library
|
|
||||||
* And can't find the record using live search
|
|
||||||
* And can't find the record using advanced search
|
|
||||||
*/
|
|
||||||
@Test(dependsOnMethods = {"searchForInplaceRecord"})
|
|
||||||
public void usersCantFindRecordAfterHide() {
|
|
||||||
recordsAPI.hideRecord(siteCollaborator.getUsername(),siteCollaborator.getPassword(),uploadedDocRecordbyCollabUser.getId());
|
|
||||||
|
|
||||||
JSONObject siteCollaboratorSearchJson = getSearchApi().liveSearchForDocuments(siteCollaborator.getUsername(),
|
|
||||||
siteCollaborator.getPassword(),
|
|
||||||
uploadedDocbyCollabUser.getName());
|
|
||||||
assertTrue("Site Collaborator able to find the document after it is hidden.",siteCollaboratorSearchJson.getJSONArray("items").isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public void tearDown() {
|
|
||||||
// clean-up collab site
|
|
||||||
dataSite.usingAdmin().deleteSite(privateSite);
|
|
||||||
|
|
||||||
// clean-up users siteCollaborator, siteConsumer, nonSiteMember
|
|
||||||
dataUser.deleteUser(siteCollaborator);
|
|
||||||
dataUser.deleteUser(siteConsumer);
|
|
||||||
dataUser.deleteUser(nonSiteMember);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,539 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.RecordContent;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.rest.v0.SearchAPI;
|
|
||||||
import org.alfresco.utility.Utility;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.*;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
/**
|
|
||||||
* Tests the search of records in Records Search page
|
|
||||||
* @author Kavit Shah
|
|
||||||
*/
|
|
||||||
public class SearchRecordsTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private Optional<UserModel> nonRmSiteUser, rm_user_search, rm_manager, rm_admin_search;
|
|
||||||
|
|
||||||
/** The default password used when creating test users. */
|
|
||||||
public static final String ROLE_RM_MANAGER = "RecordsManager";
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(SearchRecordsTests.class);
|
|
||||||
private final String CATEGORY_ALL = TEST_PREFIX + "everybody's category";
|
|
||||||
private final String FOLDER_SEARCH = TEST_PREFIX + "basic search folder";
|
|
||||||
private final String FOLDER_ADMIN_ONLY = TEST_PREFIX + "rm admin category";
|
|
||||||
private final String CATEGORY_ADMIN_ONLY = TEST_PREFIX + "rm admin category";
|
|
||||||
public static final String ROLE_RM_USER = "User";
|
|
||||||
public static final String ADMIN = "Administrator";
|
|
||||||
private final String ELECTRONIC_RECORD = TEST_PREFIX + " Electronic";
|
|
||||||
private final String UNFILED_ELECTRONIC_RECORD = TEST_PREFIX + " Unfiled Electronic";
|
|
||||||
private final String NON_ELECTRONIC_RECORD = TEST_PREFIX + " Non-Electronic";
|
|
||||||
private final String ADMIN_ELECTRONIC_RECORD = TEST_PREFIX + " admin Electronic";
|
|
||||||
public static final String TITLE = "Title";
|
|
||||||
public static final String DESCRIPTION = "Description";
|
|
||||||
public static final String TEST_CONTENT = "This is some test content";
|
|
||||||
private RecordCategory categoryAll, category_Admin_Only;
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private SearchAPI searchAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
|
||||||
public void createRecordsForSearch()
|
|
||||||
{
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
nonRmSiteUser = Optional.ofNullable(getDataUser().createRandomTestUser());
|
|
||||||
// create RM manager and RM user
|
|
||||||
createRMManager();
|
|
||||||
createRMUser();
|
|
||||||
createRMAdmin();
|
|
||||||
categoryAll = createCategoryIfDoesNotExist(CATEGORY_ALL);
|
|
||||||
createRecordFolderInCategory(FOLDER_SEARCH, categoryAll);
|
|
||||||
|
|
||||||
category_Admin_Only = createCategoryIfDoesNotExist(CATEGORY_ADMIN_ONLY);
|
|
||||||
createRecordFolderInCategory(FOLDER_ADMIN_ONLY,category_Admin_Only);
|
|
||||||
|
|
||||||
// upload records in folder in category and in Unfiled Records
|
|
||||||
uploadElectronicRecordInContainer(ELECTRONIC_RECORD, FOLDER_SEARCH);
|
|
||||||
createNonElectronicRecordInContainer(NON_ELECTRONIC_RECORD, CATEGORY_ALL, FOLDER_SEARCH);
|
|
||||||
uploadElectronicRecordInContainer(ADMIN_ELECTRONIC_RECORD, FOLDER_ADMIN_ONLY);
|
|
||||||
|
|
||||||
UnfiledContainerChild electronicRecord = UnfiledContainerChild.builder()
|
|
||||||
.name(UNFILED_ELECTRONIC_RECORD)
|
|
||||||
.nodeType(CONTENT_TYPE)
|
|
||||||
.content(RecordContent.builder().mimeType("text/plain").build())
|
|
||||||
.build();
|
|
||||||
getRecordsFromUnfiledRecordsContainer(electronicRecord);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given I have created record category X which contains record folder Y which contains record Z
|
|
||||||
* And I have selected to display record category id in the search results
|
|
||||||
* When I issue a record search whose results will contain record X
|
|
||||||
* Then record X is displayed in the results
|
|
||||||
* And the record category X's ID is also displayed in search result meta-data for record X
|
|
||||||
*/
|
|
||||||
@Test(priority = 1)
|
|
||||||
public void searchResultsWithRecordCategoryIdentifier() {
|
|
||||||
AtomicBoolean electronicRecordFound = new AtomicBoolean(false);
|
|
||||||
AtomicReference<JSONArray> items = new AtomicReference<>();
|
|
||||||
AtomicBoolean recordCategoryIdentifier = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
STEP("Open the record search page and search by the items created");
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
JSONObject searchResult = (searchAPI
|
|
||||||
.rmSearch(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
"rm",
|
|
||||||
"keywords:" + TEST_PREFIX + "*",
|
|
||||||
"records/true,undeclared/true,vital/false,folders/false,categories/false,frozen/false,cutoff/false",
|
|
||||||
"rma:identifier/asc"));
|
|
||||||
items.set((JSONArray) searchResult.get("items"));
|
|
||||||
assertFalse("Site Consumer not able to find the document.", ((JSONArray)searchResult.get("items")).isEmpty());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
STEP("Check that the records from file plan have the record category identifier displayed");
|
|
||||||
List searchList = IntStream.range(0, items.get().length()).mapToObj(i-> items.get().get(i)).collect(Collectors.toList());
|
|
||||||
|
|
||||||
searchList.stream().forEach(x -> {
|
|
||||||
Map<String, String> reconstructedUtilMap = Arrays.stream(x.toString().split(","))
|
|
||||||
.map(s -> s.split(":"))
|
|
||||||
.collect(Collectors.toMap(s -> s[0], s -> s[1]));
|
|
||||||
if(reconstructedUtilMap.get("\"name\"").contains(TEST_PREFIX + " Electronic")) {
|
|
||||||
electronicRecordFound.set(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assertFalse("The File Name with the Prefix " + TEST_PREFIX + " as Electronic Record was not found.", !electronicRecordFound.get());
|
|
||||||
|
|
||||||
STEP("Change the search filter to return only record folders and record categories");
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
JSONObject searchResult = (searchAPI
|
|
||||||
.rmSearch(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
"rm",
|
|
||||||
"keywords:" + TEST_PREFIX + "*",
|
|
||||||
"records/false,undeclared/true,vital/false,folders/true,categories/true,frozen/false,cutoff/false",
|
|
||||||
"rma:identifier/asc"));
|
|
||||||
items.set((JSONArray) searchResult.get("items"));
|
|
||||||
assertFalse("Site Consumer not able to find the document.", ((JSONArray)searchResult.get("items")).isEmpty());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
STEP("Check that the records folders and categories don't have a record category identifier displayed");
|
|
||||||
List recordFolderSearchList = IntStream.range(0, items.get().length()).mapToObj(i-> items.get().get(i)).collect(Collectors.toList());
|
|
||||||
|
|
||||||
recordFolderSearchList.stream().forEach(x -> {
|
|
||||||
Map<String, String> reconstructedUtilMap = Arrays.stream(x.toString().split(","))
|
|
||||||
.map(s -> s.split(":"))
|
|
||||||
.collect(Collectors.toMap(s -> s[0], s -> s[1]));
|
|
||||||
if(null != reconstructedUtilMap.get("\"rma_recordCategoryIdentifier\"")) {
|
|
||||||
recordCategoryIdentifier.set(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assertFalse("Record Category Identifier displayed for " + TEST_PREFIX + ".", recordCategoryIdentifier.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User with RM User role can see the records he has permission over and all in Unfiled Records
|
|
||||||
* <p>
|
|
||||||
* Given that I am a RM User
|
|
||||||
* I can see only the records in File Plan I have permission over and all in Unfiled Records
|
|
||||||
*/
|
|
||||||
@Test (priority = 2)
|
|
||||||
public void nonRMUserSearchResults() {
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(nonRmSiteUser.get().getUsername(),
|
|
||||||
nonRmSiteUser.get().getPassword(),
|
|
||||||
ELECTRONIC_RECORD));
|
|
||||||
assertFalse("The file with search term " + ELECTRONIC_RECORD + " was found using RM Not Site User "+ nonRmSiteUser.get().getUsername(),getResult(ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(nonRmSiteUser.get().getUsername(),
|
|
||||||
nonRmSiteUser.get().getPassword(),
|
|
||||||
UNFILED_ELECTRONIC_RECORD));
|
|
||||||
assertFalse("The file with search term " + UNFILED_ELECTRONIC_RECORD + " was not found using RM Not Site User "+ nonRmSiteUser.get().getUsername(),getResult(UNFILED_ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(nonRmSiteUser.get().getUsername(),
|
|
||||||
nonRmSiteUser.get().getPassword(),
|
|
||||||
NON_ELECTRONIC_RECORD));
|
|
||||||
assertFalse("The file with search term " + NON_ELECTRONIC_RECORD + " was not found using RM Not Site User "+ nonRmSiteUser.get().getUsername(),getResult(NON_ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = searchAPI
|
|
||||||
.searchForDocumentsAsUser(nonRmSiteUser.get().getUsername(),
|
|
||||||
nonRmSiteUser.get().getPassword(),
|
|
||||||
ADMIN_ELECTRONIC_RECORD);
|
|
||||||
assertFalse("The file with search term " + ADMIN_ELECTRONIC_RECORD + " was not found using RM Not Site User "+ nonRmSiteUser.get().getUsername(),getResult(ADMIN_ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User with RM User role can see the records he has permission over and all in Unfiled Records
|
|
||||||
* <p>
|
|
||||||
* Given that I am a RM User
|
|
||||||
* I can see only the records in File Plan I have permission over and all in Unfiled Records
|
|
||||||
*/
|
|
||||||
@Test (priority = 3)
|
|
||||||
public void rmUserSearchResults() {
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(categoryAll.getId(), rm_user_search.get(), PERMISSION_READ_RECORDS);
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(categoryAll.getId(), rm_user_search.get(), PERMISSION_FILE_RECORDS);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_user_search.get().getUsername(),
|
|
||||||
rm_user_search.get().getPassword(),
|
|
||||||
ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(ELECTRONIC_RECORD,stringList),"The file with search term" + ELECTRONIC_RECORD + " was not found using RM User "+ rm_user_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_user_search.get().getUsername(),
|
|
||||||
rm_user_search.get().getPassword(),
|
|
||||||
UNFILED_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(UNFILED_ELECTRONIC_RECORD,stringList),"The file with search term" + UNFILED_ELECTRONIC_RECORD + " was not found using RM User "+ rm_user_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_user_search.get().getUsername(),
|
|
||||||
rm_user_search.get().getPassword(),
|
|
||||||
NON_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(NON_ELECTRONIC_RECORD,stringList),"The file with search term" + NON_ELECTRONIC_RECORD + " was not found using RM User "+ rm_user_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_user_search.get().getUsername(),
|
|
||||||
rm_user_search.get().getPassword(),
|
|
||||||
ADMIN_ELECTRONIC_RECORD);
|
|
||||||
assertFalse("The file with search term" + ADMIN_ELECTRONIC_RECORD + " was not found using RM User "+ rm_user_search.get().getUsername(),getResult(ADMIN_ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User with RM Manager role can see the records he has permission over and all in Unfiled Records
|
|
||||||
* <p>
|
|
||||||
* Given that I am a RM Manager
|
|
||||||
* I can see only the records in File Plan I have permission over and all in Unfiled Records
|
|
||||||
*/
|
|
||||||
@Test (priority = 4)
|
|
||||||
public void rmManagerSearchResults() {
|
|
||||||
getRestAPIFactory().getRMUserAPI().addUserPermission(categoryAll.getId(), rm_manager.get(), PERMISSION_READ_RECORDS);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_manager.get().getUsername(),
|
|
||||||
rm_manager.get().getPassword(),
|
|
||||||
ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(ELECTRONIC_RECORD,stringList),"The file with search term " + ELECTRONIC_RECORD + " was not found using RM manager User "+ rm_manager.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_manager.get().getUsername(),
|
|
||||||
rm_manager.get().getPassword(),
|
|
||||||
UNFILED_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(UNFILED_ELECTRONIC_RECORD,stringList),"The file with search term " + UNFILED_ELECTRONIC_RECORD + " was not found using RM manager User "+ rm_manager.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_manager.get().getUsername(),
|
|
||||||
rm_manager.get().getPassword(),
|
|
||||||
NON_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(NON_ELECTRONIC_RECORD,stringList),"The file with search term " + NON_ELECTRONIC_RECORD + " was not found using RM manager User "+ rm_manager.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_manager.get().getUsername(),
|
|
||||||
rm_manager.get().getPassword(),
|
|
||||||
ADMIN_ELECTRONIC_RECORD);
|
|
||||||
assertFalse("The file with search term" + ADMIN_ELECTRONIC_RECORD + " was found using RM manager User "+ rm_manager.get().getUsername(),getResult(ADMIN_ELECTRONIC_RECORD,stringList));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User with RM Administrator role can see all the records
|
|
||||||
*
|
|
||||||
* Given that I am a RM Administrator
|
|
||||||
* I can see all the records in File Plan and Unfiled Records through RM Search and Advanced Search
|
|
||||||
*/
|
|
||||||
@Test(priority = 5)
|
|
||||||
public void rmAdminSearchResults() {
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_admin_search.get().getUsername(),
|
|
||||||
rm_admin_search.get().getPassword(),
|
|
||||||
ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(ELECTRONIC_RECORD,stringList),"The file with search term " + ELECTRONIC_RECORD + " was not found using RM Admin User "+ rm_admin_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_admin_search.get().getUsername(),
|
|
||||||
rm_admin_search.get().getPassword(),
|
|
||||||
UNFILED_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(UNFILED_ELECTRONIC_RECORD,stringList),"The file with search term " + UNFILED_ELECTRONIC_RECORD + " was not found using RM Admin User "+ rm_admin_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Utility.sleep(1000, 40000, () -> {
|
|
||||||
List<String> stringList = (searchAPI
|
|
||||||
.searchForDocumentsAsUser(rm_admin_search.get().getUsername(),
|
|
||||||
rm_admin_search.get().getPassword(),
|
|
||||||
NON_ELECTRONIC_RECORD));
|
|
||||||
assertTrue(getResult(NON_ELECTRONIC_RECORD,stringList),"The file with search term " + NON_ELECTRONIC_RECORD + " was not found using RM Admin User "+ rm_admin_search.get().getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e) {
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRMManager() {
|
|
||||||
// create RM manager
|
|
||||||
rm_manager = Optional.ofNullable(getDataUser().createRandomTestUser());
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
rm_manager.get().getUsername(),
|
|
||||||
ROLE_RM_MANAGER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRMUser() {
|
|
||||||
// create RM manager
|
|
||||||
rm_user_search = Optional.ofNullable(getDataUser().createRandomTestUser());
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
rm_user_search.get().getUsername(),
|
|
||||||
ROLE_RM_USER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createRMAdmin() {
|
|
||||||
// create RM Admin
|
|
||||||
rm_admin_search = Optional.ofNullable(getDataUser().createRandomTestUser());
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
rm_admin_search.get().getUsername(),
|
|
||||||
ADMIN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordCategory createCategoryIfDoesNotExist(String CATEGORY_ALL) {
|
|
||||||
return createRootCategory(getDataUser().usingAdmin().getAdminUser(), CATEGORY_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordCategoryChild createRecordFolderInCategory(String FOLDER_SEARCH, RecordCategory recordCategory) {
|
|
||||||
return createFolder(getDataUser().usingAdmin().getAdminUser(), recordCategory.getId(), FOLDER_SEARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uploadElectronicRecordInContainer(String electronic_record, String folder_search) {
|
|
||||||
recordsAPI.uploadElectronicRecord(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
getDefaultElectronicRecordProperties(electronic_record), folder_search, CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected HttpResponse createNonElectronicRecordInContainer(String name, String categoryName, String folderName) {
|
|
||||||
Map<BaseAPI.RMProperty, String> defaultProperties = new HashMap<>();
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.NAME, name);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.TITLE, TITLE);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.DESCRIPTION, DESCRIPTION);
|
|
||||||
|
|
||||||
return recordsAPI.createNonElectronicRecord(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), defaultProperties, categoryName, folderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<BaseAPI.RMProperty, String> getDefaultElectronicRecordProperties(String recordName) {
|
|
||||||
Map<BaseAPI.RMProperty, String> defaultProperties = new HashMap<>();
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.NAME, recordName);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.TITLE, TITLE);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.DESCRIPTION, DESCRIPTION);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.CONTENT, TEST_CONTENT);
|
|
||||||
return defaultProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void standardSearchTeardown() {
|
|
||||||
// delete categories
|
|
||||||
deleteRecordCategory(categoryAll.getId());
|
|
||||||
deleteRecordCategory(category_Admin_Only.getId());
|
|
||||||
|
|
||||||
// delete users
|
|
||||||
Optional.of(nonRmSiteUser).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
|
||||||
Optional.of(rm_user_search).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
|
||||||
Optional.of(rm_manager).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
|
||||||
Optional.of(rm_admin_search).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getResult(String partialRecordName, List<String> searchResults) {
|
|
||||||
if(null != searchResults) {
|
|
||||||
for (String searchResult : searchResults) {
|
|
||||||
if (searchResult.startsWith(partialRecordName)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object[][] getRecordsFromUnfiledRecordsContainer(UnfiledContainerChild electronicRecord)
|
|
||||||
{
|
|
||||||
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
|
||||||
return new String[][] {
|
|
||||||
{ unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS,
|
|
||||||
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)).getId()}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.records;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.ContentService;
|
|
||||||
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.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
|
||||||
import static org.testng.AssertJUnit.assertFalse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests to cover share action for records
|
|
||||||
* @author Kavit Shah
|
|
||||||
*/
|
|
||||||
public class ShareRecordsTest extends BaseRMRestTest {
|
|
||||||
|
|
||||||
/** data prep services*/
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI service;
|
|
||||||
@Autowired
|
|
||||||
private ContentService contentService;
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
/** Constants*/
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(ShareRecordsTest.class);
|
|
||||||
private final String CATEGORY = "CategoryWithSharedRecords" + TEST_PREFIX;
|
|
||||||
private final String FOLDER = "FolderWithSharedRecords" + TEST_PREFIX;
|
|
||||||
private final String ELECTRONIC_RECORD = "ELECTRONIC_RECORD" + TEST_PREFIX;
|
|
||||||
private final String NONELECTRONIC_REC = "NON_ELECTRONIC_RECORD" + TEST_PREFIX;
|
|
||||||
private RecordCategory category;
|
|
||||||
private RecordCategoryChild recordCategoryChild;
|
|
||||||
/**
|
|
||||||
* Given a record
|
|
||||||
* When admin tries to share it via API
|
|
||||||
* Then the record can't be shared
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-5308")
|
|
||||||
public void shareRecordViaApi()
|
|
||||||
{
|
|
||||||
//create RM Site
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
//create a category
|
|
||||||
category = createRootCategory(CATEGORY);
|
|
||||||
|
|
||||||
//create folder
|
|
||||||
recordCategoryChild = createFolder(category.getId(),FOLDER);
|
|
||||||
|
|
||||||
createNonElectronicRecord(recordCategoryChild.getId(),NONELECTRONIC_REC);
|
|
||||||
|
|
||||||
// create record to be shared
|
|
||||||
createElectronicRecord(recordCategoryChild.getId(),ELECTRONIC_RECORD);
|
|
||||||
|
|
||||||
//get the node id for the ELECTRONIC_RECORD created
|
|
||||||
String nodeRefRec1= contentService.getNodeRefByPath(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
"/Sites/" + RM_SITE_ID + "/documentLibrary/" + CATEGORY + "/" + FOLDER + "/" + service.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, ELECTRONIC_RECORD));
|
|
||||||
//check record can't be shared
|
|
||||||
assertFalse("The record has been succesfully shared",
|
|
||||||
service.shareDocument(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),nodeRefRec1 ).getKey());
|
|
||||||
//check the error code when trying to share a record
|
|
||||||
assertEquals("The API response code is not " + HttpStatus.SC_INTERNAL_SERVER_ERROR, service.shareDocument(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nodeRefRec1).getValue(),
|
|
||||||
String.valueOf( HttpStatus.SC_INTERNAL_SERVER_ERROR));
|
|
||||||
|
|
||||||
//get the node id for NONELECTRONIC_REC created
|
|
||||||
String nodeRefRec2 = contentService.getNodeRefByPath(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
"/Sites/" + RM_SITE_ID + "/documentLibrary/" + CATEGORY + "/" + FOLDER + "/" + service.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), FOLDER, NONELECTRONIC_REC));
|
|
||||||
//check record can't be shared
|
|
||||||
assertFalse("The record has been succesfully shared",
|
|
||||||
service.shareDocument(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nodeRefRec2).getKey());
|
|
||||||
//check the error code when trying to share a record
|
|
||||||
assertEquals("The API response code is not " + HttpStatus.SC_INTERNAL_SERVER_ERROR, service.shareDocument(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nodeRefRec2).getValue(),
|
|
||||||
String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public void cleanupCategory() {
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, recordCategoryChild.getName());
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, category.getName());
|
|
||||||
deleteRecordCategory(category.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -62,7 +62,6 @@ 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.requests.gscore.api.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.utils.AlfrescoRetryAnalyzer;
|
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -290,11 +289,10 @@ public class UpdateRecordsTests extends BaseRMRestTest
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
(
|
(
|
||||||
dataProvider = "completeRecords",
|
dataProvider = "completeRecords",
|
||||||
description = "Complete records can't be updated",
|
description = "Complete records can't be updated"
|
||||||
retryAnalyzer = AlfrescoRetryAnalyzer.class
|
)
|
||||||
)
|
|
||||||
@AlfrescoTest(jira="RM-4362")
|
@AlfrescoTest(jira="RM-4362")
|
||||||
@Bug (id = "APPS-132")
|
@Bug (id = "APPS-132")
|
||||||
public void completeRecordsCantBeUpdated(String electronicRecordId, String nonElectronicRecordId)
|
public void completeRecordsCantBeUpdated(String electronicRecordId, String nonElectronicRecordId)
|
||||||
|
|||||||
@@ -1,377 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.retentionschedule;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionSchedule;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleActionDefinition;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleStepCollection;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
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.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|
||||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
|
|
||||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retention schedule step test case
|
|
||||||
*/
|
|
||||||
public class RetentionScheduleStepTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private RecordCategory recordCategory;
|
|
||||||
private RetentionSchedule createdRetentionSchedule;
|
|
||||||
private final RetentionScheduleActionDefinition retentionScheduleActionDefinition = new RetentionScheduleActionDefinition();
|
|
||||||
private RetentionScheduleActionDefinition createdRetentionActionDefinition;
|
|
||||||
private UserModel nonRMuser;
|
|
||||||
private final List<String> recordCategories = new ArrayList<>();
|
|
||||||
private static final String TEST_USER = "testUser";
|
|
||||||
private static final String RECORD_CATEGORY = "recordCategory";
|
|
||||||
private static final String PERIOD_PROPERTY = "cm:created";
|
|
||||||
private static final String AUTHORITY = "authority";
|
|
||||||
private static final String INSTRUCTIONS = "instructions";
|
|
||||||
private static final int PERIOD_AMOUNT = 5;
|
|
||||||
private static final String PERIOD = "month";
|
|
||||||
private static final List<String> EVENTS = Arrays.asList("case_closed","abolished");
|
|
||||||
private static final String TRANSFER_STEP = "transfer";
|
|
||||||
private static final String RETAIN_STEP = "retain";
|
|
||||||
private static final String INVALID_PERIOD = "random";
|
|
||||||
private static final String CUTOFF_STEP = "cutoff";
|
|
||||||
private static final String DESTROY_STEP = "destroyContent";
|
|
||||||
private static final String INVALID_PASSWORD = "wrongPassword";
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForRetentionScheduleStepTests()
|
|
||||||
{
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
// create a non rm user
|
|
||||||
nonRMuser = dataUser.createRandomTestUser(TEST_USER);
|
|
||||||
//Create record category
|
|
||||||
recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
retentionSchedule.setAuthority(AUTHORITY + getRandomAlphanumeric());
|
|
||||||
retentionSchedule.setInstructions(INSTRUCTIONS + getRandomAlphanumeric());
|
|
||||||
retentionSchedule.setIsRecordLevel(false);
|
|
||||||
//Create retention schedule with a valid user
|
|
||||||
createdRetentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
|
||||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
|
|
||||||
retentionScheduleActionDefinition.setName(RETAIN_STEP);
|
|
||||||
retentionScheduleActionDefinition.setDescription(INSTRUCTIONS);
|
|
||||||
retentionScheduleActionDefinition.setPeriodAmount(PERIOD_AMOUNT);
|
|
||||||
retentionScheduleActionDefinition.setPeriodProperty(PERIOD_PROPERTY);
|
|
||||||
retentionScheduleActionDefinition.setPeriod(PERIOD);
|
|
||||||
retentionScheduleActionDefinition.setCombineRetentionStepConditions(false);
|
|
||||||
retentionScheduleActionDefinition.setEligibleOnFirstCompleteEvent(true);
|
|
||||||
retentionScheduleActionDefinition.setEvents(EVENTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 1)
|
|
||||||
public void createRetentionScheduleStepFor422()
|
|
||||||
{
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
//Creating the first action "transfer" should give 422
|
|
||||||
actionDefinition.setName(TRANSFER_STEP);
|
|
||||||
actionDefinition.setLocation("location");
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 2)
|
|
||||||
public void createRetentionScheduleStepWithInvalidPeriodValue()
|
|
||||||
{
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
//Invalid period value
|
|
||||||
actionDefinition.setPeriod(INVALID_PERIOD);
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 3)
|
|
||||||
public void createRetentionScheduleWithInvalidStep()
|
|
||||||
{
|
|
||||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition1.setName(TRANSFER_STEP);
|
|
||||||
actionDefinition1.setLocation("location");
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition2.setName(CUTOFF_STEP);
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2,retentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CONFLICT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 4)
|
|
||||||
public void createRetentionScheduleWithInvalidStepAfterDestroy()
|
|
||||||
{
|
|
||||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition1.setName(DESTROY_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition2.setName(CUTOFF_STEP);
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2,retentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CONFLICT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 5)
|
|
||||||
public void combineRetentionStepConditionsNotValidForNonAccessionStep()
|
|
||||||
{
|
|
||||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
actionDefinition.setCombineRetentionStepConditions(true);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 6)
|
|
||||||
public void createRetentionScheduleWithSameStep()
|
|
||||||
{
|
|
||||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition1.setName(RETAIN_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CONFLICT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 7)
|
|
||||||
public void createRetentionScheduleWithMultipleTransferStep()
|
|
||||||
{
|
|
||||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
|
||||||
recordCategories.add(recordCategory.getId());
|
|
||||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setName(RETAIN_STEP);
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition1.setName(TRANSFER_STEP);
|
|
||||||
actionDefinition1.setLocation("location");
|
|
||||||
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1, retentionSchedule.getId());
|
|
||||||
|
|
||||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
|
||||||
actionDefinition2.setName(TRANSFER_STEP);
|
|
||||||
actionDefinition2.setLocation("location");
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2, retentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 8)
|
|
||||||
public void createRetentionScheduleStepFor201()
|
|
||||||
{
|
|
||||||
//Create retention schedule action definition
|
|
||||||
createdRetentionActionDefinition = getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
// Find this retention schedule is created one or not
|
|
||||||
assertEquals(createdRetentionActionDefinition.getName(), retentionScheduleActionDefinition.getName());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getDescription(), retentionScheduleActionDefinition.getDescription());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getPeriodAmount(), retentionScheduleActionDefinition.getPeriodAmount());
|
|
||||||
assertEquals(createdRetentionActionDefinition.isCombineRetentionStepConditions(), retentionScheduleActionDefinition.isCombineRetentionStepConditions());
|
|
||||||
assertEquals(createdRetentionActionDefinition.isEligibleOnFirstCompleteEvent(), retentionScheduleActionDefinition.isEligibleOnFirstCompleteEvent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 9)
|
|
||||||
public void createRetentionScheduleStepFor401()
|
|
||||||
{
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), INVALID_PASSWORD)).createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 10)
|
|
||||||
public void createRetentionScheduleStepFor403()
|
|
||||||
{
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 11)
|
|
||||||
public void retentionScheduleStepFor400()
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().getRetentionScheduleStep(recordCategory.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 12)
|
|
||||||
public void createRetentionScheduleStepFor404()
|
|
||||||
{
|
|
||||||
//Create retention schedule action definition
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(retentionScheduleActionDefinition,getRandomAlphanumeric());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 13)
|
|
||||||
public void retentionScheduleStepFor403()
|
|
||||||
{
|
|
||||||
// Get retention schedule steps with user having no rights
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).getRetentionScheduleStep(createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 14)
|
|
||||||
public void retentionScheduleStepFor401()
|
|
||||||
{
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), INVALID_PASSWORD)).getRetentionScheduleStep(createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(priority = 15)
|
|
||||||
public void retentionScheduleStepWith200()
|
|
||||||
{
|
|
||||||
RetentionScheduleStepCollection receiveRetentionStepCollection = getRestAPIFactory().getRetentionScheduleAPI().getRetentionScheduleStep(createdRetentionSchedule.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
receiveRetentionStepCollection.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
RetentionScheduleActionDefinition retentionActionDef = c.getEntry();
|
|
||||||
assertNotNull(retentionActionDef.getId());
|
|
||||||
// Find this retention schedule is created one or not
|
|
||||||
assertEquals(createdRetentionActionDefinition.getId(), retentionActionDef.getId());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getName(), retentionActionDef.getName());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getDescription(), retentionActionDef.getDescription());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getPeriod(), retentionActionDef.getPeriod());
|
|
||||||
assertEquals(createdRetentionActionDefinition.getPeriodAmount(), retentionActionDef.getPeriodAmount());
|
|
||||||
assertEquals(createdRetentionActionDefinition.isCombineRetentionStepConditions(), retentionActionDef.isCombineRetentionStepConditions());
|
|
||||||
assertEquals(createdRetentionActionDefinition.isEligibleOnFirstCompleteEvent(), retentionActionDef.isEligibleOnFirstCompleteEvent());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private RetentionSchedule createRetentionSchedule(RecordCategory recordCategory)
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
retentionSchedule.setAuthority(AUTHORITY + getRandomAlphanumeric());
|
|
||||||
retentionSchedule.setInstructions(INSTRUCTIONS + getRandomAlphanumeric());
|
|
||||||
retentionSchedule.setIsRecordLevel(false);
|
|
||||||
//Create retention schedule with a valid user
|
|
||||||
retentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
|
||||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
return retentionSchedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RetentionScheduleActionDefinition getRetentionScheduleActionDefinition()
|
|
||||||
{
|
|
||||||
RetentionScheduleActionDefinition actionDefinition = new RetentionScheduleActionDefinition();
|
|
||||||
actionDefinition.setDescription(INSTRUCTIONS);
|
|
||||||
actionDefinition.setPeriodAmount(PERIOD_AMOUNT);
|
|
||||||
actionDefinition.setPeriodProperty(PERIOD_PROPERTY);
|
|
||||||
actionDefinition.setPeriod(PERIOD);
|
|
||||||
actionDefinition.setCombineRetentionStepConditions(false);
|
|
||||||
actionDefinition.setEligibleOnFirstCompleteEvent(true);
|
|
||||||
actionDefinition.setEvents(EVENTS);
|
|
||||||
return actionDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpRetentionScheduleStepTests()
|
|
||||||
{
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, recordCategory.getName());
|
|
||||||
recordCategories.forEach(this::deleteRecordCategory);
|
|
||||||
dataUser.deleteUser(nonRMuser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,270 +0,0 @@
|
|||||||
/*-
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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.retentionschedule;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionSchedule;
|
|
||||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleCollection;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
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 static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|
||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
|
|
||||||
import static org.testng.Assert.assertFalse;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
import static org.testng.AssertJUnit.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the tests for the Retention Schedule CRUD V1 API
|
|
||||||
*/
|
|
||||||
public class RetentionScheduleTests extends BaseRMRestTest
|
|
||||||
{
|
|
||||||
private RecordCategory recordCategory;
|
|
||||||
private RetentionSchedule createdRetentionSchedule;
|
|
||||||
private UserModel nonRMuser;
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForRetentionScheduleTests()
|
|
||||||
{
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
// create a non rm user
|
|
||||||
nonRMuser = dataUser.createRandomTestUser("testUser");
|
|
||||||
//Create record category
|
|
||||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to create a retention schedule with a user having no rights
|
|
||||||
* Then it will give 403 as status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 1)
|
|
||||||
public void createRetentionScheduleFor403()
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
|
|
||||||
// Create retention schedule with user having no rights
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category does not exists
|
|
||||||
* When I ask the API to create a retention schedule on a category Id
|
|
||||||
* Then it will give 404 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 2)
|
|
||||||
public void createRetentionScheduleFor404()
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
|
|
||||||
//Create retention schedule with category id not exist
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionSchedule(retentionSchedule, getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to create a retention schedule on a category id with a user having unauthorized access
|
|
||||||
* Then it will give 401 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 3)
|
|
||||||
public void createRetentionScheduleFor401()
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
|
|
||||||
//Create retention schedule with a user with unauthorized access
|
|
||||||
createdRetentionSchedule = getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), "wrongPassword")).createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to create a retention schedule with a user having access
|
|
||||||
* Then it is created with a 201 status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 4)
|
|
||||||
public void createRetentionScheduleFor201()
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
String authority = "authority" + getRandomAlphanumeric();
|
|
||||||
String instructions = "instructions" + getRandomAlphanumeric();
|
|
||||||
boolean isRecordLevel = false;
|
|
||||||
retentionSchedule.setAuthority(authority);
|
|
||||||
retentionSchedule.setInstructions(instructions);
|
|
||||||
retentionSchedule.setIsRecordLevel(isRecordLevel);
|
|
||||||
|
|
||||||
//Create retention schedule with a valid user
|
|
||||||
createdRetentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
|
||||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
assertEquals(createdRetentionSchedule.getAuthority(), authority);
|
|
||||||
assertEquals(createdRetentionSchedule.getInstructions(), instructions);
|
|
||||||
assertFalse(createdRetentionSchedule.getIsRecordLevel());
|
|
||||||
assertNotNull(createdRetentionSchedule.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to create a retention schedule on a category id having retention schedule already
|
|
||||||
* Then it will give 409 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 5)
|
|
||||||
public void createRetentionScheduleFor409()
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
|
||||||
//Create retention schedule on a category with already having retention schedule
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI()
|
|
||||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
|
||||||
|
|
||||||
assertStatusCode(CONFLICT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to get a retention schedule on a given categoryId with a user having no rights
|
|
||||||
* Then it will give 403
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 6)
|
|
||||||
public void retentionScheduleWith403()
|
|
||||||
{
|
|
||||||
//Get retention schedule with user having no rights
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).getRetentionSchedule(recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(FORBIDDEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category does not exists
|
|
||||||
* When I ask the API to get a retention schedule on a category Id
|
|
||||||
* Then it will give 404 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 7)
|
|
||||||
public void retentionScheduleWith404()
|
|
||||||
{
|
|
||||||
|
|
||||||
//Get retention schedule with category id that does not exist
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI().getRetentionSchedule(getRandomAlphanumeric());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to get a retention schedule on a categoryId with a user having unauthorized access
|
|
||||||
* Then it will give 401 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 8)
|
|
||||||
public void retentionScheduleWith401()
|
|
||||||
{
|
|
||||||
//Create retention schedule with a user with unauthorized access
|
|
||||||
getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), "wrongPassword")).getRetentionSchedule(recordCategory.getId());
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(UNAUTHORIZED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* Given that a record category exists
|
|
||||||
* When I ask the API to get a retention schedule on a categoryId with a user having access
|
|
||||||
* Then it will give retentionSchedule with 200 as a status code
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@Test(priority = 9)
|
|
||||||
public void retentionScheduleWith200()
|
|
||||||
{
|
|
||||||
RetentionScheduleCollection retentionScheduleCollection = getRestAPIFactory().getRetentionScheduleAPI().getRetentionSchedule(recordCategory.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
retentionScheduleCollection.getEntries().forEach(c ->
|
|
||||||
{
|
|
||||||
RetentionSchedule retentionSchedule = c.getEntry();
|
|
||||||
String retentionScheduleId = retentionSchedule.getId();
|
|
||||||
assertNotNull(retentionScheduleId);
|
|
||||||
logger.info("Checking retention schedule " + retentionScheduleId);
|
|
||||||
|
|
||||||
// Find this retention schedule is created one or not
|
|
||||||
assertEquals(createdRetentionSchedule.getId(), retentionScheduleId);
|
|
||||||
assertEquals(createdRetentionSchedule.getParentId(),retentionSchedule.getParentId());
|
|
||||||
assertEquals(createdRetentionSchedule.getAuthority(), retentionSchedule.getAuthority());
|
|
||||||
assertEquals(createdRetentionSchedule.getInstructions(), retentionSchedule.getInstructions());
|
|
||||||
assertEquals(createdRetentionSchedule.getIsRecordLevel(), retentionSchedule.getIsRecordLevel());
|
|
||||||
assertEquals(createdRetentionSchedule.isUnpublishedUpdates(), retentionSchedule.isUnpublishedUpdates());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpRetentionScheduleTests()
|
|
||||||
{
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, recordCategory.getName());
|
|
||||||
deleteRecordCategory(recordCategory.getId());
|
|
||||||
dataUser.deleteUser(nonRMuser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,229 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,221 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public class SearchDocumentsV1Test extends BaseRMRestTest
|
|||||||
cmisQueryModel.setLanguage("cmis");
|
cmisQueryModel.setLanguage("cmis");
|
||||||
|
|
||||||
RestRequestQueryModel aftsQueryModel = new RestRequestQueryModel();
|
RestRequestQueryModel aftsQueryModel = new RestRequestQueryModel();
|
||||||
aftsQueryModel.setQuery("cm:name:*" + SEARCH_TERM + ".txt");
|
aftsQueryModel.setQuery("cm:name:*" + SEARCH_TERM);
|
||||||
aftsQueryModel.setLanguage("afts");
|
aftsQueryModel.setLanguage("afts");
|
||||||
|
|
||||||
return new RestRequestQueryModel[][] {
|
return new RestRequestQueryModel[][] {
|
||||||
@@ -107,7 +107,7 @@ public class SearchDocumentsV1Test extends BaseRMRestTest
|
|||||||
private void waitIndexing() throws Exception
|
private void waitIndexing() throws Exception
|
||||||
{
|
{
|
||||||
RestRequestQueryModel queryType = new RestRequestQueryModel();
|
RestRequestQueryModel queryType = new RestRequestQueryModel();
|
||||||
queryType.setQuery("cm:name:*" + SEARCH_TERM + ".txt");
|
queryType.setQuery("cm:name:*" + SEARCH_TERM);
|
||||||
queryType.setLanguage("afts");
|
queryType.setLanguage("afts");
|
||||||
Utility.sleep(1000, 80000, () ->
|
Utility.sleep(1000, 80000, () ->
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,211 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.core.v0.BaseAPI;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.audit.AuditEntry;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.rest.v0.service.RMAuditService;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.DELETE_PERSON;
|
|
||||||
import static org.alfresco.rest.rm.community.model.audit.AuditEvents.LOGIN_SUCCESSFUL;
|
|
||||||
import static org.alfresco.rest.rm.community.records.SearchRecordsTests.*;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Audit Access tests
|
|
||||||
* @author Kavit Shah
|
|
||||||
*/
|
|
||||||
public class AuditAccessTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private Optional<UserModel> deletedUser;
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(AuditAccessTests.class);
|
|
||||||
private static final String DELETE_USER_EVENT = "Delete User";
|
|
||||||
private final String record1 = TEST_PREFIX + "RM-2967 uploaded record";
|
|
||||||
private final String classifiedRecord = TEST_PREFIX + "RM-2967 classified record";
|
|
||||||
private final String folderName = TEST_PREFIX + "RM-2967 folder";
|
|
||||||
private final String categoryName = TEST_PREFIX + "RM-2967 category";
|
|
||||||
private final String editedCategoryName = "edited " + categoryName;
|
|
||||||
private final String editedFolderName = "edited " + folderName;
|
|
||||||
private final String editedRecordName = "edited " + record1;
|
|
||||||
private final String login_successfull = "Login Successful";
|
|
||||||
private RecordCategory categoryAll;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RMAuditService rmAuditService;
|
|
||||||
|
|
||||||
@Test(priority = 1)
|
|
||||||
@AlfrescoTest(jira = "RM-2967")
|
|
||||||
public void deleteRMUsersShowFullAuditTest() {
|
|
||||||
|
|
||||||
createTestPrecondition();
|
|
||||||
updateCategoryMetadata();
|
|
||||||
updateFolderMetadata();
|
|
||||||
updateRecordMetadata();
|
|
||||||
|
|
||||||
// delete record category and folder with rm_admin_deleted
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(deletedUser.get().getUsername(), deletedUser.get().getPassword(),
|
|
||||||
RM_SITE_ID, editedFolderName);
|
|
||||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(deletedUser.get().getUsername(), deletedUser.get().getPassword(),
|
|
||||||
RM_SITE_ID, editedCategoryName);
|
|
||||||
|
|
||||||
// delete the user
|
|
||||||
Optional.of(deletedUser).ifPresent(x -> getDataUser().deleteUser(x.get()));
|
|
||||||
|
|
||||||
//check for RM-5235 fix
|
|
||||||
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getDataUser().usingAdmin().getAdminUser(),
|
|
||||||
DELETE_PERSON);
|
|
||||||
|
|
||||||
assertTrue("Delete user event not found in the audit log.", auditEntries.stream().anyMatch(
|
|
||||||
auditEntry -> auditEntry.getEvent().equals(DELETE_USER_EVENT)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test(priority = 2)
|
|
||||||
public void filterEventsByLoginSuccessful()
|
|
||||||
{
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
List<AuditEntry> auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getDataUser().usingAdmin().getAdminUser(),
|
|
||||||
LOGIN_SUCCESSFUL);
|
|
||||||
|
|
||||||
assertFalse("Audit results should contain at least one Login Successful event",
|
|
||||||
auditEntries.isEmpty());
|
|
||||||
|
|
||||||
assertTrue("Audit results contain only Login Successful events",
|
|
||||||
auditEntries.stream()
|
|
||||||
.allMatch(e -> e.getEvent().startsWith(LOGIN_SUCCESSFUL.toString()) || e.getEvent().startsWith(login_successfull)));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates the required precondition for the test
|
|
||||||
* <p/>
|
|
||||||
* See Precondition in current class JavaDoc
|
|
||||||
*/
|
|
||||||
private void createTestPrecondition() {
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
// create "rm deleted user" user if it does not exist and assign it to RM Administrator role
|
|
||||||
createDeletedUser();
|
|
||||||
|
|
||||||
// create category and folder
|
|
||||||
categoryAll = createCategoryIfDoesNotExist(categoryName,deletedUser.get());
|
|
||||||
createRecordFolderInCategory(folderName,categoryAll,deletedUser.get());
|
|
||||||
// upload an electronic record
|
|
||||||
|
|
||||||
recordsAPI.uploadElectronicRecord(deletedUser.get().getUsername(), deletedUser.get().getPassword(), getDefaultElectronicRecordProperties(record1), folderName, CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
// upload another electronic record and classify it
|
|
||||||
recordsAPI.uploadElectronicRecord(deletedUser.get().getUsername(), deletedUser.get().getPassword(), getDefaultElectronicRecordProperties(classifiedRecord), folderName, CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createDeletedUser() {
|
|
||||||
// create Deleted User
|
|
||||||
deletedUser = Optional.ofNullable(getDataUser().createRandomTestUser());
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
deletedUser.get().getUsername(),
|
|
||||||
ADMIN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateCategoryMetadata() {
|
|
||||||
HashMap<BaseAPI.RMProperty, String> categoryProperties = new HashMap<>();
|
|
||||||
categoryProperties.put(BaseAPI.RMProperty.NAME, editedCategoryName);
|
|
||||||
categoryProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
|
||||||
categoryProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
|
||||||
|
|
||||||
// edit some category's properties
|
|
||||||
String categoryNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + categoryName);
|
|
||||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), categoryNodeRef, categoryProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateFolderMetadata() {
|
|
||||||
HashMap<BaseAPI.RMProperty, String> folderProperties = new HashMap<>();
|
|
||||||
folderProperties.put(BaseAPI.RMProperty.NAME, editedFolderName);
|
|
||||||
folderProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
|
||||||
folderProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
|
||||||
|
|
||||||
// edit some folder's properties
|
|
||||||
String folderNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + editedCategoryName + "/" + folderName);
|
|
||||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), folderNodeRef, folderProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateRecordMetadata() {
|
|
||||||
HashMap<BaseAPI.RMProperty, String> recordProperties = new HashMap<>();
|
|
||||||
recordProperties.put(BaseAPI.RMProperty.NAME, editedRecordName);
|
|
||||||
recordProperties.put(BaseAPI.RMProperty.TITLE, "edited " + TITLE);
|
|
||||||
recordProperties.put(BaseAPI.RMProperty.AUTHOR, "edited author");
|
|
||||||
recordProperties.put(BaseAPI.RMProperty.DESCRIPTION, "edited " + DESCRIPTION);
|
|
||||||
|
|
||||||
// edit some record's properties
|
|
||||||
String recordName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), editedFolderName, record1);
|
|
||||||
String recordNodeRef = NODE_PREFIX + rmRolesAndActionsAPI.getItemNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), "/" + editedCategoryName + "/" + editedFolderName + "/" + recordName);
|
|
||||||
rmRolesAndActionsAPI.updateMetadata(deletedUser.get().getUsername(), deletedUser.get().getPassword(), recordNodeRef, recordProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private RecordCategory createCategoryIfDoesNotExist(String CATEGORY_ALL, UserModel deletedUser) {
|
|
||||||
return createRootCategory(deletedUser, CATEGORY_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RecordCategoryChild createRecordFolderInCategory(String FOLDER_SEARCH, RecordCategory recordCategory, UserModel deletedUser) {
|
|
||||||
return createFolder(deletedUser, recordCategory.getId(), FOLDER_SEARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<BaseAPI.RMProperty, String> getDefaultElectronicRecordProperties(String recordName) {
|
|
||||||
Map<BaseAPI.RMProperty, String> defaultProperties = new HashMap<>();
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.NAME, recordName);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.TITLE, TITLE);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.DESCRIPTION, DESCRIPTION);
|
|
||||||
defaultProperties.put(BaseAPI.RMProperty.CONTENT, TEST_CONTENT);
|
|
||||||
return defaultProperties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.record.Record;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
|
||||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RulesAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.*;
|
|
||||||
public class BasicRulesIntegrationTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
private final static String title = "Rule to complete";
|
|
||||||
private final static String description = "Rule to describe";
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
@Autowired
|
|
||||||
private RulesAPI rulesAPI;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-2794")
|
|
||||||
public void basicRulesIntegration() {
|
|
||||||
|
|
||||||
|
|
||||||
STEP("Create the RM site if doesn't exist");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
STEP("Create record categories and record folders");
|
|
||||||
RecordCategory Category = createRootCategory(getRandomName("recordCategory"));
|
|
||||||
String recordFolder1 = createRecordFolder(Category.getId(), getRandomName("recFolder")).getId();
|
|
||||||
|
|
||||||
|
|
||||||
//create a rule for completing a record
|
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1")
|
|
||||||
.applyToChildren(true).title(title)
|
|
||||||
.actions(Collections.singletonList(ActionsOnRule.COMPLETE_RECORD.getActionValue()));
|
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + Category.getId(), ruleDefinition);
|
|
||||||
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
|
|
||||||
//create two electronic record in record folder
|
|
||||||
String electronicRecordId1 = createElectronicRecord(recordFolder1, ELECTRONIC_RECORD_NAME).getId();
|
|
||||||
String electronicRecordId2 = createElectronicRecord(recordFolder1, ELECTRONIC_RECORD_NAME).getId();
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Update the rules for record Category
|
|
||||||
rulesAPI.updateRule(getAdminUser().getUsername(), getAdminUser().getPassword(),
|
|
||||||
NODE_PREFIX + Category.getId(), ruleDefinition.description("description").id(description));
|
|
||||||
|
|
||||||
//Delete the root category and rules
|
|
||||||
deleteRecordCategory(Category.getId());
|
|
||||||
rulesAPI.deleteAllRulesOnContainer(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + Category.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class CreateCategoriesTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
private RecordCategory rootCategory;
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
private RecordCategory Category1;
|
|
||||||
private RecordCategory Category2;
|
|
||||||
private RecordCategory SubCategory1;
|
|
||||||
private RecordCategory SubCategory2;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForCreateCategoriesTests()
|
|
||||||
{
|
|
||||||
STEP("Create the RM site if doesn't exist");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
STEP("Create two category");
|
|
||||||
Category1 = createRootCategory(getRandomName("Category1"));
|
|
||||||
|
|
||||||
Category2= createRootCategory(getRandomName("Category2"));
|
|
||||||
|
|
||||||
STEP("Create Sub category");
|
|
||||||
RecordCategoryChild subCategory1 = createRecordCategory(Category1.getId(), getRandomName("subCategory1"));
|
|
||||||
RecordCategoryChild subCategory2 = createRecordCategory(Category2.getId(), getRandomName("subCategory2"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test @AlfrescoTest(jira = "RM-2756")
|
|
||||||
public void createCategories() throws Exception {
|
|
||||||
|
|
||||||
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
STEP("copy category 1 to File Plan.");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(Category1.getId())).copy(createBodyForMoveCopy(filePlan.getId()));
|
|
||||||
|
|
||||||
STEP("copy category 1 to category 2");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(Category1.getId())).copy(createBodyForMoveCopy(Category2.getId()));
|
|
||||||
|
|
||||||
String categoryName = "Category name " + getRandomAlphanumeric();
|
|
||||||
String categoryTitle = "Category title " + getRandomAlphanumeric();
|
|
||||||
|
|
||||||
|
|
||||||
// Create the root record category
|
|
||||||
RecordCategory Category1 = createRootCategory(categoryName, categoryTitle);
|
|
||||||
|
|
||||||
String newCategoryName = "Rename " + categoryName;
|
|
||||||
|
|
||||||
// Build the properties which will be updated
|
|
||||||
RecordCategory recordCategoryUpdated = Category1.builder().name(newCategoryName).build();
|
|
||||||
|
|
||||||
// Update the record category
|
|
||||||
RecordCategory renamedRecordCategory = getRestAPIFactory().getRecordCategoryAPI().updateRecordCategory(recordCategoryUpdated,Category1.getId());
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// verify renamed component and editTitle component still has this parent
|
|
||||||
assertEquals(renamedRecordCategory.getParentId(), filePlan.getId());
|
|
||||||
|
|
||||||
STEP("move category 1 edited copy to File Plan");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(renamedRecordCategory.getId())).move(createBodyForMoveCopy(filePlan.getId()));
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
// delete All the categories
|
|
||||||
deleteRecordCategory(Category1.getId());
|
|
||||||
deleteRecordCategory(Category2.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.common.ReviewPeriod;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.*;
|
|
||||||
|
|
||||||
public class CreateFoldersTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(CreateCategoriesTests.class);
|
|
||||||
private final String RM_ADMIN = TEST_PREFIX + "rm_admin";
|
|
||||||
private RecordCategory Category1;
|
|
||||||
private RecordCategory Category2;
|
|
||||||
private RecordCategoryChild recordCategoryChild;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForCreateFolderTests() {
|
|
||||||
STEP("Create the RM site if doesn't exist");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create RM Admin user");
|
|
||||||
rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN,
|
|
||||||
getAdminUser().getPassword(),
|
|
||||||
"Administrator");
|
|
||||||
|
|
||||||
STEP("Create two category");
|
|
||||||
Category1 = createRootCategory(getRandomName("Category1"));
|
|
||||||
|
|
||||||
Category2 = createRootCategory(getRandomName("Category2"));
|
|
||||||
|
|
||||||
// Create a record folder inside the category 1
|
|
||||||
recordCategoryChild = createRecordFolder(Category1.getId(), getRandomName("recFolder"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-2757")
|
|
||||||
public void createFolders() throws Exception {
|
|
||||||
|
|
||||||
// Create record category first
|
|
||||||
String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
|
|
||||||
String folderName = "The folder name is updated" + getRandomAlphanumeric();
|
|
||||||
String folderTitle = "Update title " + getRandomAlphanumeric();
|
|
||||||
String location = "Location "+ getRandomAlphanumeric();
|
|
||||||
|
|
||||||
// Create the record folder properties to update
|
|
||||||
RecordFolder recordFolder = RecordFolder.builder()
|
|
||||||
.name(folderName)
|
|
||||||
.properties(RecordFolderProperties.builder()
|
|
||||||
.title(folderTitle)
|
|
||||||
.description(folderDescription)
|
|
||||||
.vitalRecordIndicator(true)
|
|
||||||
.reviewPeriod(new ReviewPeriod("month","1"))
|
|
||||||
.location(location)
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Update the record folder
|
|
||||||
RecordFolder updatedRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolder, recordCategoryChild.getId());
|
|
||||||
|
|
||||||
// Check the Response Status Code
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
STEP("copy updated Record in category 1 and category 2");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).copy(createBodyForMoveCopy(Category1.getId()));
|
|
||||||
//assertStatusCode(OK);
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).copy(createBodyForMoveCopy(Category2.getId()));
|
|
||||||
//assertStatusCode(OK);
|
|
||||||
|
|
||||||
|
|
||||||
// Delete the Updated folder
|
|
||||||
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
|
|
||||||
String recordFolderId = updatedRecordFolder.getId();
|
|
||||||
recordFolderAPI.deleteRecordFolder(recordFolderId);
|
|
||||||
|
|
||||||
// Check the response status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
|
|
||||||
// Check the record folder is not found
|
|
||||||
recordFolderAPI.getRecordFolder(recordFolderId);
|
|
||||||
|
|
||||||
// Check the response status code
|
|
||||||
assertStatusCode(NOT_FOUND);
|
|
||||||
|
|
||||||
STEP("move updated Record from category 1 to category 2");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(updatedRecordFolder.getId())).move(createBodyForMoveCopy(Category2.getId()));
|
|
||||||
|
|
||||||
// move category 2 to category 1
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(Category2.getId())).move(createBodyForMoveCopy(Category1.getId()));
|
|
||||||
|
|
||||||
// Delete the record category
|
|
||||||
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
|
||||||
String recordCategoryId = Category1.getId();
|
|
||||||
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
|
||||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
|
||||||
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
|
||||||
import org.alfresco.rest.v0.RulesAPI;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.data.DataContent;
|
|
||||||
import org.alfresco.utility.data.DataSite;
|
|
||||||
import org.alfresco.utility.data.DataUserAIS;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FolderModel;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
|
|
||||||
public class DeclareDocsAsRecordsOnUpdateRuleNewVersionTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DataSite dataSite;
|
|
||||||
private SiteModel publicSite;
|
|
||||||
private RecordCategory recordCategory;
|
|
||||||
@Autowired
|
|
||||||
private RulesAPI rulesAPI;
|
|
||||||
@Autowired
|
|
||||||
protected DataContent dataContent;
|
|
||||||
@Autowired
|
|
||||||
@Getter(value = PROTECTED)
|
|
||||||
protected DataUserAIS dataUser;
|
|
||||||
private final static String title = "Rule to convert document as record";
|
|
||||||
|
|
||||||
@BeforeClass (alwaysRun = true)
|
|
||||||
public void setUp()
|
|
||||||
{
|
|
||||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
recordCategory = createRootCategory(getRandomName("recordCategory"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-1521")
|
|
||||||
public void declareDocsAsRecordsOnUpdateRuleNewVersion() {
|
|
||||||
FolderModel testFolder;
|
|
||||||
|
|
||||||
STEP("Create test collaboration site to store documents in.");
|
|
||||||
publicSite = dataSite.usingAdmin().createPublicRandomSite();
|
|
||||||
|
|
||||||
STEP("Create a record folder with a DECLARE_AS_RECORD");
|
|
||||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
|
||||||
.applyToChildren(true)
|
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
|
||||||
|
|
||||||
STEP("Create a document in the collaboration site");
|
|
||||||
FileModel testFile = dataContent.usingSite(publicSite)
|
|
||||||
.usingAdmin()
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
assertStatusCode(CREATED);
|
|
||||||
|
|
||||||
|
|
||||||
// verify the declared record is in Unfilled Records folder
|
|
||||||
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
|
||||||
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
|
||||||
.getEntries()
|
|
||||||
.stream()
|
|
||||||
.filter(e -> e.getEntry().getId().equals(testFile.getNodeRefWithoutVersion()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
//delete rm items
|
|
||||||
deleteRecordCategory(recordCategory.getId());
|
|
||||||
STEP("Delete the record.");
|
|
||||||
//delete created collaboration site
|
|
||||||
dataSite.deleteSite(publicSite);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
|
||||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.annotations.AfterMethod;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.BeforeMethod;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
import static org.testng.AssertJUnit.assertNotNull;
|
|
||||||
|
|
||||||
|
|
||||||
public class DestroyRecordFolderActionsTest extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private RecordCategory Category1,CATEGORY_TO_MOVE;
|
|
||||||
@Autowired
|
|
||||||
private DispositionScheduleService dispositionScheduleService;
|
|
||||||
@Autowired
|
|
||||||
private RecordFoldersAPI recordFoldersAPI;
|
|
||||||
private final String TEST_PREFIX = generateTestPrefix(DestroyRecordFolderActionsTest.class);
|
|
||||||
private final String folderDisposition = TEST_PREFIX + "RM-2937 folder ghosting";
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
private void setUp(){
|
|
||||||
|
|
||||||
STEP("Create the RM site if doesn't exist");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create two record category");
|
|
||||||
Category1 = createRootCategory(getRandomName("Category1"));
|
|
||||||
CATEGORY_TO_MOVE = createRootCategory(getRandomName("CATEGORY_TO_MOVE"));
|
|
||||||
|
|
||||||
//create retention schedule
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
|
||||||
|
|
||||||
// add cut off step
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
|
||||||
|
|
||||||
// add destroy step with ghosting
|
|
||||||
dispositionScheduleService.addDestroyWithGhostingImmediatelyAfterCutOff(Category1.getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest (jira = "RM-1621")
|
|
||||||
public void moveOnCutOffDestroyFolders() throws Exception {
|
|
||||||
|
|
||||||
//create folders
|
|
||||||
RecordCategoryChild FOLDER_DESTROY = createFolder(getAdminUser(),Category1.getId(),folderDisposition);
|
|
||||||
|
|
||||||
// edit disposition date
|
|
||||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),FOLDER_DESTROY.getName());
|
|
||||||
|
|
||||||
// cut off the FOLDER_DESTROY
|
|
||||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),FOLDER_DESTROY.getName());
|
|
||||||
|
|
||||||
|
|
||||||
// Destroy the FOLDER_DESTROY
|
|
||||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),FOLDER_DESTROY.getName());
|
|
||||||
|
|
||||||
|
|
||||||
//Move the FOLDER_DESTROY within the CATEGORY_TO_MOVE.");
|
|
||||||
getRestAPIFactory().getNodeAPI(toContentModel(FOLDER_DESTROY.getId())).move(createBodyForMoveCopy(CATEGORY_TO_MOVE.getId()));
|
|
||||||
assertStatusCode(OK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterMethod(alwaysRun = true)
|
|
||||||
private void deletePreconditions() {
|
|
||||||
|
|
||||||
deleteRecordCategory(Category1.getId());
|
|
||||||
deleteRecordCategory(CATEGORY_TO_MOVE.getId());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,439 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.rest.core.v0.RMEvents;
|
|
||||||
import org.alfresco.rest.model.RestNodeBodyMoveCopyModel;
|
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
|
||||||
import org.alfresco.rest.requests.Node;
|
|
||||||
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.user.UserRoles;
|
|
||||||
import org.alfresco.rest.v0.LinksAPI;
|
|
||||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordFoldersAPI;
|
|
||||||
import org.alfresco.rest.v0.RecordsAPI;
|
|
||||||
import org.alfresco.rest.v0.service.DispositionScheduleService;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.model.RepoTestModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.http.HttpEntity;
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
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.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_REF_WORKSPACE_SPACES_STORE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.CUT_OFF_ASPECT;
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.DATE_FILED;
|
|
||||||
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.springframework.http.HttpStatus.NO_CONTENT;
|
|
||||||
|
|
||||||
public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
|
||||||
@Autowired
|
|
||||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
|
||||||
@Autowired
|
|
||||||
private DispositionScheduleService dispositionScheduleService;
|
|
||||||
@Autowired
|
|
||||||
private LinksAPI linksAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordsAPI recordsAPI;
|
|
||||||
@Autowired
|
|
||||||
private RecordFoldersAPI recordFoldersAPI;
|
|
||||||
private final static String TEST_PREFIX = generateTestPrefix(DispositionScheduleLinkedRecordsTest.class);
|
|
||||||
private static final String CATEGORY_RM_3077 = TEST_PREFIX + "RM-3077_manager_sees_me";
|
|
||||||
private static final String COPY_CATEGORY_RM_3077 = "Copy_of_" + CATEGORY_RM_3077;
|
|
||||||
private static final String FOLDER_RM_3077 = "RM-3077_folder_"+ CATEGORY_RM_3077;
|
|
||||||
private static final String COPY_FOLDER_RM_3077 = "Copy_of_" + FOLDER_RM_3077;
|
|
||||||
private static final String FIRST_CATEGORY_RM_3060 = TEST_PREFIX + "RM-3060_category_record";
|
|
||||||
private static final String SECOND_CATEGORY_RM_3060 = "Copy_of_" + FIRST_CATEGORY_RM_3060;
|
|
||||||
private static final String FIRST_FOLDER_RM_3060 = TEST_PREFIX + "RM-3060_folder";
|
|
||||||
private static final String SECOND_FOLDER_RM_3060 = TEST_PREFIX + "RM-3060_disposition_on_Record_Level";
|
|
||||||
private static final String ELECTRONIC_RECORD_RM_3060 = TEST_PREFIX + "RM-3060_electronic_1_record";
|
|
||||||
private static final String NON_ELECTRONIC_RECORD_RM_3060 = TEST_PREFIX + "RM-3060_non-electronic_record";
|
|
||||||
private static final String FIRST_CATEGORY_RM_1622 = TEST_PREFIX + "RM-1622_category_record";
|
|
||||||
private static final String SECOND_CATEGORY_RM_1622 = "Copy_of_" + FIRST_CATEGORY_RM_1622;
|
|
||||||
private static final String FIRST_FOLDER_RM_1622 = TEST_PREFIX + "RM-1622_folder";
|
|
||||||
private static final String ELECTRONIC_RECORD_RM_1622 = TEST_PREFIX + "RM-1622_electronic_1_record";
|
|
||||||
private static final String SECOND_FOLDER_RM_1622 = TEST_PREFIX + "RM-1622_disposition_on_Record_Level";
|
|
||||||
private static final String TRANSFER_LOCATION = TEST_PREFIX + "RM-3060_transferred_records";
|
|
||||||
public static final String TRANSFER_TYPE = "rma:transferred";
|
|
||||||
private FilePlan filePlanModel;
|
|
||||||
private UserModel rmAdmin;
|
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void setupDispositionScheduleLinkedRecordsTest() {
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
//get file plan
|
|
||||||
filePlanModel = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// create "rm admin" user if it does not exist and assign it to RM Administrator role
|
|
||||||
rmAdmin = getDataUser().createRandomTestUser();
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),rmAdmin.getUsername(),
|
|
||||||
UserRoles.ROLE_RM_ADMIN.roleId);
|
|
||||||
|
|
||||||
// create "rm Manager" user if it does not exist and assign it to RM Administrator role
|
|
||||||
UserModel rmManager = getDataUser().createRandomTestUser();
|
|
||||||
rmRolesAndActionsAPI.assignRoleToUser(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), rmManager.getUsername(),
|
|
||||||
UserRoles.ROLE_RM_MANAGER.roleId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disposition Schedule on Record Folder with linked records test
|
|
||||||
* <p>
|
|
||||||
* Precondition:
|
|
||||||
* <p>
|
|
||||||
* Create rm_manager user that would have RM Managers role, rm_admin that would have RM Administrator role.
|
|
||||||
* Log in with admin user, create a category "manager sees me", give rm_manager read&file permission over it.
|
|
||||||
* Create a disposition schedule for it that would cut off folders after 1 day from created date. Copy the category.
|
|
||||||
* <p>
|
|
||||||
* <p/> TestRail Test C775<p/>
|
|
||||||
**/
|
|
||||||
@Test(enabled = false) // temporary disabled, see ACS-6073
|
|
||||||
@AlfrescoTest(jira = "RM-1622")
|
|
||||||
public void dispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
|
||||||
STEP("Create record category");
|
|
||||||
RecordCategory category1 = createRootCategory(CATEGORY_RM_3077);
|
|
||||||
|
|
||||||
//create retention schedule
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(category1.getName(), false);
|
|
||||||
|
|
||||||
// add cut off step
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(category1.getName(), "day|2", CREATED_DATE);
|
|
||||||
|
|
||||||
//create a copy of the category recordsCategory
|
|
||||||
String copyCategoryId = copyCategory(getAdminUser(), category1.getId(), COPY_CATEGORY_RM_3077);
|
|
||||||
|
|
||||||
// create folders in both categories
|
|
||||||
RecordCategoryChild catFolder = createRecordFolder(category1.getId(), FOLDER_RM_3077);
|
|
||||||
createRecordFolder(copyCategoryId, COPY_FOLDER_RM_3077);
|
|
||||||
|
|
||||||
// create record files
|
|
||||||
String electronicRecord = "RM-2801 electronic record";
|
|
||||||
Record elRecord = createElectronicRecord(catFolder.getId(), electronicRecord);
|
|
||||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), catFolder.getName(), electronicRecord);
|
|
||||||
|
|
||||||
String nonElectronicRecord = "RM-2801 non-electronic record";
|
|
||||||
Record nonElRecord = createNonElectronicRecord(catFolder.getId(), nonElectronicRecord);
|
|
||||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), catFolder.getName(), nonElectronicRecord);
|
|
||||||
|
|
||||||
// link the records to copy folder, then complete them
|
|
||||||
List<String> recordLists = new ArrayList<>();
|
|
||||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + elRecord.getId());
|
|
||||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + nonElRecord.getId());
|
|
||||||
|
|
||||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK, COPY_CATEGORY_RM_3077 + "/" +
|
|
||||||
COPY_FOLDER_RM_3077, recordLists);
|
|
||||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), elRecordFullName);
|
|
||||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), nonElRecordFullName);
|
|
||||||
|
|
||||||
// edit disposition date
|
|
||||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(), catFolder.getName());
|
|
||||||
|
|
||||||
// cut off the Folder
|
|
||||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"), catFolder.getName());
|
|
||||||
|
|
||||||
// Verify the Content
|
|
||||||
Node electronicNode = getNode(elRecord.getId());
|
|
||||||
assertTrue("The content of " + electronicRecord + " is available",
|
|
||||||
StringUtils.isEmpty(electronicNode.getNodeContent().getResponse().getBody().asString()));
|
|
||||||
|
|
||||||
// verify the Properties
|
|
||||||
AssertJUnit.assertNull("The properties are present even after cutting off the record.", elRecord.getProperties().getTitle());
|
|
||||||
|
|
||||||
// delete precondition
|
|
||||||
deleteRecordCategory(category1.getId());
|
|
||||||
deleteRecordCategory(copyCategoryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test covering RM-3060
|
|
||||||
* Check the disposition steps for a record can be executed
|
|
||||||
* When the record is linked to a folder with the same disposition schedule
|
|
||||||
* */
|
|
||||||
@Test(enabled = false) // temporary disabled, see ACS-6073
|
|
||||||
@AlfrescoTest (jira = "RM-3060")
|
|
||||||
public void sameDispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
|
||||||
|
|
||||||
// create a category with retention applied on records level
|
|
||||||
RecordCategory recordCategory = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
|
||||||
.createRootRecordCategory(RecordCategory.builder().name(FIRST_CATEGORY_RM_3060).build(),
|
|
||||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(FIRST_CATEGORY_RM_3060, true);
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(FIRST_CATEGORY_RM_3060, "week|1", DATE_FILED);
|
|
||||||
dispositionScheduleService.addTransferAfterEventStep(
|
|
||||||
FIRST_CATEGORY_RM_3060, TRANSFER_LOCATION, RMEvents.CASE_CLOSED.getEventName());
|
|
||||||
dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(FIRST_CATEGORY_RM_3060, "week|1", CUT_OFF_DATE);
|
|
||||||
|
|
||||||
// make a copy of the category created
|
|
||||||
String categorySecondId = copyCategory(getAdminUser(), recordCategory.getId(), SECOND_CATEGORY_RM_3060);
|
|
||||||
|
|
||||||
// create a folder on the category firstCategoryRM3060 with a complete electronic record
|
|
||||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(recordCategory.getId(),
|
|
||||||
FIRST_FOLDER_RM_3060);
|
|
||||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),
|
|
||||||
ELECTRONIC_RECORD_RM_3060);
|
|
||||||
|
|
||||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), FIRST_FOLDER_RM_3060, ELECTRONIC_RECORD_RM_3060);
|
|
||||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + FIRST_CATEGORY_RM_3060 + "/" + FIRST_FOLDER_RM_3060);
|
|
||||||
|
|
||||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
|
||||||
|
|
||||||
// create a folder on the category secondCategoryRM3060 with a non electronic record
|
|
||||||
RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(categorySecondId,
|
|
||||||
SECOND_FOLDER_RM_3060);
|
|
||||||
Record secondNonElectronicRecord = createNonElectronicRecord(secondFolderRecordCategoryChild.getId(),
|
|
||||||
NON_ELECTRONIC_RECORD_RM_3060);
|
|
||||||
|
|
||||||
// link the nonElectronicRecordRM3060 to firstFolderRM3060
|
|
||||||
List<String> recordLists = new ArrayList<>();
|
|
||||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
|
||||||
|
|
||||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK, SECOND_CATEGORY_RM_3060 + "/" +
|
|
||||||
SECOND_FOLDER_RM_3060, recordLists);
|
|
||||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(),
|
|
||||||
SECOND_FOLDER_RM_3060, secondNonElectronicRecord.getName());
|
|
||||||
String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + SECOND_CATEGORY_RM_3060
|
|
||||||
+ "/" + SECOND_FOLDER_RM_3060);
|
|
||||||
|
|
||||||
// complete records and cut them off
|
|
||||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), nonElRecordFullName);
|
|
||||||
|
|
||||||
// edit the disposition date
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
|
||||||
|
|
||||||
// cut off the record
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
|
||||||
|
|
||||||
//check the record is cut off
|
|
||||||
AssertJUnit.assertTrue("The file " + NON_ELECTRONIC_RECORD_RM_3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
|
||||||
|
|
||||||
// link the electronic record to secondFolderRM3060
|
|
||||||
recordLists.clear();
|
|
||||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
|
||||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK, SECOND_CATEGORY_RM_3060 + "/" +
|
|
||||||
SECOND_FOLDER_RM_3060, recordLists);
|
|
||||||
|
|
||||||
// edit the disposition date and cut off the record
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
|
||||||
|
|
||||||
AssertJUnit.assertTrue("The file " + ELECTRONIC_RECORD_RM_3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
|
||||||
|
|
||||||
// open the record and complete the disposition schedule event
|
|
||||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(), elRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
|
||||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(), nonElRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
|
||||||
|
|
||||||
// transfer the files & complete transfers
|
|
||||||
HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + SECOND_CATEGORY_RM_3060
|
|
||||||
+ "/" + SECOND_FOLDER_RM_3060));
|
|
||||||
|
|
||||||
String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
|
||||||
|
|
||||||
HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + FIRST_CATEGORY_RM_3060
|
|
||||||
+ "/" + FIRST_FOLDER_RM_3060));
|
|
||||||
|
|
||||||
String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
|
||||||
|
|
||||||
AssertJUnit.assertTrue("The file " + ELECTRONIC_RECORD_RM_3060 + " has not been successfully transferred", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
|
||||||
AssertJUnit.assertTrue("The file " + NON_ELECTRONIC_RECORD_RM_3060 + " has not been successfully transferred.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
|
||||||
|
|
||||||
// edit the disposition date for nonElectronicRecordRM3060 & electronicRecordRM3060
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
|
||||||
|
|
||||||
// destroy nonElectronicRecordRM3060 & electronicRecordRM3060 records
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
|
||||||
|
|
||||||
// check the file is not displayed
|
|
||||||
assertNull("The file " + NON_ELECTRONIC_RECORD_RM_3060 + " has not been successfully destroyed.", secondNonElectronicRecord.getContent());
|
|
||||||
assertNull("The file " + ELECTRONIC_RECORD_RM_3060 + " has not been successfully destroyed.", firstElectronicRecord.getContent());
|
|
||||||
|
|
||||||
// delete precondition
|
|
||||||
deleteRecordCategory(recordCategory.getId());
|
|
||||||
deleteRecordCategory(categorySecondId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String copyCategory(UserModel user, String categoryId, String copyName) {
|
|
||||||
RepoTestModel repoTestModel = new RepoTestModel() {};
|
|
||||||
repoTestModel.setNodeRef(categoryId);
|
|
||||||
RestNodeModel restNodeModel;
|
|
||||||
|
|
||||||
RestNodeBodyMoveCopyModel copyDestinationInfo = new RestNodeBodyMoveCopyModel();
|
|
||||||
copyDestinationInfo.setTargetParentId(filePlanModel.getId());
|
|
||||||
copyDestinationInfo.setName(copyName);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
restNodeModel = getRestAPIFactory().getNodeAPI(user, repoTestModel).copy(copyDestinationInfo);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Problem copying category.", e);
|
|
||||||
}
|
|
||||||
return restNodeModel.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Node getNode(String recordId)
|
|
||||||
{
|
|
||||||
RepoTestModel repoTestModel = new RepoTestModel() {};
|
|
||||||
repoTestModel.setNodeRef(recordId);
|
|
||||||
return getRestAPIFactory().getNodeAPI(repoTestModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTransferId(HttpResponse httpResponse,String nodeRef) {
|
|
||||||
HttpEntity entity = httpResponse.getEntity();
|
|
||||||
String responseString;
|
|
||||||
try {
|
|
||||||
responseString = EntityUtils.toString(entity, "UTF-8");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
JSONObject result = new JSONObject(responseString);
|
|
||||||
return result
|
|
||||||
.getJSONObject("results")
|
|
||||||
.get(nodeRef)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-1622")
|
|
||||||
public void sameLevelDispositionScheduleStepsPeriodsCalculation() throws Exception {
|
|
||||||
|
|
||||||
// create a category with retention applied on records level
|
|
||||||
RecordCategory catsameLevel1 = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
|
||||||
.createRootRecordCategory(RecordCategory.builder().name(
|
|
||||||
FIRST_CATEGORY_RM_1622).build(),
|
|
||||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
|
||||||
RecordCategory catsameLevel2 = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
|
||||||
.createRootRecordCategory(RecordCategory.builder().name(
|
|
||||||
SECOND_CATEGORY_RM_1622).build(),
|
|
||||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
|
||||||
|
|
||||||
// create retention schedule applied on records for category 1
|
|
||||||
dispositionScheduleService.createCategoryRetentionSchedule(FIRST_CATEGORY_RM_1622, true);
|
|
||||||
|
|
||||||
// with retain immediately after record creation date and cut 1 day after record creation date
|
|
||||||
dispositionScheduleService.addCutOffAfterPeriodStep(FIRST_CATEGORY_RM_1622, "day|1", DATE_FILED);
|
|
||||||
|
|
||||||
|
|
||||||
// create a folder on the category firstCategoryRM1622 with a complete electronic record
|
|
||||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(catsameLevel1.getId(),
|
|
||||||
FIRST_FOLDER_RM_1622);
|
|
||||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),
|
|
||||||
ELECTRONIC_RECORD_RM_1622);
|
|
||||||
|
|
||||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), FIRST_FOLDER_RM_1622, ELECTRONIC_RECORD_RM_1622);
|
|
||||||
recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + FIRST_CATEGORY_RM_1622 + "/" + FIRST_FOLDER_RM_1622);
|
|
||||||
|
|
||||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
|
||||||
|
|
||||||
// create a folder on the category secondCategoryRM1622 with a non electronic record
|
|
||||||
createRecordFolder(catsameLevel2.getId(), SECOND_FOLDER_RM_1622);
|
|
||||||
String elRecordNameNodeRefs = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + FIRST_CATEGORY_RM_1622 + "/" + FIRST_FOLDER_RM_1622);
|
|
||||||
|
|
||||||
|
|
||||||
// link it to the folder in second category through the details page
|
|
||||||
List<String> recordLists = new ArrayList<>();
|
|
||||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + firstElectronicRecord.getId());
|
|
||||||
|
|
||||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
|
||||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK, SECOND_CATEGORY_RM_1622 + "/" +
|
|
||||||
SECOND_FOLDER_RM_1622, recordLists);
|
|
||||||
|
|
||||||
// edit disposition date
|
|
||||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
|
||||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test (dependsOnMethods = {"sameLevelDispositionScheduleStepsPeriodsCalculation" })
|
|
||||||
public void deleteLongestPeriodTestPrecondition() {
|
|
||||||
// Delete the RM site
|
|
||||||
getRestAPIFactory().getRMSiteAPI().deleteRMSite();
|
|
||||||
|
|
||||||
// Verify the status code
|
|
||||||
assertStatusCode(NO_CONTENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* -
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
* -
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
* -
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
* -
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.smoke;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
|
||||||
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
|
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
|
||||||
import org.alfresco.rest.v0.RecordCategoriesAPI;
|
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
|
||||||
import org.alfresco.test.AlfrescoTest;
|
|
||||||
import org.alfresco.utility.Utility;
|
|
||||||
import org.alfresco.utility.data.DataContent;
|
|
||||||
import org.alfresco.utility.data.DataSite;
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
|
||||||
import org.alfresco.utility.model.FileType;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
|
||||||
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
|
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
|
||||||
import static org.springframework.test.util.AssertionErrors.assertTrue;
|
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
public class FileAsRecordTests extends BaseRMRestTest {
|
|
||||||
|
|
||||||
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
|
||||||
private static final String CATEGORY_ADMIN = "catAdmin" + generateTestPrefix(FileAsRecordTests.class);
|
|
||||||
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
|
||||||
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
|
||||||
|
|
||||||
private UserModel nonRMuser,rmManager;
|
|
||||||
private SiteModel testSite;
|
|
||||||
private FileModel document, documentDeclared;
|
|
||||||
private RecordCategory category_manager, category_admin;
|
|
||||||
private RecordCategoryChild folder_admin, folder_manager ;
|
|
||||||
@Autowired
|
|
||||||
private DataSite dataSite;
|
|
||||||
@Autowired
|
|
||||||
private DataContent dataContent;
|
|
||||||
@Autowired
|
|
||||||
private RoleService roleService;
|
|
||||||
@Autowired
|
|
||||||
private RecordCategoriesAPI recordCategoriesAPI;
|
|
||||||
/**
|
|
||||||
* Create preconditions:
|
|
||||||
* <pre>
|
|
||||||
* 1. RM site is created
|
|
||||||
* 2. Two users: user without RM role and a user with RM manager role
|
|
||||||
* 3. Two Record categories with one folder each
|
|
||||||
* 4. User with RM MANAGER role has Filling permission over one category
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void preconditionForFileAsRecordRecordTests()
|
|
||||||
{
|
|
||||||
STEP("Create the RM site if doesn't exist");
|
|
||||||
createRMSiteIfNotExists();
|
|
||||||
|
|
||||||
STEP("Create a user");
|
|
||||||
nonRMuser = dataUser.createRandomTestUser("testUser");
|
|
||||||
|
|
||||||
STEP("Create a collaboration site");
|
|
||||||
testSite = dataSite.usingUser(nonRMuser).createPublicRandomSite();
|
|
||||||
|
|
||||||
STEP("Create a document with the user without RM role");
|
|
||||||
document = dataContent.usingSite(testSite)
|
|
||||||
.usingUser(nonRMuser)
|
|
||||||
.createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
STEP("Create two categories with two folders");
|
|
||||||
category_manager = createRootCategory(CATEGORY_MANAGER);
|
|
||||||
category_admin = createRootCategory(CATEGORY_ADMIN);
|
|
||||||
folder_admin = createFolder(category_admin.getId(),FOLDER_ADMIN);
|
|
||||||
folder_manager = createFolder(category_manager.getId(),FOLDER_MANAGER);
|
|
||||||
|
|
||||||
STEP("Create an rm user and give filling permission over CATEGORY_MANAGER record category");
|
|
||||||
RecordCategory recordCategory = new RecordCategory().builder()
|
|
||||||
.id(category_manager.getId())
|
|
||||||
.build();
|
|
||||||
rmManager = roleService.createCollaboratorWithRMRoleAndPermission(testSite, recordCategory,
|
|
||||||
UserRoles.ROLE_RM_MANAGER, PERMISSION_FILING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given I have selected the record folder I want to file my declared record to
|
|
||||||
* When I confirm the action
|
|
||||||
* Then the dialog closes
|
|
||||||
* And the document is now shown as a record in the collaboration site
|
|
||||||
* And if I navigated to the record folder, as any user who had the right permissions, then I would see the
|
|
||||||
* record filed
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest(jira = "RM-6780")
|
|
||||||
public void checkFileAsRecordToRecordFolder() throws Exception {
|
|
||||||
|
|
||||||
AtomicReference<RecordFolderCollection> apiChildren = new AtomicReference<>();
|
|
||||||
STEP("Create a document with the user with RM role");
|
|
||||||
documentDeclared = dataContent.usingSite(testSite).usingUser(rmManager)
|
|
||||||
.createContent(new FileModel("checkDeclareAndFileToRecordFolder", FileType.TEXT_PLAIN));
|
|
||||||
|
|
||||||
STEP("Declare and file into a record folder the document uploaded");
|
|
||||||
|
|
||||||
getRestAPIFactory().getActionsAPI(rmManager).declareAndFile(documentDeclared,
|
|
||||||
Utility.buildPath(CATEGORY_MANAGER, FOLDER_MANAGER));
|
|
||||||
|
|
||||||
STEP("Check the file is a record within the collaboration site");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Utility.sleep(1000, 40000, () ->
|
|
||||||
{
|
|
||||||
JSONObject collaboratorSearchJson = getSearchApi().liveSearchForDocuments(rmManager.getUsername(),
|
|
||||||
rmManager.getPassword(),
|
|
||||||
documentDeclared.getName());
|
|
||||||
assertTrue("Rm Manager not able to find the document.", collaboratorSearchJson.getJSONArray("items").length() != 0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
STEP("Check the record is filed into the record folder.");
|
|
||||||
// Get children from API
|
|
||||||
// List children from API
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Utility.sleep(1000, 40000, () ->
|
|
||||||
{
|
|
||||||
apiChildren.set((RecordFolderCollection) getRestAPIFactory()
|
|
||||||
.getRecordFolderAPI(rmManager).getRecordFolderChildren(folder_manager.getId(), "include=properties")
|
|
||||||
.assertThat().entriesListIsNotEmpty().assertThat().entriesListIsNotEmpty());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
fail("InterruptedException received while waiting for results.");
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals(apiChildren.get()
|
|
||||||
.getEntries()
|
|
||||||
.get(0)
|
|
||||||
.getEntry()
|
|
||||||
.getProperties()
|
|
||||||
.getOriginalName(),documentDeclared.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given I have selected the "File As Record" action
|
|
||||||
* When I confirm the action without selecting a location to file to
|
|
||||||
* Then the record is declared in the unfiled folder
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
@AlfrescoTest (jira = "RM-6780")
|
|
||||||
public void fileAsRecordToUnfiledRecordFolder() throws Exception {
|
|
||||||
STEP("Create a document with the user without RM role");
|
|
||||||
FileModel inplaceRecord = dataContent.usingSite(testSite).usingUser(rmManager)
|
|
||||||
.createContent(new FileModel("declareAndFileToIntoUnfiledRecordFolder",
|
|
||||||
FileType.TEXT_PLAIN));
|
|
||||||
|
|
||||||
STEP("Click on Declare and file without selecting a record folder");
|
|
||||||
getRestAPIFactory().getActionsAPI(rmManager).declareAndFile(inplaceRecord,"");
|
|
||||||
|
|
||||||
STEP("Check the file is declared in unfiled record folder");
|
|
||||||
Assert.assertTrue(isMatchingRecordInUnfiledRecords(inplaceRecord), "Record should be filed to Unfiled Records folder");
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
public void cleanUpForFileAsRecordRecordTests() {
|
|
||||||
STEP("Delete the collaboration site");
|
|
||||||
dataSite.usingUser(nonRMuser).deleteSite(testSite);
|
|
||||||
|
|
||||||
STEP("Empty the trashcan.");
|
|
||||||
restClient.authenticateUser(nonRMuser).withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(toContentModel(testSite.getId()));
|
|
||||||
|
|
||||||
getRestAPIFactory()
|
|
||||||
.getUnfiledContainersAPI(rmManager)
|
|
||||||
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
|
||||||
.getEntries()
|
|
||||||
.stream()
|
|
||||||
.forEach(x -> getRestAPIFactory()
|
|
||||||
.getRecordsAPI()
|
|
||||||
.deleteRecord(x.getEntry().getId()));
|
|
||||||
|
|
||||||
STEP("Cleanup Documents inside folders");
|
|
||||||
|
|
||||||
STEP("Delete folders");
|
|
||||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(folder_admin.getId());
|
|
||||||
getRestAPIFactory().getRecordFolderAPI().deleteRecordFolder(folder_manager.getId());
|
|
||||||
|
|
||||||
STEP("Delete categories");
|
|
||||||
recordCategoriesAPI.deleteCategory(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), category_manager.getName());
|
|
||||||
recordCategoriesAPI.deleteCategory(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
|
||||||
getDataUser().usingAdmin().getAdminUser().getPassword(), category_admin.getName());
|
|
||||||
|
|
||||||
STEP("Delete Users");
|
|
||||||
dataUser.deleteUser(nonRMuser);
|
|
||||||
dataUser.deleteUser(rmManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user