mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge changes from feature/RM-6873_RemoveActiveContentFromHold
This commit is contained in:
@@ -205,6 +205,8 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
List<NodeRef> frozenNodes = getHeld(hold);
|
||||
for (NodeRef frozenNode : frozenNodes)
|
||||
{
|
||||
//set in transaction cache in order not to trigger update policy when removing the child association
|
||||
transactionalResourceHelper.getSet("frozen").add(frozenNode);
|
||||
removeFreezeAspect(frozenNode, 1);
|
||||
}
|
||||
|
||||
@@ -231,6 +233,8 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
if (nodeService.hasAspect(nodeRef, ASPECT_FROZEN))
|
||||
{
|
||||
// remove the freeze aspect from the node
|
||||
//set in transaction cache in order not to trigger update policy when removing the aspect
|
||||
transactionalResourceHelper.getSet("frozen").add(nodeRef);
|
||||
nodeService.removeAspect(nodeRef, ASPECT_FROZEN);
|
||||
}
|
||||
|
||||
@@ -245,6 +249,8 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
if (recordsOtherHolds.size() == index)
|
||||
{
|
||||
// remove the freeze aspect from the node
|
||||
//set in transaction cache in order not to trigger update policy when removing the aspect
|
||||
transactionalResourceHelper.getSet("frozen").add(record);
|
||||
nodeService.removeAspect(record, ASPECT_FROZEN);
|
||||
}
|
||||
}
|
||||
@@ -646,7 +652,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
if (!nodeService.hasAspect(nodeRef, ASPECT_FROZEN))
|
||||
{
|
||||
//set in transaction cache in order not to trigger update policy when adding the aspect
|
||||
transactionalResourceHelper.getSet(nodeRef).add("frozen");
|
||||
transactionalResourceHelper.getSet("frozen").add(nodeRef);
|
||||
// add freeze aspect
|
||||
nodeService.addAspect(nodeRef, ASPECT_FROZEN, props);
|
||||
|
||||
@@ -732,33 +738,26 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
// run as system so we don't run into further permission issues
|
||||
// we already know we have to have the correct capability to get here
|
||||
authenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
// remove from hold
|
||||
nodeService.removeChild(hold, nodeRef);
|
||||
authenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
// remove from hold
|
||||
//set in transaction cache in order not to trigger update policy when removing the child association
|
||||
transactionalResourceHelper.getSet("frozen").add(nodeRef);
|
||||
nodeService.removeChild(hold, nodeRef);
|
||||
|
||||
// audit that the node has been remove from the hold
|
||||
// TODO add details of the hold that the node was removed from
|
||||
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_REMOVE_FROM_HOLD);
|
||||
// audit that the node has been remove from the hold
|
||||
// TODO add details of the hold that the node was removed from
|
||||
recordsManagementAuditService.auditEvent(nodeRef, AUDIT_REMOVE_FROM_HOLD);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return null;
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// run as system as we can't be sure if have remove aspect rights on node
|
||||
authenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
removeFreezeAspect(nodeRef, 0);
|
||||
return null;
|
||||
}
|
||||
authenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
removeFreezeAspect(nodeRef, 0);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -38,8 +38,6 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.repo.content.ContentServicePolicies;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
@@ -47,10 +45,11 @@ import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* rma:frozen behaviour bean
|
||||
@@ -67,9 +66,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
||||
NodeServicePolicies.OnAddAspectPolicy,
|
||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||
NodeServicePolicies.OnMoveNodePolicy,
|
||||
ContentServicePolicies.OnContentUpdatePolicy,
|
||||
CopyServicePolicies.BeforeCopyPolicy
|
||||
NodeServicePolicies.BeforeMoveNodePolicy
|
||||
{
|
||||
/** freeze service */
|
||||
protected FreezeService freezeService;
|
||||
@@ -99,7 +96,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
||||
if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef))
|
||||
{
|
||||
// never allow to delete a frozen node
|
||||
throw new AccessDeniedException("Frozen nodes can not be deleted.");
|
||||
throw new PermissionDeniedException(I18NUtil.getMessage("rm.hold.delete-frozen-node"));
|
||||
}
|
||||
|
||||
// check children
|
||||
@@ -125,7 +122,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
||||
if (freezeService.isFrozen(nodeRef))
|
||||
{
|
||||
// never allow to delete a node with a frozen child
|
||||
throw new AccessDeniedException("Can not delete node, because it contains a frozen child node.");
|
||||
throw new PermissionDeniedException(I18NUtil.getMessage("rm.hold.delete-node-frozen-children"));
|
||||
}
|
||||
|
||||
// check children
|
||||
@@ -209,16 +206,16 @@ public class FrozenAspect extends BaseBehaviourBean
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef)
|
||||
public void beforeMoveNode(ChildAssociationRef oldChildAssocRef, NodeRef newParentRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
if (nodeService.exists(newChildAssocRef.getParentRef()) &&
|
||||
nodeService.exists(newChildAssocRef.getChildRef()))
|
||||
if (nodeService.exists(oldChildAssocRef.getChildRef()) &&
|
||||
freezeService.isFrozen(oldChildAssocRef.getChildRef()))
|
||||
{
|
||||
throw new AccessDeniedException("Frozen nodes can not be moved.");
|
||||
throw new PermissionDeniedException(I18NUtil.getMessage("rm.hold.move-frozen-node"));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
@@ -233,59 +230,18 @@ public class FrozenAspect extends BaseBehaviourBean
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
|
||||
{
|
||||
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
// check to not throw exception when the aspect is being added
|
||||
if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef) &&
|
||||
!transactionalResourceHelper.getSet(nodeRef).contains("frozen") )
|
||||
!transactionalResourceHelper.getSet("frozen").contains(nodeRef) )
|
||||
{
|
||||
throw new AccessDeniedException("Frozen nodes can not be updated.");
|
||||
throw new PermissionDeniedException(I18NUtil.getMessage("rm.hold.update-frozen-node"));
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Behaviour associated with updating the content
|
||||
* <p>
|
||||
* Ensures that the content of a frozen node can not be updated
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef))
|
||||
{
|
||||
// never allow to update the content of a frozen node
|
||||
throw new AccessDeniedException("Frozen nodes content can not be updated.");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS
|
||||
)
|
||||
public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem((RunAsWork<Void>) () -> {
|
||||
if (nodeService.exists(sourceNodeRef) && freezeService.isFrozen(sourceNodeRef))
|
||||
{
|
||||
throw new AccessDeniedException("Frozen nodes can not be copied.");
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user