mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge master into feature/RM-4357_and_RM_4373
This commit is contained in:
@@ -37,6 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
@@ -61,10 +62,12 @@ import org.alfresco.service.namespace.QName;
|
||||
public class FilePlanType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnCreateNodePolicy,
|
||||
NodeServicePolicies.OnDeleteNodePolicy
|
||||
NodeServicePolicies.OnDeleteNodePolicy,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy
|
||||
{
|
||||
private final static List<QName> ACCEPTED_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD_CONTAINER, TYPE_TRANSFER_CONTAINER, TYPE_UNFILED_RECORD_CONTAINER);
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_RECORD_CATEGORY);
|
||||
private static final String BEHAVIOUR_NAME = "onDeleteFilePlan";
|
||||
|
||||
/** file plan service */
|
||||
private FilePlanService filePlanService;
|
||||
@@ -78,6 +81,21 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
/** file plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/**
|
||||
* Unfiled Record Container Type behaviour bean
|
||||
*/
|
||||
private UnfiledRecordContainerType unfilerRecordContainerType;
|
||||
|
||||
/**
|
||||
* Transfer Container Type behaviour bean
|
||||
*/
|
||||
private TransferContainerType transferContainerType;
|
||||
|
||||
/**
|
||||
* Hold Container Type behaviour bean
|
||||
*/
|
||||
private HoldContainerType holdContainerType;
|
||||
|
||||
/**
|
||||
* @return File plan service
|
||||
*/
|
||||
@@ -142,6 +160,49 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unfilerRecordContainerType - unfiled record container type behaviour bean
|
||||
*/
|
||||
public void setUnfilerRecordContainerType(UnfiledRecordContainerType unfilerRecordContainerType)
|
||||
{
|
||||
this.unfilerRecordContainerType = unfilerRecordContainerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transferContainerType - transfer container type behaviour bean
|
||||
*/
|
||||
public void setTransferContainerType(TransferContainerType transferContainerType)
|
||||
{
|
||||
this.transferContainerType = transferContainerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param holdContainerType - hold container type behaviour bean
|
||||
*/
|
||||
public void setHoldContainerType(HoldContainerType holdContainerType)
|
||||
{
|
||||
this.holdContainerType = holdContainerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).enable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateChildAssociationPolicy#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@@ -194,15 +255,49 @@ public class FilePlanType extends BaseBehaviourBean
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy#onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef, boolean)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||
)
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
unfilerRecordContainerType.disable();
|
||||
transferContainerType.disable();
|
||||
holdContainerType.disable();
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
policy = "alf:onDeleteNode",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
@Override
|
||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean archived)
|
||||
public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean archived)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@@ -97,6 +97,8 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
/** Authority service */
|
||||
private AuthorityService authorityService;
|
||||
|
||||
private FilePlanType filePlanType;
|
||||
|
||||
/** Map of file plan type's key'ed by corresponding site types */
|
||||
protected Map<QName, QName> mapFilePlanType = new HashMap<QName, QName>(3);
|
||||
|
||||
@@ -133,6 +135,11 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
public void setFilePlanType(FilePlanType filePlanType)
|
||||
{
|
||||
this.filePlanType = filePlanType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a file plan type for a specific site type.
|
||||
*
|
||||
@@ -302,6 +309,7 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
return null;
|
||||
}
|
||||
});
|
||||
filePlanType.disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,4 +362,15 @@ public class RmSiteType extends BaseBehaviourBean
|
||||
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
policy = "alf:onDeleteNode",
|
||||
notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT
|
||||
)
|
||||
public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||
{
|
||||
filePlanType.enable();
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import java.util.List;
|
||||
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;
|
||||
@@ -47,9 +48,30 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
@BehaviourBean(defaultType = "rma:unfiledRecordContainer")
|
||||
public class UnfiledRecordContainerType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||
NodeServicePolicies.OnDeleteNodePolicy
|
||||
{
|
||||
private static final String BEHAVIOUR_NAME = "onDeleteUnfiledRecordContainer";
|
||||
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_UNFILED_RECORD_FOLDER, ContentModel.TYPE_CONTENT, TYPE_NON_ELECTRONIC_DOCUMENT);
|
||||
|
||||
/**
|
||||
* Disable the behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void disable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable behaviours for this transaction
|
||||
*
|
||||
*/
|
||||
public void enable()
|
||||
{
|
||||
getBehaviour(BEHAVIOUR_NAME).enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||
@@ -57,4 +79,15 @@ public class UnfiledRecordContainerType extends BaseBehaviourBean
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.CLASS,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived)
|
||||
{
|
||||
throw new IntegrityException("Operation failed. Deletion of Unfiled Record Container is not allowed.", null);
|
||||
}
|
||||
}
|
||||
|
@@ -49,8 +49,6 @@ import org.alfresco.rest.api.impl.NodesImpl;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rm.rest.api.RMNodes;
|
||||
import org.alfresco.rm.rest.api.model.FileplanComponentNode;
|
||||
import org.alfresco.rm.rest.api.model.RecordCategoryNode;
|
||||
@@ -415,22 +413,4 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden this method just in order to use our isSpecialNode method since core method could not be overridden.
|
||||
*
|
||||
* TODO remove this after isSpecialNode will be made protected in core(REPO-1459).
|
||||
*/
|
||||
@Override
|
||||
public void deleteNode(String nodeId, Parameters parameters)
|
||||
{
|
||||
NodeRef nodeRef = validateOrLookupNode(nodeId, null);
|
||||
QName nodeType = nodeService.getType(nodeRef);
|
||||
|
||||
if (isSpecialNode(nodeRef, nodeType))
|
||||
{
|
||||
throw new PermissionDeniedException("Cannot delete: " + nodeId);
|
||||
}
|
||||
super.deleteNode(nodeId, parameters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user