mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4293: created capabilities for deleting transfer container and hold
container and restricted the deletion from behaviour beans
This commit is contained in:
@@ -83,6 +83,10 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
|
||||
private UnfiledRecordContainerType unfilerRecordContainerType;
|
||||
|
||||
private TransferContainerType transferContainerType;
|
||||
|
||||
private HoldContainerType holdContainerType;
|
||||
|
||||
/**
|
||||
* @return File plan service
|
||||
*/
|
||||
@@ -152,6 +156,15 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
this.unfilerRecordContainerType = unfilerRecordContainerType;
|
||||
}
|
||||
|
||||
public void setTransferContainerType(TransferContainerType transferContainerType)
|
||||
{
|
||||
this.transferContainerType = transferContainerType;
|
||||
}
|
||||
|
||||
public void setHoldContainerType(HoldContainerType holdContainerType)
|
||||
{
|
||||
this.holdContainerType = holdContainerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
@@ -234,6 +247,8 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived)
|
||||
{
|
||||
unfilerRecordContainerType.enable();
|
||||
transferContainerType.enable();
|
||||
holdContainerType.enable();
|
||||
throw new IntegrityException("Operation failed. Deletion of File Plan is not allowed.", null);
|
||||
}
|
||||
|
||||
@@ -249,6 +264,8 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
unfilerRecordContainerType.disable();
|
||||
transferContainerType.disable();
|
||||
holdContainerType.disable();
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
@@ -262,5 +279,7 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
// tear down the file plan roles
|
||||
getFilePlanRoleService().tearDownFilePlanRoles(childAssocRef.getChildRef());
|
||||
unfilerRecordContainerType.enable();
|
||||
transferContainerType.enable();
|
||||
holdContainerType.enable();
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
@@ -49,10 +50,31 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
@BehaviourBean(defaultType = "rma:holdContainer")
|
||||
public class HoldContainerType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnDeleteNodePolicy
|
||||
{
|
||||
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD);
|
||||
private static final String DELETE_BEHAVIOUR_NAME = "onDeleteHoldContainer";
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
getBehaviour(DELETE_BEHAVIOUR_NAME).disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
getBehaviour(DELETE_BEHAVIOUR_NAME).enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* On every event
|
||||
@@ -74,6 +96,16 @@ public class HoldContainerType extends BaseBehaviourBean
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT) == true) { throw new AlfrescoRuntimeException(
|
||||
I18NUtil.getMessage(MSG_ERROR_ADD_CONTENT_CONTAINER)); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
name = DELETE_BEHAVIOUR_NAME
|
||||
)
|
||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||
{
|
||||
throw new IntegrityException("Operation failed. Deletion of Hold Container is not allowed.", null);
|
||||
}
|
||||
}
|
||||
|
@@ -46,11 +46,15 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*/
|
||||
@BehaviourBean(defaultType = "rma:transferContainer")
|
||||
public class TransferContainerType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnDeleteNodePolicy
|
||||
|
||||
{
|
||||
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
||||
private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER = "rm.action.create.transfer.container.child-error-message";
|
||||
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferContainer";
|
||||
private static final String DELETE_BEHAVIOUR_NAME = "onDeleteTransferContainer";
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
@@ -59,6 +63,7 @@ public class TransferContainerType extends BaseBehaviourBean
|
||||
public void disable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).disable();
|
||||
getBehaviour(DELETE_BEHAVIOUR_NAME).disable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +73,7 @@ public class TransferContainerType extends BaseBehaviourBean
|
||||
public void enable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).enable();
|
||||
getBehaviour(DELETE_BEHAVIOUR_NAME).enable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +100,15 @@ public class TransferContainerType extends BaseBehaviourBean
|
||||
if (instanceOf(nodeRef, ContentModel.TYPE_CONTENT) == true) { throw new AlfrescoRuntimeException(
|
||||
I18NUtil.getMessage(MSG_ERROR_ADD_CONTENT_CONTAINER)); }
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
name = DELETE_BEHAVIOUR_NAME
|
||||
)
|
||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||
{
|
||||
throw new IntegrityException("Operation failed. Deletion of Transfer Container is not allowed.", null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user