) () -> {
+
if (nodeService.exists(nodeRef) &&
(isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
{
@@ -214,4 +200,91 @@ public class FrozenAspect extends BaseBehaviourBean
});
}
+ /**
+ * Behaviour associated with moving a frozen node
+ *
+ * Prevent frozen items being moved
+ */
+ @Override
+ @Behaviour
+ (
+ kind = BehaviourKind.ASSOCIATION,
+ notificationFrequency = NotificationFrequency.FIRST_EVENT
+ )
+ public void onMoveNode(final ChildAssociationRef oldChildAssocRef, final ChildAssociationRef newChildAssocRef)
+ {
+ AuthenticationUtil.runAsSystem((RunAsWork) () -> {
+ if (nodeService.exists(newChildAssocRef.getParentRef()) &&
+ nodeService.exists(newChildAssocRef.getChildRef()))
+ {
+ throw new AccessDeniedException("Frozen nodes can not be moved.");
+ }
+ return null;
+ });
+ }
+
+ /**
+ * Behaviour associated with updating properties
+ *
+ * Prevents frozen items being updated
+ */
+ @Override
+ @Behaviour
+ (
+ kind = BehaviourKind.CLASS,
+ notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
+ )
+ public void onUpdateProperties(NodeRef nodeRef, Map before, Map after)
+
+ {
+ AuthenticationUtil.runAsSystem((RunAsWork) () -> {
+ // check to not throw exception when the aspect is being added
+ if (nodeService.exists(nodeRef) && freezeService.isFrozen(nodeRef) &&
+ !transactionalResourceHelper.getSet(nodeRef).contains("frozen") )
+ {
+ throw new AccessDeniedException("Frozen nodes can not be updated.");
+ }
+ return null;
+ });
+ }
+
+ /**
+ * Behaviour associated with updating the content
+ *
+ * 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) () -> {
+ 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) () -> {
+ if (nodeService.exists(sourceNodeRef) && freezeService.isFrozen(sourceNodeRef))
+ {
+ throw new AccessDeniedException("Frozen nodes can not be copied.");
+ }
+
+ return null;
+ });
+ }
}