mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -53,6 +53,7 @@ import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
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.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -108,6 +109,7 @@ public class CopyServiceImplTest extends TestCase
|
||||
private PersonService personService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private CheckOutCheckInService cociService;
|
||||
|
||||
/*
|
||||
* Data used by the tests
|
||||
@@ -183,6 +185,7 @@ public class CopyServiceImplTest extends TestCase
|
||||
personService = serviceRegistry.getPersonService();
|
||||
authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
|
||||
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
|
||||
cociService = (CheckOutCheckInService) ctx.getBean("checkOutCheckInService");
|
||||
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
|
||||
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
@@ -777,6 +780,82 @@ public class CopyServiceImplTest extends TestCase
|
||||
// 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
|
||||
{
|
||||
QName nodeOneAssocName = QName.createQName("{test}nodeOne");
|
||||
|
@@ -23,6 +23,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Simple <i>copy behaviour</i> to prevent any copying.
|
||||
@@ -73,4 +74,14 @@ public class DoNothingCopyBehaviourCallback extends AbstractCopyBehaviourCallbac
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user