Fixes ALF-11964: It's impossible to copy folder that contains a content node and a copy of that content node

- the DoNothingCopyBehaviourCallback now does nothing with peer associations too.
 - added a couple of test cases to cover the problem scenarios

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32791 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2011-12-15 16:02:20 +00:00
parent 9983505cbf
commit 80a8a9cf24
2 changed files with 90 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -108,6 +109,7 @@ public class CopyServiceImplTest extends TestCase
private PersonService personService; private PersonService personService;
private AuthenticationComponent authenticationComponent; private AuthenticationComponent authenticationComponent;
private MutableAuthenticationService authenticationService; private MutableAuthenticationService authenticationService;
private CheckOutCheckInService cociService;
/* /*
* Data used by the tests * Data used by the tests
@@ -183,6 +185,7 @@ public class CopyServiceImplTest extends TestCase
personService = serviceRegistry.getPersonService(); personService = serviceRegistry.getPersonService();
authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent"); authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
cociService = (CheckOutCheckInService) ctx.getBean("checkOutCheckInService");
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO"); dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
@@ -777,6 +780,82 @@ public class CopyServiceImplTest extends TestCase
// NodeStoreInspector.dumpNodeStore(nodeService, storeRef)); // NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
} }
/**
* Tests copying a folder that contains both a node and a copy of that node.
*/
public void testALF11964_part1()
{
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
PropertyMap props = new PropertyMap();
// Need to create a potentially recursive node structure
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
NodeRef nodeOne = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTAINER,
props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
NodeRef nodeTwo = nodeService.createNode(
nodeOne,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTENT,
props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
NodeRef nodeThree = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTAINER,
props).getChildRef();
copyService.copy(nodeTwo, nodeOne, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
integrityChecker.checkIntegrity();
}
/**
* Tests copying a folder that contains both a checked-out node and its working copy.
*/
public void testALF11964_part2()
{
IntegrityChecker integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
PropertyMap props = new PropertyMap();
// Need to create a potentially recursive node structure
props.put(ContentModel.PROP_NODE_UUID, "nodeOne");
NodeRef nodeOne = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTAINER,
props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeTwo");
NodeRef nodeTwo = nodeService.createNode(
nodeOne,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTENT,
props).getChildRef();
props.put(ContentModel.PROP_NODE_UUID, "nodeThree");
NodeRef nodeThree = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_CONTAINER,
props).getChildRef();
cociService.checkout(nodeTwo);
copyService.copy(nodeOne, nodeThree, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, true);
integrityChecker.checkIntegrity();
}
public void testCopyResidualProperties() throws Exception public void testCopyResidualProperties() throws Exception
{ {
QName nodeOneAssocName = QName.createQName("{test}nodeOne"); QName nodeOneAssocName = QName.createQName("{test}nodeOne");

View File

@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/** /**
* Simple <i>copy behaviour</i> to prevent any copying. * Simple <i>copy behaviour</i> to prevent any copying.
@@ -73,4 +74,14 @@ public class DoNothingCopyBehaviourCallback extends AbstractCopyBehaviourCallbac
{ {
return Collections.emptyMap(); return Collections.emptyMap();
} }
@Override
public Pair<AssocCopySourceAction, AssocCopyTargetAction> getAssociationCopyAction(QName classQName,
CopyDetails copyDetails, CopyAssociationDetails assocCopyDetails)
{
return new Pair<AssocCopySourceAction, AssocCopyTargetAction>(AssocCopySourceAction.IGNORE,
AssocCopyTargetAction.USE_COPIED_OTHERWISE_ORIGINAL_TARGET);
}
} }