Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

78500: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      76815: Merged V4.2.3 (4.2.3) to V4.2-BUG-FIX (4.2.4)
         76612: Merged DEV to V4.2.3 (4.2.3)
            73832: MNT-11695 : Site cannot be deleted if copy/move outbound rule exists
            Added a test to simulate the issue.
            73871: MNT-11695 : Site cannot be deleted if copy/move outbound rule exists
            Added a check for the destination not to be in a pending delete list for copy action executer.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82572 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Erik Winlof
2014-09-03 12:20:30 +00:00
parent ddef482f7e
commit e35970c3f1
2 changed files with 73 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2014 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -22,7 +22,9 @@
package org.alfresco.repo.action.executer; package org.alfresco.repo.action.executer;
import java.util.List; import java.util.List;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; import org.alfresco.query.PagingResults;
import org.alfresco.repo.action.ParameterDefinitionImpl; import org.alfresco.repo.action.ParameterDefinitionImpl;
@@ -36,6 +38,7 @@ import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.rule.RuleServiceException; import org.alfresco.service.cmr.rule.RuleServiceException;
import org.alfresco.service.namespace.QName;
/** /**
* Copy action executor. * Copy action executor.
@@ -98,13 +101,21 @@ public class CopyActionExecuter extends ActionExecuterAbstractBase
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{ {
if (!nodeService.exists(actionedUponNodeRef)) if (!nodeService.exists(actionedUponNodeRef))
{ {
return; return;
} }
NodeRef destinationParent = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER); NodeRef destinationParent = (NodeRef) ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
// Get the deep copy value // Check the destination not to be in a pending delete list
boolean deepCopy = false; // MNT-11695
Set<QName> destinationAspects = nodeService.getAspects(destinationParent);
if (destinationAspects.contains(ContentModel.ASPECT_PENDING_DELETE))
{
return;
}
// Get the deep copy value
boolean deepCopy = false;
Boolean deepCopyValue = (Boolean)ruleAction.getParameterValue(PARAM_DEEP_COPY); Boolean deepCopyValue = (Boolean)ruleAction.getParameterValue(PARAM_DEEP_COPY);
if (deepCopyValue != null) if (deepCopyValue != null)
{ {
@@ -165,5 +176,5 @@ public class CopyActionExecuter extends ActionExecuterAbstractBase
originalAssoc.getQName(), originalAssoc.getQName(),
deepCopy); deepCopy);
} }
} }
} }

View File

@@ -1236,4 +1236,58 @@ public class RuleServiceImplTest extends BaseRuleTest
((RuntimeRuleService) ruleService).executePendingRules(); ((RuntimeRuleService) ruleService).executePendingRules();
assertTrue("Pending rule was not executed", this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE)); assertTrue("Pending rule was not executed", this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE));
} }
/**
* Test for MNT-11695
*/
public void testOutBoundRuleTriggerForPendingDelete() throws Exception
{
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
// Create 1 folder with 2 folders inside
NodeRef parentFolderNodeRef = this.nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("parentnode" + GUID.generate()),
ContentModel.TYPE_FOLDER).getChildRef();
NodeRef folder1NodeRef = this.nodeService.createNode(parentFolderNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("parentnode" + GUID.generate()),
ContentModel.TYPE_FOLDER).getChildRef();
NodeRef folder2NodeRef = this.nodeService.createNode(parentFolderNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("parentnode" + GUID.generate()),
ContentModel.TYPE_FOLDER).getChildRef();
// Create rule for folder1
Rule testRule = new Rule();
testRule.setRuleTypes(Collections.singletonList(RuleType.OUTBOUND));
testRule.setTitle("RuleServiceTest" + GUID.generate());
testRule.setDescription(DESCRIPTION);
testRule.applyToChildren(true);
Action action = this.actionService.createAction(CopyActionExecuter.NAME);
action.setParameterValue(CopyActionExecuter.PARAM_DESTINATION_FOLDER, folder2NodeRef);
testRule.setAction(action);
this.ruleService.saveRule(folder1NodeRef, testRule);
assertNotNull("Rule was not saved", testRule.getNodeRef());
QName actionedQName = QName.createQName("actioneduponnode" + GUID.generate());
// New node
NodeRef actionedUponNodeRef = this.nodeService.createNode(folder1NodeRef, ContentModel.ASSOC_CHILDREN, actionedQName, ContentModel.TYPE_CONTENT).getChildRef();
ContentWriter writer = this.contentService.getWriter(actionedUponNodeRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype("text/plain");
writer.putContent("TestContent");
txn.commit();
// Remove the parent folder
txn = transactionService.getUserTransaction();
txn.begin();
try
{
nodeService.deleteNode(parentFolderNodeRef);
}
catch (Exception e)
{
fail("The nodes should be deleted without errors, but exception was thrown: " + e);
}
txn.commit();
txn = transactionService.getUserTransaction();
txn.begin();
assertFalse("The folder should be deleted.", nodeService.exists(parentFolderNodeRef));
txn.commit();
}
} }