mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4326: allow creation in transfer container only from
TransferServiceImpl
This commit is contained in:
@@ -26,8 +26,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.security.InvalidParameterException;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -38,7 +37,6 @@ import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -52,7 +50,25 @@ public class TransferContainerType extends BaseBehaviourBean
|
||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
|
||||
{
|
||||
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_TRANSFER);
|
||||
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferContainer";
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* On every event
|
||||
@@ -61,11 +77,14 @@ public class TransferContainerType extends BaseBehaviourBean
|
||||
* boolean)
|
||||
*/
|
||||
@Override
|
||||
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
||||
@Behaviour
|
||||
(
|
||||
kind = BehaviourKind.ASSOCIATION,
|
||||
name = BEHAVIOUR_NAME
|
||||
)
|
||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||
{
|
||||
// check the created child is of an accepted type
|
||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||
throw new InvalidParameterException("Operation failed. Creation is not allowed in Transfer Container");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -41,6 +41,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.rma.type.TransferContainerType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
|
||||
@@ -87,6 +88,8 @@ public class TransferServiceImpl extends ServiceBaseImpl
|
||||
/** Freeze Service */
|
||||
protected FreezeService freezeService;
|
||||
|
||||
protected TransferContainerType transferContainerType;
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
@@ -127,6 +130,11 @@ public class TransferServiceImpl extends ServiceBaseImpl
|
||||
this.freezeService = freezeService;
|
||||
}
|
||||
|
||||
public void setTransferContainerType(TransferContainerType transferContainerType)
|
||||
{
|
||||
this.transferContainerType = transferContainerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean)
|
||||
*/
|
||||
@@ -164,12 +172,21 @@ public class TransferServiceImpl extends ServiceBaseImpl
|
||||
}
|
||||
|
||||
NodeRef transferContainer = filePlanService.getTransferContainer(root);
|
||||
transferNodeRef = nodeService.createNode(transferContainer,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(RM_URI, transferName),
|
||||
TYPE_TRANSFER,
|
||||
transferProps).getChildRef();
|
||||
|
||||
transferContainerType.disable();
|
||||
try
|
||||
{
|
||||
transferNodeRef = nodeService.createNode(transferContainer,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(RM_URI, transferName),
|
||||
TYPE_TRANSFER,
|
||||
transferProps).getChildRef();
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
transferContainerType.enable();
|
||||
}
|
||||
// Bind the hold node reference to the transaction
|
||||
AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);
|
||||
}
|
||||
@@ -253,12 +270,12 @@ public class TransferServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Could not complete a transfer that contains held folders");
|
||||
}
|
||||
|
||||
|
||||
if(freezeService.hasFrozenChildren(assoc.getChildRef()))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Cound not complete a transfer that contains folders with held children");
|
||||
}
|
||||
|
||||
|
||||
markComplete(assoc.getChildRef(), accessionIndicator, transferLocation);
|
||||
}
|
||||
|
||||
|
@@ -413,10 +413,6 @@ public class RMNodesImpl extends NodesImpl implements RMNodes
|
||||
{
|
||||
throw new PermissionDeniedException("POST request not allowed in Transfer Folder.");
|
||||
}
|
||||
else if(RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(parentNodeRefType))
|
||||
{
|
||||
throw new PermissionDeniedException("POST request not allowed in Transfer Container.");
|
||||
}
|
||||
else if(RecordsManagementModel.TYPE_HOLD.equals(parentNodeRefType))
|
||||
{
|
||||
throw new PermissionDeniedException("POST request not allowed in Hold Folder.");
|
||||
|
Reference in New Issue
Block a user