mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-6904 Tiding up
This commit is contained in:
@@ -44,6 +44,9 @@ import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.repo.content.ContentServicePolicies;
|
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.node.NodeServicePolicies;
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||||
@@ -73,9 +76,10 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
implements NodeServicePolicies.BeforeDeleteNodePolicy,
|
implements NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||||
NodeServicePolicies.OnAddAspectPolicy,
|
NodeServicePolicies.OnAddAspectPolicy,
|
||||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||||
NodeServicePolicies.OnCreateChildAssociationPolicy,
|
|
||||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||||
ContentServicePolicies.OnContentUpdatePolicy
|
NodeServicePolicies.OnMoveNodePolicy,
|
||||||
|
ContentServicePolicies.OnContentUpdatePolicy,
|
||||||
|
CopyServicePolicies.BeforeCopyPolicy
|
||||||
{
|
{
|
||||||
/** file plan service */
|
/** file plan service */
|
||||||
protected FilePlanService filePlanService;
|
protected FilePlanService filePlanService;
|
||||||
@@ -117,17 +121,14 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
@Override
|
@Override
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
if (nodeService.exists(nodeRef))
|
if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef))
|
||||||
{
|
{
|
||||||
if (freezeService.isFrozen(nodeRef))
|
// never allow to delete a frozen node
|
||||||
{
|
throw new AccessDeniedException("Frozen nodes can not be deleted.");
|
||||||
// never allowed to delete a frozen node
|
|
||||||
throw new AccessDeniedException("Frozen nodes can not be deleted.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check children
|
|
||||||
checkChildren(nodeService.getChildAssocs(nodeRef));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check children
|
||||||
|
checkChildren(nodeService.getChildAssocs(nodeRef));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -208,22 +209,22 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
if (nodeService.exists(record) &&
|
if (nodeService.exists(record) &&
|
||||||
isRecord(record))
|
isRecord(record))
|
||||||
{
|
{
|
||||||
// get the owning record folder
|
// get the owning record folder
|
||||||
NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef();
|
NodeRef recordFolder = nodeService.getPrimaryParent(record).getParentRef();
|
||||||
|
|
||||||
// check that the aspect has been added
|
// check that the aspect has been added
|
||||||
if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN))
|
if (nodeService.hasAspect(recordFolder, ASPECT_HELD_CHILDREN))
|
||||||
{
|
{
|
||||||
// decrement current count
|
// decrement current count
|
||||||
int currentCount = (Integer)nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT);
|
int currentCount = (Integer) nodeService.getProperty(recordFolder, PROP_HELD_CHILDREN_COUNT);
|
||||||
if (currentCount > 0)
|
if (currentCount > 0)
|
||||||
{
|
{
|
||||||
currentCount = currentCount - 1;
|
currentCount = currentCount - 1;
|
||||||
nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount);
|
nodeService.setProperty(recordFolder, PROP_HELD_CHILDREN_COUNT, currentCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -232,9 +233,9 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behaviour associated with moving/copying a frozen node
|
* Behaviour associated with moving a frozen node
|
||||||
* <p>
|
* <p>
|
||||||
* Prevent frozen items being moved or copied
|
* Prevent frozen items being moved
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Behaviour
|
@Behaviour
|
||||||
@@ -242,22 +243,21 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
kind = BehaviourKind.ASSOCIATION,
|
kind = BehaviourKind.ASSOCIATION,
|
||||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||||
)
|
)
|
||||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
NodeRef childNodeRef = childAssocRef.getChildRef();
|
if (nodeService.exists(newChildAssocRef.getParentRef()) &&
|
||||||
if (freezeService.isFrozen(childNodeRef))
|
nodeService.exists(newChildAssocRef.getChildRef()))
|
||||||
{
|
{
|
||||||
// never allow to move or copy a frozen node
|
throw new AccessDeniedException("Frozen nodes can not be moved.");
|
||||||
throw new AccessDeniedException("Frozen nodes can not be moved or copied.");
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,6 +272,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||||
)
|
)
|
||||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||||
|
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||||
{
|
{
|
||||||
@@ -314,16 +315,36 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
@Override
|
@Override
|
||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
if (nodeService.exists(nodeRef))
|
if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef))
|
||||||
{
|
|
||||||
if (freezeService.isFrozen(nodeRef))
|
|
||||||
{
|
{
|
||||||
// never allow to update the content of a frozen node
|
// never allow to update the content of a frozen node
|
||||||
throw new AccessDeniedException("Frozen nodes content can not be updated.");
|
throw new AccessDeniedException("Frozen nodes content can not be updated.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Behaviour
|
||||||
|
(
|
||||||
|
kind = BehaviourKind.CLASS
|
||||||
|
)
|
||||||
|
public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
||||||
|
{
|
||||||
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork()
|
||||||
|
{
|
||||||
|
//nodeService.getPrimaryParent(sourceNodeRef).getParentRef()
|
||||||
|
if (nodeService.exists(sourceNodeRef) && freezeService.isFrozen(sourceNodeRef))
|
||||||
|
{
|
||||||
|
throw new AccessDeniedException("Frozen nodes can not be copied.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user