Compare commits

..

182 Commits

Author SHA1 Message Date
alfresco-build
646211fea0 [maven-release-plugin][skip ci] prepare release 20.45-DEV 2022-12-16 15:18:32 +00:00
Damian.Ujma@hyland.com
6520228db4 Test dev release [skip tests] 2022-12-16 16:01:12 +01:00
Damian.Ujma@hyland.com
6c0c6d4872 Test [skip tests] 2022-12-16 15:42:37 +01:00
Damian.Ujma@hyland.com
bf89b6f154 Test [skip repo][tas] 2022-12-16 15:39:05 +01:00
Damian.Ujma@hyland.com
3fd00f1d40 Test [latest db][skip db][ags on MySQL] 2022-12-16 15:36:01 +01:00
Damian.Ujma@hyland.com
a490a23f9a Test [db][ags] 2022-12-16 15:17:56 +01:00
Damian.Ujma@hyland.com
547bcb4759 Test [db][ags] 2022-12-16 15:02:50 +01:00
Damian.Ujma@hyland.com
583467904a ACS-3841 Fix pull_request trigger 2022-12-16 13:51:32 +01:00
Damian.Ujma@hyland.com
cc8dcc51e1 ACS-3841 Refine worksflows 2022-12-16 13:21:50 +01:00
Damian.Ujma@hyland.com
c59f0c9c4d Merge branch 'master' into feature/ACS-3841_migrate_to_gha 2022-12-16 12:32:01 +01:00
Damian.Ujma@hyland.com
c3b01aa89e Revert "ACS-3841 Test WebDAV TAS test [tas]" 2022-12-16 12:31:53 +01:00
Travis CI User
60a04b0402 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-16 11:03:04 +00:00
Travis CI User
c50c10ef2b [maven-release-plugin][skip ci] prepare release 20.44 2022-12-16 11:03:01 +00:00
Damian Ujma
cdbe3292e0 ACS-3841 Add missing logs for WebDAV TAS tests (#1629)
* ACS-3841 Add missing logs

* ACS-3841 Reformat code + fix grep
2022-12-16 11:27:02 +01:00
Damian.Ujma@hyland.com
2c860b827f ACS-3841 Rename steps 2022-12-15 15:58:58 +01:00
Travis CI User
54843fa336 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-15 14:09:45 +00:00
Travis CI User
c66bb48258 [maven-release-plugin][skip ci] prepare release 20.43 2022-12-15 14:09:41 +00:00
Damian.Ujma@hyland.com
fdc8c0ade1 ACS-3841 Adopt setup-java-build action from alfresco-build-tools [tas] 2022-12-15 14:29:37 +01:00
kcichonczyk
077752ad86 bumped IE version to 2.0.6 (ACS-4054) (#1628) 2022-12-15 14:28:46 +01:00
Damian.Ujma@hyland.com
004ea6e049 ACS-3841 Test WebDAV TAS test [tas] 2022-12-15 14:24:28 +01:00
Damian.Ujma@hyland.com
d77fa7dead ACS-3841 Fix postgres jobs conditions [db] 2022-12-15 12:36:16 +01:00
Damian.Ujma@hyland.com
256398a15d ACS-3841 Add the init step to all jobs 2022-12-15 10:56:19 +01:00
Travis CI User
1749b2d74b [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-14 16:39:51 +00:00
Travis CI User
eea23b0d2a [maven-release-plugin][skip ci] prepare release 20.42 2022-12-14 16:39:48 +00:00
George Evangelopoulos
88b6a8e5b3 ACS-4030: Delete category endpoint (#1618)
* ACS-4030: Delete category endpoint implementation and tests
2022-12-14 16:00:59 +00:00
Damian.Ujma@hyland.com
c8abb9d3fc ACS-3841 Fix GIT_EMAIL variable 2022-12-14 16:26:21 +01:00
Damian.Ujma@hyland.com
d07a47d088 ACS-3841 Set continue-on-error [tas][db][ags] 2022-12-14 10:47:11 +01:00
Damian.Ujma@hyland.com
94cb9de79b ACS-3841 Fix tests [tas][db][ags] 2022-12-14 08:52:47 +01:00
Travis CI User
28114338c8 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-13 16:59:55 +00:00
Travis CI User
78e1d5863c [maven-release-plugin][skip ci] prepare release 20.41 2022-12-13 16:59:52 +00:00
Maciej Pichura
0aae95b255 ACS-4031 list category children (#1617)
* ACS-4031: Get category children endpoint.

* ACS-4031: Fix in E2E test.

* ACS-4031: Adding more unit tests.

* Fix test description

Co-authored-by: Tom Page <tpage-alfresco@users.noreply.github.com>

* Fix test description

Co-authored-by: Tom Page <tpage-alfresco@users.noreply.github.com>

* ACS-4031: Refactoring after code review.

* ACS-4031: Updating E2E test after latest logic refactor.

Co-authored-by: Tom Page <tpage-alfresco@users.noreply.github.com>
2022-12-13 17:13:02 +01:00
Damian.Ujma@hyland.com
841735491d ACS-3841 Improve conditions [tas][db][ags] 2022-12-13 16:54:01 +01:00
Damian.Ujma@hyland.com
42e29d95de ACS-3841 Improve conditions [tas][db][ags] 2022-12-13 16:51:59 +01:00
Damian.Ujma@hyland.com
5749a1a67a ACS-3841 Improve maven_release.sh 2022-12-12 10:37:09 +01:00
Damian.Ujma@hyland.com
9dce05cb5b Merge branch 'master' into feature/ACS-3841_migrate_to_gha 2022-12-12 10:28:02 +01:00
Travis CI User
c1198a0145 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-11 00:10:54 +00:00
Travis CI User
6bd50fda1a [maven-release-plugin][skip ci] prepare release 20.40 2022-12-11 00:10:52 +00:00
Alfresco CI User
ace6eca99b [force] Force release for 2022-12-11. 2022-12-11 00:03:34 +00:00
Travis CI User
0f8349dc4c [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-09 10:34:04 +00:00
Travis CI User
eb7bcbfbfb [maven-release-plugin][skip ci] prepare release 20.39 2022-12-09 10:34:02 +00:00
dependabot[bot]
d9bbc9c628 Bump alfresco-googledrive-repo-community (#1611)
Bumps [alfresco-googledrive-repo-community](https://github.com/Alfresco/googledrive) from 3.3.1-DEV-LOG4J2 to 3.4.0-A1.
- [Release notes](https://github.com/Alfresco/googledrive/releases)
- [Changelog](https://github.com/Alfresco/googledrive/blob/master/docs/build-and-release-101.md)
- [Commits](https://github.com/Alfresco/googledrive/compare/3.3.1-DEV-LOG4J2...3.4.0-A1)

---
updated-dependencies:
- dependency-name: org.alfresco.integrations:alfresco-googledrive-repo-community
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-09 10:53:15 +01:00
Travis CI User
5c434f7898 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-08 17:19:04 +00:00
Travis CI User
06a25a48da [maven-release-plugin][skip ci] prepare release 20.38 2022-12-08 17:19:01 +00:00
Maciej Pichura
f511436823 ACS-4032 create category (multiple categories pagination fix) (#1610)
* ACS-4032: Some fixes and refactors after verification. Fixing pagination info on POST multiple entities response.

* ACS-4032: Some fixes and refactors after verification. Fixing pagination info on POST multiple entities response.

* Fixing a test STEP description

Co-authored-by: Tom Page <tpage-alfresco@users.noreply.github.com>

Co-authored-by: Tom Page <tpage-alfresco@users.noreply.github.com>
2022-12-08 17:40:56 +01:00
Travis CI User
f96b3012c4 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-08 10:17:34 +00:00
Travis CI User
415aa2ca33 [maven-release-plugin][skip ci] prepare release 20.37 2022-12-08 10:17:31 +00:00
Maciej Pichura
b701f9a994 ACS-4032 Create category (POST) (#1606)
* ACS-4028 Get category by id (#1591)

* ACS-4028: Get category by id endpoint.

* ACS-4028: Get category by id endpoint.

* ACS-4028: Get category by id endpoint - integration TAS tests.

* ACS-4028: Get category by id endpoint - refactoring.

* ACS-4028: Adding test to test suite.

* ACS-4028: Fixes after code review.

* ACS-4032: Initial code for POST category endpoint.

* ACS-4032: Full implementation for POST category endpoint + tests.

* ACS-4032: Some fixes and refactors after code review.
2022-12-08 10:43:22 +01:00
Travis CI User
d04043b015 [maven-release-plugin][skip ci] prepare for next development iteration 2022-12-08 08:59:35 +00:00
Travis CI User
e3241fe178 [maven-release-plugin][skip ci] prepare release 20.36 2022-12-08 08:59:32 +00:00
Damian Ujma
ea8ed0eec3 ACS-4142 Update AOS version (#1607) 2022-12-08 09:20:03 +01:00
Damian.Ujma@hyland.com
f06f2edaa1 ACS-3841 Rename directory [db][tas][db][ags][ags on MySQL] 2022-12-05 17:02:19 +01:00
Damian.Ujma@hyland.com
24e685b70e ACS-3841 Set preserve-order to false [ags] 2022-12-05 15:06:24 +01:00
Damian.Ujma@hyland.com
e603f7882f ACS-3841 Revert ubuntu version for ags rest api test [ags] 2022-12-05 10:23:04 +01:00
Damian.Ujma@hyland.com
683e73e687 ACS-3841 Add the license header [ags] 2022-12-05 09:51:35 +01:00
Damian.Ujma@hyland.com
15fe18ca9f ACS-3841 Run on ubuntu-18.04 [ags] 2022-12-05 09:43:52 +01:00
Damian.Ujma@hyland.com
ce47b25fd8 ACS-3841 Test AlphabeticallyPriorityInterceptor [ags] 2022-12-05 09:31:23 +01:00
Damian.Ujma@hyland.com
cc3d965414 Revert "ACS-3841 Test without records [ags]"
This reverts commit 9ee412df04.
2022-12-01 10:17:44 +01:00
Damian.Ujma@hyland.com
9ee412df04 ACS-3841 Test without records [ags] 2022-11-28 17:14:10 +01:00
Damian.Ujma@hyland.com
e9a0a31c84 ACS-3841 Reverse tests order [ags] 2022-11-28 16:29:07 +01:00
Damian.Ujma@hyland.com
7dd8aef46c ACS-3841 Reverse tests order [ags] 2022-11-28 16:26:08 +01:00
Damian.Ujma@hyland.com
4e14c2cbd7 ACS-3841 Fix test order [db][tas][db][ags][ags on MySQL] 2022-11-28 14:57:41 +01:00
Damian.Ujma@hyland.com
b618ea7e06 ACS-3841 Fix condition [db][tas][db][ags][ags on MySQL] 2022-11-25 16:27:21 +01:00
Damian.Ujma@hyland.com
f67a08c7e3 ACS-3841 Improve jobs conditions [db][tas][db][ags][ags on MySQL] 2022-11-25 16:13:33 +01:00
Damian.Ujma@hyland.com
1a3d59dfa1 ACS-3841 Fix steps [db][tas][db][ags][ags on MySQL] 2022-11-25 13:26:11 +01:00
Damian.Ujma@hyland.com
1b6d8af497 ACS-3841 Fix custom action [db][tas][db][ags][ags on MySQL] 2022-11-25 13:23:45 +01:00
Damian.Ujma@hyland.com
c4c910b13e Revert "ACS-3841 Remove useless var [db][tas][db][ags][ags on MySQL]" 2022-11-25 13:21:57 +01:00
Damian.Ujma@hyland.com
e9af1baa86 ACS-3841 Test 2022-11-25 13:20:42 +01:00
Damian.Ujma@hyland.com
7927c7a119 ACS-3841 Test 2022-11-25 13:19:40 +01:00
Damian.Ujma@hyland.com
3a5c47babb ACS-3841 Test 2022-11-25 13:18:19 +01:00
Damian.Ujma@hyland.com
7f6c503434 ACS-3841 Remove useless var [db][tas][db][ags][ags on MySQL] 2022-11-25 13:17:04 +01:00
Damian.Ujma@hyland.com
18acbf65dc ACS-3841 Use custom actions to setup build tools [db][tas][db][ags][ags on MySQL] 2022-11-25 13:08:32 +01:00
Damian.Ujma@hyland.com
50b7d83495 ACS-3841 Remove travis references 2022-11-25 09:38:15 +01:00
Damian.Ujma@hyland.com
c9f64210e4 ACS-3841 Remove quay login step [db][tas][db][ags][ags on MySQL] 2022-11-24 16:27:38 +01:00
Damian.Ujma@hyland.com
4bbf264cdc ACS-3841 Fix remote-api tests [db][tas][db][ags][ags on MySQL] 2022-11-24 15:57:29 +01:00
Damian.Ujma@hyland.com
7c21ec298d ACS-3841 Fix remote-api tests [db][tas][db][ags][ags on MySQL] 2022-11-24 15:47:07 +01:00
Damian.Ujma@hyland.com
85d7fccf11 ACS-3841 Test [db][tas][db][ags][ags on MySQL] 2022-11-24 13:57:07 +01:00
Damian.Ujma@hyland.com
e51457d535 ACS-3841 Test [db][tas][db][ags][ags on MySQL] 2022-11-23 16:27:18 +01:00
Damian.Ujma@hyland.com
f5bbdd7ead ACS-3841 Fix syntax [tas] 2022-11-23 14:39:55 +01:00
Damian.Ujma@hyland.com
8885e91a58 ACS-3841 Fix syntax [tas] 2022-11-23 14:33:28 +01:00
Damian.Ujma@hyland.com
d652244292 ACS-3841 Test Remote-api-AppContextTestSuites + [tas] 2022-11-23 14:19:32 +01:00
Damian.Ujma@hyland.com
f04ca4b77f ACS-3841 Fix transformers tag 2022-11-23 12:22:02 +01:00
Damian.Ujma@hyland.com
ad2b107afd ACS-3841 Fix transformers tag 2022-11-23 12:12:32 +01:00
Damian.Ujma@hyland.com
75f68c612e ACS-3841 Fix internal script 2022-11-23 12:05:06 +01:00
Damian.Ujma@hyland.com
d3ff57bffc ACS-3841 Fix matrix strategy vars 2022-11-23 11:34:29 +01:00
Damian.Ujma@hyland.com
82efc2e564 ACS-3841 Add mariadb matrix tests 2022-11-23 10:38:17 +01:00
Damian.Ujma@hyland.com
af3e6f6009 ACS-3841 Test a matrix strategy 2022-11-23 10:00:06 +01:00
Damian.Ujma@hyland.com
457bb5b469 ACS-3841 Test a matrix strategy 2022-11-23 09:36:46 +01:00
Damian.Ujma@hyland.com
0f70ac9eba ACS-3841 Test a matrix strategy 2022-11-23 09:31:40 +01:00
Damian.Ujma@hyland.com
2bff9eeb00 Revert "ACS-3465 Redefine the tests order"
This reverts commit 670ff0de10.
2022-11-22 10:30:30 +01:00
Damian.Ujma@hyland.com
46b3021541 ACS-3841 Rename the ci scripts directory 2022-11-22 10:30:20 +01:00
Damian.Ujma@hyland.com
614884a4f6 ACS-3841 Fix step env 2022-11-21 17:21:04 +01:00
Damian.Ujma@hyland.com
615759f148 ACS-3841 Create docker-compose for dbs 2022-11-21 17:01:21 +01:00
Damian.Ujma@hyland.com
d323e7e3aa ACS-3841 Fix postgres port 2022-11-21 16:20:31 +01:00
Damian.Ujma@hyland.com
fee2a75049 Merge branch 'master' into feature/ACS-3841_migrate_to_gha 2022-11-21 16:11:39 +01:00
Damian.Ujma@hyland.com
35b2d64876 ACS-3841 Fix docker-compose 2022-11-21 15:37:18 +01:00
Damian.Ujma@hyland.com
115260470c ACS-3841 Fix docker-compose 2022-11-21 15:29:15 +01:00
Damian.Ujma@hyland.com
16727dce57 ACS-3841 Test cache local Maven 2022-11-21 14:58:18 +01:00
Damian.Ujma@hyland.com
670ff0de10 ACS-3465 Redefine the tests order 2022-09-02 08:54:03 +02:00
Damian.Ujma@hyland.com
e93ea3bcce ACS-3465 Fix 'needs' section 2022-09-01 13:39:58 +02:00
Damian.Ujma@hyland.com
f70743ed33 ACS-3465 Add required global env variables 2022-09-01 10:44:14 +02:00
Damian.Ujma@hyland.com
95ba57d06f Merge branch 'feature/ACS-3465_migrating_to_gh_actions' of github.com:Alfresco/alfresco-community-repo into feature/ACS-3465_migrating_to_gh_actions 2022-09-01 10:38:05 +02:00
Damian.Ujma@hyland.com
cb165c67b1 ACS-3465 Remove unnecessary conditions 2022-09-01 10:37:43 +02:00
mikolajbrzezinski
ca276a9e82 fix ifs 2022-09-01 10:11:24 +02:00
Damian.Ujma@hyland.com
c7f6e876dd ACS-3465 Add jobs names 2022-09-01 09:55:22 +02:00
Damian.Ujma@hyland.com
b6131b3dd3 ACS-3465 Revert changes in build.sh 2022-08-31 16:28:12 +02:00
Damian.Ujma@hyland.com
54b96280fc ACS-3465 Add a dependency to AGS-Community-Rest-API-Tests 2022-08-31 16:13:47 +02:00
Damian.Ujma@hyland.com
48fa7748f1 ACS-3465 Fix on.push.branches 2022-08-31 16:12:53 +02:00
Damian.Ujma@hyland.com
5f6795eff0 Merge branch 'feature/ACS-3465_migrating_to_gh_actions_du' of github.com:Alfresco/alfresco-community-repo into feature/ACS-3465_migrating_to_gh_actions_du
 Conflicts:
	.github/workflows/ci.yml
2022-08-31 16:11:00 +02:00
Damian.Ujma@hyland.com
e9c87493d0 ACS-3465 Add a condition for AGS-Community-Rest-API-Tests 2022-08-31 16:06:06 +02:00
Damian.Ujma@hyland.com
440582d176 ACS-3465 Remove maven version forcing 2022-08-31 16:01:21 +02:00
Damian.Ujma@hyland.com
9353865c25 Merge branch 'feature/ACS-3465_migrating_to_gh_actions' into feature/ACS-3465_migrating_to_gh_actions_du
# Conflicts:
#	.github/workflows/ci.yml
2022-08-31 16:00:41 +02:00
Damian.Ujma@hyland.com
f58ca49b06 ACS-3465 Add AGS-Community-Rest-API-Tests 2022-08-31 15:58:09 +02:00
Damian.Ujma@hyland.com
f6382f28d3 ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-31 15:19:50 +02:00
Damian.Ujma@hyland.com
50652a4fab Revert "ACS-3465 Increase timeout AGS-Community-Rest-API-Tests"
This reverts commit d6fb3814ab.
2022-08-31 15:16:53 +02:00
mikolajbrzezinski
93adf7515a fix ifs 2022-08-31 15:08:56 +02:00
Damian.Ujma@hyland.com
d6fb3814ab ACS-3465 Increase timeout AGS-Community-Rest-API-Tests 2022-08-31 14:39:31 +02:00
mikolajbrzezinski
93c1ee9cbf add ifs 2022-08-31 13:48:53 +02:00
Damian.Ujma@hyland.com
5c82775afb ACS-3465 Force Maven 3.5.4 for AGS-Community-Rest-API-Tests 2022-08-31 12:40:18 +02:00
Damian.Ujma@hyland.com
3535801e5c ACS-3465 Fix AGS-Community-Rest-API-Tests 2022-08-31 09:52:33 +02:00
Damian.Ujma@hyland.com
9d537e6158 ACS-3465 Fix merging 2022-08-30 16:38:56 +02:00
Damian.Ujma@hyland.com
f783d4bbc1 Merge branch 'feature/ACS-3465_migrating_to_gh_actions_du' of github.com:Alfresco/alfresco-community-repo into feature/ACS-3465_migrating_to_gh_actions_du
 Conflicts:
	.github/workflows/ci.yml
	scripts/gh-actions/maven_release.sh
2022-08-30 16:29:40 +02:00
Damian.Ujma@hyland.com
ff18fba533 ACS-3465 Add AGS-Community-Rest-API-Tests, Push-to-Nexus, Update-downstream jobs
ACS-3465 Test AGS-Community-Rest-API-Tests

ACS-3465 Test AGS-Community-Rest-API-Tests

ACS-3465 Test script execution

ACS-3465 Increase SearchRecordsTests timeout

ACS-3465 Make a script executable

ACS-3465 Test script execution

ACS-3465 Fix build step in AGS-Community-Rest-API-Tests

ACS-3465 Test AGS-Community-Rest-API-Tests

ACS-3465 Test AGS-Community-Rest-API-Tests

ACS-3465 Test AGS-Community-Rest-API-Tests
2022-08-30 16:28:53 +02:00
Damian.Ujma@hyland.com
a093a10484 ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-30 09:49:12 +02:00
mikolajbrzezinski
f9ca64bb51 fix requires local images 2022-08-30 09:38:04 +02:00
Damian.Ujma@hyland.com
08cbc94ee7 ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-30 09:21:02 +02:00
mikolajbrzezinski
22b9179961 cleanup 2022-08-29 17:10:08 +02:00
Damian.Ujma@hyland.com
eec1596872 ACS-3465 Test script execution 2022-08-29 16:12:37 +02:00
Damian.Ujma@hyland.com
ffe31c2a6a ACS-3465 Increase SearchRecordsTests timeout 2022-08-29 15:51:15 +02:00
Damian.Ujma@hyland.com
da4bd743e1 ACS-3465 Make a script executable 2022-08-29 15:28:03 +02:00
Damian.Ujma@hyland.com
b1f4b5fa93 ACS-3465 Test script execution 2022-08-29 14:36:04 +02:00
mikolajbrzezinski
f166fef906 fix require local images 2022-08-29 14:14:14 +02:00
mikolajbrzezinski
29470674ce fix remote api 2 2022-08-29 14:05:40 +02:00
mikolajbrzezinski
9eefea8904 fix 2022-08-29 13:50:44 +02:00
Damian.Ujma@hyland.com
01a4b7886b ACS-3465 Fix build step in AGS-Community-Rest-API-Tests 2022-08-29 13:44:33 +02:00
Damian.Ujma@hyland.com
79445d40fc ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-29 13:26:19 +02:00
Damian.Ujma@hyland.com
448687294d ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-29 13:25:42 +02:00
Damian.Ujma@hyland.com
56d374a915 ACS-3465 Test AGS-Community-Rest-API-Tests 2022-08-29 13:23:28 +02:00
mikolajbrzezinski
94b33bf7a9 no tag 2022-08-29 12:37:56 +02:00
mikolajbrzezinski
c53d71fc75 Revert "check with specific poms"
This reverts commit eff1ab0744.
2022-08-29 11:24:49 +02:00
mikolajbrzezinski
eff1ab0744 check with specific poms 2022-08-29 11:15:39 +02:00
mikolajbrzezinski
196e37e8d9 check more tests 2022-08-29 10:28:18 +02:00
mikolajbrzezinski
9886d4afe3 check with setting REQUIRES_LOCAL_IMAGES 2022-08-26 17:27:35 +02:00
mikolajbrzezinski
9105056738 check with setting REQUIRES_LOCAL_IMAGES 2022-08-26 17:27:06 +02:00
mikolajbrzezinski
a8484b3644 change verify 2022-08-26 16:54:29 +02:00
mikolajbrzezinski
e53377947e change verify 2022-08-26 16:20:21 +02:00
mikolajbrzezinski
77d67d4ed9 Revert "Change POM"
This reverts commit b5bd2be96e.
2022-08-26 16:15:40 +02:00
mikolajbrzezinski
b5bd2be96e Change POM 2022-08-26 16:13:09 +02:00
mikolajbrzezinski
770acdba38 Update env variables list 2022-08-26 15:46:27 +02:00
mikolajbrzezinski
1f3b024a28 Check with init 2022-08-26 15:20:15 +02:00
mikolajbrzezinski
bf72cbf0b0 Check simple bash command 2022-08-26 14:56:20 +02:00
mikolajbrzezinski
5c1ec44387 fix paths 2022-08-26 13:50:16 +02:00
mikolajbrzezinski
c536f53293 fix env variable 2022-08-26 12:15:03 +02:00
mikolajbrzezinski
b056e166cc Fix timeout and add step 2022-08-26 12:12:28 +02:00
mikolajbrzezinski
87bfcdbadd Check AGS 2022-08-26 11:25:55 +02:00
mikolajbrzezinski
62e09bd1ac Check AGS 2022-08-26 10:45:40 +02:00
mikolajbrzezinski
c9e7d798e5 Check rest api tas tests 2022-08-26 10:19:27 +02:00
mikolajbrzezinski
8762148a68 Clean up 2022-08-25 17:12:42 +02:00
mikolajbrzezinski
04af833ba6 Clean up 2022-08-25 17:11:44 +02:00
mikolajbrzezinski
5b6f56a2ef Clean up 2022-08-25 17:07:38 +02:00
mikolajbrzezinski
ea60259b36 Clean up 2022-08-25 16:25:46 +02:00
mikolajbrzezinski
a050488d8e Block veracode and add test suite 2022-08-25 16:19:46 +02:00
mikolajbrzezinski
0dde0315f1 Check veracode with fixes 2022-08-25 15:36:30 +02:00
mikolajbrzezinski
42da3ee691 Fix all Unit Tests Suite 2022-08-25 14:47:32 +02:00
mikolajbrzezinski
8d15375874 Fix transformers tag 2022-08-25 13:55:16 +02:00
mikolajbrzezinski
18a39ac0fd Fix transformers tag 2022-08-25 13:25:07 +02:00
mikolajbrzezinski
ad9bce3812 Fix transformers tag 2022-08-25 13:08:20 +02:00
mikolajbrzezinski
0401246d96 Check if can get the transformers tag 2022-08-25 12:42:04 +02:00
mikolajbrzezinski
bdce8a0329 check doker run job and veracode 2022-08-25 10:43:56 +02:00
mikolajbrzezinski
a4417a0ebf .travis.settings.xml 2022-08-25 10:03:25 +02:00
mikolajbrzezinski
905b34e64b travis.settings.xml 2022-08-25 09:55:23 +02:00
mikolajbrzezinski
a05c8c6634 Update 2022-08-24 18:10:56 +02:00
mikolajbrzezinski
8781d82216 change uses to run 2022-08-24 18:05:19 +02:00
mikolajbrzezinski
9be2a90f81 remove SRCCLR_API_TOKEN 2022-08-24 18:03:38 +02:00
mikolajbrzezinski
d56e53c0ef Add SRCCLR_API_TOKEN 2022-08-24 17:43:06 +02:00
mikolajbrzezinski
4ccb22acbb Try AllUnitTestsSuite 2022-08-24 17:31:34 +02:00
mikolajbrzezinski
f3c45a13dd try without transformers tag 2022-08-24 16:43:49 +02:00
mikolajbrzezinski
5f24b4c3cd add global variables and test veracode 2022-08-24 16:42:42 +02:00
mikolajbrzezinski
f7c07c30f5 add check-out 2022-08-24 16:03:24 +02:00
mikolajbrzezinski
a0ae0dd4ec Fix scripts path 2022-08-24 15:22:04 +02:00
mikolajbrzezinski
bbd7c46ddd Remove unnecesary action folder adn turn off travis for the branch 2022-08-24 15:19:13 +02:00
mikolajbrzezinski
87c0fa228e Change trigger and add clean cache to prepare 2022-08-24 14:03:19 +02:00
mikolajbrzezinski
72182f4ef5 Add skeleton 2022-08-23 19:13:05 +02:00
71 changed files with 2349 additions and 899 deletions

564
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,564 @@
name: Alfresco Community Repo CI
on:
pull_request:
branches:
- feature/**
- fix/**
push:
branches:
# - feature/**
- fix/**
workflow_call:
workflow_dispatch:
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
LOG_WARN: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
TAS_ENVIRONMENT: ./packaging/tests/environment
TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts
jobs:
prepare:
name: "Prepare"
runs-on: ubuntu-latest
if: >
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
# - name: "Prepare environment"
# run: bash ./scripts/ci/prepare.sh
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
veracode:
name: "Source Clear Scan (SCA)"
runs-on: ubuntu-latest
needs: [prepare]
if: >
((github.ref_name == 'master' || contains(github.ref_name, 'release/')) && github.event_name != 'pull_request') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: "Init"
run: bash ./scripts/ci/init.sh
- uses: Alfresco/alfresco-build-tools/.github/actions/veracode@master
with:
srcclr-api-token: ${{ secrets.SRCCLR_API_TOKEN }}
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
all_unit_tests_suite:
name: "Core, Data-Model, Repository - AllUnitTestsSuite - Build and test"
runs-on: ubuntu-latest
needs: [prepare]
if: >
! contains(github.event.head_commit.message, '[skip repo]') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Run tests"
run: |
mvn -B test -pl core,data-model -am -DfailIfNoTests=false
mvn -B test -pl "repository,mmt" -am "-Dtest=AllUnitTestsSuite,AllMmtUnitTestSuite" -DfailIfNoTests=false
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
remote_api_app_context_test_suites:
name: Remote-api - ${{ matrix.testSuite }}
runs-on: ubuntu-latest
needs: [prepare]
if: >
! contains(github.event.head_commit.message, '[skip repo]') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
include:
- testSuite: AppContext01TestSuite
compose-profile: default
- testSuite: AppContext02TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContext03TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContext04TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContextExtraTestSuite
compose-profile: default
env:
REQUIRES_INSTALLED_ARTIFACTS: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
bash ./scripts/ci/build.sh
- name: "Set transformers tag"
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
- name: "Run tests"
run: mvn -B test -pl remote-api -Dtest=${{ matrix.testSuite }} -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_mariadb_tests:
name: Repository - MariaDB ${{ matrix.version }} tests
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/')) &&
github.event_name != 'pull_request' &&
! contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[db]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
version: ['10.2.18', '10.4', '10.5']
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
env:
MARIADB_VERSION: ${{ matrix.version }}
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_mariadb_10_6_tests:
name: "Repository - MariaDB 10.6 tests"
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
! contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mariadb up -d
env:
MARIADB_VERSION: 10.6
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_mysql_tests:
name: Repository - MySQL 8 tests
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request') &&
! contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile mysql up -d
env:
MYSQL_VERSION: 8
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_postgresql_13_7_tests:
name: "Repository - PostgreSQL 13.7 tests"
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/')) && github.event_name != 'pull_request' &&
! contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[db]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
env:
POSTGRES_VERSION: 10.6
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_postgresql_14_4_tests:
name: "Repository - PostgreSQL 14.4 tests"
runs-on: ubuntu-latest
needs: [prepare]
if: >
(!contains(github.event.head_commit.message, '[skip db]') ||
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose-db.yaml --profile postgres up -d
env:
POSTGRES_VERSION: 14.4
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=AllDBTestsTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_messaging_tests:
name: Repository - Messaging tests
runs-on: ubuntu-latest
needs: [prepare]
if: >
! contains(github.event.head_commit.message, '[skip repo]') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile activemq up -d
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=CamelRoutesTest,CamelComponentsTest -DfailIfNoTests=false
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
repository_app_context_test_suites:
name: Repository - ${{ matrix.testSuite }}
runs-on: ubuntu-latest
needs: [prepare]
if: >
! contains(github.event.head_commit.message, '[skip repo]') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
include:
- testSuite: AppContext01TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContext02TestSuite
compose-profile: default
- testSuite: AppContext03TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContext04TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContext05TestSuite
compose-profile: default
mvn-options: '"-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"'
- testSuite: AppContext06TestSuite
compose-profile: with-transform-core-aio
- testSuite: AppContextExtraTestSuite
compose-profile: with-transform-core-aio
- testSuite: MiscContextTestSuite
compose-profile: with-transform-core-aio
- testSuite: SearchTestSuite
compose-profile: default
mvn-options: '-Dindex.subsystem.name=solr6'
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up IDS"
run: |
if [ "${{ matrix.testSuite }}" == 'AppContext05TestSuite' ];
then
mkdir -p "${HOME}/tmp"
cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp"
echo "HOST_IP=$(hostname -I | cut -f1 -d' ')" >> $GITHUB_ENV
docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2
fi
- name: "Set transformers tag"
run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d
- name: "Run tests"
run: mvn -B test -pl repository -am -Dtest=${{ matrix.testSuite }} -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco ${{ matrix.mvn-options }}
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
tas-tests:
name: ${{ matrix.test-name }}
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
! contains(github.event.head_commit.message, '[skip tas]')) ||
contains(github.event.head_commit.message, '[tas]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
include:
- test-name: "REST API TAS tests part1"
pom-dir: tas-restapi
test-profile: run-restapi-part1
- test-name: "REST API TAS tests part2"
pom-dir: tas-restapi
test-profile: run-restapi-part2
- test-name: "REST API TAS tests part3"
pom-dir: tas-restapi
test-profile: run-restapi-part3
- test-name: "CMIS TAS tests - BROWSER binding"
pom-dir: tas-cmis
test-profile: run-cmis-browser
- test-name: "CMIS TAS tests - ATOM binding"
pom-dir: tas-cmis
test-profile: run-cmis-atom
- test-name: "CMIS TAS tests - WEBSERVICES binding"
pom-dir: tas-cmis
test-profile: run-cmis-webservices
- test-name: "Email TAS tests"
pom-dir: tas-email
- test-name: "WebDAV TAS tests"
pom-dir: tas-webdav
- test-name: "Integration TAS tests"
pom-dir: tas-integration
env:
REQUIRES_LOCAL_IMAGES: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
bash ./scripts/ci/build.sh
- name: "Set up the environment"
run: |
${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-minimal+transforms.yml
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
- name: "Set up the environment for integration tests"
run: |
if [ "${{ matrix.test-name }}" == 'Integration TAS tests' ];
then
mvn install -pl :alfresco-community-repo-integration-test -am -DskipTests -Pall-tas-tests
fi
- name: "Run tests"
id: tests
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: mvn -B verify -f packaging/tests/${{ matrix.pom-dir }}/pom.xml -Pall-tas-tests,${{ matrix.test-profile }} -Denvironment=default -DrunBugs=false
- name: "Print output after success"
if: ${{ always() }} && outcome.tests.outcome == 'success'
run: ${TAS_SCRIPTS}/output_tests_run.sh "packaging/tests/${{ matrix.pom-dir }}"
- name: "Print output after failure"
if: ${{ always() }} && outcome.tests.outcome == 'failure'
run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "packaging/tests/${{ matrix.pom-dir }}"
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
share_services_share_services_test_suite:
name: Share Services - ShareServicesTestSuite
runs-on: ubuntu-latest
needs: [prepare]
if: >
! contains(github.event.head_commit.message, '[skip repo]') &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Set up the environment"
run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile postgres up -d
- name: "Run tests"
run: mvn -B test -pl :alfresco-share-services -am -Dtest=ShareServicesTestSuite -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
ags_tests_postgressql:
name: AGS Integration Tests 0${{ matrix.part }} (PostgreSQL) ${{ matrix.test-name }}
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
! contains(github.event.head_commit.message, '[skip ags]')) ||
contains(github.event.head_commit.message, '[ags]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
part: [1, 2, 3, 4]
env:
REQUIRES_INSTALLED_ARTIFACTS: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
bash ./scripts/ci/build.sh
- name: "Verify"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
ags_tests_mysql:
name: AGS Integration Tests 0${{ matrix.part }} (MySQL) ${{ matrix.test-name }}
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
! contains(github.event.head_commit.message, '[skip ags]')) ||
contains(github.event.head_commit.message, '[ags on MySQL]')) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
strategy:
fail-fast: false
matrix:
part: [1, 2, 3, 4]
env:
REQUIRES_INSTALLED_ARTIFACTS: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
bash ./scripts/ci/build.sh
- name: "Verify"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: mvn --file amps/ags/pom.xml -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt${{ matrix.part }} ${{ env.LOG_WARN }}
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
ags_community_rest_api_tests:
name: "AGS Community Rest API Tests"
runs-on: ubuntu-latest
needs: [prepare]
if: >
(((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.event_name == 'pull_request' ) &&
! contains(github.event.head_commit.message, '[skip ags]') && ! contains(github.event.head_commit.message, '[skip tas]')) ||
(contains(github.event.head_commit.message, '[ags]') && contains(github.event.head_commit.message, '[tas]'))) &&
! contains(github.event.head_commit.message, '[skip tests]') &&
! contains(github.event.head_commit.message, '[force]')
env:
REQUIRES_LOCAL_IMAGES: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
bash ./scripts/ci/build.sh
- name: "Set up the environment"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
${{ env.TAS_SCRIPTS }}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml
${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco"
mvn -B install -pl :alfresco-governance-services-automation-community-rest-api -am -Pags -Pall-tas-tests -DskipTests
- name: "Test"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests
- name: "Get logs and move to deploy_dir"
shell: bash
if: ${{ always() }}
run: |
bash amps/ags/ci/scripts/getLogs.sh
mkdir -p deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests
mv "alfresco.log" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
mv "solr.log" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
mv "./amps/ags/rm-automation/rm-automation-community-rest-api/target/reports" "deploy_dir/community/${{ github.run_number }}/AGS-Community-Rest-API-Tests"
- name: "Configure AWS credentials"
if: ${{ always() }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AGS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AGS_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: "Upload artifacts to Amazon S3 bucket"
if: ${{ always() }}
run: aws s3 cp --recursive ./deploy_dir s3://ags-travis-artifacts
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh

71
.github/workflows/master_release.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: Master/Release branch workflow
on:
push:
branches:
- master
- release/**
- feature/ACS-3841_test_migration
env:
GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }}
GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }}
GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60
jobs:
run_ci:
uses: ./.github/workflows/ci.yml
secrets: inherit
push_to_nexus:
name: "Push to Nexus"
runs-on: ubuntu-latest
needs: [run_ci]
if: >
always() &&
(needs.run_ci.result == 'skipped' || needs.run_ci.result == 'success') &&
(! contains(github.event.head_commit.message, '[no release]')) &&
(github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.ref_name == 'feature/ACS-3841_test_migration') &&
(github.event_name != 'pull_request')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Release"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash scripts/ci/verify_release_tag.sh
bash scripts/ci/maven_release.sh
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh
update_downstream:
name: "Update alfresco-enterprise-repo"
runs-on: ubuntu-latest
needs: [run_ci, push_to_nexus]
if: >
always() &&
(needs.run_ci.result == 'skipped' || needs.run_ci.result == 'success') &&
(! contains(github.event.head_commit.message, '[no downstream]')) &&
((github.ref_name == 'master' || contains(github.ref_name, 'release/') || github.ref_name == 'feature/ACS-3841_test_migration') && github.event_name != 'pull_request')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/acs-community-packaging/.github/actions/get-build-info@feature/ACS-3844_migrate-to-GHA
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@master
- name: "Init"
run: bash ./scripts/ci/init.sh
- name: "Update downstream"
run: bash ./scripts/ci/update_downstream.sh
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
- name: "Clean Maven cache"
if: ${{ always() }}
run: bash ./scripts/ci/cleanup_cache.sh

View File

@@ -19,10 +19,7 @@ before_cache: bash scripts/travis/cleanup_cache.sh
branches:
only:
- master
- /release\/.*/
- /feature\/.*/
- /fix\/.*/
- none
env:
global:

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<build>

View File

@@ -1,39 +1,46 @@
/*
* #%L
* Alfresco Remote API
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* 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.utils;
package org.alfresco.rest.framework.core.exceptions;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* The addressed Relationship Resource was not found
*/
public class EventAlreadyExistsException extends ApiException {
import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.ITestContext;
private static final long serialVersionUID = -3675294374348951929L;
public EventAlreadyExistsException(String msgId, Object[] msgParams) {
super(msgId, msgParams);
public class AlphabeticallyPriorityInterceptor implements IMethodInterceptor
{
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods,
ITestContext context)
{
return methods.stream().sorted(Comparator.comparing(el -> el.getMethod().getTestClass().toString()))
.collect(Collectors.toList());
}
}
}

View File

@@ -1,7 +1,10 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000">
<test name="restapi">
<listeners>
<listener class-name="org.alfresco.rest.rm.community.utils.AlphabeticallyPriorityInterceptor" />
</listeners>
<test name="restapi" preserve-order="false">
<packages>
<package name="org.alfresco.rest.rm.community.*"/>
</packages>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -1,3 +1,3 @@
SOLR6_TAG=2.0.6-A4
SOLR6_TAG=2.0.6
POSTGRES_TAG=14.4
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8

View File

@@ -175,14 +175,6 @@
<property name="nodesModelFactory" ref="nodesModelFactory" />
</bean>
<bean class="org.alfresco.rm.rest.api.events.EventEntityResource">
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
</bean>
<bean class="org.alfresco.rm.rest.api.events.EventTypeEntityResource">
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
</bean>
<!-- extended sites bean definition -->
<bean id="rm.sites" class="org.alfresco.rm.rest.api.impl.RMSitesImpl" parent="sites">
<property name="siteSurfConfig" ref="rm.siteSurfConfig" />
@@ -217,8 +209,6 @@
<entry key="org.alfresco.service.cmr.attributes.DuplicateAttributeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
<entry key="org.alfresco.module.org_alfresco_module_rm.record.RecordCreationException" value="422" />
<entry key="org.alfresco.service.cmr.model.FileExistsException" value="409" />
<entry key="org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException" value="409" />
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="404" />
</map>
</property>
</bean>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -1,222 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.events;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.ResourceParameter;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rm.rest.api.model.EventBody;
import org.alfresco.rm.rest.api.model.EventInfo;
import org.alfresco.util.GUID;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static org.alfresco.util.ParameterCheck.mandatory;
/**
* Event entity resource
*/
@EntityResource(name = "events", title = "Events")
public class EventEntityResource implements EntityResourceAction.Read<EventInfo>,
EntityResourceAction.ReadById<EventInfo>,
EntityResourceAction.Update<EventBody>,
EntityResourceAction.Create<EventBody> {
private RecordsManagementEventService recordsManagementEventService;
/**
* Set the records management event service
*
* @param rmEventService
*/
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
{
this.recordsManagementEventService = rmEventService;
}
@Override
@WebApiDescription(title = "Return a single event identified by 'eventId'")
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
public EventInfo readById(String eventId, Parameters parameters) throws EntityNotFoundException
{
mandatory("eventId", eventId);
RecordsManagementEvent event = null;
if (eventExists(eventId))
{
// Get the event
event = recordsManagementEventService.getEvent(eventId);
}
return EventInfo.fromRecordsManagementEvent(event);
}
@Override
@WebApiDescription(title = "Return a list of events")
public CollectionWithPagingInfo<EventInfo> readAll(Parameters params)
{
Paging paging = params.getPaging();
List<EventInfo> eventInfoList = recordsManagementEventService.getEvents().stream()
.map(EventInfo::fromRecordsManagementEvent)
.collect(Collectors.toList());
int totalCount = eventInfoList.size();
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
return CollectionWithPagingInfo.asPaged(paging, eventInfoList.stream()
.skip(paging.getSkipCount())
.limit(paging.getMaxItems())
.collect(Collectors.toList()), hasMoreItems, totalCount);
}
@Override
@WebApiDescription(title = "Create a new event")
public List<EventBody> create(List<EventBody> eventBodyList, Parameters parameters)
{
//TODO: 403 User not allowed to update event error still needs to be implemented
mandatory("eventBodyList", eventBodyList);
for (EventBody eventBody : eventBodyList) {
mandatory("eventName", eventBody.getName());
mandatory("eventType", eventBody.getType());
}
List<EventBody> responseEventBodyList = new ArrayList<>();
for (EventBody eventBody : eventBodyList) {
String eventId = GUID.generate();
String eventName = eventBody.getName();
String eventType = eventBody.getType();
if(canCreateEvent(eventId, eventName)) {
RecordsManagementEvent event = recordsManagementEventService.addEvent(eventType, eventId, eventName);
responseEventBodyList.add(EventBody.fromRecordsManagementEvent(event));
}
}
return responseEventBodyList;
}
@Override
@WebApiDescription(title = "Update a single event identified by 'eventId'")
@WebApiParam(name = "eventId", title = "The event id", kind = ResourceParameter.KIND.URL_PATH)
public EventBody update(String eventId, EventBody eventBody, Parameters parameters)
{
//TODO: 403 User not allowed to update event error still needs to be implemented
mandatory("eventId", eventId);
mandatory("eventName", eventBody.getName());
mandatory("eventType", eventBody.getType());
RecordsManagementEvent event = null;
if (canEditEvent(eventBody.getName(), eventId, eventBody.getType()))
{
// Create event
event = recordsManagementEventService.addEvent(eventBody.getType(), eventId, eventBody.getName());
}
else
{
// Get event
event = recordsManagementEventService.getEvent(eventId);
}
return EventBody.fromRecordsManagementEvent(event);
}
/**
* Helper method for checking if an event exists or not. Throws an
* error if the event does not exist.
*
* @param eventId The id of the event
*/
private boolean eventExists(String eventId)
{
boolean eventExists = true;
// Check the event exists
if (!recordsManagementEventService.existsEvent(eventId))
{
throw new EntityNotFoundException(eventId);
}
return eventExists;
}
/**
* Helper method for checking if an event can be created or not. Throws an
* error if the event already exists.
*
* @param eventId The id of the event
* @param eventName The name of the event
*/
private boolean canCreateEvent(String eventId, String eventName)
{
boolean canCreateEvent = true;
if (!recordsManagementEventService.canCreateEvent(eventName, eventId))
{
throw new EventAlreadyExistsException("framework.exception.CreateEventAlreadyExists", new Object[] {eventName});
}
return canCreateEvent;
}
/**
* Helper method for checking if an event can be edited or not. Throws an
* error if an event with the same display label already exists.
*
* @param eventName The name of the event
* @param eventId The id of the event
* @param eventType The type of the event
* @return true if the event can be edited, false otherwise
*/
private boolean canEditEvent(String eventName, String eventId, String eventType)
{
boolean canEditEvent = false;
if (eventExists(eventId)) {
try
{
canEditEvent = recordsManagementEventService.canEditEvent(eventName, eventId, eventType);
}
catch (AlfrescoRuntimeException are)
{
throw new EventAlreadyExistsException("framework.exception.UpdateEventAlreadyExists", new Object[] {eventName});
}
}
return canEditEvent;
}
}

View File

@@ -1,76 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.events;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rm.rest.api.model.EventTypeInfo;
import java.util.List;
import java.util.stream.Collectors;
/**
* Event Type entity resource
*/
@EntityResource(name = "event-types", title = "Event Types")
public class EventTypeEntityResource implements EntityResourceAction.Read<EventTypeInfo> {
private RecordsManagementEventService recordsManagementEventService;
/**
* Set the records management event service
* @param rmEventService
*/
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
{
this.recordsManagementEventService = rmEventService;
}
@Override
@WebApiDescription(title = "Return a list of different event types")
public CollectionWithPagingInfo<EventTypeInfo> readAll(Parameters params)
{
// TODO: AssociationName and ActionOnAssociatedNode properties still need to be assigned.
Paging paging = params.getPaging();
List<EventTypeInfo> eventTypeInfoList = recordsManagementEventService.getEventTypes().stream()
.map(EventTypeInfo::fromRecordsManagementEventType)
.collect(Collectors.toList());
int totalCount = eventTypeInfoList.size();
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
return CollectionWithPagingInfo.asPaged(paging, eventTypeInfoList.stream()
.skip(paging.getSkipCount())
.limit(paging.getMaxItems())
.collect(Collectors.toList()), hasMoreItems, totalCount);
}
}

View File

@@ -1,71 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.model;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
/**
* The EventBody model to be exposed through REST API.
*/
public class EventBody {
private String name;
private String type;
public static EventBody fromRecordsManagementEvent(RecordsManagementEvent event)
{
EventBody eventBody = new EventBody();
if(event != null) {
eventBody.setName(event.getDisplayLabel());
eventBody.setType(event.getType());
}
return eventBody;
}
public EventBody() {}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
}

View File

@@ -1,82 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.model;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
/**
* The EventInfo model to be exposed through REST API.
*/
public class EventInfo {
private String id;
private String name;
private String type;
public static EventInfo fromRecordsManagementEvent(RecordsManagementEvent event)
{
EventInfo eventInfo = new EventInfo();
if (event != null) {
eventInfo.setName(event.getDisplayLabel());
eventInfo.setId(event.getName());
eventInfo.setType(event.getType());
}
return eventInfo;
}
public EventInfo() {}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
}

View File

@@ -1,105 +0,0 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* -
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* -
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.model;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
/**
* The EventTypeInfo model to be exposed through REST API.
*/
public class EventTypeInfo {
private String id;
private String name;
private boolean isAutomatic;
private String associationName;
private String actionOnAssociatedNode;
public static EventTypeInfo fromRecordsManagementEventType(RecordsManagementEventType eventType)
{
EventTypeInfo eventTypeInfo = new EventTypeInfo();
if (eventType != null) {
eventTypeInfo.setName(eventType.getDisplayLabel());
eventTypeInfo.setId(eventType.getName());
eventTypeInfo.setAutomatic(eventType.isAutomaticEvent());
}
return eventTypeInfo;
}
public EventTypeInfo() {}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean isAutomatic()
{
return isAutomatic;
}
public void setAutomatic(boolean automatic)
{
isAutomatic = automatic;
}
public String getAssociationName()
{
return associationName;
}
public void setAssociationName(String associationName)
{
this.associationName = associationName;
}
public String getActionOnAssociatedNode()
{
return actionOnAssociatedNode;
}
public void setActionOnAssociatedNode(String actionOnAssociatedNode)
{
this.actionOnAssociatedNode = actionOnAssociatedNode;
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<dependencies>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<dependencies>

View File

@@ -9,6 +9,6 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
</project>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -1,3 +1,3 @@
SOLR6_TAG=2.0.6-A4
SOLR6_TAG=2.0.6
POSTGRES_TAG=14.4
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<modules>

View File

@@ -4,4 +4,4 @@ TAS_DIRECTORY=$1
cd ${TAS_DIRECTORY}
cat target/reports/alfresco-tas.log | grep "*** STARTING"
cat target/reports/alfresco-tas.log | grep -a "*** STARTING"

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<organization>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<developers>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -1,5 +1,7 @@
package org.alfresco.rest.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.alfresco.rest.core.IRestModel;
import org.alfresco.utility.model.TestModel;
@@ -47,8 +49,7 @@ This must be unique within the parent category.
private boolean hasChildren;
/**
The number of nodes that are assigned to this category.
*/
*/
private long count;
public String getId()
@@ -99,6 +100,33 @@ This must be unique within the parent category.
public void setCount(long count)
{
this.count = count;
}
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RestCategoryModel that = (RestCategoryModel) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode()
{
return Objects.hash(id);
}
@Override
public String toString()
{
return "RestCategoryModel{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", parentId='" + parentId + '\'' +
", hasChildren=" + hasChildren +
", count=" + count +
'}';
}
}

View File

@@ -1,34 +1,35 @@
/*
* #%L
* Alfresco Records Management Module
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* 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.
* -
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/**
* Package info that defines the Information Governance Events REST API
*/
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
package org.alfresco.rm.rest.api.events;
import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.WebApi;
package org.alfresco.rest.model;
import org.alfresco.rest.core.RestModels;
public class RestCategoryModelsCollection extends RestModels<RestCategoryModel, RestCandidateModelsCollection>
{
}

View File

@@ -25,9 +25,14 @@
*/
package org.alfresco.rest.requests;
import static org.alfresco.rest.core.JsonBodyGenerator.arrayToJson;
import java.util.List;
import org.alfresco.rest.core.RestRequest;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.model.RestCategoryModel;
import org.alfresco.rest.model.RestCategoryModelsCollection;
import org.springframework.http.HttpMethod;
public class Categories extends ModelRequest<Categories>
@@ -41,9 +46,9 @@ public class Categories extends ModelRequest<Categories>
}
/**
* Retrieves a category with ID using GET call on using GET call on "/tags/{tagId}"
* Retrieves a category with ID using GET call on "/categories/{categoryId}"
*
* @return
* @return RestCategoryModel
*/
public RestCategoryModel getCategory()
{
@@ -52,4 +57,51 @@ public class Categories extends ModelRequest<Categories>
return restWrapper.processModel(RestCategoryModel.class, request);
}
/**
* Create several categories in one request.
*
* @param restCategoryModels The list of categories to create.
* @return The list of created categories with additional data populated by the repository.
*/
public RestCategoryModelsCollection createCategoriesList(List<RestCategoryModel> restCategoryModels) {
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, arrayToJson(restCategoryModels), "categories/{categoryId}/subcategories", category.getId());
return restWrapper.processModels(RestCategoryModelsCollection.class, request);
}
/**
* Create single category.
*
* @param restCategoryModel The categories to create.
* @return Created category with additional data populated by the repository.
*/
public RestCategoryModel createSingleCategory(RestCategoryModel restCategoryModel)
{
RestRequest request = RestRequest
.requestWithBody(HttpMethod.POST, restCategoryModel.toJson(), "categories/{categoryId}/subcategories", category.getId());
return restWrapper.processModel(RestCategoryModel.class, request);
}
/**
* Get parent category children.
*
* @return The list of child categories.
*/
public RestCategoryModelsCollection getCategoryChildren()
{
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "categories/{categoryId}/subcategories", category.getId());
return restWrapper.processModels(RestCategoryModelsCollection.class, request);
}
/**
* Delete category.
*
* - DELETE /categories/{categoryId}
*/
public void deleteCategory()
{
RestRequest request = RestRequest.
simpleRequest(HttpMethod.DELETE, "/categories/{categoryId}", category.getId());
restWrapper.processEmptyModel(request);
}
}

View File

@@ -0,0 +1,273 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.categories;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestCategoryModel;
import org.alfresco.rest.model.RestCategoryModelsCollection;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class CreateCategoriesTests extends RestTest
{
private static final String FIELD_NAME = "name";
private static final String FIELD_PARENT_ID = "parentId";
private static final String FIELD_HAS_CHILDREN = "hasChildren";
private static final String FIELD_ID = "id";
private UserModel user;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
STEP("Create a user");
user = dataUser.createRandomTestUser();
}
/**
* Check we can create a category as direct child of root category
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateCategoryUnderRoot()
{
STEP("Create a category under root category (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName());
createdCategory.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId());
createdCategory.assertThat().field(FIELD_HAS_CHILDREN).is(false);
}
/**
* Check we get 400 error when attempting to create a category with empty name
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateCategoryWithoutName_andFail()
{
STEP("Create a category under root category (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(StringUtils.EMPTY);
restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Category name must not be null or empty");
}
/**
* Check we can create several categories as children of a created category
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateSeveralSubCategories()
{
STEP("Create a category under root category (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName())
.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId())
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
.assertThat().field(FIELD_ID).isNotEmpty();
STEP("Create two categories under the previously created (as admin)");
final int categoriesNumber = 2;
final List<RestCategoryModel> categoriesToCreate = getCategoriesToCreate(categoriesNumber);
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(createdCategory)
.createCategoriesList(categoriesToCreate);
restClient.assertStatusCodeIs(CREATED);
createdSubCategories.assertThat()
.entriesListCountIs(categoriesToCreate.size());
IntStream.range(0, categoriesNumber)
.forEach(i -> createdSubCategories.getEntries().get(i).onModel()
.assertThat().field(FIELD_NAME).is(categoriesToCreate.get(i).getName())
.assertThat().field(FIELD_PARENT_ID).is(createdCategory.getId())
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
.assertThat().field(FIELD_ID).isNotEmpty()
);
STEP("Get the parent category and check if it now has children (as regular user)");
final RestCategoryModel parentCategoryFromGet = restClient.authenticateUser(user)
.withCoreAPI()
.usingCategory(createdCategory)
.getCategory();
parentCategoryFromGet.assertThat().field(FIELD_HAS_CHILDREN).is(true);
}
/**
* Check we can create over 100 categories as children of a created category and pagination information is proper.
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateOver100SubCategories()
{
STEP("Create a category under root category (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
createdCategory.assertThat().field(FIELD_NAME).is(aCategory.getName())
.assertThat().field(FIELD_PARENT_ID).is(rootCategory.getId())
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
.assertThat().field(FIELD_ID).isNotEmpty();
STEP("Create more than a hundred categories under the previously created (as admin)");
final int categoriesNumber = 120;
final List<RestCategoryModel> categoriesToCreate = getCategoriesToCreate(categoriesNumber);
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(createdCategory)
.createCategoriesList(categoriesToCreate);
restClient.assertStatusCodeIs(CREATED);
createdSubCategories.assertThat()
.entriesListCountIs(categoriesToCreate.size());
IntStream.range(0, categoriesNumber)
.forEach(i -> createdSubCategories.getEntries().get(i).onModel()
.assertThat().field(FIELD_NAME).is(categoriesToCreate.get(i).getName())
.assertThat().field(FIELD_PARENT_ID).is(createdCategory.getId())
.assertThat().field(FIELD_HAS_CHILDREN).is(false)
.assertThat().field(FIELD_ID).isNotEmpty()
);
createdSubCategories.getPagination().assertThat().field("count").is(categoriesNumber)
.assertThat().field("totalItems").is(categoriesNumber)
.assertThat().field("maxItems").is(categoriesNumber)
.assertThat().field("skipCount").is(0)
.assertThat().field("hasMoreItems").is(false);
}
/**
* Check we cannot create a category as direct child of root category as non-admin user
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateCategoryUnderRootAsRegularUser_andFail()
{
STEP("Create a category under root category (as user)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
restClient.authenticateUser(user)
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(FORBIDDEN).assertLastError().containsSummary("Current user does not have permission to create a category");
}
/**
* Check we cannot create a category under non existing parent node
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateCategoryUnderNonExistingParent_andFail()
{
STEP("Create a category under non existing category node (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
final String id = "non-existing-node-id";
rootCategory.setId(id);
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary("The entity with id: " + id + " was not found");
}
/**
* Check we cannot create a category under a node which is not a category
*/
@Test(groups = {TestGroup.REST_API})
public void testCreateCategoryUnderFolderNode_andFail()
{
STEP("Create a site and a folder inside it");
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Create a category under folder node (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId(folder.getNodeRef());
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
}
static List<RestCategoryModel> getCategoriesToCreate(final int count)
{
return IntStream.range(0, count)
.mapToObj(i -> {
final RestCategoryModel aSubCategory = new RestCategoryModel();
aSubCategory.setName((RandomData.getRandomName("SubCategory")));
return aSubCategory;
})
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,133 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.categories;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.model.RestCategoryModel;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
import org.alfresco.utility.model.UserModel;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
public class DeleteCategoriesTests extends RestTest {
private UserModel user;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
STEP("Create a user");
user = dataUser.createRandomTestUser();
}
/**
* Check we can delete a category.
*/
@Test(groups = {TestGroup.REST_API})
public void testDeleteCategory()
{
STEP("Create a category and send a request to delete it.");
RestCategoryModel aCategory = createCategory();
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(aCategory).deleteCategory();
restClient.assertStatusCodeIs(NO_CONTENT);
STEP("Ensure that the category has been deleted by sending a GET request and receiving 404.");
restClient.authenticateUser(user).withCoreAPI().usingCategory(aCategory).getCategory();
restClient.assertStatusCodeIs(NOT_FOUND);
}
/**
* Check we get an error when trying to delete a category as a non-admin user.
*/
@Test(groups = {TestGroup.REST_API})
public void testDeleteCategoryAsRegularUser_andFail()
{
RestCategoryModel aCategory = createCategory();
restClient.authenticateUser(user).withCoreAPI().usingCategory(aCategory).deleteCategory();
restClient.assertStatusCodeIs(FORBIDDEN).assertLastError().containsSummary("Current user does not have permission to delete a category");
}
/**
* Check we receive 404 error when trying to delete a category with a non-existent node id.
*/
@Test(groups = {TestGroup.REST_API})
public void testDeleteNonExistentCategory()
{
STEP("Get category with non-existent id");
final RestCategoryModel rootCategory = new RestCategoryModel();
final String id = "non-existing-dummy-id";
rootCategory.setId(id);
STEP("Attempt to delete category with non-existent id and receive 404");
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(rootCategory).deleteCategory();
restClient.assertStatusCodeIs(NOT_FOUND);
}
/**
* Attempt to delete a category when providing a node id that doesn't belong to a category
*/
@Test(groups = {TestGroup.REST_API})
public void testDeleteCategory_givenNonCategoryNodeId()
{
STEP("Create a site and a folder inside it");
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
String id = folder.getNodeRef();
STEP("Create a category, set its id to the folder id and attempt to delete it");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setId(id);
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingCategory(aCategory).deleteCategory();
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
}
public RestCategoryModel createCategory()
{
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
return createdCategory;
}
}

View File

@@ -28,10 +28,20 @@ package org.alfresco.rest.categories;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertTrue;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestResponse;
import org.alfresco.rest.model.RestCategoryModel;
import org.alfresco.rest.model.RestCategoryModelsCollection;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TestGroup;
@@ -41,6 +51,10 @@ import org.testng.annotations.Test;
public class GetCategoriesTests extends RestTest
{
private static final List<String> DEFAULT_ROOT_CATEGORIES = List.of("Software Document Classification", "Languages", "Regions", "Tags");
private static final String ROOT = "-root-";
private static final String NON_EXISTING_CATEGORY_ID = "non-existing-category-id";
private UserModel user;
@BeforeClass(alwaysRun = true)
@@ -50,21 +64,52 @@ public class GetCategoriesTests extends RestTest
user = dataUser.createRandomTestUser();
}
/**
* Check we can get a category which we just created in as direct child of root category
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryById()
{
STEP("Create a category under root category (as admin)");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId(ROOT);
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName(RandomData.getRandomName("Category"));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
createdCategory.assertThat()
.field("name").is(aCategory.getName());
createdCategory.assertThat()
.field("parentId").is(rootCategory.getId());
createdCategory.assertThat()
.field("hasChildren").is(false);
STEP("Get the created category (as regular user)");
final RestCategoryModel categoryFromGet =
restClient.authenticateUser(user).withCoreAPI().usingCategory(createdCategory).getCategory();
restClient.assertStatusCodeIs(OK);
categoryFromGet.assertThat().isEqualTo(createdCategory);
}
/**
* Check we get an error when passing -root- as category id
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryByIdProvidingRootAsId()
{
STEP("Get category with -root- as id (which does not exist)");
STEP("Get category with -root- as id");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId("-root-");
rootCategory.setId(ROOT);
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
restClient.assertStatusCodeIs(NOT_FOUND);
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
}
/**
* Check we get an error when passing as category id
* Check we get an error when passing folder node id as category id
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryByIdProvidingFolderAsId()
@@ -77,7 +122,101 @@ public class GetCategoriesTests extends RestTest
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId(folder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
restClient.assertStatusCodeIs(BAD_REQUEST);
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
}
/**
* Check we get an error when passing non existing as category id
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryByIdProvidingNonExistingId()
{
STEP("Get category with id which does not exist");
final RestCategoryModel rootCategory = new RestCategoryModel();
final String id = NON_EXISTING_CATEGORY_ID;
rootCategory.setId(id);
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategory();
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary(id);
}
/**
* Check we can get children category of a root category
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryChildren()
{
STEP("Get category children with -root- as parent id");
final RestCategoryModel rootCategory = new RestCategoryModel();
rootCategory.setId(ROOT);
RestCategoryModelsCollection childCategoriesList =
restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
restClient.assertStatusCodeIs(OK);
childCategoriesList.assertThat().entriesListIsNotEmpty();
assertTrue(childCategoriesList.getEntries().stream()
.map(RestCategoryModel::onModel)
.map(RestCategoryModel::getName)
.collect(Collectors.toList())
.containsAll(DEFAULT_ROOT_CATEGORIES));
STEP("Create a new category under root and make sure it is returned as one of root's children");
final RestCategoryModel aCategory = new RestCategoryModel();
aCategory.setName((RandomData.getRandomName("newCategoryUnderRoot")));
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(rootCategory)
.createSingleCategory(aCategory);
restClient.assertStatusCodeIs(CREATED);
childCategoriesList = restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
restClient.assertStatusCodeIs(OK);
assertTrue(childCategoriesList.getEntries().stream()
.map(RestCategoryModel::onModel)
.map(RestCategoryModel::getId)
.collect(Collectors.toList())
.contains(createdCategory.getId()));
STEP("Create 2 more categories under newCategoryUnderRoot and make sure they are returned as children");
final int categoriesCount = 2;
final List<RestCategoryModel> categoriesToCreate = CreateCategoriesTests.getCategoriesToCreate(categoriesCount);
final RestCategoryModelsCollection createdSubCategories = restClient.authenticateUser(dataUser.getAdminUser())
.withCoreAPI()
.usingCategory(createdCategory)
.createCategoriesList(categoriesToCreate);
restClient.assertStatusCodeIs(CREATED);
childCategoriesList = restClient.authenticateUser(user).withCoreAPI().usingCategory(rootCategory).getCategoryChildren();
restClient.assertStatusCodeIs(OK);
childCategoriesList.getEntries().containsAll(createdSubCategories.getEntries());
}
/**
* Check we get an error when passing folder node id as parent category id when getting children.
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryChildrenProvidingFolderAsId()
{
STEP("Create a site and a folder inside it");
final SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Get category children with folder id passed as parent id");
final RestCategoryModel parentCategory = new RestCategoryModel();
parentCategory.setId(folder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingCategory(parentCategory).getCategoryChildren();
restClient.assertStatusCodeIs(BAD_REQUEST).assertLastError().containsSummary("Node id does not refer to a valid category");
}
/**
* Check we get an error when passing a non-existent node id as parent category id when getting children.
*/
@Test(groups = {TestGroup.REST_API})
public void testGetCategoryChildrenProvidingNonExistingParent()
{
STEP("Get category with folder id passed as id");
final RestCategoryModel parentCategory = new RestCategoryModel();
final String parentId = NON_EXISTING_CATEGORY_ID;
parentCategory.setId(parentId);
restClient.authenticateUser(user).withCoreAPI().usingCategory(parentCategory).getCategoryChildren();
restClient.assertStatusCodeIs(NOT_FOUND).assertLastError().containsSummary(parentId);
}
}

View File

@@ -56,6 +56,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.json.Json;
import javax.json.JsonObject;
@@ -63,6 +64,7 @@ import javax.json.JsonObject;
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
import org.alfresco.rest.model.RestActionConstraintModel;
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
import org.alfresco.rest.model.RestPaginationModel;
import org.alfresco.rest.model.RestRuleModel;
import org.alfresco.rest.model.RestRuleModelsCollection;
import org.alfresco.utility.constants.UserRole;
@@ -267,6 +269,38 @@ public class CreateRulesTests extends RulesRestTest
.assertThat().field("name").is(ruleNames.get(i)));
}
/** Check we can create over 100 rules and get them all back in response. */
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
public void createOver100Rules()
{
STEP("Create a list of 120 rules in one POST request");
final int ruleCount = 120;
final String ruleNamePrefix = "multiRule";
final List<RestRuleModel> ruleModels = IntStream.rangeClosed(1, ruleCount)
.mapToObj(i -> rulesUtils.createRuleModel(ruleNamePrefix + i))
.collect(Collectors.toList());
final FolderModel aFolder = dataContent.usingUser(user).usingSite(site).createFolder();
final RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(aFolder).usingDefaultRuleSet()
.createListOfRules(ruleModels);
restClient.assertStatusCodeIs(CREATED);
assertEquals("Unexpected number of rules received in response.", ruleCount, rules.getEntries().size());
IntStream.range(0, ruleModels.size()).forEach(i ->
rules.getEntries().get(i).onModel()
.assertThat().field("id").isNotNull()
.assertThat().field("name").is(ruleNamePrefix + (i + 1)));
rules.getPagination()
.assertThat().field("count").is(ruleCount)
.assertThat().field("totalItems").is(ruleCount)
.assertThat().field("maxItems").is(ruleCount)
.assertThat().field("skipCount").is(0)
.assertThat().field("hasMoreItems").is(false);
}
/** Try to create several rules with an error in one of them. */
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
public void createRulesWithOneError()

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<developers>

View File

@@ -1,17 +1,25 @@
package org.alfresco.webdav;
import java.lang.reflect.Method;
import org.alfresco.utility.data.DataContent;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.LogFactory;
import org.alfresco.utility.network.ServerHealth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.slf4j.Logger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
@ContextConfiguration("classpath:alfresco-webdav-context.xml")
public abstract class WebDavTest extends AbstractTestNGSpringContextTests
{
private static final Logger LOG = LogFactory.getLogger();
@Autowired
protected DataSite dataSite;
@@ -36,4 +44,16 @@ public abstract class WebDavTest extends AbstractTestNGSpringContextTests
// The webdav protocol is enabled by default.
//webDavProtocol.assertThat().protocolIsEnabled();
}
}
@BeforeMethod(alwaysRun=true)
public void showStartTestInfo(Method method)
{
LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
}
@AfterMethod(alwaysRun=true)
public void showEndTestInfo(Method method)
{
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<properties>

View File

@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -109,8 +109,8 @@
<dependency.jakarta-json-path.version>2.7.0</dependency.jakarta-json-path.version>
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
<alfresco.googledrive.version>3.3.1-DEV-LOG4J2</alfresco.googledrive.version>
<alfresco.aos-module.version>1.5.0-DEV-LOG4J2</alfresco.aos-module.version>
<alfresco.googledrive.version>3.4.0-A1</alfresco.googledrive.version>
<alfresco.aos-module.version>1.6.0-A1</alfresco.aos-module.version>
<alfresco.api-explorer.version>7.3.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
@@ -148,7 +148,7 @@
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
<url>https://github.com/Alfresco/alfresco-community-repo</url>
<tag>HEAD</tag>
<tag>20.45-DEV</tag>
</scm>
<distributionManagement>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<dependencies>

View File

@@ -26,13 +26,22 @@
package org.alfresco.rest.api;
import java.util.List;
import org.alfresco.rest.api.model.Category;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.Experimental;
import org.alfresco.service.cmr.repository.NodeRef;
@Experimental
public interface Categories
{
Category getCategoryById(String id, Parameters params);
List<Category> createSubcategories(String parentCategoryId, List<Category> categories, Parameters parameters);
CollectionWithPagingInfo<Category> getCategoryChildren(String parentCategoryId, Parameters params);
void deleteCategoryById(String id, Parameters params);
}

View File

@@ -41,7 +41,8 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
* @author mpichura
*/
@EntityResource(name = "categories", title = "Categories")
public class CategoriesEntityResource implements EntityResourceAction.ReadById<Category>
public class CategoriesEntityResource implements EntityResourceAction.ReadById<Category>,
EntityResourceAction.Delete
{
private final Categories categories;
@@ -58,4 +59,12 @@ public class CategoriesEntityResource implements EntityResourceAction.ReadById<C
{
return categories.getCategoryById(id, parameters);
}
@WebApiDescription(title = "Delete category",
description = "Delete a category given its node id",
successStatus = HttpServletResponse.SC_NO_CONTENT)
@Override
public void delete(String id, Parameters parameters) {
categories.deleteCategoryById(id, parameters);
}
}

View File

@@ -0,0 +1,69 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.categories;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.rest.api.Categories;
import org.alfresco.rest.api.model.Category;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
@RelationshipResource(name = "subcategories", entityResource = CategoriesEntityResource.class, title = "Subcategories")
public class SubcategoriesRelation implements RelationshipResourceAction.Create<Category>, RelationshipResourceAction.Read<Category>
{
private final Categories categories;
public SubcategoriesRelation(Categories categories)
{
this.categories = categories;
}
@WebApiDescription(title = "Create a category",
description = "Creates one or more categories under a parent category",
successStatus = HttpServletResponse.SC_CREATED)
@Override
public List<Category> create(String parentCategoryId, List<Category> categoryList, Parameters parameters)
{
return categories.createSubcategories(parentCategoryId, categoryList, parameters);
}
@WebApiDescription(title = "List category direct children",
description = "Lists direct children of a parent category",
successStatus = HttpServletResponse.SC_OK)
@Override
public CollectionWithPagingInfo<Category> readAll(String parentCategoryId, Parameters params)
{
return categories.getCategoryChildren(parentCategoryId, params);
}
}

View File

@@ -29,31 +29,47 @@ package org.alfresco.rest.api.impl;
import static org.alfresco.rest.api.Nodes.PATH_ROOT;
import java.util.List;
import java.util.stream.Collectors;
import org.alfresco.model.ContentModel;
import org.alfresco.rest.api.Categories;
import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Category;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.ListPage;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.Experimental;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@Experimental
public class CategoriesImpl implements Categories
{
static final String NOT_A_VALID_CATEGORY = "Node id does not refer to a valid category";
static final String NO_PERMISSION_TO_CREATE_A_CATEGORY = "Current user does not have permission to create a category";
static final String NO_PERMISSION_TO_DELETE_A_CATEGORY = "Current user does not have permission to delete a category";
private static final String NOT_NULL_OR_EMPTY = "Category name must not be null or empty";
private final AuthorityService authorityService;
private final CategoryService categoryService;
private final Nodes nodes;
private final NodeService nodeService;
public CategoriesImpl(Nodes nodes, NodeService nodeService)
public CategoriesImpl(AuthorityService authorityService, CategoryService categoryService, Nodes nodes, NodeService nodeService)
{
this.authorityService = authorityService;
this.categoryService = categoryService;
this.nodes = nodes;
this.nodeService = nodeService;
}
@@ -61,28 +77,121 @@ public class CategoriesImpl implements Categories
@Override
public Category getCategoryById(final String id, final Parameters params)
{
final NodeRef nodeRef = nodes.validateNode(id);
final boolean isCategory = nodes.isSubClass(nodeRef, ContentModel.TYPE_CATEGORY, false);
if (!isCategory || isRootCategory(nodeRef))
final NodeRef nodeRef = getCategoryNodeRef(id);
if (isRootCategory(nodeRef))
{
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{id});
}
return mapToCategory(nodeRef);
}
@Override
public List<Category> createSubcategories(String parentCategoryId, List<Category> categories, Parameters parameters)
{
if (!authorityService.hasAdminAuthority())
{
throw new PermissionDeniedException(NO_PERMISSION_TO_CREATE_A_CATEGORY);
}
final NodeRef parentNodeRef = getCategoryNodeRef(parentCategoryId);
final List<NodeRef> categoryNodeRefs = categories.stream()
.map(c -> createCategoryNodeRef(parentNodeRef, c))
.collect(Collectors.toList());
return categoryNodeRefs.stream()
.map(this::mapToCategory)
.collect(Collectors.toList());
}
@Override
public CollectionWithPagingInfo<Category> getCategoryChildren(String parentCategoryId, Parameters params)
{
final NodeRef parentNodeRef = getCategoryNodeRef(parentCategoryId);
final List<ChildAssociationRef> childCategoriesAssocs = nodeService.getChildAssocs(parentNodeRef).stream()
.filter(ca -> ContentModel.ASSOC_SUBCATEGORIES.equals(ca.getTypeQName()))
.collect(Collectors.toList());
final List<Category> categories = childCategoriesAssocs.stream()
.map(c -> mapToCategory(c.getChildRef()))
.collect(Collectors.toList());
return ListPage.of(categories, params.getPaging());
}
@Override
public void deleteCategoryById(String id, Parameters params)
{
if (!authorityService.hasAdminAuthority())
{
throw new PermissionDeniedException(NO_PERMISSION_TO_DELETE_A_CATEGORY);
}
final NodeRef nodeRef = nodes.validateNode(id);
if (isNotACategory(nodeRef) || isRootCategory(nodeRef))
{
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{id});
}
nodeService.deleteNode(nodeRef);
}
/**
* This method gets category NodeRef for a given category id.
* If '-root-' is passed as category id, then it's retrieved as a call to {@link org.alfresco.service.cmr.search.CategoryService#getRootCategoryNodeRef}
* In all other cases it's retrieved as a node of a category type {@link #validateCategoryNode(String)}
* @param nodeId category node id
* @return NodRef of category node
*/
private NodeRef getCategoryNodeRef(String nodeId)
{
return PATH_ROOT.equals(nodeId) ?
categoryService.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE)
.orElseThrow(() -> new EntityNotFoundException(nodeId)) :
validateCategoryNode(nodeId);
}
/**
* Validates if the node exists and is a category.
* @param nodeId (presumably) category node id
* @return category NodeRef
*/
private NodeRef validateCategoryNode(String nodeId)
{
final NodeRef nodeRef = nodes.validateNode(nodeId);
if (isNotACategory(nodeRef))
{
throw new InvalidArgumentException(NOT_A_VALID_CATEGORY, new String[]{nodeId});
}
return nodeRef;
}
private NodeRef createCategoryNodeRef(NodeRef parentNodeRef, Category c)
{
if (StringUtils.isEmpty(c.getName())) {
throw new InvalidArgumentException(NOT_NULL_OR_EMPTY);
}
return categoryService.createCategory(parentNodeRef, c.getName());
}
private boolean isNotACategory(NodeRef nodeRef)
{
return !nodes.isSubClass(nodeRef, ContentModel.TYPE_CATEGORY, false);
}
private Category mapToCategory(NodeRef nodeRef)
{
final Node categoryNode = nodes.getNode(nodeRef.getId());
final Category category = new Category();
category.setId(nodeRef.getId());
category.setName(categoryNode.getName());
category.setParentId(getParentId(nodeRef));
final boolean hasChildren = CollectionUtils
.isNotEmpty(nodeService.getChildAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false));
category.setHasChildren(hasChildren);
return category;
return Category.builder()
.id(nodeRef.getId())
.name(categoryNode.getName())
.parentId(getParentId(nodeRef))
.hasChildren(hasChildren)
.create();
}
private boolean isRootCategory(final NodeRef nodeRef)
{
final List<ChildAssociationRef> parentAssocs = nodeService.getParentAssocs(nodeRef);
return parentAssocs.stream().anyMatch(pa -> pa.getQName().equals(ContentModel.ASPECT_GEN_CLASSIFIABLE));
return parentAssocs.stream().anyMatch(pa -> ContentModel.ASPECT_GEN_CLASSIFIABLE.equals(pa.getQName()));
}
private String getParentId(final NodeRef nodeRef)

View File

@@ -26,6 +26,8 @@
package org.alfresco.rest.api.model;
import java.util.Objects;
public class Category
{
private String id;
@@ -72,4 +74,68 @@ public class Category
{
this.hasChildren = hasChildren;
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Category category = (Category) o;
return hasChildren == category.hasChildren && Objects.equals(id, category.id) && name.equals(category.name) &&
Objects.equals(parentId, category.parentId);
}
@Override
public int hashCode()
{
return Objects.hash(id, name, parentId, hasChildren);
}
public static Builder builder()
{
return new Builder();
}
public static class Builder
{
private String id;
private String name;
private String parentId;
private boolean hasChildren;
public Builder id(String id)
{
this.id = id;
return this;
}
public Builder name(String name)
{
this.name = name;
return this;
}
public Builder parentId(String parentId)
{
this.parentId = parentId;
return this;
}
public Builder hasChildren(boolean hasChildren)
{
this.hasChildren = hasChildren;
return this;
}
public Category create()
{
final Category category = new Category();
category.setId(id);
category.setName(name);
category.setParentId(parentId);
category.setHasChildren(hasChildren);
return category;
}
}
}

View File

@@ -44,6 +44,7 @@ import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartResource
import org.alfresco.rest.framework.resource.actions.interfaces.MultiPartRelationshipResourceAction;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
import org.alfresco.rest.framework.tools.RecognizedParamsExtractor;
@@ -377,7 +378,8 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
{
if (created !=null && created.size() > 1)
{
return CollectionWithPagingInfo.asPagedCollection(created.toArray());
final Paging pagingAll = Paging.valueOf(0, created.size());
return CollectionWithPagingInfo.asPaged(pagingAll, created);
}
else
{

View File

@@ -7,8 +7,6 @@ framework.exception.InvalidQuery=An invalid WHERE query was received. {0}
framework.exception.InvalidSelect=An invalid {1} query was received. {0}
framework.exception.NotFound={0} was not found
framework.exception.EntityNotFound=The entity with id: {0} was not found
framework.exception.CreateEventAlreadyExists=Cannot create event. An event with name: {0} already exists
framework.exception.UpdateEventAlreadyExists=Cannot update event. An event with name: {0} already exists
framework.exception.RelationshipNotFound=The relationship resource was not found for the entity with id: {0} and a relationship id of {1}
framework.exception.PermissionDenied=Permission was denied
framework.exception.StaleEntity=Attempt to update a stale entity

View File

@@ -830,6 +830,8 @@
</bean>
<bean id="categories" class="org.alfresco.rest.api.impl.CategoriesImpl">
<constructor-arg name="authorityService" ref="AuthorityService"/>
<constructor-arg name="categoryService" ref="CategoryService"/>
<constructor-arg name="nodes" ref="nodes"/>
<constructor-arg name="nodeService" ref="NodeService"/>
</bean>
@@ -1099,10 +1101,14 @@
<constructor-arg name="categories" ref="Categories"/>
</bean>
<bean class="org.alfresco.rest.api.categories.SubcategoriesRelation">
<constructor-arg name="categories" ref="Categories"/>
</bean>
<bean class="org.alfresco.rest.api.tags.TagsEntityResource">
<property name="tags" ref="Tags" />
</bean>
<bean class="org.alfresco.rest.api.people.PersonSitesRelation">
<property name="sites" ref="Sites" />
</bean>

View File

@@ -0,0 +1,105 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.categories;
import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.alfresco.rest.api.Categories;
import org.alfresco.rest.api.model.Category;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SubcategoriesRelationTest
{
private static final String PARENT_CATEGORY_ID = "parent-category-node-id";
private static final String CATEGORY_ID = "category-node-id";
private static final String CATEGORY_NAME = "categoryName";
private static final String SUBCATEGORY_NAME_PREFIX = "childCategoryName";
@Mock
private Categories categoriesMock;
@Mock
private Parameters parametersMock;
@InjectMocks
private SubcategoriesRelation objectUnderTest;
@Test
public void testCreateSubcategory()
{
final Category categoryToCreate = Category.builder().name(CATEGORY_NAME).create();
final Category category = Category.builder().name(CATEGORY_NAME).parentId(PARENT_CATEGORY_ID).hasChildren(false).id(CATEGORY_ID).create();
final List<Category> categoriesToCreate = List.of(categoryToCreate);
given(categoriesMock.createSubcategories(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock)).willReturn(List.of(category));
//when
List<Category> categories = objectUnderTest.create(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock);
then(categoriesMock).should().createSubcategories(PARENT_CATEGORY_ID, categoriesToCreate, parametersMock);
then(categoriesMock).shouldHaveNoMoreInteractions();
assertEquals(List.of(category), categories);
}
@Test
public void testGetCategoryChildren() {
final CollectionWithPagingInfo<Category> categoryChildren = getCategories(3);
given(categoriesMock.getCategoryChildren(PARENT_CATEGORY_ID, parametersMock)).willReturn(categoryChildren);
//when
final CollectionWithPagingInfo<Category> returnedChildren = objectUnderTest.readAll(PARENT_CATEGORY_ID, parametersMock);
then(categoriesMock).should().getCategoryChildren(PARENT_CATEGORY_ID, parametersMock);
then(categoriesMock).shouldHaveNoMoreInteractions();
assertEquals(categoryChildren, returnedChildren);
}
private CollectionWithPagingInfo<Category> getCategories(final int count)
{
return CollectionWithPagingInfo.asPaged(Paging.DEFAULT,
IntStream.range(0, count)
.mapToObj(i -> Category.builder().name(SUBCATEGORY_NAME_PREFIX + "-" + i)
.parentId(PARENT_CATEGORY_ID)
.hasChildren(false)
.id(CATEGORY_ID + "-" + i)
.create())
.collect(Collectors.toList())
);
}
}

View File

@@ -26,15 +26,20 @@
package org.alfresco.rest.api.impl;
import static org.alfresco.rest.api.Nodes.PATH_ROOT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.alfresco.model.ContentModel;
import org.alfresco.rest.api.Nodes;
@@ -42,11 +47,15 @@ import org.alfresco.rest.api.model.Category;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -69,6 +78,10 @@ public class CategoriesImplTest
@Mock
private Parameters parametersMock;
@Mock
private AuthorityService authorityServiceMock;
@Mock
private CategoryService categoryServiceMock;
@Mock
private ChildAssociationRef dummyChildAssociationRefMock;
@Mock
private ChildAssociationRef categoryChildAssociationRefMock;
@@ -93,6 +106,8 @@ public class CategoriesImplTest
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getParentAssocs(categoryRootNodeRef);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
}
@Test
@@ -126,10 +141,16 @@ public class CategoriesImplTest
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
assertEquals(categoryNode.getName(), category.getName());
assertEquals(CATEGORY_ID, category.getId());
assertEquals(PARENT_ID, category.getParentId());
assertTrue(category.getHasChildren());
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
final Category expectedCategory = Category.builder()
.id(CATEGORY_ID)
.name(categoryNode.getName())
.hasChildren(true)
.parentId(PARENT_ID)
.create();
assertEquals(expectedCategory, category);
}
@Test
@@ -162,10 +183,16 @@ public class CategoriesImplTest
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
assertEquals(categoryNode.getName(), category.getName());
assertEquals(CATEGORY_ID, category.getId());
assertEquals(PARENT_ID, category.getParentId());
assertFalse(category.getHasChildren());
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
final Category expectedCategory = Category.builder()
.id(CATEGORY_ID)
.name(categoryNode.getName())
.hasChildren(false)
.parentId(PARENT_ID)
.create();
assertEquals(expectedCategory, category);
}
@Test
@@ -183,6 +210,8 @@ public class CategoriesImplTest
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
}
@Test
@@ -197,5 +226,430 @@ public class CategoriesImplTest
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
}
@Test
public void testDeleteCategoryById_asAdmin()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef categoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(categoryNodeRef);
given(nodesMock.isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
final Node categoryNode = new Node();
categoryNode.setName(CATEGORY_NAME);
categoryNode.setNodeId(CATEGORY_ID);
final NodeRef parentNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
categoryNode.setParentId(parentNodeRef);
//when
objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock);
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(CATEGORY_ID);
then(nodesMock).should().isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getParentAssocs(categoryNodeRef);
then(nodeServiceMock).should().deleteNode(categoryNodeRef);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
}
@Test
public void testDeleteCategoryById_asNonAdminUser()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(false);
//when
assertThrows(PermissionDeniedException.class, () -> objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).shouldHaveNoInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
}
@Test
public void testDeleteCategoryById_nonCategoryId()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef categoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
given(nodesMock.validateNode(CATEGORY_ID)).willReturn(categoryNodeRef);
given(nodesMock.isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
//when
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.deleteCategoryById(CATEGORY_ID, parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(CATEGORY_ID);
then(nodesMock).should().isSubClass(categoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
}
@Test
public void testDeleteCategoryById_rootCategory()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef categoryRootNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CAT_ROOT_NODE_ID);
given(nodesMock.validateNode(CAT_ROOT_NODE_ID)).willReturn(categoryRootNodeRef);
given(nodesMock.isSubClass(categoryRootNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
given(categoryChildAssociationRefMock.getQName()).willReturn(ContentModel.ASPECT_GEN_CLASSIFIABLE);
given(nodeServiceMock.getParentAssocs(categoryRootNodeRef)).willReturn(List.of(categoryChildAssociationRefMock));
//when
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.deleteCategoryById(CAT_ROOT_NODE_ID, parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(CAT_ROOT_NODE_ID);
then(nodesMock).should().isSubClass(categoryRootNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getParentAssocs(categoryRootNodeRef);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
}
@Test
public void testCreateCategoryUnderRoot()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PATH_ROOT);
given(categoryServiceMock.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE))
.willReturn(Optional.of(parentCategoryNodeRef));
final NodeRef categoryNodeRef = prepareCategoryNodeRef();
given(categoryServiceMock.createCategory(parentCategoryNodeRef, CATEGORY_NAME)).willReturn(categoryNodeRef);
given(nodesMock.getNode(CATEGORY_ID)).willReturn(prepareCategoryNode());
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentCategoryNodeRef, null, categoryNodeRef);
given(nodeServiceMock.getPrimaryParent(categoryNodeRef)).willReturn(parentAssoc);
given(nodeServiceMock.getParentAssocs(parentCategoryNodeRef)).willReturn(List.of(parentAssoc));
given(nodeServiceMock.getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false))
.willReturn(Collections.emptyList());
//when
final List<Category> createdCategories = objectUnderTest.createSubcategories(PATH_ROOT, prepareCategories(), parametersMock);
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().getNode(CATEGORY_ID);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getPrimaryParent(categoryNodeRef);
then(nodeServiceMock).should().getParentAssocs(parentCategoryNodeRef);
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(categoryServiceMock).should().getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
then(categoryServiceMock).should().createCategory(parentCategoryNodeRef, CATEGORY_NAME);
then(categoryServiceMock).shouldHaveNoMoreInteractions();
assertEquals(1, createdCategories.size());
final Category expectedCategory = Category.builder()
.id(CATEGORY_ID)
.name(CATEGORY_NAME)
.hasChildren(false)
.parentId(PATH_ROOT)
.create();
final Category createdCategory = createdCategories.iterator().next();
assertEquals(expectedCategory, createdCategory);
}
@Test
public void testCreateCategory()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
final NodeRef categoryNodeRef = prepareCategoryNodeRef();
given(categoryServiceMock.createCategory(parentCategoryNodeRef, CATEGORY_NAME)).willReturn(categoryNodeRef);
given(nodesMock.getNode(CATEGORY_ID)).willReturn(prepareCategoryNode());
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentCategoryNodeRef, null, categoryNodeRef);
given(nodeServiceMock.getPrimaryParent(categoryNodeRef)).willReturn(parentAssoc);
given(nodeServiceMock.getParentAssocs(parentCategoryNodeRef)).willReturn(List.of(parentAssoc));
given(nodeServiceMock.getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false))
.willReturn(Collections.emptyList());
//when
final List<Category> createdCategories = objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock);
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).should().getNode(CATEGORY_ID);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getPrimaryParent(categoryNodeRef);
then(nodeServiceMock).should().getParentAssocs(parentCategoryNodeRef);
then(nodeServiceMock).should().getChildAssocs(categoryNodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(categoryServiceMock).should().createCategory(parentCategoryNodeRef, CATEGORY_NAME);
then(categoryServiceMock).shouldHaveNoMoreInteractions();
assertEquals(1, createdCategories.size());
final Category expectedCategory = Category.builder()
.id(CATEGORY_ID)
.name(CATEGORY_NAME)
.hasChildren(false)
.parentId(PARENT_ID)
.create();
final Category createdCategory = createdCategories.iterator().next();
assertEquals(expectedCategory, createdCategory);
}
@Test
public void testCreateCategories_noPermissions()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(false);
//when
assertThrows(PermissionDeniedException.class,
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).shouldHaveNoInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
}
@Test
public void testCreateCategories_wrongParentNodeType()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
//when
assertThrows(InvalidArgumentException.class,
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
}
@Test
public void testCreateCategories_nonExistingParentNode()
{
given(authorityServiceMock.hasAdminAuthority()).willReturn(true);
given(nodesMock.validateNode(PARENT_ID)).willThrow(EntityNotFoundException.class);
//when
assertThrows(EntityNotFoundException.class,
() -> objectUnderTest.createSubcategories(PARENT_ID, prepareCategories(), parametersMock));
then(authorityServiceMock).should().hasAdminAuthority();
then(authorityServiceMock).shouldHaveNoMoreInteractions();
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
}
@Test
public void testGetRootCategoryChildren()
{
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PATH_ROOT);
given(categoryServiceMock.getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE))
.willReturn(Optional.of(parentCategoryNodeRef));
final int childrenCount = 3;
final List<ChildAssociationRef> childAssociationRefMocks = prepareChildAssocMocks(childrenCount, parentCategoryNodeRef);
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(childAssociationRefMocks);
childAssociationRefMocks.forEach(this::prepareCategoryNodeMocks);
//when
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PATH_ROOT, parametersMock);
then(categoryServiceMock).should().getRootCategoryNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
then(categoryServiceMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
childAssociationRefMocks.forEach(ca -> {
then(nodesMock).should().getNode(ca.getChildRef().getId());
then(nodeServiceMock).should()
.getChildAssocs(ca.getChildRef(), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).should().getPrimaryParent(ca.getChildRef());
});
then(nodeServiceMock).should(times(childrenCount)).getParentAssocs(parentCategoryNodeRef);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
assertEquals(childAssociationRefMocks.size(), categoryChildren.getTotalItems().intValue());
final List<Category> categoryChildrenList = new ArrayList<>(categoryChildren.getCollection());
assertEquals(childAssociationRefMocks.size(), categoryChildrenList.size());
IntStream.range(0, childrenCount).forEach(i -> doCategoryAssertions(categoryChildrenList.get(i), i, PATH_ROOT));
}
@Test
public void testGetCategoryChildren()
{
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
final int childrenCount = 3;
final List<ChildAssociationRef> childAssociationRefMocks = prepareChildAssocMocks(childrenCount, parentCategoryNodeRef);
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(childAssociationRefMocks);
childAssociationRefMocks.forEach(this::prepareCategoryNodeMocks);
//when
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock);
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
childAssociationRefMocks.forEach(ca -> {
then(nodesMock).should().getNode(ca.getChildRef().getId());
then(nodeServiceMock).should()
.getChildAssocs(ca.getChildRef(), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
then(nodeServiceMock).should().getPrimaryParent(ca.getChildRef());
});
then(nodeServiceMock).should(times(childrenCount)).getParentAssocs(parentCategoryNodeRef);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
assertEquals(childAssociationRefMocks.size(), categoryChildren.getTotalItems().intValue());
final List<Category> categoryChildrenList = new ArrayList<>(categoryChildren.getCollection());
assertEquals(childAssociationRefMocks.size(), categoryChildrenList.size());
IntStream.range(0, childrenCount).forEach(i -> doCategoryAssertions(categoryChildrenList.get(i), i, PARENT_ID));
}
@Test
public void testGetCategoryChildren_noChildren()
{
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(Collections.emptyList());
//when
final CollectionWithPagingInfo<Category> categoryChildren = objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock);
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).should().getChildAssocs(parentCategoryNodeRef);
then(nodeServiceMock).shouldHaveNoMoreInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
assertEquals(0, categoryChildren.getTotalItems().intValue());
}
@Test
public void testGetCategoryChildren_wrongParentNodeType()
{
final NodeRef parentCategoryNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(false);
//when
assertThrows(InvalidArgumentException.class, () -> objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock));
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).should().isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
}
@Test
public void testGetCategoryChildren_nonExistingParentNode()
{
given(nodesMock.validateNode(PARENT_ID)).willThrow(EntityNotFoundException.class);
//when
assertThrows(EntityNotFoundException.class, () -> objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock));
then(nodesMock).should().validateNode(PARENT_ID);
then(nodesMock).shouldHaveNoMoreInteractions();
then(nodeServiceMock).shouldHaveNoInteractions();
then(categoryServiceMock).shouldHaveNoInteractions();
then(authorityServiceMock).shouldHaveNoInteractions();
}
private Node prepareCategoryNode()
{
final NodeRef parentNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, PARENT_ID);
return prepareCategoryNode(CATEGORY_NAME, CATEGORY_ID, parentNodeRef);
}
private Node prepareCategoryNode(final String name, final String id, final NodeRef parentNodeRef)
{
final Node categoryNode = new Node();
categoryNode.setName(name);
categoryNode.setNodeId(id);
categoryNode.setParentId(parentNodeRef);
return categoryNode;
}
private NodeRef prepareCategoryNodeRef()
{
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID);
}
private List<Category> prepareCategories()
{
return List.of(Category.builder()
.name(CATEGORY_NAME)
.create());
}
private List<ChildAssociationRef> prepareChildAssocMocks(final int count, NodeRef parentCategoryNodeRef)
{
return IntStream.range(0, count).mapToObj(i -> {
ChildAssociationRef dummyChildAssocMock = mock(ChildAssociationRef.class);
given(dummyChildAssocMock.getTypeQName()).willReturn(ContentModel.ASSOC_SUBCATEGORIES);
given(dummyChildAssocMock.getChildRef())
.willReturn(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CATEGORY_ID + "-" + i));
given(dummyChildAssocMock.getParentRef()).willReturn(parentCategoryNodeRef);
return dummyChildAssocMock;
})
.collect(Collectors.toList());
}
private void prepareCategoryNodeMocks(ChildAssociationRef childAssociationRef)
{
final NodeRef childRef = childAssociationRef.getChildRef();
final String id = childRef.getId();
final String name = id.replace(CATEGORY_ID, CATEGORY_NAME);
final NodeRef parentRef = childAssociationRef.getParentRef();
given(nodesMock.getNode(id)).willReturn(prepareCategoryNode(name, id, parentRef));
final ChildAssociationRef parentAssoc = new ChildAssociationRef(null, parentRef, null, childRef);
given(nodeServiceMock.getPrimaryParent(childRef)).willReturn(parentAssoc);
given(nodeServiceMock.getParentAssocs(parentRef)).willReturn(List.of(parentAssoc));
}
private void doCategoryAssertions(final Category category, final int index, final String parentId)
{
final Category expectedCategory = Category.builder()
.id(CATEGORY_ID + "-" + index)
.name(CATEGORY_NAME + "-" + index)
.parentId(parentId)
.hasChildren(false)
.create();
assertEquals(expectedCategory, category);
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>20.36-SNAPSHOT</version>
<version>20.45-DEV</version>
</parent>
<dependencies>

View File

@@ -573,6 +573,7 @@
org.alfresco.service.cmr.search.CategoryService.deleteClassification=ACL_ALLOW
org.alfresco.service.cmr.search.CategoryService.deleteCategory=ACL_ALLOW
org.alfresco.service.cmr.search.CategoryService.getTopCategories=ACL_ALLOW
org.alfresco.service.cmr.search.CategoryService.getRootCategoryNodeRef=ACL_ALLOW
org.alfresco.service.cmr.search.CategoryService.*=ACL_DENY
</value>
</property>

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set +vx
function cloneRepo() {
local REPO="${1}"
local TAG_OR_BRANCH="${2}"
printf "Cloning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
# clone the repository branch/tag
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
rm -rf "$(basename "${REPO%.git}")"
git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}"
popd >/dev/null
}
set -vx

