[RM-795] Can't copy/link to record. Reworked Copy policies. The record aspect is now not copied. A new Unique Record Identifier is generated on for the copy. Other record properties are generated when the record is copied into new record folder. Removed old copy behaviour. Behaviour filter is now added to the policy. The filter is used to disable the id check at the end of copy (on commit) so that a new id can be added to the copy.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@54675 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jared Ottley
2013-08-29 20:16:27 +00:00
parent d187621f9a
commit 811fe439eb
2 changed files with 51 additions and 30 deletions

View File

@@ -78,6 +78,7 @@
class="org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordCopyBehaviours" class="org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordCopyBehaviours"
init-method="init"> init-method="init">
<property name="policyComponent" ref="policyComponent"/> <property name="policyComponent" ref="policyComponent"/>
<property name="behaviourFilter" ref="policyBehaviourFilter"/>
<property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/> <property name="recordsManagementServiceRegistry" ref="RecordsManagementServiceRegistry"/>
</bean> </bean>

View File

@@ -18,7 +18,6 @@
*/ */
package org.alfresco.module.org_alfresco_module_rm.model.behaviour; package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -26,11 +25,12 @@ import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.copy.AbstractCopyBehaviourCallback;
import org.alfresco.repo.copy.CopyBehaviourCallback; import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails; import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback; import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
@@ -51,6 +51,9 @@ public class RecordCopyBehaviours implements RecordsManagementModel
/** The policy component */ /** The policy component */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
/** The Behaviour Filter */
private BehaviourFilter behaviourFilter;
/** The rm service registry */ /** The rm service registry */
private RecordsManagementServiceRegistry rmServiceRegistry; private RecordsManagementServiceRegistry rmServiceRegistry;
@@ -67,6 +70,16 @@ public class RecordCopyBehaviours implements RecordsManagementModel
this.policyComponent = policyComponent; this.policyComponent = policyComponent;
} }
/**
* Set the behaviour Filter
*
* @param behaviourFilter
*/
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
}
/** /**
* Set the rm service registry. * Set the rm service registry.
* *
@@ -98,7 +111,19 @@ public class RecordCopyBehaviours implements RecordsManagementModel
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"), QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
ASPECT_RECORD_COMPONENT_ID, ASPECT_RECORD_COMPONENT_ID,
new JavaBehaviour(this, "getIdCallback")); new JavaBehaviour(this, "getDoNothingCopyCallback"));
//On Copy we need a new ID
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCopyComplete"),
ASPECT_RECORD_COMPONENT_ID,
new JavaBehaviour(this, "generateId", NotificationFrequency.TRANSACTION_COMMIT));
//Don't copy the Aspect Record -- it should be regenerated
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
ASPECT_RECORD,
new JavaBehaviour(this, "getDoNothingCopyCallback"));
// Move behaviour // Move behaviour
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
@@ -108,7 +133,7 @@ public class RecordCopyBehaviours implements RecordsManagementModel
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"),
RecordsManagementModel.TYPE_RECORD_FOLDER, RecordsManagementModel.TYPE_RECORD_FOLDER,
new JavaBehaviour(this, "onMoveRecordFolderNode", NotificationFrequency.FIRST_EVENT)); new JavaBehaviour(this, "onMoveRecordFolderNode", NotificationFrequency.FIRST_EVENT));
} }
/** /**
@@ -219,33 +244,28 @@ public class RecordCopyBehaviours implements RecordsManagementModel
return new DoNothingCopyBehaviourCallback(); return new DoNothingCopyBehaviourCallback();
} }
public CopyBehaviourCallback getIdCallback(QName classRef, CopyDetails copyDetails) /**
* Generate and set a new ID for copy of a record
*
* @param classRef
* @param sourceNodeRef
* @param targetNodeRef
* @param copyToNewNode
* @param copyMap
*/
@SuppressWarnings("rawtypes")
public void generateId(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef, boolean copyToNewNode, Map copyMap)
{ {
return new AbstractCopyBehaviourCallback() final IdentifierService rmIdentifierService = rmServiceRegistry.getIdentifierService();
{ final NodeService nodeService = rmServiceRegistry.getNodeService();
public ChildAssocCopyAction getChildAssociationCopyAction(
QName classQName, //Generate the id for the copy
CopyDetails copyDetails, String id = rmIdentifierService.generateIdentifier(nodeService.getType(nodeService.getPrimaryParent(targetNodeRef).getParentRef()), (nodeService.getPrimaryParent(targetNodeRef).getParentRef()));
CopyChildAssociationDetails childAssocCopyDetails)
{ //We need to allow the id to be overwritten disable the policy protecting changes to the id
return null; behaviourFilter.disableBehaviour(targetNodeRef, ASPECT_RECORD_COMPONENT_ID);
} nodeService.setProperty(targetNodeRef, PROP_IDENTIFIER, id);
behaviourFilter.enableBehaviour(targetNodeRef, ASPECT_RECORD_COMPONENT_ID);
public Map<QName, Serializable> getCopyProperties(
QName classQName,
CopyDetails copyDetails,
Map<QName, Serializable> properties)
{
properties.put(PROP_IDENTIFIER, properties.get(PROP_IDENTIFIER) + "1");
return properties;
}
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
{
return true;
}
};
} }
/** /**