From 8c69fd1399f1520a667218e1d3359bbbd84dcc4a Mon Sep 17 00:00:00 2001 From: roxana Date: Tue, 1 Nov 2016 15:25:04 +0200 Subject: [PATCH 1/8] Changed the test a bit to check a more complex case. --- .../disposition/MultipleSchedulesTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java index 26d119210d..fc23b3390a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/disposition/MultipleSchedulesTest.java @@ -34,6 +34,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"; @@ -48,6 +52,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; @@ -82,6 +90,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, @@ -103,9 +112,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); } /** @@ -123,6 +144,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); @@ -187,19 +209,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."); } } From cb11d527d47e0496d41033fb1408c6676eb9f025 Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 10:19:24 +0200 Subject: [PATCH 2/8] Update record disposition action as of date if it changed, to have the same value as next disposition action as of date. --- .../RecordsManagementSearchBehaviour.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 80e3aec4b4..11fc347bce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -510,12 +511,16 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - if (!methodCached("updateDispositionActionProperties", record)) + Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); + // update disposition action as of if it changed + // @since 2.3.1 + // @see https://issues.alfresco.com/jira/browse/RM-4313 + if (!methodCached("updateDispositionActionProperties", record) + || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) { 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)); @@ -553,6 +558,22 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } } } + + /** + * Check if recordSearchDispositionActionAsOf property has been changed + * + * @param currentDate current as of date value + * @param updatedDate new as of date value + * @return true if the as of date has been changed + */ + private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) + { + if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + { + return true; + } + return currentDate.compareTo(updatedDate) != 0; + } /** * On update of event execution information behaviour\ From 59c6fcca39202e99231ee6e04a68bc9ee58830ae Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 14 Oct 2016 18:41:00 +0300 Subject: [PATCH 3/8] RM-4249 - workaround : replaced maxEntries with a positive value (cherry picked from commit 4b76fb838fd24d9c26e7d8d5e58449d71637062e) --- .../audit/RecordsManagementAuditQueryParameters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java index 4af11575b8..266cfcf3b8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditQueryParameters.java @@ -31,7 +31,7 @@ import org.alfresco.service.namespace.QName; */ public final class RecordsManagementAuditQueryParameters { - private int maxEntries = -1; + private int maxEntries = Integer.MAX_VALUE; private String user; private NodeRef nodeRef; private Date dateFrom; From 373439822c77d69ba3d0a6df5c360b5732f4fc8c Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 17:08:09 +0200 Subject: [PATCH 4/8] Revert changes and removed cache check. --- .../RecordsManagementSearchBehaviour.java | 84 +++++++------------ 1 file changed, 30 insertions(+), 54 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 11fc347bce..ed3c445788 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -511,68 +510,45 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + Map props = nodeService.getProperties(record); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - // update disposition action as of if it changed - // @since 2.3.1 - // @see https://issues.alfresco.com/jira/browse/RM-4313 - if (!methodCached("updateDispositionActionProperties", record) - || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) + + 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); - - 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); } } - } - - /** - * Check if recordSearchDispositionActionAsOf property has been changed - * - * @param currentDate current as of date value - * @param updatedDate new as of date value - * @return true if the as of date has been changed - */ - private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) - { - if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + + nodeService.setProperties(record, props); + + if (logger.isDebugEnabled()) { - return true; + 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)); } - return currentDate.compareTo(updatedDate) != 0; } /** From c6810b33dd2f17e93af9a9e1b0b3172350b39fdf Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Tue, 18 Oct 2016 18:28:29 +0300 Subject: [PATCH 5/8] fixed audit unit tests (cherry picked from commit 7a33945dffff0d7f29691ead503318daaffea4a4) --- .../RecordsManagementAuditServiceImplTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java index 3188b2cc65..d2245ed565 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementAuditServiceImplTest.java @@ -162,9 +162,9 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase // "audit.start", "audit.view" and "Update RM Object"; entries = getAuditTrail(3, ADMIN_USER); - assertEquals(entries.get(0).getEvent(), "audit.start"); + assertEquals(entries.get(2).getEvent(), "audit.start"); assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(0).getEvent(), "Update RM Object"); // New "audit.view" event was generated - will be visible on next getAuditTrail(). @@ -176,14 +176,14 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase nodeService.deleteNode(record); List entries = getAuditTrail(5, ADMIN_USER); - assertEquals(entries.get(0).getEvent(), "audit.start"); - assertEquals(entries.get(1).getEvent(), "audit.view"); - assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(4).getEvent(), "audit.start"); assertEquals(entries.get(3).getEvent(), "audit.view"); + assertEquals(entries.get(2).getEvent(), "Update RM Object"); + assertEquals(entries.get(1).getEvent(), "audit.view"); // Show the audit contains a reference to the deleted item: - assertEquals(entries.get(4).getEvent(), "Delete RM Object"); - assertEquals(entries.get(4).getNodeRef(), record); + assertEquals(entries.get(0).getEvent(), "Delete RM Object"); + assertEquals(entries.get(0).getNodeRef(), record); return null; } @@ -203,7 +203,7 @@ public class RecordsManagementAuditServiceImplTest extends BaseRMTestCase // show the audit has been updated List entries = getAuditTrail(3, ADMIN_USER); - final RecordsManagementAuditEntry entry = entries.get(2); + final RecordsManagementAuditEntry entry = entries.get(0); assertNotNull(entry); // investigate the contents of the audit entry From 3b75d70ba70b79add9953bba65b02ac7ccd53f13 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 9 Nov 2016 13:17:00 +0000 Subject: [PATCH 6/8] Update version to 2.3.1. --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-server/pom.xml | 2 +- temp | 0 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 temp diff --git a/pom.xml b/pom.xml index 7d56dd2c18..9ae57a0520 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm-parent pom - 2.3.1-SNAPSHOT + 2.3.1 Alfresco Records Management http://www.alfresco.org/ diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index e88c8062f1..f59d7531ff 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-parent - 2.3.1-SNAPSHOT + 2.3.1 diff --git a/rm-server/pom.xml b/rm-server/pom.xml index 7d347cf2a7..2a3146275f 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -5,7 +5,7 @@ org.alfresco alfresco-rm-parent - 2.3.1-SNAPSHOT + 2.3.1 4.0.0 alfresco-rm-server diff --git a/temp b/temp new file mode 100644 index 0000000000..e69de29bb2 From d376ae50c3d0e63f193659847d74cf36e11aab35 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 9 Nov 2016 13:48:25 +0000 Subject: [PATCH 7/8] Update version to 2.3.1.1-SNAPSHOT. --- pom.xml | 2 +- rm-automation/pom.xml | 2 +- rm-server/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9ae57a0520..1a202ae62d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-rm-parent pom - 2.3.1 + 2.3.1.1-SNAPSHOT Alfresco Records Management http://www.alfresco.org/ diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index f59d7531ff..94d74c0504 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-rm-parent - 2.3.1 + 2.3.1.1-SNAPSHOT diff --git a/rm-server/pom.xml b/rm-server/pom.xml index 2a3146275f..63783bd4c6 100644 --- a/rm-server/pom.xml +++ b/rm-server/pom.xml @@ -5,7 +5,7 @@ org.alfresco alfresco-rm-parent - 2.3.1 + 2.3.1.1-SNAPSHOT 4.0.0 alfresco-rm-server From bea04479adff0bc84089bcaa1aff9b7073431fb2 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 11 Nov 2016 15:39:37 +0000 Subject: [PATCH 8/8] Remove spurious temp file. --- temp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 temp diff --git a/temp b/temp deleted file mode 100644 index e69de29bb2..0000000000