View File

@@ -0,0 +1,40 @@
version: "3"
services:
postgres:
profiles: ["postgres"]
image: postgres:${POSTGRES_VERSION}
environment:
- POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco
command: postgres -c max_connections=300
ports:
- "5433:5432"
mariadb:
profiles: ["mariadb"]
image: mariadb:${MARIADB_VERSION}
command: --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
- MYSQL_ROOT_PASSWORD=alfresco
- MYSQL_USER=alfresco
- MYSQL_DATABASE=alfresco
- MYSQL_PASSWORD=alfresco
ports:
- "3307:3306"
mysql:
profiles: ["mysql"]
image: mysql:${MYSQL_VERSION}
command: --transaction-isolation='READ-COMMITTED'
environment:
- MYSQL_ROOT_PASSWORD=alfresco
- MYSQL_USER=alfresco
- MYSQL_DATABASE=alfresco
- MYSQL_PASSWORD=alfresco
ports:
- "3307:3306"
activemq:
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
ports:
- "5672:5672" # AMQP
- "61616:61616" # OpenWire

View File

@@ -0,0 +1,26 @@
version: "3"
services:
transform-core-aio:
profiles: ["with-transform-core-aio"]
image: alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG}
environment:
JAVA_OPTS: " -Xms256m -Xmx256m"
ports:
- "8090:8090"
postgres:
image: postgres:14.4
profiles: ["default", "with-transform-core-aio", "postgres"]
environment:
- POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco
command: postgres -c max_connections=300
ports:
- "5433:5432"
activemq:
profiles: ["default", "with-transform-core-aio", "activemq"]
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
ports:
- "5672:5672" # AMQP
- "61616:61616" # OpenWire

