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/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."); } }