mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	Compare commits
	
		
			27 Commits
		
	
	
		
			17.94
			...
			hack/hacka
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | cd8ef77b3e | ||
|  | 8622e0e102 | ||
|  | 69170dde35 | ||
|  | c848024130 | ||
|  | 553f78bb1e | ||
|  | 9a3ceb21a8 | ||
|  | 57d0ff62dc | ||
|  | 42bd94c1da | ||
|  | c5dd6538f8 | ||
|  | 152c036d86 | ||
|  | f2055f91dc | ||
|  | a1d7f0d479 | ||
|  | 8476f01b35 | ||
|  | 6c4b9e458a | ||
|  | 0f99dec012 | ||
|  | 06c7836e70 | ||
|  | 2ceb7384bf | ||
|  | d848c83a57 | ||
|  | be7572a978 | ||
|  | ef45aaf9cc | ||
|  | 6f834909f6 | ||
|  | b928598bd7 | ||
|  | 678eeab278 | ||
|  | 45f9bd6569 | ||
|  | 23b8c0e7a6 | ||
|  | 9c98f7b0fb | ||
|  | 6e1d5c81e2 | 
							
								
								
									
										11
									
								
								.github/workflows/hackathon.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								.github/workflows/hackathon.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | name: Hackathon | ||||||