View File

@@ -5,7 +5,7 @@ set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
# Maven Setup
mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml"
mkdir -p "${HOME}/.m2" && cp -f .github/.ci.settings.xml "${HOME}/.m2/settings.xml"
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf
# Docker Logins

View File

@@ -4,23 +4,22 @@ PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
# Use full history for release
git checkout -B "${TRAVIS_BRANCH}"
# Add email to link commits to user
git checkout -B "${BRANCH_NAME}"
# Define git identity for commits
git config user.email "${GIT_EMAIL}"
git config user.name "${GIT_USERNAME}"
# Run the release plugin - with "[skip ci]" in the release commit message
mvn -B \
-Pall-tas-tests \
-Pags \
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${BUILD_NUMBER}" \
release:clean release:prepare release:perform \
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \
-Dusername="${GIT_USERNAME}" \
-Dpassword="${GIT_PASSWORD}"
popd
set +vex
echo "=========================== Finishing Release Script =========================="

View File

@@ -7,8 +7,8 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh"
#Fetch the latest changes, as Travis will only checkout the PR commit
git fetch origin "${TRAVIS_BRANCH}"
git checkout "${TRAVIS_BRANCH}"
git fetch origin "${BRANCH_NAME}"
git checkout "${BRANCH_NAME}"
git pull
# Retrieve the current Community version - latest tag on the current branch
@@ -16,7 +16,7 @@ VERSION="$(git describe --abbrev=0 --tags)"
DOWNSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-repo.git"
cloneRepo "${DOWNSTREAM_REPO}" "${TRAVIS_BRANCH}"
cloneRepo "${DOWNSTREAM_REPO}" "${BRANCH_NAME}"
cd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${DOWNSTREAM_REPO%.git}")"
@@ -33,8 +33,8 @@ git status
git --no-pager diff pom.xml
git add pom.xml
if [[ "${TRAVIS_COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
FORCE_TOKEN=$(echo "${TRAVIS_COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
if [[ "${COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
FORCE_TOKEN=$(echo "${COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
git commit --allow-empty -m "${FORCE_TOKEN} Update upstream version to ${VERSION}"
git push
elif git status --untracked-files=no --porcelain | grep -q '^' ; then

View File

@@ -1,193 +0,0 @@
#!/usr/bin/env bash
set +vx
function isPullRequestBuild() {
test "${TRAVIS_PULL_REQUEST}" != "false"
}
function isBranchBuild() {
test "${TRAVIS_PULL_REQUEST}" = "false"
}
function cloneRepo() {
local REPO="${1}"
local TAG_OR_BRANCH="${2}"
printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
# clone the repository branch/tag
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
rm -rf "$(basename "${REPO%.git}")"
git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}"
popd >/dev/null
}
function retrievePomParentVersion() {
local REPO="${1}"
if [ -z "${REPO}" ]; then
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
else
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null
fi
sed -n '/<parent>/,/<\/parent>/p' pom.xml \
| sed -n '/<version>/,/<\/version>/p' \
| tr -d '\n' \
| grep -oP '(?<=<version>).*(?=</version>)' \
| xargs
popd >/dev/null
}
function retrievePomProperty() {
local KEY="${1}"
local REPO="${2}"
if [ -z "${REPO}" ]; then
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
else
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null
fi
sed -n '/<properties>/,/<\/properties>/p' pom.xml \
| sed -n "/<${KEY}>/,/<\/${KEY}>/p" \
| tr -d '\n' \
| grep -oP "(?<=<${KEY}>).*(?=</${KEY}>)" \
| xargs
popd >/dev/null
}
function evaluatePomProperty() {
local KEY="${1}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null
mvn -B -q help:evaluate -Dexpression="${KEY}" -DforceStdout
popd >/dev/null
}
function remoteBranchExists() {
local REMOTE_REPO="${1}"
local BRANCH="${2}"
git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH}" &>/dev/null
}
function identifyUpstreamSourceBranch() {
local UPSTREAM_REPO="${1}"
# if it's a pull request, use the source branch name (if it exists)
if isPullRequestBuild && remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_PULL_REQUEST_BRANCH}" ; then
echo "${TRAVIS_PULL_REQUEST_BRANCH}"
exit 0
fi
# otherwise use the current branch name (or in case of PRs, the target branch name)
if remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}" ; then
echo "${TRAVIS_BRANCH}"
exit 0
fi
# if none of the previous exists, use the "master" branch
echo "master"
}
function pullUpstreamTag() {
local UPSTREAM_REPO="${1}"
local TAG="${2}"
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
}
function pullSameBranch() {
local UPSTREAM_REPO="${1}"
local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")"
cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"
}
function buildUpstreamTag() {
local UPSTREAM_REPO="${1}"
local TAG="${2}"
local EXTRA_BUILD_ARGUMENTS="${3}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS}
popd
}
function buildSameBranchOnUpstream() {
local UPSTREAM_REPO="${1}"
local EXTRA_BUILD_ARGUMENTS="${2}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS}
mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml
popd
}
function pullUpstreamTagAndBuildDockerImage() {
local UPSTREAM_REPO="${1}"
local TAG="${2}"
local EXTRA_BUILD_ARGUMENTS="${3}"
cloneRepo "${UPSTREAM_REPO}" "${TAG}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS}
popd
}
function pullAndBuildSameBranchOnUpstream() {
local UPSTREAM_REPO="${1}"
local EXTRA_BUILD_ARGUMENTS="${2}"
local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")"
cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}"
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"
cd "$(basename "${UPSTREAM_REPO%.git}")"
mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS}
mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml
popd
}
function retieveLatestTag() {
local REPO="${1}"
local BRANCH="${2}"
local LOCAL_PATH="/tmp/$(basename "${REPO%.git}")"
git clone -q -b "${BRANCH}" "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" "${LOCAL_PATH}"
pushd "${LOCAL_PATH}" >/dev/null
git describe --abbrev=0 --tags
popd >/dev/null
rm -rf "${LOCAL_PATH}"
}
set -vx

View File

@@ -1,26 +0,0 @@
#!/usr/bin/env bash
echo "=========================== Starting SourceClear Script ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set +e -v -x
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"
mvn -B -q clean install \
-DskipTests \
-Dmaven.javadoc.skip=true \
com.srcclr:srcclr-maven-plugin:scan \
-Dcom.srcclr.apiToken=${SRCCLR_API_TOKEN} > scan.log
SUCCESS=$? # this will read exit code of the previous command
if [ -z "$VERACODE_FAILS_BUILD" ] || [ "$VERACODE_FAILS_BUILD" = false ] ; then
SUCCESS=0
fi
cat scan.log | grep -e 'Full Report Details' -e 'Failed'
popd
set +vex
echo "=========================== Finishing SourceClear Script =========================="
exit ${SUCCESS}