RM-4293: created capabilities for deleting transfer container and hold

container and restricted the deletion from behaviour beans
This commit is contained in:
Silviu Dinuta
2016-11-16 15:09:58 +02:00
parent 7d884e857c
commit bee71d2dbd
7 changed files with 128 additions and 3 deletions

View File

@@ -198,7 +198,7 @@ public class FilePlanTests extends BaseRestTest
/**
* Given that a file plan exists
* When I ask the API to delete the file plan
* Then the 403 response code is returned.
* Then the 422 response code is returned.
*/
@Test
(
@@ -217,6 +217,40 @@ public class FilePlanTests extends BaseRestTest
// Delete the file plan component
filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString());
// Check the DELETE response status code
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}
/**
* Given that a file plan exists and I am a non RM user
* When I ask the API to delete the file plan
* Then the 403 response code is returned.
*/
@Test
(
description = "Check the response code when deleting the special file plan components with non RM user",
dataProviderClass = TestData.class,
dataProvider = "getContainers"
)
public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception
{
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Disconnect the current user from the API session
rmSiteAPI.usingRestWrapper().disconnect();
// Authenticate admin user to Alfresco REST API
restClient.authenticateUser(dataUser.getAdminUser());
// Create a random user
UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
// Authenticate using the random user
filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser);
// Delete the file plan component
filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString());
// Check the DELETE response status code
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
}

View File

@@ -94,4 +94,23 @@
</property>
</bean>
<bean id="rmDeleteTransferContainerCapability"
parent="declarativeCapability">
<property name="name" value="DeleteTransferContainer"/>
<property name="kinds">
<list>
<value>TRANSFER_CONTAINER</value>
</list>
</property>
</bean>
<bean id="rmDeleteHoldContainerCapability"
parent="declarativeCapability">
<property name="name" value="DeleteHoldContainer"/>
<property name="kinds">
<list>
<value>HOLD_CONTAINER</value>
</list>
</property>
</bean>
</beans>

View File

@@ -25,6 +25,8 @@
<ref bean="rmDeleteUnfiledRecordsContainerFolderCapability"/>
<ref bean="rmDeleteHoldCapability"/>
<ref bean="rmUnlinkFromRecordFolderCapability"/>
<ref bean="rmDeleteTransferContainerCapability"/>
<ref bean="rmDeleteHoldContainerCapability"/>
</list>
</property>
</bean>

View File

@@ -77,6 +77,8 @@
<property name="recordFolderService" ref="RecordFolderService" />
<property name="filePlanRoleService" ref="FilePlanRoleService" />
<property name="unfilerRecordContainerType" ref="rma.unfiledRecordsContainer" />
<property name="transferContainerType" ref="rma.transferContainer" />
<property name="holdContainerType" ref="rma.holdContainer" />
</bean>
<bean id="rma.holdContainer" class="org.alfresco.module.org_alfresco_module_rm.model.rma.type.HoldContainerType" parent="rm.baseBehaviour">

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}