136820 mmuller: MNT-15365 Forbid pending rule applying on working copies. Added test.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@136820 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2017-05-19 15:17:15 +00:00
parent 1e3a40232a
commit 24fbd605ff
2 changed files with 76 additions and 50 deletions

View File

@@ -151,6 +151,11 @@ public abstract class RuleTriggerAbstractBase implements RuleTrigger
{ {
return; return;
} }
// MNT-15365 No rule applying on working copies
if (nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY))
{
return;
}
// Do not trigger rules for rule and action type nodes // Do not trigger rules for rule and action type nodes
if (ignoreTrigger(actionedUponNodeRef) == false) if (ignoreTrigger(actionedUponNodeRef) == false)
{ {

View File

@@ -133,6 +133,27 @@ public class RuleTriggerTest extends BaseSpringTest
assertTrue(ruleType.rulesTriggered); assertTrue(ruleType.rulesTriggered);
} }
// MNT-15365
public void testOnUpdateNodeTriggerOnWorkingCopy()
{
NodeRef nodeRef = this.nodeService.createNode(
this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTAINER).getChildRef();
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY, null);
TestRuleType ruleType = createTestRuleType(ON_UPDATE_NODE_TRIGGER);
assertFalse(ruleType.rulesTriggered);
// Try and trigger the type
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, "nameChanged");
// Check to see if the rule type has been triggered. It shouldn't trigger because it is a working copy
assertFalse(ruleType.rulesTriggered);
}
// public void testOnDeleteNodeTrigger() // public void testOnDeleteNodeTrigger()
// { // {
// NodeRef nodeRef = this.nodeService.createNode( // NodeRef nodeRef = this.nodeService.createNode(