mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-3687: Execute rules API: Remove field "isEachInheritedRuleExecuted" (#1476)
* ACS-3620: E2Es - API for manual triggering rules on a folder
This commit is contained in:
@@ -43,7 +43,6 @@ import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestRuleExecutionBodyModel;
|
||||
import org.alfresco.rest.model.RestRuleExecutionModel;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -112,7 +111,6 @@ public class ExecuteRulesTests extends RestTest
|
||||
STEP("Execute rule");
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachInheritedRuleExecuted").is(false);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
STEP("Check if only Audio aspect was added");
|
||||
@@ -133,11 +131,9 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT, LOCKABLE_ASPECT);
|
||||
|
||||
STEP("Execute rules including inherited rules");
|
||||
RestRuleExecutionBodyModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
ruleExecutionRequest.setIsEachInheritedRuleExecuted(true);
|
||||
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(ruleExecutionRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachInheritedRuleExecuted").is(true);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
STEP("Check if Audio and Lockable aspects were added");
|
||||
@@ -163,11 +159,10 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT, LOCKABLE_ASPECT);
|
||||
|
||||
STEP("Execute rules on parent folder including sub-folders");
|
||||
RestRuleExecutionBodyModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
ruleExecutionRequest.setIsEachSubFolderIncluded(true);
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).executeRules(ruleExecutionRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachInheritedRuleExecuted").is(false);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(true);
|
||||
|
||||
STEP("Check if Lockable aspects was added to parent folder's file");
|
||||
@@ -182,7 +177,6 @@ public class ExecuteRulesTests extends RestTest
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
assertThat(fileNode)
|
||||
.containsAspects(AUDIO_ASPECT, LOCKABLE_ASPECT);
|
||||
// LOCKABLE_ASPECT shouldn't be present here, see ACS-3683
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +199,6 @@ public class ExecuteRulesTests extends RestTest
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
executionResult.assertThat().field("isEachInheritedRuleExecuted").is(false);
|
||||
|
||||
STEP("Check if Audio aspect is still missing");
|
||||
fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode();
|
||||
@@ -231,10 +224,8 @@ public class ExecuteRulesTests extends RestTest
|
||||
|
||||
STEP("Execute child folder rules including inherited rules");
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
executionResult.setIsEachInheritedRuleExecuted(true);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
executionResult.assertThat().field("isEachInheritedRuleExecuted").is(true);
|
||||
|
||||
STEP("Check if Audio aspect is present and Lockable is still missing");
|
||||
fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode();
|
||||
@@ -248,7 +239,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
* Try to execute private folder's rules by user not added to site and receive 403.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.ACTIONS })
|
||||
public void executeRules_privateFolder()
|
||||
public void executeRules_privateFolderResultsWith403()
|
||||
{
|
||||
STEP("Using admin create private site, folder and rule");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
@@ -265,7 +256,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
* Try to execute private folder's rules as site contributor and receive 403.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.ACTIONS })
|
||||
public void executeRules_privateFolderAsContributor()
|
||||
public void executeRules_privateFolderAsContributorResultsWith403()
|
||||
{
|
||||
STEP("Using admin create private site, folder, file in it, rule and add user to site as contributor");
|
||||
UserModel contributor = dataUser.createRandomTestUser();
|
||||
@@ -314,7 +305,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
* Try to execute rule with broken action and receive 500.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.ACTIONS })
|
||||
public void executeRules_brokenAction()
|
||||
public void executeRules_brokenActionResultsWith500()
|
||||
{
|
||||
STEP("Update folder rule with broken action");
|
||||
RestActionBodyExecTemplateModel brokenAction = createCustomActionModel("set-property-value", Map.of("aspect-name", AUDIO_ASPECT));
|
||||
|
@@ -37,7 +37,7 @@ import java.util.Map;
|
||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.model.RestRuleExecutionBodyModel;
|
||||
import org.alfresco.rest.model.RestRuleExecutionModel;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
import org.alfresco.rest.model.RestSimpleConditionDefinitionModel;
|
||||
|
||||
@@ -209,16 +209,15 @@ public class RulesTestsUtils
|
||||
return createCompositeCondition(AND, inverted, null, simpleConditions);
|
||||
}
|
||||
|
||||
public static RestRuleExecutionBodyModel createRuleExecutionRequest()
|
||||
public static RestRuleExecutionModel createRuleExecutionRequest()
|
||||
{
|
||||
return createRuleExecutionRequest(false, false);
|
||||
return createRuleExecutionRequest(false);
|
||||
}
|
||||
|
||||
public static RestRuleExecutionBodyModel createRuleExecutionRequest(boolean eachSubFolderIncluded, boolean eachInheritedRuleExecuted)
|
||||
public static RestRuleExecutionModel createRuleExecutionRequest(boolean eachSubFolderIncluded)
|
||||
{
|
||||
RestRuleExecutionBodyModel ruleExecutionBody = new RestRuleExecutionBodyModel();
|
||||
RestRuleExecutionModel ruleExecutionBody = new RestRuleExecutionModel();
|
||||
ruleExecutionBody.setIsEachSubFolderIncluded(eachSubFolderIncluded);
|
||||
ruleExecutionBody.setIsEachInheritedRuleExecuted(eachInheritedRuleExecuted);
|
||||
|
||||
return ruleExecutionBody;
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@@ -123,7 +123,7 @@
|
||||
<dependency.mariadb.version>2.7.4</dependency.mariadb.version>
|
||||
<dependency.tas-utility.version>3.0.56</dependency.tas-utility.version>
|
||||
<dependency.rest-assured.version>5.2.0</dependency.rest-assured.version>
|
||||
<dependency.tas-restapi.version>1.128</dependency.tas-restapi.version>
|
||||
<dependency.tas-restapi.version>1.132</dependency.tas-restapi.version>
|
||||
<dependency.tas-email.version>1.9</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
|
||||
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>
|
||||
|
@@ -104,7 +104,6 @@ public interface Rules
|
||||
*
|
||||
* @param folderNodeId - the ID of a folder
|
||||
* @param eachSubFolderIncluded - indicates if rules should be executed also on sub-folders
|
||||
* @param eachInheritedRuleExecuted - indicates if the inherited rules should be also executed
|
||||
*/
|
||||
RuleExecution executeRules(final String folderNodeId, final boolean eachSubFolderIncluded, final boolean eachInheritedRuleExecuted);
|
||||
RuleExecution executeRules(final String folderNodeId, final boolean eachSubFolderIncluded);
|
||||
}
|
||||
|
@@ -133,12 +133,12 @@ public class RulesImpl implements Rules
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleExecution executeRules(final String folderNodeId, final boolean eachSubFolderIncluded, final boolean eachInheritedRuleExecuted)
|
||||
public RuleExecution executeRules(final String folderNodeId, final boolean eachSubFolderIncluded)
|
||||
{
|
||||
final NodeRef folderNodeRef = validator.validateFolderNode(folderNodeId, false);
|
||||
final Map<String, Serializable> parameterValues = new HashMap<>();
|
||||
parameterValues.put(ExecuteAllRulesActionExecuter.PARAM_RUN_ALL_RULES_ON_CHILDREN, eachSubFolderIncluded);
|
||||
parameterValues.put(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, eachInheritedRuleExecuted);
|
||||
parameterValues.put(ExecuteAllRulesActionExecuter.PARAM_EXECUTE_INHERITED_RULES, true);
|
||||
final ActionImpl action = new ActionImpl(null, GUID.generate(), ExecuteAllRulesActionExecuter.NAME);
|
||||
action.setNodeRef(folderNodeRef);
|
||||
action.setParameterValues(parameterValues);
|
||||
@@ -148,7 +148,6 @@ public class RulesImpl implements Rules
|
||||
|
||||
return RuleExecution.builder()
|
||||
.eachSubFolderIncluded(eachSubFolderIncluded)
|
||||
.eachInheritedRuleExecuted(eachInheritedRuleExecuted)
|
||||
.create();
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,6 @@ import org.alfresco.service.Experimental;
|
||||
public class RuleExecution
|
||||
{
|
||||
private boolean eachSubFolderIncluded;
|
||||
private boolean eachInheritedRuleExecuted;
|
||||
|
||||
public boolean getIsEachSubFolderIncluded()
|
||||
{
|
||||
@@ -45,20 +44,10 @@ public class RuleExecution
|
||||
this.eachSubFolderIncluded = eachSubFolderIncluded;
|
||||
}
|
||||
|
||||
public boolean getIsEachInheritedRuleExecuted()
|
||||
{
|
||||
return eachInheritedRuleExecuted;
|
||||
}
|
||||
|
||||
public void setIsEachInheritedRuleExecuted(boolean eachInheritedRuleExecuted)
|
||||
{
|
||||
this.eachInheritedRuleExecuted = eachInheritedRuleExecuted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "RuleExecution{" + "eachSubFolderIncluded=" + eachSubFolderIncluded + ", eachInheritedRuleExecuted=" + eachInheritedRuleExecuted + '}';
|
||||
return "RuleExecution{" + "eachSubFolderIncluded=" + eachSubFolderIncluded + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,13 +58,13 @@ public class RuleExecution
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
RuleExecution that = (RuleExecution) o;
|
||||
return eachSubFolderIncluded == that.eachSubFolderIncluded && eachInheritedRuleExecuted == that.eachInheritedRuleExecuted;
|
||||
return eachSubFolderIncluded == that.eachSubFolderIncluded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(eachSubFolderIncluded, eachInheritedRuleExecuted);
|
||||
return Objects.hash(eachSubFolderIncluded);
|
||||
}
|
||||
|
||||
public static Builder builder()
|
||||
@@ -86,7 +75,6 @@ public class RuleExecution
|
||||
public static class Builder
|
||||
{
|
||||
private boolean eachSubFolderIncluded;
|
||||
private boolean eachInheritedRuleExecuted;
|
||||
|
||||
public Builder eachSubFolderIncluded(boolean eachSubFolderIncluded)
|
||||
{
|
||||
@@ -94,17 +82,10 @@ public class RuleExecution
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder eachInheritedRuleExecuted(boolean eachInheritedRuleExecuted)
|
||||
{
|
||||
this.eachInheritedRuleExecuted = eachInheritedRuleExecuted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleExecution create()
|
||||
{
|
||||
final RuleExecution ruleExecution = new RuleExecution();
|
||||
ruleExecution.setIsEachSubFolderIncluded(eachSubFolderIncluded);
|
||||
ruleExecution.setIsEachInheritedRuleExecuted(eachInheritedRuleExecuted);
|
||||
return ruleExecution;
|
||||
}
|
||||
}
|
||||
|
@@ -65,6 +65,6 @@ public class NodeRuleExecutionsRelation implements RelationshipResourceAction.Cr
|
||||
public List<RuleExecution> create(String folderNodeId, List<RuleExecution> ruleExecutionParameters, Parameters parameters)
|
||||
{
|
||||
final RuleExecution ruleExecution = ruleExecutionParameters.stream().findFirst().orElse(new RuleExecution());
|
||||
return List.of(rules.executeRules(folderNodeId, ruleExecution.getIsEachSubFolderIncluded(), ruleExecution.getIsEachInheritedRuleExecuted()));
|
||||
return List.of(rules.executeRules(folderNodeId, ruleExecution.getIsEachSubFolderIncluded()));
|
||||
}
|
||||
}
|
||||
|
@@ -634,12 +634,9 @@ public class RulesImplTest extends TestCase
|
||||
public void testExecuteRule()
|
||||
{
|
||||
// when
|
||||
final RuleExecution actualRuleExecution = rules.executeRules(FOLDER_NODE_ID, INCLUDE_SUB_FOLDERS, EXECUTE_INHERITED_RULES);
|
||||
final RuleExecution actualRuleExecution = rules.executeRules(FOLDER_NODE_ID, INCLUDE_SUB_FOLDERS);
|
||||
|
||||
final RuleExecution expectedRuleExecution = RuleExecution.builder()
|
||||
.eachSubFolderIncluded(INCLUDE_SUB_FOLDERS)
|
||||
.eachInheritedRuleExecuted(EXECUTE_INHERITED_RULES)
|
||||
.create();
|
||||
final RuleExecution expectedRuleExecution = RuleExecution.builder().eachSubFolderIncluded(INCLUDE_SUB_FOLDERS).create();
|
||||
final ActionImpl expectedAction = new ActionImpl(null, null, ExecuteAllRulesActionExecuter.NAME);
|
||||
expectedAction.setNodeRef(FOLDER_NODE_REF);
|
||||
expectedAction.setParameterValues(Map.of(
|
||||
|
Reference in New Issue
Block a user