|  |  | ||||||
|  | on: | ||||||
|  |   push: | ||||||
|  |  | ||||||
|  | jobs: | ||||||
|  |   sleep: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v3 | ||||||
|  |       - run: sleep 240 | ||||||
| @@ -7,7 +7,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-community-repo-amps</artifactId> |       <artifactId>alfresco-community-repo-amps</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <modules> |    <modules> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> |       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <modules> |    <modules> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-governance-services-automation-community-repo</artifactId> |       <artifactId>alfresco-governance-services-automation-community-repo</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <build> |    <build> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> |       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <modules> |    <modules> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-governance-services-community-repo-parent</artifactId> |       <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <properties> |    <properties> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-governance-services-community-repo-parent</artifactId> |         <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <build> |     <build> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <modules> |     <modules> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-amps</artifactId> |         <artifactId>alfresco-community-repo-amps</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <properties> |     <properties> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|    <parent> |    <parent> | ||||||
|       <groupId>org.alfresco</groupId> |       <groupId>org.alfresco</groupId> | ||||||
|       <artifactId>alfresco-community-repo</artifactId> |       <artifactId>alfresco-community-repo</artifactId> | ||||||
|       <version>17.94</version> |       <version>17.102-SNAPSHOT</version> | ||||||
|    </parent> |    </parent> | ||||||
|  |  | ||||||
|    <dependencies> |    <dependencies> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <properties> |     <properties> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <dependencies> |     <dependencies> | ||||||
|   | |||||||
| @@ -9,6 +9,6 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> |         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
| </project> | </project> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> |         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <properties> |     <properties> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <modules> |     <modules> | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> |         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <modules> |     <modules> | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-tests</artifactId> |         <artifactId>alfresco-community-repo-tests</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <developers> |     <developers> | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-tests</artifactId> |         <artifactId>alfresco-community-repo-tests</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <developers> |     <developers> | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-tests</artifactId> |         <artifactId>alfresco-community-repo-tests</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <developers> |     <developers> | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-tests</artifactId> |         <artifactId>alfresco-community-repo-tests</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <developers> |     <developers> | ||||||
|   | |||||||
| @@ -27,14 +27,7 @@ package org.alfresco.rest.rules; | |||||||
|  |  | ||||||
| import static java.util.stream.Collectors.toList; | import static java.util.stream.Collectors.toList; | ||||||
|  |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.RULE_NAME_DEFAULT; | import static org.alfresco.rest.rules.RulesTestsUtils.*; | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.addActionContextParams; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createCustomActionModel; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createDefaultActionModel; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createEmptyConditionModel; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModelWithDefaultName; |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModelWithDefaultValues; |  | ||||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||||
| import static org.alfresco.utility.constants.UserRole.SiteConsumer; | import static org.alfresco.utility.constants.UserRole.SiteConsumer; | ||||||
| import static org.alfresco.utility.constants.UserRole.SiteContributor; | import static org.alfresco.utility.constants.UserRole.SiteContributor; | ||||||
| @@ -95,12 +88,12 @@ public class CreateRulesTests extends RestTest | |||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||||
|     public void createRule() |     public void createRule() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); |         RestRuleModel ruleModel = createRuleModelWithModifiedValues(); | ||||||
|  |  | ||||||
|         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() |         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
|                                        .createSingleRule(ruleModel); |                                        .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|         RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); |         RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues(); | ||||||
|         expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions())); |         expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions())); | ||||||
|         expectedRuleModel.setConditions(createEmptyConditionModel()); |         expectedRuleModel.setConditions(createEmptyConditionModel()); | ||||||
|         restClient.assertStatusCodeIs(CREATED); |         restClient.assertStatusCodeIs(CREATED); | ||||||
| @@ -278,7 +271,7 @@ public class CreateRulesTests extends RestTest | |||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||||
|     public void createRuleWithoutDescription() |     public void createRuleWithoutDescription() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         UserModel admin = dataUser.getAdminUser(); |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |  | ||||||
|         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() |         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
| @@ -294,7 +287,7 @@ public class CreateRulesTests extends RestTest | |||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||||
|     public void createRuleWithoutTriggers() |     public void createRuleWithoutTriggers() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         UserModel admin = dataUser.getAdminUser(); |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |  | ||||||
|         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() |         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
| @@ -310,7 +303,7 @@ public class CreateRulesTests extends RestTest | |||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||||
|     public void createRuleWithoutErrorScript() |     public void createRuleWithoutErrorScript() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         UserModel admin = dataUser.getAdminUser(); |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |  | ||||||
|         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() |         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
| @@ -326,7 +319,7 @@ public class CreateRulesTests extends RestTest | |||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||||
|     public void createRuleWithSharedFlag() |     public void createRuleWithSharedFlag() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         ruleModel.setIsShared(true); |         ruleModel.setIsShared(true); | ||||||
|         UserModel admin = dataUser.getAdminUser(); |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |  | ||||||
| @@ -382,7 +375,7 @@ public class CreateRulesTests extends RestTest | |||||||
|         final RestActionBodyExecTemplateModel checkOutAction = createCustomActionModel("check-out", checkOutParams); |         final RestActionBodyExecTemplateModel checkOutAction = createCustomActionModel("check-out", checkOutParams); | ||||||
|         final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id"); |         final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id"); | ||||||
|         final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel("script", scriptParams); |         final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel("script", scriptParams); | ||||||
|         final RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         final RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         ruleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction)); |         ruleModel.setActions(Arrays.asList(copyAction, checkOutAction, scriptAction)); | ||||||
|  |  | ||||||
|         final UserModel admin = dataUser.getAdminUser(); |         final UserModel admin = dataUser.getAdminUser(); | ||||||
| @@ -390,7 +383,7 @@ public class CreateRulesTests extends RestTest | |||||||
|         final RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() |         final RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
|                 .createSingleRule(ruleModel); |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|         final RestRuleModel expectedRuleModel = createRuleModelWithDefaultName(); |         final RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); | ||||||
|         expectedRuleModel.setActions(addActionContextParams(Arrays.asList(copyAction, checkOutAction, scriptAction))); |         expectedRuleModel.setActions(addActionContextParams(Arrays.asList(copyAction, checkOutAction, scriptAction))); | ||||||
|         expectedRuleModel.setConditions(createEmptyConditionModel()); |         expectedRuleModel.setConditions(createEmptyConditionModel()); | ||||||
|         expectedRuleModel.setTriggers(List.of("inbound")); |         expectedRuleModel.setTriggers(List.of("inbound")); | ||||||
|   | |||||||
| @@ -27,13 +27,14 @@ package org.alfresco.rest.rules; | |||||||
|  |  | ||||||
| import static java.util.stream.Collectors.toList; | import static java.util.stream.Collectors.toList; | ||||||
|  |  | ||||||
| import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | import static org.alfresco.rest.rules.RulesTestsUtils.*; | ||||||
| import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | import static org.alfresco.utility.constants.UserRole.SiteCollaborator; | ||||||
| import static org.alfresco.utility.report.log.Step.STEP; | import static org.alfresco.utility.report.log.Step.STEP; | ||||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||||
| import static org.springframework.http.HttpStatus.FORBIDDEN; | import static org.springframework.http.HttpStatus.FORBIDDEN; | ||||||
| import static org.springframework.http.HttpStatus.NOT_FOUND; | import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||||
| import static org.springframework.http.HttpStatus.OK; | import static org.springframework.http.HttpStatus.OK; | ||||||
|  | import static org.springframework.http.HttpStatus.CREATED; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.stream.IntStream; | import java.util.stream.IntStream; | ||||||
| @@ -60,6 +61,8 @@ public class GetRulesTests extends RestTest | |||||||
|     private FolderModel ruleFolder; |     private FolderModel ruleFolder; | ||||||
|     private List<RestRuleModel> createdRules; |     private List<RestRuleModel> createdRules; | ||||||
|     private RestRuleModel createdRuleA; |     private RestRuleModel createdRuleA; | ||||||
|  |     private static final String IGNORE_ID = "id"; | ||||||
|  |     private static final String IGNORE_IS_SHARED = "isShared"; | ||||||
|  |  | ||||||
|     @BeforeClass(alwaysRun = true) |     @BeforeClass(alwaysRun = true) | ||||||
|     public void dataPreparation() |     public void dataPreparation() | ||||||
| @@ -133,7 +136,7 @@ public class GetRulesTests extends RestTest | |||||||
|         restClient.assertStatusCodeIs(NOT_FOUND); |         restClient.assertStatusCodeIs(NOT_FOUND); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** Check we can get all the rules for a folder along with the extra "include" fields. */ |     /** Check we can get all the rules for a folder along with the extra "include" and "other" fields. */ | ||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||||
|     public void getRulesListWithIncludedFields() |     public void getRulesListWithIncludedFields() | ||||||
|     { |     { | ||||||
| @@ -145,7 +148,14 @@ public class GetRulesTests extends RestTest | |||||||
|         rules.assertThat().entriesListCountIs(createdRules.size()); |         rules.assertThat().entriesListCountIs(createdRules.size()); | ||||||
|         IntStream.range(0, createdRules.size()).forEach(i -> |         IntStream.range(0, createdRules.size()).forEach(i -> | ||||||
|                 rules.getEntries().get(i).onModel() |                 rules.getEntries().get(i).onModel() | ||||||
|                      .assertThat().field("isShared").isNotNull()); |                      .assertThat().field("isShared").isNotNull() | ||||||
|  |                         .assertThat().field("description").isNull() | ||||||
|  |                         .assertThat().field("enabled").is(false) | ||||||
|  |                         .assertThat().field("cascade").is(false) | ||||||
|  |                         .assertThat().field("asynchronous").is(false) | ||||||
|  |                         .assertThat().field("errorScript").isNull() | ||||||
|  |                         .assertThat().field("shared").isNull() | ||||||
|  |                         .assertThat().field("triggers").is("[inbound]")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -166,6 +176,54 @@ public class GetRulesTests extends RestTest | |||||||
|             .assertThat().field("isShared").isNull(); |             .assertThat().field("isShared").isNull(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** Check we can get rule's other fields */ | ||||||
|  |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||||
|  |     public void getRulesOtherFieldsModified() | ||||||
|  |     { | ||||||
|  |         STEP("Create a rule with all other fields default values modified"); | ||||||
|  |         RestRuleModel ruleModel = createRuleModelWithModifiedValues(); | ||||||
|  |         ruleModel.setTriggers(List.of("update")); | ||||||
|  |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|  |         RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues(); | ||||||
|  |         expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions())); | ||||||
|  |         expectedRuleModel.setTriggers(List.of("update")); | ||||||
|  |         expectedRuleModel.setConditions(createEmptyConditionModel()); | ||||||
|  |  | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |         rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED) | ||||||
|  |                 .assertThat().field("id").isNotNull() | ||||||
|  |                 .assertThat().field("isShared").isNull(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** Check we can get rule's "other" fields */ | ||||||
|  |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY }) | ||||||
|  |     public void getRulesDefaultFields() | ||||||
|  |     { | ||||||
|  |         STEP("Create a rule with all other fields default values"); | ||||||
|  |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|  |         UserModel admin = dataUser.getAdminUser(); | ||||||
|  |         FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|  |         RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); | ||||||
|  |         expectedRuleModel.setActions(addActionContextParams(expectedRuleModel.getActions())); | ||||||
|  |         expectedRuleModel.setTriggers(List.of("inbound")); | ||||||
|  |         expectedRuleModel.setConditions(createEmptyConditionModel()); | ||||||
|  |  | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |  | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |         rule.assertThat().isEqualTo(expectedRuleModel, IGNORE_ID, IGNORE_IS_SHARED) | ||||||
|  |                 .assertThat().field("id").isNotNull() | ||||||
|  |                 .assertThat().field("isShared").isNull(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** Check we get a 404 if trying to load a rule from a folder that doesn't exist. */ |     /** Check we get a 404 if trying to load a rule from a folder that doesn't exist. */ | ||||||
|     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) |     @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) | ||||||
|     public void getSingleRuleFromNonExistentFolder() |     public void getSingleRuleFromNonExistentFolder() | ||||||
|   | |||||||
| @@ -0,0 +1,313 @@ | |||||||
|  | /* | ||||||
|  |  * #%L | ||||||
|  |  * Alfresco Remote API | ||||||
|  |  * %% | ||||||
|  |  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||||
|  |  * %% | ||||||
|  |  * This file is part of the Alfresco software. | ||||||
|  |  * If the software was purchased under a paid Alfresco license, the terms of | ||||||
|  |  * the paid license agreement will prevail.  Otherwise, the software is | ||||||
|  |  * provided under the following open source license terms: | ||||||
|  |  * | ||||||
|  |  * Alfresco is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Lesser General Public License as published by | ||||||
|  |  * the Free Software Foundation, either version 3 of the License, or | ||||||
|  |  * (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * Alfresco is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  *  GNU Lesser General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Lesser General Public License | ||||||
|  |  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  * #L% | ||||||
|  |  */ | ||||||
|  | package org.alfresco.rest.rules; | ||||||
|  |  | ||||||
|  | import static org.alfresco.rest.rules.RulesTestsUtils.createRuleModel; | ||||||
|  | import static org.alfresco.utility.report.log.Step.STEP; | ||||||
|  | import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||||||
|  | import static org.springframework.http.HttpStatus.CREATED; | ||||||
|  | import static org.springframework.http.HttpStatus.NOT_FOUND; | ||||||
|  |  | ||||||
|  | import org.alfresco.dataprep.CMISUtil; | ||||||
|  | import org.alfresco.rest.RestTest; | ||||||
|  | import org.alfresco.rest.model.RestRuleModel; | ||||||
|  | import org.alfresco.rest.model.RestRuleModelsCollection; | ||||||
|  | import org.alfresco.rest.model.RestRuleSetLinkModel; | ||||||
|  | import org.alfresco.rest.model.RestRuleSetModel; | ||||||
|  | import org.alfresco.rest.model.RestRuleSetModelsCollection; | ||||||
|  | import org.alfresco.utility.model.FileModel; | ||||||
|  | import org.alfresco.utility.model.FolderModel; | ||||||
|  | import org.alfresco.utility.model.SiteModel; | ||||||
|  | import org.alfresco.utility.model.TestGroup; | ||||||
|  | import org.alfresco.utility.model.UserModel; | ||||||
|  | import org.testng.annotations.BeforeClass; | ||||||
|  | import org.testng.annotations.Test; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Tests for /nodes/{nodeId}/rule-set-links. | ||||||
|  |  */ | ||||||
|  | @Test(groups = {TestGroup.RULES}) | ||||||
|  | public class RuleSetLinksTests extends RestTest | ||||||
|  | { | ||||||
|  |     private UserModel user; | ||||||
|  |     private SiteModel site; | ||||||
|  |  | ||||||
|  |     @BeforeClass(alwaysRun = true) | ||||||
|  |     public void dataPreparation() | ||||||
|  |     { | ||||||
|  |         STEP("Create a user and site."); | ||||||
|  |         user = dataUser.createRandomTestUser(); | ||||||
|  |         site = dataSite.usingUser(user).createPublicRandomSite(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we can link to folder containing a rule set. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToFolderContainingRules() | ||||||
|  |     { | ||||||
|  |         STEP("Create folders in existing site"); | ||||||
|  |         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Create a rule in the rule folder."); | ||||||
|  |         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||||
|  |         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|  |         STEP("Get the rule sets for the folder and find the rule set id"); | ||||||
|  |         final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         ruleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); | ||||||
|  |  | ||||||
|  |         STEP("Link to a rule folder"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(ruleFolder.getNodeRef()); | ||||||
|  |         final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result"); | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |         final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel(); | ||||||
|  |         expectedLink.setId(ruleSetId); | ||||||
|  |         ruleLink.assertThat().isEqualTo(expectedLink); | ||||||
|  |  | ||||||
|  |         STEP("Check if folder returns same rules"); | ||||||
|  |         final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(folder) | ||||||
|  |                 .usingDefaultRuleSet() | ||||||
|  |                 .getListOfRules(); | ||||||
|  |         linkedRules.assertThat().entriesListCountIs(1); | ||||||
|  |         linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); | ||||||
|  |  | ||||||
|  |         STEP("Check if folder returns rule set with linked inclusionType"); | ||||||
|  |         final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(folder) | ||||||
|  |                 .include("inclusionType") | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         linkedRuleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final RestRuleSetModel expectedRuleSet = new RestRuleSetModel(); | ||||||
|  |         expectedRuleSet.setId(ruleSetId); | ||||||
|  |         expectedRuleSet.setInclusionType("linked"); | ||||||
|  |         linkedRuleSets.getEntries() | ||||||
|  |                 .get(0).onModel().assertThat().isEqualTo(expectedRuleSet); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we can link to a rule set. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToRuleSet() | ||||||
|  |     { | ||||||
|  |         STEP("Create folders in existing site"); | ||||||
|  |         final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Create a rule in the rule folder."); | ||||||
|  |         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||||
|  |         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|  |         STEP("Get the rule sets for the folder and find the rule set id"); | ||||||
|  |         final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         ruleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); | ||||||
|  |  | ||||||
|  |         STEP("Link to a rule set"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(ruleSetId); | ||||||
|  |         final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result"); | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |         final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel(); | ||||||
|  |         expectedLink.setId(ruleSetId); | ||||||
|  |         ruleLink.assertThat().isEqualTo(expectedLink); | ||||||
|  |  | ||||||
|  |         STEP("Check if folder returns same rules"); | ||||||
|  |         final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(folder) | ||||||
|  |                 .usingDefaultRuleSet() | ||||||
|  |                 .getListOfRules(); | ||||||
|  |         linkedRules.assertThat().entriesListCountIs(1); | ||||||
|  |         linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); | ||||||
|  |  | ||||||
|  |         STEP("Check if folder returns rule set with linked inclusionType"); | ||||||
|  |         final RestRuleSetModelsCollection likedRuleSets = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(folder) | ||||||
|  |                 .include("inclusionType") | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         likedRuleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final RestRuleSetModel expectedRuleSet = new RestRuleSetModel(); | ||||||
|  |         expectedRuleSet.setId(ruleSetId); | ||||||
|  |         expectedRuleSet.setInclusionType("linked"); | ||||||
|  |         likedRuleSets.getEntries() | ||||||
|  |                 .get(0).onModel().assertThat().isEqualTo(expectedRuleSet); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we get 404 when linking to a non-existing rule set/folder. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToNonExistingRuleSet() | ||||||
|  |     { | ||||||
|  |         STEP("Create a folder in existing site"); | ||||||
|  |         final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Link to non-existing rule set"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId("dummy-rule-set-id"); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result is 404"); | ||||||
|  |         restClient.assertStatusCodeIs(NOT_FOUND); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we get bad request error when linking to a folder without rules. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToFolderWithoutRules() | ||||||
|  |     { | ||||||
|  |         STEP("Create 2 folders without rules in existing site"); | ||||||
|  |         final FolderModel folder1 = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FolderModel folder2 = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Link to a folder without rules"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(folder2.getNodeRef()); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result is 400"); | ||||||
|  |         restClient.assertStatusCodeIs(BAD_REQUEST) | ||||||
|  |                 .assertLastError().containsSummary("The target node has no rules to link."); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we get bad request error when linking from a folder which already has rules. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkFromFolderWithRules() | ||||||
|  |     { | ||||||
|  |         STEP("Create folders in existing site"); | ||||||
|  |         final FolderModel folder1 = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FolderModel folder2 = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Create rules in both folders."); | ||||||
|  |         RestRuleModel ruleModel1 = createRuleModel("ruleName1"); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel1); | ||||||
|  |         RestRuleModel ruleModel2 = createRuleModel("ruleName2"); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder2).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel2); | ||||||
|  |  | ||||||
|  |         STEP("Link from a folder with rules"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(folder2.getNodeRef()); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result is 400"); | ||||||
|  |         restClient.assertStatusCodeIs(BAD_REQUEST) | ||||||
|  |                 .assertLastError().containsSummary( | ||||||
|  |                 "Unable to link to a ruleset because the folder has pre-existing rules or is already linked to a ruleset."); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we get bad request error when linking to a file node. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToFileNode() | ||||||
|  |     { | ||||||
|  |         STEP("Create a folder in existing site"); | ||||||
|  |         final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FileModel fileContent = dataContent.usingUser(user).usingSite(site).createContent(CMISUtil.DocumentType.TEXT_PLAIN); | ||||||
|  |  | ||||||
|  |         STEP("Link to a file node"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(fileContent.getNodeRef()); | ||||||
|  |         restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result is 400"); | ||||||
|  |         restClient.assertStatusCodeIs(BAD_REQUEST) | ||||||
|  |                 .assertLastError().containsSummary("NodeId of a folder is expected!"); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Check we can link to a parent folder with rules. | ||||||
|  |      */ | ||||||
|  |     @Test(groups = {TestGroup.REST_API, TestGroup.RULES}) | ||||||
|  |     public void linkToParentNodeWithRules() | ||||||
|  |     { | ||||||
|  |         STEP("Create parent/child folders in existing site"); | ||||||
|  |         final FolderModel parentFolder = dataContent.usingUser(user).usingSite(site).createFolder(); | ||||||
|  |         final FolderModel childFolder = dataContent.usingUser(user).usingSite(site).usingResource(parentFolder).createFolder(); | ||||||
|  |  | ||||||
|  |         STEP("Create a rule in the parent folder."); | ||||||
|  |         RestRuleModel ruleModel = createRuleModel("ruleName"); | ||||||
|  |         RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet() | ||||||
|  |                 .createSingleRule(ruleModel); | ||||||
|  |  | ||||||
|  |         STEP("Get the rule sets for the folder and find the rule set id"); | ||||||
|  |         final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder) | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         ruleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); | ||||||
|  |  | ||||||
|  |         STEP("Link to the parent folder"); | ||||||
|  |         final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); | ||||||
|  |         request.setId(parentFolder.getNodeRef()); | ||||||
|  |         final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).createRuleLink(request); | ||||||
|  |  | ||||||
|  |         STEP("Assert link result"); | ||||||
|  |         restClient.assertStatusCodeIs(CREATED); | ||||||
|  |         final RestRuleSetLinkModel expectedLink = new RestRuleSetLinkModel(); | ||||||
|  |         expectedLink.setId(ruleSetId); | ||||||
|  |         ruleLink.assertThat().isEqualTo(expectedLink); | ||||||
|  |  | ||||||
|  |         STEP("Check if child folder returns same rules"); | ||||||
|  |         final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(childFolder) | ||||||
|  |                 .usingDefaultRuleSet() | ||||||
|  |                 .getListOfRules(); | ||||||
|  |         linkedRules.assertThat().entriesListCountIs(1); | ||||||
|  |         linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); | ||||||
|  |  | ||||||
|  |         STEP("Check if child folder returns rule set with linked inclusionType"); | ||||||
|  |         final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI() | ||||||
|  |                 .usingNode(childFolder) | ||||||
|  |                 .include("inclusionType") | ||||||
|  |                 .getListOfRuleSets(); | ||||||
|  |         linkedRuleSets.assertThat().entriesListCountIs(1); | ||||||
|  |         final RestRuleSetModel expectedRuleSet = new RestRuleSetModel(); | ||||||
|  |         expectedRuleSet.setId(ruleSetId); | ||||||
|  |         expectedRuleSet.setInclusionType("linked"); | ||||||
|  |         linkedRuleSets.getEntries() | ||||||
|  |                 .get(0).onModel().assertThat().isEqualTo(expectedRuleSet); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -50,9 +50,9 @@ public class RulesTestsUtils | |||||||
|      * |      * | ||||||
|      * @return The created rule model. |      * @return The created rule model. | ||||||
|      */ |      */ | ||||||
|     public static RestRuleModel createRuleModelWithDefaultValues() |     public static RestRuleModel createRuleModelWithModifiedValues() | ||||||
|     { |     { | ||||||
|         RestRuleModel ruleModel = createRuleModelWithDefaultName(); |         RestRuleModel ruleModel = createRuleModelWithDefaultValues(); | ||||||
|         ruleModel.setDescription(RULE_DESCRIPTION_DEFAULT); |         ruleModel.setDescription(RULE_DESCRIPTION_DEFAULT); | ||||||
|         ruleModel.setEnabled(RULE_ENABLED_DEFAULT); |         ruleModel.setEnabled(RULE_ENABLED_DEFAULT); | ||||||
|         ruleModel.setCascade(RULE_CASCADE_DEFAULT); |         ruleModel.setCascade(RULE_CASCADE_DEFAULT); | ||||||
| @@ -64,7 +64,7 @@ public class RulesTestsUtils | |||||||
|         return ruleModel; |         return ruleModel; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static RestRuleModel createRuleModelWithDefaultName() |     public static RestRuleModel createRuleModelWithDefaultValues() | ||||||
|     { |     { | ||||||
|         return createRuleModel(RULE_NAME_DEFAULT, List.of(createDefaultActionModel())); |         return createRuleModel(RULE_NAME_DEFAULT, List.of(createDefaultActionModel())); | ||||||
|     } |     } | ||||||
| @@ -97,7 +97,7 @@ public class RulesTestsUtils | |||||||
|     public static RestActionBodyExecTemplateModel createDefaultActionModel() |     public static RestActionBodyExecTemplateModel createDefaultActionModel() | ||||||
|     { |     { | ||||||
|         RestActionBodyExecTemplateModel restActionModel = new RestActionBodyExecTemplateModel(); |         RestActionBodyExecTemplateModel restActionModel = new RestActionBodyExecTemplateModel(); | ||||||
|         restActionModel.setActionDefinitionId("add-features"); |         restActionModel.setActionDefinitionId("set-property-value"); | ||||||
|         restActionModel.setParams(Map.of("aspect-name", "cm:audio")); |         restActionModel.setParams(Map.of("aspect-name", "cm:audio")); | ||||||
|         return restActionModel; |         return restActionModel; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-tests</artifactId> |         <artifactId>alfresco-community-repo-tests</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <developers> |     <developers> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> |         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <properties> |     <properties> | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | |||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | <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> |     <modelVersion>4.0.0</modelVersion> | ||||||
|     <artifactId>alfresco-community-repo</artifactId> |     <artifactId>alfresco-community-repo</artifactId> | ||||||
|     <version>17.94</version> |     <version>17.102-SNAPSHOT</version> | ||||||
|     <packaging>pom</packaging> |     <packaging>pom</packaging> | ||||||
|     <name>Alfresco Community Repo Parent</name> |     <name>Alfresco Community Repo Parent</name> | ||||||
|  |  | ||||||
| @@ -51,8 +51,8 @@ | |||||||
|         <dependency.alfresco-log-sanitizer.version>0.2</dependency.alfresco-log-sanitizer.version> |         <dependency.alfresco-log-sanitizer.version>0.2</dependency.alfresco-log-sanitizer.version> | ||||||
|         <dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version> |         <dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version> | ||||||
|         <dependency.activiti.version>5.23.0</dependency.activiti.version> |         <dependency.activiti.version>5.23.0</dependency.activiti.version> | ||||||
|         <dependency.alfresco-transform-service.version>1.5.3</dependency.alfresco-transform-service.version> |         <dependency.alfresco-transform-service.version>1.5.4-A3</dependency.alfresco-transform-service.version> | ||||||
|         <dependency.alfresco-transform-core.version>2.6.0</dependency.alfresco-transform-core.version> |         <dependency.alfresco-transform-core.version>2.7.0-A1</dependency.alfresco-transform-core.version> | ||||||
|         <dependency.alfresco-greenmail.version>6.4</dependency.alfresco-greenmail.version> |         <dependency.alfresco-greenmail.version>6.4</dependency.alfresco-greenmail.version> | ||||||
|         <dependency.acs-event-model.version>0.0.16</dependency.acs-event-model.version> |         <dependency.acs-event-model.version>0.0.16</dependency.acs-event-model.version> | ||||||
|  |  | ||||||
| @@ -82,7 +82,7 @@ | |||||||
|         <dependency.truezip.version>7.7.10</dependency.truezip.version> |         <dependency.truezip.version>7.7.10</dependency.truezip.version> | ||||||
|         <dependency.poi.version>5.2.2</dependency.poi.version> |         <dependency.poi.version>5.2.2</dependency.poi.version> | ||||||
|         <dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version> |         <dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version> | ||||||
|         <dependency.keycloak.version>15.0.2</dependency.keycloak.version> |         <dependency.keycloak.version>18.0.0</dependency.keycloak.version> | ||||||
|         <dependency.jboss.logging.version>3.5.0.Final</dependency.jboss.logging.version> |         <dependency.jboss.logging.version>3.5.0.Final</dependency.jboss.logging.version> | ||||||
|         <dependency.camel.version>3.15.0</dependency.camel.version> <!-- when bumping this version, please keep track/sync with included netty.io dependencies (can cause dependency conflicts)--> |         <dependency.camel.version>3.15.0</dependency.camel.version> <!-- when bumping this version, please keep track/sync with included netty.io dependencies (can cause dependency conflicts)--> | ||||||
|         <dependency.activemq.version>5.17.1</dependency.activemq.version> |         <dependency.activemq.version>5.17.1</dependency.activemq.version> | ||||||
| @@ -120,7 +120,7 @@ | |||||||
|         <dependency.mariadb.version>2.7.4</dependency.mariadb.version> |         <dependency.mariadb.version>2.7.4</dependency.mariadb.version> | ||||||
|         <dependency.tas-utility.version>3.0.49</dependency.tas-utility.version> |         <dependency.tas-utility.version>3.0.49</dependency.tas-utility.version> | ||||||
|         <dependency.rest-assured.version>5.1.1</dependency.rest-assured.version> |         <dependency.rest-assured.version>5.1.1</dependency.rest-assured.version> | ||||||
|         <dependency.tas-restapi.version>1.114</dependency.tas-restapi.version> |         <dependency.tas-restapi.version>1.115</dependency.tas-restapi.version> | ||||||
|         <dependency.tas-cmis.version>1.32</dependency.tas-cmis.version> |         <dependency.tas-cmis.version>1.32</dependency.tas-cmis.version> | ||||||
|         <dependency.tas-email.version>1.9</dependency.tas-email.version> |         <dependency.tas-email.version>1.9</dependency.tas-email.version> | ||||||
|         <dependency.tas-webdav.version>1.7</dependency.tas-webdav.version> |         <dependency.tas-webdav.version>1.7</dependency.tas-webdav.version> | ||||||
| @@ -148,7 +148,7 @@ | |||||||
|         <connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection> |         <connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection> | ||||||
|         <developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection> |         <developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection> | ||||||
|         <url>https://github.com/Alfresco/alfresco-community-repo</url> |         <url>https://github.com/Alfresco/alfresco-community-repo</url> | ||||||
|         <tag>17.94</tag> |         <tag>HEAD</tag> | ||||||
|     </scm> |     </scm> | ||||||
|  |  | ||||||
|     <distributionManagement> |     <distributionManagement> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <dependencies> |     <dependencies> | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|     <parent> |     <parent> | ||||||
|         <groupId>org.alfresco</groupId> |         <groupId>org.alfresco</groupId> | ||||||
|         <artifactId>alfresco-community-repo</artifactId> |         <artifactId>alfresco-community-repo</artifactId> | ||||||
|         <version>17.94</version> |         <version>17.102-SNAPSHOT</version> | ||||||
|     </parent> |     </parent> | ||||||
|  |  | ||||||
|     <dependencies> |     <dependencies> | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  * #%L |  * #%L | ||||||
|  * Alfresco Repository |  * Alfresco Repository | ||||||
|  * %% |  * %% | ||||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited |  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||||
|  * %% |  * %% | ||||||
|  * This file is part of the Alfresco software. |  * This file is part of the Alfresco software. | ||||||
|  * If the software was purchased under a paid Alfresco license, the terms of |  * If the software was purchased under a paid Alfresco license, the terms of | ||||||
| @@ -39,6 +39,7 @@ import java.util.List; | |||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.Set; | import java.util.Set; | ||||||
|  | import java.util.Arrays; | ||||||
|  |  | ||||||
| import org.alfresco.model.ContentModel; | import org.alfresco.model.ContentModel; | ||||||
| import org.alfresco.repo.node.MLPropertyInterceptor; | import org.alfresco.repo.node.MLPropertyInterceptor; | ||||||
| @@ -77,6 +78,7 @@ import org.alfresco.service.descriptor.DescriptorService; | |||||||
| import org.alfresco.service.namespace.NamespaceService; | import org.alfresco.service.namespace.NamespaceService; | ||||||
| import org.alfresco.service.namespace.QName; | import org.alfresco.service.namespace.QName; | ||||||
| import org.alfresco.service.namespace.RegexQNamePattern; | import org.alfresco.service.namespace.RegexQNamePattern; | ||||||
|  | import org.apache.commons.lang3.math.NumberUtils; | ||||||
| import org.dom4j.io.OutputFormat; | import org.dom4j.io.OutputFormat; | ||||||
| import org.dom4j.io.XMLWriter; | import org.dom4j.io.XMLWriter; | ||||||
| import org.springframework.extensions.surf.util.ParameterCheck; | import org.springframework.extensions.surf.util.ParameterCheck; | ||||||
| @@ -100,6 +102,8 @@ public class ExporterComponent | |||||||
|     private AuthenticationService authenticationService; |     private AuthenticationService authenticationService; | ||||||
|     private PermissionService permissionService; |     private PermissionService permissionService; | ||||||
|  |  | ||||||
|  |     private String exportChunkSize; | ||||||
|  |      | ||||||
|  |  | ||||||
|     /** Indent Size */ |     /** Indent Size */ | ||||||
|     private int indentSize = 2; |     private int indentSize = 2; | ||||||
| @@ -179,6 +183,14 @@ public class ExporterComponent | |||||||
|         this.exportSecondaryNodes = exportSecondaryNodes; |         this.exportSecondaryNodes = exportSecondaryNodes; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @param exportChunkSize  the exportChunkSize | ||||||
|  |      */ | ||||||
|  |     public void setExportChunkSize(String exportChunkSize) | ||||||
|  |     { | ||||||
|  |         this.exportChunkSize = exportChunkSize; | ||||||
|  |     } | ||||||
|  |      | ||||||
|     /* (non-Javadoc) |     /* (non-Javadoc) | ||||||
|      * @see org.alfresco.service.cmr.view.ExporterService#exportView(java.io.OutputStream, org.alfresco.service.cmr.view.ExporterCrawlerParameters, org.alfresco.service.cmr.view.Exporter) |      * @see org.alfresco.service.cmr.view.ExporterService#exportView(java.io.OutputStream, org.alfresco.service.cmr.view.ExporterCrawlerParameters, org.alfresco.service.cmr.view.Exporter) | ||||||
|      */ |      */ | ||||||
| @@ -943,28 +955,23 @@ public class ExporterComponent | |||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 // Current strategy is to determine if node is a child of the root exported node |                 // Current strategy is to determine if node is a child of the root exported node | ||||||
|                 for (NodeRef exportRoot : context.getExportList()) |                 if (context.getExportMap() != null) | ||||||
|                 { |                 { | ||||||
|                     if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true) |                     for (NodeRef[] listNodeRef : context.getExportMap().values()) | ||||||
|                     { |                     { | ||||||
|                         // node to export is the root export node (and root is to be exported) |                         for (NodeRef exportRoot : listNodeRef) | ||||||
|                         isWithin = true; |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         // locate export root in primary parent path of node |  | ||||||
|                         Path nodePath = nodeService.getPath(nodeRef); |  | ||||||
|                         for (int i = nodePath.size() - 1; i >= 0; i--) |  | ||||||
|                         { |                         { | ||||||
|                             Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i); |                             isWithin = checkIsWithin(nodeRef, exportRoot, parameters); | ||||||
|                             if (pathElement.getRef().getChildRef().equals(exportRoot)) |  | ||||||
|                             { |  | ||||||
|                                 isWithin = true; |  | ||||||
|                                 break; |  | ||||||
|                             } |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     for (NodeRef exportRoot : context.getExportList()) | ||||||
|  |                     { | ||||||
|  |                         isWithin = checkIsWithin(nodeRef, exportRoot, parameters); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             catch (AccessDeniedException accessErr) |             catch (AccessDeniedException accessErr) | ||||||
|             { |             { | ||||||
| @@ -979,6 +986,28 @@ public class ExporterComponent | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private boolean checkIsWithin(NodeRef nodeRef, NodeRef exportRoot, ExporterCrawlerParameters parameters){ | ||||||
|  |         if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true) | ||||||
|  |         { | ||||||
|  |             // node to export is the root export node (and root is to be exported) | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             // locate export root in primary parent path of node | ||||||
|  |             Path nodePath = nodeService.getPath(nodeRef); | ||||||
|  |             for (int i = nodePath.size() - 1; i >= 0; i--) | ||||||
|  |             { | ||||||
|  |                 Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i); | ||||||
|  |                 if (pathElement.getRef().getChildRef().equals(exportRoot)) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Exporter Context |      * Exporter Context | ||||||
| @@ -986,7 +1015,9 @@ public class ExporterComponent | |||||||
|     private class ExporterContextImpl implements ExporterContext |     private class ExporterContextImpl implements ExporterContext | ||||||
|     { |     { | ||||||
|         private NodeRef[] exportList; |         private NodeRef[] exportList; | ||||||
|  |         private Map<Integer,NodeRef[]> exportListMap; | ||||||
|         private NodeRef[] parentList; |         private NodeRef[] parentList; | ||||||
|  |         private Map<Integer,NodeRef[]> parentListMap; | ||||||
|         private String exportedBy; |         private String exportedBy; | ||||||
|         private Date exportedDate; |         private Date exportedDate; | ||||||
|         private String exporterVersion; |         private String exporterVersion; | ||||||
| @@ -995,6 +1026,8 @@ public class ExporterComponent | |||||||
|         private Map<Integer, Set<NodeRef>> nodesWithAssociations = new HashMap<Integer, Set<NodeRef>>(); |         private Map<Integer, Set<NodeRef>> nodesWithAssociations = new HashMap<Integer, Set<NodeRef>>(); | ||||||
|          |          | ||||||
|         private int index; |         private int index; | ||||||
|  |         private int indexSubList; | ||||||
|  |         private int chunkSize; | ||||||
|  |  | ||||||
|  |  | ||||||
|         /** |         /** | ||||||
| @@ -1005,6 +1038,16 @@ public class ExporterComponent | |||||||
|         public ExporterContextImpl(ExporterCrawlerParameters parameters) |         public ExporterContextImpl(ExporterCrawlerParameters parameters) | ||||||
|         { |         { | ||||||
|             index = 0; |             index = 0; | ||||||
|  |             indexSubList = 0; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |             if(!NumberUtils.isParsable(exportChunkSize)){ | ||||||
|  |                 chunkSize = 10; | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 chunkSize = Integer.parseInt(exportChunkSize); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             // get current user performing export |             // get current user performing export | ||||||
|             String currentUserName = authenticationService.getCurrentUserName(); |             String currentUserName = authenticationService.getCurrentUserName(); | ||||||
| @@ -1022,24 +1065,80 @@ public class ExporterComponent | |||||||
|                 NodeRef exportOf = getNodeRef(parameters.getExportFrom()); |                 NodeRef exportOf = getNodeRef(parameters.getExportFrom()); | ||||||
|                 exportList[0] = exportOf; |                 exportList[0] = exportOf; | ||||||
|             } |             } | ||||||
|             parentList = new NodeRef[exportList.length]; |             if(exportList.length > chunkSize) | ||||||
|             for (int i = 0; i < exportList.length; i++) |  | ||||||
|             { |             { | ||||||
|                 parentList[i] = getParent(exportList[i], parameters.isCrawlSelf()); |                 exportListMap = splitArray(exportList); | ||||||
|  |  | ||||||
|  |                 parentListMap = new HashMap<>(); | ||||||
|  |                 for(Map.Entry<Integer, NodeRef[]> exportEntrySet : exportListMap.entrySet()) | ||||||
|  |                 { | ||||||
|  |                     parentList= new NodeRef[exportEntrySet.getValue().length]; | ||||||
|  |                     for (int i = 0; i < exportEntrySet.getValue().length; i++) | ||||||
|  |                     { | ||||||
|  |                         parentList[i] = getParent(exportEntrySet.getValue()[i], parameters.isCrawlSelf()); | ||||||
|  |                     } | ||||||
|  |                     parentListMap.put(exportEntrySet.getKey(), parentList); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else{ | ||||||
|  |                 parentList = new NodeRef[exportList.length]; | ||||||
|  |                 for (int i = 0; i < exportList.length; i++) | ||||||
|  |                 { | ||||||
|  |                     parentList[i] = getParent(exportList[i], parameters.isCrawlSelf()); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // get exporter version |             // get exporter version | ||||||
|             exporterVersion = descriptorService.getServerDescriptor().getVersion(); |             exporterVersion = descriptorService.getServerDescriptor().getVersion(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         public Map<Integer, NodeRef[]> splitArray(NodeRef[] arrayToSplit){ | ||||||
|  |             if(chunkSize <= 0){ | ||||||
|  |                 return null; | ||||||
|  |             } | ||||||
|  |             int rest = arrayToSplit.length % chunkSize; | ||||||
|  |             int chunks = arrayToSplit.length / chunkSize + (rest > 0 ? 1 : 0); | ||||||
|  |             Map<Integer, NodeRef[]> arrays = new HashMap<>() ; | ||||||
|  |             for(Integer i = 0; i < (rest > 0 ? chunks - 1 : chunks); i++){ | ||||||
|  |                 arrays.put(i, Arrays.copyOfRange(arrayToSplit, i * chunkSize, i * chunkSize + chunkSize)); | ||||||
|  |             } | ||||||
|  |             if(rest > 0){ | ||||||
|  |                 arrays.put(chunks - 1, Arrays.copyOfRange(arrayToSplit, (chunks - 1) * chunkSize, (chunks - 1) * chunkSize + rest)); | ||||||
|  |             } | ||||||
|  |             return arrays; | ||||||
|  |         } | ||||||
|  |          | ||||||
|         public boolean canRetrieve() |         public boolean canRetrieve() | ||||||
|         { |         { | ||||||
|             return index < exportList.length; |             if(exportListMap != null) | ||||||
|  |             { | ||||||
|  |                 if (exportListMap.containsKey(indexSubList)) | ||||||
|  |                 { | ||||||
|  |                     return index < exportListMap.get(indexSubList).length; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 return index < exportList.length; | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         public int setNextValue() |         public int setNextValue() | ||||||
|         { |         { | ||||||
|             return ++index; |             if(exportListMap != null && (index == exportListMap.get(indexSubList).length-1)){ | ||||||
|  |                 resetContext(); | ||||||
|  |                 if(indexSubList <= exportListMap.size()) | ||||||
|  |                 { | ||||||
|  |                     ++indexSubList; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else{ | ||||||
|  |                 ++index; | ||||||
|  |             } | ||||||
|  |             return index; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         public void resetContext() |         public void resetContext() | ||||||
| @@ -1078,7 +1177,13 @@ public class ExporterComponent | |||||||
|         { |         { | ||||||
|             if (canRetrieve()) |             if (canRetrieve()) | ||||||
|             { |             { | ||||||
|                 return exportList[index]; |                 if(exportListMap!=null) | ||||||
|  |                 { | ||||||
|  |                     return exportListMap.get(indexSubList)[index]; | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     return exportList[index]; | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
| @@ -1091,7 +1196,13 @@ public class ExporterComponent | |||||||
|         { |         { | ||||||
|             if (canRetrieve()) |             if (canRetrieve()) | ||||||
|             { |             { | ||||||
|                 return parentList[index]; |                 if(parentListMap!=null) | ||||||
|  |                 { | ||||||
|  |                     return parentListMap.get(indexSubList)[index]; | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     return parentList[index]; | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
| @@ -1105,6 +1216,11 @@ public class ExporterComponent | |||||||
|             return exportList; |             return exportList; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         public Map<Integer, NodeRef[]> getExportMap() | ||||||
|  |         { | ||||||
|  |             return exportListMap; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /* |         /* | ||||||
|          * (non-Javadoc) |          * (non-Javadoc) | ||||||
|          * @see org.alfresco.service.cmr.view.ExporterContext#getExportParentList() |          * @see org.alfresco.service.cmr.view.ExporterContext#getExportParentList() | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  * #%L |  * #%L | ||||||
|  * Alfresco Repository |  * Alfresco Repository | ||||||
|  * %% |  * %% | ||||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited |  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||||
|  * %% |  * %% | ||||||
|  * This file is part of the Alfresco software. |  * This file is part of the Alfresco software. | ||||||
|  * If the software was purchased under a paid Alfresco license, the terms of |  * If the software was purchased under a paid Alfresco license, the terms of | ||||||
| @@ -26,6 +26,7 @@ | |||||||
| package org.alfresco.service.cmr.view; | package org.alfresco.service.cmr.view; | ||||||
|  |  | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
| import org.alfresco.service.cmr.repository.NodeRef; | import org.alfresco.service.cmr.repository.NodeRef; | ||||||
|  |  | ||||||
| @@ -74,6 +75,8 @@ public interface ExporterContext | |||||||
|      */ |      */ | ||||||
|     public NodeRef[] getExportList(); |     public NodeRef[] getExportList(); | ||||||
|  |  | ||||||
|  |     public Map<Integer, NodeRef[]> getExportMap(); | ||||||
|  |      | ||||||
|     /** |     /** | ||||||
|      * Gets list of parents for exporting nodes |      * Gets list of parents for exporting nodes | ||||||
|      *  |      *  | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  * #%L |  * #%L | ||||||
|  * Alfresco Repository |  * Alfresco Repository | ||||||
|  * %% |  * %% | ||||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited |  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||||
|  * %% |  * %% | ||||||
|  * This file is part of the Alfresco software. |  * This file is part of the Alfresco software. | ||||||
|  * If the software was purchased under a paid Alfresco license, the terms of |  * If the software was purchased under a paid Alfresco license, the terms of | ||||||
| @@ -76,4 +76,5 @@ public interface ExporterService | |||||||
|     @Auditable(parameters = {"exporter", "parameters", "progress"}) |     @Auditable(parameters = {"exporter", "parameters", "progress"}) | ||||||
|     public void exportView(Exporter exporter, ExporterCrawlerParameters parameters, Exporter progress); |     public void exportView(Exporter exporter, ExporterCrawlerParameters parameters, Exporter progress); | ||||||
|  |  | ||||||
|  |     public void setExportChunkSize(String exportChunkSize); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -130,6 +130,9 @@ | |||||||
|         <property name="permissionService"> |         <property name="permissionService"> | ||||||
|             <ref bean="PermissionService" /> |             <ref bean="PermissionService" /> | ||||||
|         </property> |         </property> | ||||||
|  |         <property name="exportChunkSize"> | ||||||
|  |             <value>${rm.export.chunk.size}</value> | ||||||
|  |         </property> | ||||||
|     </bean> |     </bean> | ||||||
|  |  | ||||||
|    <bean id="repositoryExporterComponent" class="org.alfresco.repo.exporter.RepositoryExporterComponent"> |    <bean id="repositoryExporterComponent" class="org.alfresco.repo.exporter.RepositoryExporterComponent"> | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  * #%L |  * #%L | ||||||
|  * Alfresco Repository |  * Alfresco Repository | ||||||
|  * %% |  * %% | ||||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited |  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||||
|  * %% |  * %% | ||||||
|  * This file is part of the Alfresco software.  |  * This file is part of the Alfresco software.  | ||||||
|  * If the software was purchased under a paid Alfresco license, the terms of  |  * If the software was purchased under a paid Alfresco license, the terms of  | ||||||
| @@ -33,7 +33,10 @@ import java.io.InputStream; | |||||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||||
| import java.io.Serializable; | import java.io.Serializable; | ||||||
|  | import java.io.BufferedReader; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  | import java.util.Enumeration; | ||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.Collections; | import java.util.Collections; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| @@ -41,6 +44,8 @@ import java.util.Iterator; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  | import java.util.zip.ZipEntry; | ||||||
|  | import java.util.zip.ZipFile; | ||||||
|  |  | ||||||
| import org.alfresco.model.ContentModel; | import org.alfresco.model.ContentModel; | ||||||
| import org.alfresco.repo.importer.ACPImportPackageHandler; | import org.alfresco.repo.importer.ACPImportPackageHandler; | ||||||
| @@ -50,12 +55,7 @@ import org.alfresco.repo.security.permissions.PermissionServiceSPI; | |||||||
| import org.alfresco.service.ServiceRegistry; | import org.alfresco.service.ServiceRegistry; | ||||||
| import org.alfresco.service.cmr.model.FileFolderService; | import org.alfresco.service.cmr.model.FileFolderService; | ||||||
| import org.alfresco.service.cmr.model.FileInfo; | import org.alfresco.service.cmr.model.FileInfo; | ||||||
| import org.alfresco.service.cmr.repository.ChildAssociationRef; | import org.alfresco.service.cmr.repository.*; | ||||||
| import org.alfresco.service.cmr.repository.ContentData; |  | ||||||
| import org.alfresco.service.cmr.repository.MLText; |  | ||||||
| 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.search.CategoryService; | ||||||
| import org.alfresco.service.cmr.security.AccessPermission; | import org.alfresco.service.cmr.security.AccessPermission; | ||||||
| import org.alfresco.service.cmr.security.AccessStatus; | import org.alfresco.service.cmr.security.AccessStatus; | ||||||
| @@ -68,6 +68,7 @@ import org.alfresco.service.cmr.view.ExporterService; | |||||||
| import org.alfresco.service.cmr.view.ImportPackageHandler; | import org.alfresco.service.cmr.view.ImportPackageHandler; | ||||||
| import org.alfresco.service.cmr.view.ImporterService; | import org.alfresco.service.cmr.view.ImporterService; | ||||||
| import org.alfresco.service.cmr.view.Location; | import org.alfresco.service.cmr.view.Location; | ||||||
|  |  | ||||||
| import org.alfresco.service.namespace.QName; | import org.alfresco.service.namespace.QName; | ||||||
| import org.alfresco.service.transaction.TransactionService; | import org.alfresco.service.transaction.TransactionService; | ||||||
| import org.alfresco.test_category.OwnJVMTestsCategory; | import org.alfresco.test_category.OwnJVMTestsCategory; | ||||||
| @@ -82,6 +83,7 @@ import org.junit.Before; | |||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import org.junit.experimental.categories.Category; | import org.junit.experimental.categories.Category; | ||||||
| import org.springframework.extensions.surf.util.I18NUtil; | import org.springframework.extensions.surf.util.I18NUtil; | ||||||
|  | import org.springframework.extensions.surf.util.InputStreamContent; | ||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| @Category({OwnJVMTestsCategory.class, LuceneTests.class}) | @Category({OwnJVMTestsCategory.class, LuceneTests.class}) | ||||||
| @@ -95,6 +97,7 @@ public class ExporterComponentTest extends BaseSpringTest | |||||||
|     private FileFolderService fileFolderService; |     private FileFolderService fileFolderService; | ||||||
|     private CategoryService categoryService; |     private CategoryService categoryService; | ||||||
|     private TransactionService transactionService; |     private TransactionService transactionService; | ||||||
|  |     private ContentService contentService; | ||||||
|     private StoreRef storeRef; |     private StoreRef storeRef; | ||||||
|     private AuthenticationComponent authenticationComponent; |     private AuthenticationComponent authenticationComponent; | ||||||
|     private PermissionServiceSPI permissionService; |     private PermissionServiceSPI permissionService; | ||||||
| @@ -112,6 +115,7 @@ public class ExporterComponentTest extends BaseSpringTest | |||||||
|         categoryService = (CategoryService) applicationContext.getBean("categoryService");      |         categoryService = (CategoryService) applicationContext.getBean("categoryService");      | ||||||
|         transactionService = (TransactionService) applicationContext.getBean("transactionService"); |         transactionService = (TransactionService) applicationContext.getBean("transactionService"); | ||||||
|         permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService"); |         permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService"); | ||||||
|  |         contentService = (ContentService) applicationContext.getBean("contentService"); | ||||||
|  |  | ||||||
|         this.authenticationService = (MutableAuthenticationService) applicationContext.getBean("AuthenticationService"); |         this.authenticationService = (MutableAuthenticationService) applicationContext.getBean("AuthenticationService"); | ||||||
|         this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); |         this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); | ||||||
| @@ -151,8 +155,6 @@ public class ExporterComponentTest extends BaseSpringTest | |||||||
|         OutputStream output = new FileOutputStream(tempFile); |         OutputStream output = new FileOutputStream(tempFile); | ||||||
|         ExporterCrawlerParameters parameters = new ExporterCrawlerParameters(); |         ExporterCrawlerParameters parameters = new ExporterCrawlerParameters(); | ||||||
|         parameters.setExportFrom(location); |         parameters.setExportFrom(location); | ||||||
| //        parameters.setExcludeAspects(new QName[] { ContentModel.ASPECT_AUDITABLE }); |  | ||||||
| //        parameters.setExcludeChildAssocs(new QName[] { ContentModel.ASSOC_CONTAINS }); |  | ||||||
|  |  | ||||||
|         File acpFile = TempFileProvider.createTempFile("alf", ACPExportPackageHandler.ACP_EXTENSION); |         File acpFile = TempFileProvider.createTempFile("alf", ACPExportPackageHandler.ACP_EXTENSION); | ||||||
|         File dataFile = new File("test"); |         File dataFile = new File("test"); | ||||||
| @@ -162,6 +164,81 @@ public class ExporterComponentTest extends BaseSpringTest | |||||||
|         acpHandler.setExportAsFolders(true); |         acpHandler.setExportAsFolders(true); | ||||||
|         exporterService.exportView(acpHandler, parameters, testProgress); |         exporterService.exportView(acpHandler, parameters, testProgress); | ||||||
|         output.close(); |         output.close(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void testExportWithChunkedList() | ||||||
|  |             throws Exception | ||||||
|  |     { | ||||||
|  |         TestProgress testProgress = new TestProgress(); | ||||||
|  |         Location location = new Location(storeRef); | ||||||
|  |  | ||||||
|  |         String testFile = "_testFile"; | ||||||
|  |         int numberOfNodesToExport = 20; | ||||||
|  |         // now export | ||||||
|  |         location.setPath("/system"); | ||||||
|  |         File tempFile = TempFileProvider.createTempFile("xmlexporttest", ".xml"); | ||||||
|  |         OutputStream output = new FileOutputStream(tempFile); | ||||||
|  |         ExporterCrawlerParameters parameters = new ExporterCrawlerParameters(); | ||||||
|  |         parameters.setExportFrom(location); | ||||||
|  |  | ||||||
|  |         File acpFile = TempFileProvider.createTempFile("alf", ACPExportPackageHandler.ACP_EXTENSION); | ||||||
|  |         File dataFile = new File("test"); | ||||||
|  |         File contentDir = new File("test"); | ||||||
|  |         ACPExportPackageHandler acpHandler = new ACPExportPackageHandler(new FileOutputStream(acpFile), dataFile, contentDir, null); | ||||||
|  |         acpHandler.setNodeService(nodeService); | ||||||
|  |         acpHandler.setExportAsFolders(true); | ||||||
|  |         NodeRef nodeRef = (location == null) ? null : location.getNodeRef(); | ||||||
|  |         if (nodeRef == null) | ||||||
|  |         { | ||||||
|  |             // If a specific node has not been provided, default to the root | ||||||
|  |             nodeRef = nodeService.getRootNode(location.getStoreRef()); | ||||||
|  |         } | ||||||
|  |         NodeRef[] childRefs = new NodeRef[numberOfNodesToExport]; | ||||||
|  |  | ||||||
|  |         for (int i = 0; i < numberOfNodesToExport; i++) | ||||||
|  |         { | ||||||
|  |             Map<QName, Serializable> props = new HashMap<QName, Serializable>(); | ||||||
|  |             props.put(ContentModel.PROP_NAME, this.getClass() + testFile + i); | ||||||
|  |             childRefs[i] = nodeService.createNode(nodeRef, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_CONTENT, props).getChildRef(); | ||||||
|  |         } | ||||||
|  |         parameters.getExportFrom().setNodeRefs(childRefs); | ||||||
|  |         parameters.setCrawlSelf(true); | ||||||
|  |         exporterService.setExportChunkSize("3"); | ||||||
|  |         exporterService.exportView(acpHandler, parameters, testProgress); | ||||||
|  |         output.close(); | ||||||
|  |         ZipFile zipFile = new ZipFile(acpFile.getAbsolutePath()); | ||||||
|  |  | ||||||
|  |         Enumeration<? extends ZipEntry> entries = zipFile.entries(); | ||||||
|  |         int numberOfExportedNodes = 0; | ||||||
|  |         while(entries.hasMoreElements()){ | ||||||
|  |             ZipEntry entry = entries.nextElement(); | ||||||
|  |             InputStream stream = zipFile.getInputStream(entry); | ||||||
|  |             try (BufferedReader br = new BufferedReader(new InputStreamReader( | ||||||
|  |                     stream, StandardCharsets.UTF_8));) { | ||||||
|  |  | ||||||
|  |                 String line; | ||||||
|  |  | ||||||
|  |                 while ((line = br.readLine()) != null) { | ||||||
|  |  | ||||||
|  |                     if(line.contains(testFile)){ | ||||||
|  |                         numberOfExportedNodes++; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             stream.close(); | ||||||
|  |         } | ||||||
|  |         zipFile.close(); | ||||||
|  |  | ||||||
|  |         assertEquals(numberOfNodesToExport, numberOfExportedNodes); | ||||||
|  |  | ||||||
|  |         parameters.getExportFrom().setNodeRefs(null); | ||||||
|  |         for (int i = 0; i < numberOfNodesToExport; i++) | ||||||
|  |         { | ||||||
|  |             nodeService.deleteNode(childRefs[i]); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user