mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-4351 - alien invasion - copy behaviour.
implementation copy alien + unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21968 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -204,6 +204,14 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
TransferModel.ASPECT_TRANSFERRED,
|
||||
new JavaBehaviour(this, "onCreateChildAssociation", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
/**
|
||||
* For every copy of a transferred node run onCopyTransferred
|
||||
*/
|
||||
this.getPolicyComponent().bindClassBehaviour(
|
||||
CopyServicePolicies.OnCopyNodePolicy.QNAME,
|
||||
TransferModel.ASPECT_TRANSFERRED,
|
||||
new JavaBehaviour(this, "onCopyTransferred", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
/**
|
||||
* For every new child of a node with the trx:alien aspect run this.onCreateChildAssociation
|
||||
*/
|
||||
@@ -237,13 +245,12 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
new JavaBehaviour(this, "onMoveNode", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
/**
|
||||
* For every copy of a transferred node
|
||||
* For every copy of an alien node remove the alien aspect
|
||||
*/
|
||||
this.getPolicyComponent().bindClassBehaviour(
|
||||
CopyServicePolicies.OnCopyNodePolicy.QNAME,
|
||||
TransferModel.ASPECT_TRANSFERRED,
|
||||
new JavaBehaviour(this, "onCopyTransferred", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
TransferModel.ASPECT_ALIEN,
|
||||
new JavaBehaviour(this, "onCopyAlien", NotificationFrequency.EVERY_EVENT));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1066,6 +1073,15 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
return TransferredAspectCopyBehaviourCallback.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* When an alien node is copied, don't copy the alien aspect.
|
||||
*/
|
||||
public CopyBehaviourCallback onCopyAlien(QName classRef,
|
||||
CopyDetails copyDetails)
|
||||
{
|
||||
return AlienAspectCopyBehaviourCallback.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the default copy behaviour to prevent copying of transferred aspect and properties.
|
||||
*
|
||||
@@ -1104,6 +1120,46 @@ public class RepoTransferReceiverImpl implements TransferReceiver,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the default copy behaviour to prevent copying of alien aspect and properties.
|
||||
*
|
||||
* @author Mark Rogers
|
||||
* @since 3.4
|
||||
*/
|
||||
private static class AlienAspectCopyBehaviourCallback extends DefaultCopyBehaviourCallback
|
||||
{
|
||||
private static final CopyBehaviourCallback INSTANCE = new AlienAspectCopyBehaviourCallback();
|
||||
|
||||
/**
|
||||
* @return Returns an empty map
|
||||
*/
|
||||
@Override
|
||||
public Map<QName, Serializable> getCopyProperties(
|
||||
QName classQName, CopyDetails copyDetails, Map<QName, Serializable> properties)
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't copy the transferred aspect.
|
||||
*
|
||||
* @return Returns <tt>true</tt> always
|
||||
*/
|
||||
@Override
|
||||
public boolean getMustCopy(QName classQName, CopyDetails copyDetails)
|
||||
{
|
||||
if(classQName.equals(TransferModel.ASPECT_ALIEN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setDescriptorService(DescriptorService descriptorService)
|
||||
{
|
||||
|
Reference in New Issue
Block a user