diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index d1b5d5f907..2306424f57 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -702,6 +702,7 @@ public abstract class BaseAPI public enum RM_ACTIONS { EDIT_DISPOSITION_DATE("editDispositionActionAsOfDate"), + END_RETENTION("retain"), CUT_OFF("cutoff"), UNDO_CUT_OFF("undoCutoff"), TRANSFER("transfer"), diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java index a21d2b69f4..6abe3d69b9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java @@ -47,6 +47,7 @@ import java.io.File; import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.v0.BaseAPI.RM_ACTIONS; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.common.ReviewPeriod; import org.alfresco.rest.rm.community.model.record.Record; @@ -55,6 +56,7 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder; import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties; import org.alfresco.rest.v0.HoldsAPI; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; import org.alfresco.rest.v0.service.DispositionScheduleService; import org.alfresco.test.AlfrescoTest; import org.alfresco.utility.Utility; @@ -81,6 +83,7 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest private static FolderModel folderModel; private static RecordCategoryChild recordFolder; private static Record recordFrozen, recordNotHeld; + private static RecordCategory categoryWithRS; @Autowired private HoldsAPI holdsAPI; @@ -88,6 +91,9 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest @Autowired private DispositionScheduleService dispositionScheduleService; + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + @BeforeClass (alwaysRun = true) public void preconditionForPreventActionsOnFrozenContent() throws Exception { @@ -276,12 +282,52 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest assertNotNull(folderWithRS.getProperties().getRecordSearchDispositionInstructions()); } + + /** + * Given a record category with a disposition schedule applied to records + * And the disposition schedule has a retain step immediately and destroy step immediately + * And a complete record added to one hold + * When I execute the retain action + * Then the action is executed + * And the record search disposition schedule properties are updated + * + * @throws Exception + */ + @Test + @AlfrescoTest (jira = "RM-6931") + public void retainActionOnFrozenHeldRecords() throws Exception + { + STEP("Add a category with a disposition schedule."); + categoryWithRS = createRootCategory(getRandomName("CategoryWithRS")); + dispositionScheduleService.createCategoryRetentionSchedule(categoryWithRS.getName(), true); + dispositionScheduleService.addRetainAfterPeriodStep(categoryWithRS.getName(), "immediately"); + dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(categoryWithRS.getName(), "immediately"); + + STEP("Create record folder with a record."); + RecordCategoryChild folder = createFolder(categoryWithRS.getId(), getRandomName("RecFolder")); + Record record = createElectronicRecord(folder.getId(), getRandomName("elRecord")); + completeRecord(record.getId()); + + STEP("Add the record to the hold"); + holdsAPI.addItemToHold(getAdminUser().getUsername(), getAdminUser().getPassword(), record.getId(), HOLD_ONE); + + STEP("Execute the retain action"); + rmRolesAndActionsAPI.executeAction(getAdminUser().getUsername(), getAdminUser().getPassword(), record.getName(), + RM_ACTIONS.END_RETENTION); + + STEP("Check the record search disposition properties"); + Record recordUpdated = getRestAPIFactory().getRecordsAPI().getRecord(record.getId()); + assertTrue(recordUpdated.getProperties().getRecordSearchDispositionActionName().contains(RM_ACTIONS.DESTROY.getAction())); + assertTrue(recordUpdated.getProperties().getRecordSearchDispositionPeriod().contains("immediately")); + } + @AfterClass (alwaysRun = true) public void cleanUpPreventActionsOnFrozenContent() throws Exception { holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_ONE); dataSite.usingAdmin().deleteSite(testSite); getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordFolder.getParentId()); + getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(categoryWithRS.getId()); } } 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 2e45677bc5..ed9f0ce31b 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 @@ -526,7 +526,6 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel // Clear the events nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, null); - } return null; @@ -599,7 +598,6 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel frozenAspect.enableOnPropUpdateFrozenAspect(); } - if (logger.isDebugEnabled()) { logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + @@ -646,7 +644,6 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); - } } }