cm:copiedfrom aspect is not applied to copies of type not derived from cm:object

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29292 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-07-25 08:45:41 +00:00
parent 18a50d8532
commit a4a5605403
2 changed files with 31 additions and 1 deletions

View File

@@ -596,7 +596,12 @@ public class CopyServiceImpl implements CopyService
originalAssoc.getTargetRef(), originalAssoc.getTargetRef(),
ContentModel.ASSOC_ORIGINAL); ContentModel.ASSOC_ORIGINAL);
} }
internalNodeService.createAssociation(copyTarget, sourceNodeRef, ContentModel.ASSOC_ORIGINAL); // We create the link if the source is a cm:object
QName sourceTypeQName = internalNodeService.getType(sourceNodeRef);
if (dictionaryService.isSubClass(sourceTypeQName, ContentModel.TYPE_CMOBJECT))
{
internalNodeService.createAssociation(copyTarget, sourceNodeRef, ContentModel.ASSOC_ORIGINAL);
}
// Copy permissions // Copy permissions
copyPermissions(sourceNodeRef, copyTarget); copyPermissions(sourceNodeRef, copyTarget);

View File

@@ -619,6 +619,31 @@ public class CopyServiceImplTest extends TestCase
assertNull("Original should not be present. ", originalCheck); assertNull("Original should not be present. ", originalCheck);
} }
/**
* Test the behaviour of the aspect when copying types not derived from <b>cm:object</b>
*/
public void testCopiedFromAspect_NonObject()
{
// Create the node used for copying
ChildAssociationRef childAssocRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}test"),
ContentModel.TYPE_BASE,
createTypePropertyBag());
NodeRef nodeRef = childAssocRef.getChildRef();
// If we copy this, there should not be a cm:source association
NodeRef copyNodeRef = copyService.copy(
nodeRef,
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}copyAssoc"));
assertFalse(
"cm:copiedfrom should not be present",
nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
}
public void testCopyNodeWithRules() public void testCopyNodeWithRules()
{ {
// Create a new rule and add it to the source noderef // Create a new rule and add it to the source noderef