diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java index 6a9f1691a4..0843a5e840 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponent.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * POJO for file plan component * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponent { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java index c4ace365e8..e5929014f8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentAlias.java @@ -17,7 +17,7 @@ import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString; * File plan component alias enumeration * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum FilePlanComponentAlias { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java index 3d3bd42609..70bd836090 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentEntry.java @@ -21,7 +21,7 @@ import org.alfresco.rest.core.RestModels; * POJO for file plan component entry * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentEntry extends RestModels { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java index 7fc8c356df..9d8415d960 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentFields.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * File plan component field names constants * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentFields { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java index 019085c12a..a7d5f1f9c3 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentIdNamePair.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for id/name pair * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentIdNamePair { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java index 084b2c08ad..3e75c01396 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentPath.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; * POJO for FilePlanComponent path parameter *
* @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ @JsonIgnoreProperties(ignoreUnknown = true) public class FilePlanComponentPath diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java index 5f40de6f83..a7179e831a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentProperties.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * POJO for file plan component properties * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ //FIXME: Once the fields have been added the JsonIgnoreProperties annotation should be removed @JsonIgnoreProperties (ignoreUnknown = true) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java index e76c58c938..052ad17f7b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java @@ -17,7 +17,7 @@ import static org.alfresco.rest.rm.util.ParameterCheck.mandatoryString; * File plan component type enumeration * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum FilePlanComponentType { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java index 2a79da8b9e..7983cd9250 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentUserInfo.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for file plan component created by object * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentUserInfo { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java index 0b50a94d56..5cee5e7629 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentsCollection.java @@ -17,7 +17,7 @@ import org.alfresco.rest.core.RestModels; * Handle collection of FilePlanComponents * * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ public class FilePlanComponentsCollection extends RestModels { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java index ba7fa00564..c96a2bc9f9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/ReviewPeriod.java @@ -4,7 +4,7 @@ package org.alfresco.rest.rm.model.fileplancomponents; * POJO for the review period * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class ReviewPeriod { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java index c68d56bf96..08846558f9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSite.java @@ -19,7 +19,7 @@ import org.alfresco.rest.model.RestSiteModel; * POJO for RM Site component * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSite extends RestSiteModel { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java index c2b57860bf..96b16a678d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteCompliance.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.model.site; * RM Site compliance * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public enum RMSiteCompliance { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java index 075b9e1b87..4dd9cf918d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/site/RMSiteFields.java @@ -24,7 +24,7 @@ package org.alfresco.rest.rm.model.site; *} * @author Tuna Aksoy * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSiteFields { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java index de87b72593..a29146e434 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/FilePlanComponentAPI.java @@ -33,7 +33,7 @@ import org.springframework.stereotype.Component; * * @author Tuna Aksoy * @author Kristijan Conkas - * @since 1.0 + * @since 2.6 */ @Component @Scope(value = "prototype") diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java index 44ed0e9c38..11e5ca45ba 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/requests/RMSiteAPI.java @@ -31,7 +31,7 @@ import org.springframework.stereotype.Component; * * @author Tuna Aksoy * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ @Component @Scope (value = "prototype") diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java index 49e7a56eb5..462d832ff4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/util/ParameterCheck.java @@ -17,7 +17,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank; * Utility class for checking parameters * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class ParameterCheck { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java index d11d730c9d..e50a7f07ff 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/AllowableOperations.java @@ -15,7 +15,7 @@ package org.alfresco.rest.rm.base; * List of allowable operations * * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class AllowableOperations { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java index 6129987124..089120d436 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/BaseRestTest.java @@ -50,7 +50,7 @@ import org.testng.annotations.BeforeClass; * * @author Kristijan Conkas * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ @Configuration @PropertySource("classpath:default.properties") diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java index 46b634a7c1..ad27070b51 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java @@ -32,7 +32,7 @@ import org.testng.annotations.DataProvider; * Test data used in tests * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public interface TestData { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java index 574f4f14bb..ebc396e80f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/FilePlanTests.java @@ -52,7 +52,7 @@ import org.testng.annotations.Test; * the File Plan CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class FilePlanTests extends BaseRestTest { @@ -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); } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java index 78d527e30a..f05303b119 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java @@ -54,7 +54,7 @@ import org.testng.annotations.Test; * * @author Kristijan Conkas * @author Tuna Aksoy - * @since 1.0 + * @since 2.6 */ public class RecordCategoryTest extends BaseRestTest { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java index 0c9b1e8de5..9b0fd45e1a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordFolderTests.java @@ -61,7 +61,7 @@ import org.testng.annotations.Test; * the Record Folder CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RecordFolderTests extends BaseRestTest { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java index c3bee9cfab..3919935fac 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/site/RMSiteTests.java @@ -51,7 +51,7 @@ import org.testng.annotations.Test; * the RM site CRUD API * * @author Rodica Sutu - * @since 1.0 + * @since 2.6 */ public class RMSiteTests extends BaseRestTest { diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml index e8eeae8602..b7d1e33fd6 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-fileplan-context.xml @@ -94,4 +94,35 @@ + + + + + TRANSFER_CONTAINER + + + + + + + + + + + + + + + HOLD_CONTAINER + + + + + + + + + \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml index 91a50ef89d..3b67d92639 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml @@ -25,6 +25,8 @@ + + diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index fe6cedfd6d..aba5909bb3 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -76,6 +76,9 @@ + + + @@ -112,6 +115,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index aacda376c7..6917cc8899 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -519,48 +519,45 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - if (!methodCached("updateDispositionActionProperties", record)) + Map props = nodeService.getProperties(record); + + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); + + props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); + props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); + props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + if (daDefinition != null) { - Map props = nodeService.getProperties(record); - - DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - - props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName()); - props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate()); - props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); - if (daDefinition != null) + Period period = daDefinition.getPeriod(); + if (period != null) { - Period period = daDefinition.getPeriod(); - if (period != null) - { - props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); - } - else - { - props.put(PROP_RS_DISPOSITION_PERIOD, null); - props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); - } + props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); } - - nodeService.setProperties(record, props); - - if (logger.isDebugEnabled()) + else { - logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_NAME)); - logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD)); - logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + props.put(PROP_RS_DISPOSITION_PERIOD, null); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); } } + + nodeService.setProperties(record, props); + + if (logger.isDebugEnabled()) + { + logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_NAME)); + logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD)); + logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + } } /** diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java index 3cc8cba850..94c496ac8b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/FilePlanType.java @@ -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 ACCEPTED_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD_CONTAINER, TYPE_TRANSFER_CONTAINER, TYPE_UNFILED_RECORD_CONTAINER); private final static List 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(); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java index 989b92699b..2326b41f64 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerType.java @@ -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 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); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 82eb0b57ac..40b7842c08 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -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 mapFilePlanType = new HashMap(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(); + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java index d0fba4ff99..6fb4cca3ef 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/TransferContainerType.java @@ -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); + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java index b0b78a9bbb..4c0c1e9df9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerType.java @@ -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 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); + } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java index b127e2fbe1..97a1bc9e3c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/rm/rest/api/impl/RMNodesImpl.java @@ -48,8 +48,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; @@ -380,22 +378,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); - } } diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java index f2b55655b2..f18a3d2b5d 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java @@ -66,6 +66,10 @@ public class MultipleSchedulesTest extends BaseRMTestCase protected static final String CATEGORY_B_NAME = TEST_PREFIX + "CategoryB"; /** The name to use for the folder within the second category. */ protected static final String FOLDER_B_NAME = TEST_PREFIX + "FolderB"; + /** The name to use for the third category. */ + protected static final String CATEGORY_C_NAME = TEST_PREFIX + "CategoryC"; + /** The name to use for the folder within the third category. */ + protected static final String FOLDER_C_NAME = TEST_PREFIX + "FolderC"; /** The name to use for the record. */ protected static final String RECORD_NAME = TEST_PREFIX + "Record"; @@ -80,6 +84,10 @@ public class MultipleSchedulesTest extends BaseRMTestCase private NodeRef categoryB; /** The folder node within the second category. */ private NodeRef folderB; + /** The third category node. */ + private NodeRef categoryC; + /** The folder node within the third category. */ + private NodeRef folderC; /** The record node. */ private NodeRef record; @@ -114,6 +122,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase // Create two categories. categoryA = filePlanService.createRecordCategory(filePlan, CATEGORY_A_NAME); categoryB = filePlanService.createRecordCategory(filePlan, CATEGORY_B_NAME); + categoryC = filePlanService.createRecordCategory(filePlan, CATEGORY_C_NAME); // Create a disposition schedule for category A (Cut off immediately, then Destroy immediately). DispositionSchedule dispSchedA = utils.createBasicDispositionSchedule(categoryA, "instructions", "authority", true, false); Map cutOffParamsA = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME, @@ -135,9 +144,21 @@ public class MultipleSchedulesTest extends BaseRMTestCase PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_WEEK, PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE); dispositionService.addDispositionActionDefinition(dispSchedB, destroyParamsB); + // Create a disposition schedule for category C (Cut off immediately, then Destroy one year after cutoff). + DispositionSchedule dispSchedC = utils.createBasicDispositionSchedule(categoryC, "instructions", "authority", true, false); + Map cutOffParamsC = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME, + PROP_DISPOSITION_DESCRIPTION, "description", + PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionService.addDispositionActionDefinition(dispSchedC, cutOffParamsC); + Map destroyParamsC = ImmutableMap.of(PROP_DISPOSITION_ACTION_NAME, DestroyAction.NAME, + PROP_DISPOSITION_DESCRIPTION, "description", + PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_ONE_YEAR, + PROP_DISPOSITION_PERIOD_PROPERTY, PROP_CUT_OFF_DATE); + dispositionService.addDispositionActionDefinition(dispSchedC, destroyParamsC); // Create a folder within each category. folderA = recordFolderService.createRecordFolder(categoryA, FOLDER_A_NAME); folderB = recordFolderService.createRecordFolder(categoryB, FOLDER_B_NAME); + folderC = recordFolderService.createRecordFolder(categoryC, FOLDER_C_NAME); } /** @@ -155,6 +176,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase test() .given(() -> { setUpFilePlan(); + // Create a record filed under category A and linked to category B. record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef(); recordService.link(record, folderB); @@ -219,19 +241,22 @@ public class MultipleSchedulesTest extends BaseRMTestCase test() .given(() -> { setUpFilePlan(); - // Create a record filed under category A and linked to category B. + // Create a record filed under category A and linked to category B and C. record = fileFolderService.create(folderA, RECORD_NAME, ContentModel.TYPE_CONTENT).getNodeRef(); recordService.link(record, folderB); - }) - .when(() -> { + recordService.link(record, folderC); // Cut off the record. dispositionService.cutoffDisposableItem(record); + // Ensure the update has been applied to the record. + internalDispositionService.updateNextDispositionAction(record); + }) + .when(() -> { // Unlink the record from folder B. recordService.unlink(record, folderB); }) .then() - .expect(true) + .expect(false) .from(() -> dispositionService.isNextDispositionActionEligible(record)) - .because("Destroy action should be available, as the record should follow its origin disposition schedule."); + .because("Destroy action shouldn't be available, as the record should follow disposition schedule from category C."); } } diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java new file mode 100644 index 0000000000..aac6266d89 --- /dev/null +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4293Test.java @@ -0,0 +1,126 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + * + */ + +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.repo.node.integrity.IntegrityException; +import org.alfresco.service.cmr.repository.NodeRef; + +/** + * Test for RM-4293 + * + * @author Silviu Dinuta + * @since 2.6 + * + */ +public class RM4293Test extends BaseRMTestCase +{ + public void testDeleteSpecialContainers() throws Exception + { + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); + assertNotNull(holdContainer); + + try + { + fileFolderService.delete(holdContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Hold Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef transferContainer = filePlanService.getTransferContainer(filePlan); + assertNotNull(transferContainer); + try + { + fileFolderService.delete(transferContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Transfer Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan); + assertNotNull(unfiledRecordContainer); + + try + { + fileFolderService.delete(unfiledRecordContainer); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("Unfiled Record Container can't be deleted.") + } + return null; + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + try + { + fileFolderService.delete(filePlan); + fail("This should have thrown an exception"); + } + catch (IntegrityException e) + { + // ("FilePlan can't be deleted.") + } + return null; + } + }); + } +} diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java index 3ae63a99c2..a584ffc75b 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/rm/rest/api/impl/RMNodesImplUnitTest.java @@ -35,9 +35,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.security.InvalidParameterException; @@ -52,8 +49,6 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest; import org.alfresco.repo.model.Repository; import org.alfresco.rest.api.model.Node; 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; @@ -609,121 +604,6 @@ public class RMNodesImplUnitTest extends BaseUnitTest assertEquals(nodeRef, validateOrLookupNode); } - @Test - public void testDeleteNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - setupCompanyHomeAndPrimaryParent(nodeRef); - - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - verify(mockedFileFolderService, times(1)).delete(nodeRef); - } - - @Test - public void testDeleteFileplanNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as filePlan can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteTransfersContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Trnsfers container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteHoldsContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - - NodeRef transferContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(transferContainerNodeRef); - - when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Holds container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - - @Test - public void testDeleteUnfiledRecordsContainerNode() throws Exception - { - NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService); - Parameters mockedParameters = mock(Parameters.class); - QName mockedType = AlfMock.generateQName(); - when(mockedNodeService.getType(nodeRef)).thenReturn(mockedType); - - NodeRef filePlanNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getFilePlanBySiteId(RM_SITE_ID)).thenReturn(filePlanNodeRef); - - NodeRef transferContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getTransferContainer(filePlanNodeRef)).thenReturn(transferContainerNodeRef); - - NodeRef holdContainerNodeRef = AlfMock.generateNodeRef(mockedNodeService); - when(mockedFilePlanService.getHoldContainer(filePlanNodeRef)).thenReturn(holdContainerNodeRef); - - when(mockedFilePlanService.getUnfiledContainer(filePlanNodeRef)).thenReturn(nodeRef); - try - { - rmNodesImpl.deleteNode(nodeRef.getId(), mockedParameters); - fail("Expected ecxeption as Unfiled Records container can't be deleted."); - } - catch(PermissionDeniedException ex) - { - assertEquals("Cannot delete: " + nodeRef.getId(), ex.getMsgId()); - } - verify(mockedFileFolderService, never()).delete(nodeRef); - } - private void setupCompanyHomeAndPrimaryParent(NodeRef nodeRef) { NodeRef companyHomeNodeRef = AlfMock.generateNodeRef(mockedNodeService);