Fixed MOB-426: Refactor CopyService: Apply new pattern to existing policy handlers

Fallout:
1. Policy handling for 'onCopy' has been changed to 'getCopyCallback'
2. All existing policy usage was refactored to control behaviour more closely
3. The default child association behaviour has changed:
3.1 Types and aspects control their own child association behaviour
3.2 cm:folder recurses into primary children, but merely copies the secondary association
3.3 cm:rule recurses into primary children
3.4 unless behaviour is defined for a child association, there is no recursion or copying
4. Node association behavior has changed
4.1 There is no copying of node associations.  Each type and aspect must handle this by
    recording nodes and fixing up the required associations in the onCopyComplete.
4.2 If there is a requirement, this can be added to the callback later

See 'org.alfresco.repo.copy.AbstractCopyBehaviourCallback' and derived classes for examples.

Areas to test with particular attention:
1. Normal copy behaviour
2. Copy of documents with discussions
3. Check-in check-out
4. Check-in, check-out of documents where a discussion was added to working copy
5. Copies of documents with thumbnails
6. Copies of documents with rules
7. Copying of hierarchies that contain rules to copy to another location within the hierarchy
8. Copying into folders where named children already exist


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13915 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2009-04-09 14:48:02 +00:00
parent 0b57c06ad3
commit d6586351c1
29 changed files with 5920 additions and 4222 deletions

View File

@@ -27,7 +27,10 @@ package org.alfresco.repo.model.ml;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.CopyServicePolicies;
import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope;
@@ -65,9 +68,9 @@ public class EmptyTranslationAspect implements
public void init()
{
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyNode"),
ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION,
new JavaBehaviour(this, "onCopyNode"));
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION,
new JavaBehaviour(this, "getCopyCallback"));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onContentUpdate"),
@@ -94,8 +97,6 @@ public class EmptyTranslationAspect implements
/**
* Copy a <b>cm:mlEmptyTranslation<b> is not permit.
*
* @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyNodePolicy#onCopyNode(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.StoreRef, boolean, org.alfresco.repo.policy.PolicyScope)
*/
public void onCopyNode(QName classRef, NodeRef sourceNodeRef, StoreRef destinationStoreRef, boolean copyToNewNode, PolicyScope copyDetails)
{
@@ -104,8 +105,6 @@ public class EmptyTranslationAspect implements
/**
* If a content is added to a <b>cm:mlEmptyTranslation<b>, remove this aspect.
*
* @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
{
@@ -115,4 +114,35 @@ public class EmptyTranslationAspect implements
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_TEMPORARY);
}
}
/**
* Extends the NO-OP copy behaviour to generate an exception if copied. In other words,
* the presence of {@link ContentModel#ASPECT_MULTILINGUAL_EMPTY_TRANSLATION} should prevent
* a node from being copied; if this is not done by the copy client, it is enforced here.
*
* @author Derek Hulley
* @since 3.2
*/
private static class EmptyTranslationAspectCopyBehaviourCallback extends DoNothingCopyBehaviourCallback
{
private static final CopyBehaviourCallback INSTANCE = new EmptyTranslationAspectCopyBehaviourCallback();
/**
* @throws IllegalStateException always
*/
@Override
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
{
throw new IllegalStateException(
"Nodes with " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " may not be copied");
}
}
/**
* @return Returns {@link EmptyTranslationAspectCopyBehaviourCallback}
*/
public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails)
{
return EmptyTranslationAspectCopyBehaviourCallback.INSTANCE;
}
}