From c879e92b4c979e8da9ee654d4a8c529233a28384 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 19 Feb 2015 10:45:21 +0000 Subject: [PATCH] RM-1914 : "Related Record Transferred To Inactive Storage" is not completed automatically - Merged revision 97301 from /DEV/BUGFIXING/V2.3-2015_02_17 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@97461 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../event/OnReferencedRecordActionedUpon.java | 7 +- .../integration/issue/IssueTestSuite.java | 3 +- .../test/integration/issue/RM1914Test.java | 139 ++++++++++++++++++ 3 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java index 9b6d581f4e..37f039aeb2 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/OnReferencedRecordActionedUpon.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution; import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService; import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction; @@ -50,7 +51,8 @@ import org.alfresco.service.namespace.RegexQNamePattern; */ @BehaviourBean public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEventTypeImpl - implements RecordsManagementModel + implements RecordsManagementModel, + BeforeRMActionExecution { /** Disposition service */ @@ -146,13 +148,14 @@ public class OnReferencedRecordActionedUpon extends SimpleRecordsManagementEvent * @param name * @param parameters */ + @Override @Behaviour ( kind = BehaviourKind.CLASS, type = "rma:filePlanComponent", notificationFrequency = NotificationFrequency.FIRST_EVENT ) - public void beforeActionExecution(final NodeRef nodeRef, final String name, final Map parameters) + public void beforeRMActionExecution(final NodeRef nodeRef, final String name, final Map parameters) { AuthenticationUtil.RunAsWork work = new AuthenticationUtil.RunAsWork() { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java index cb45eefc4c..e3fd8e72d5 100755 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/IssueTestSuite.java @@ -45,7 +45,8 @@ import org.junit.runners.Suite.SuiteClasses; RM1799Test.class, RM1814Test.class, RM978Test.class, - RM1887Test.class + RM1887Test.class, + RM1914Test.class }) public class IssueTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java new file mode 100644 index 0000000000..4f75c5bb68 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1914Test.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.integration.issue; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction; +import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferCompleteAction; +import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule; +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.GUID; +import org.apache.commons.lang.StringUtils; + +/** + * + * @author Ana Bozianu + * @since 2.3 + */ +public class RM1914Test extends BaseRMTestCase +{ + + public void testRM1914() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + + NodeRef record1; + NodeRef record2; + + public void given() + { + // 1. Any Category1, Category2 are created + NodeRef category1 = filePlanService.createRecordCategory(filePlan, GUID.generate()); + NodeRef category2 = filePlanService.createRecordCategory(filePlan, GUID.generate()); + + + // 2. Disposition schedule is created for the Category1: + // - applied on Record + Map dsProps = new HashMap(3); + dsProps.put(PROP_DISPOSITION_AUTHORITY, CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY); + dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, GUID.generate()); + dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, true); + + DispositionSchedule dispositionSchedule1 = dispositionService.createDispositionSchedule(category1, dsProps); + + // - add cutoff after "Related Record Transferred To Inactive Storage" completion event + Map dispositionAction1 = new HashMap(3); + dispositionAction1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + dispositionAction1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + + List events = new ArrayList(1); + events.add("related_record_trasfered_inactive_storage"); + dispositionAction1.put(PROP_DISPOSITION_EVENT, (Serializable)events); + + dispositionService.addDispositionActionDefinition(dispositionSchedule1, dispositionAction1); + + + // 3. Folder1 > Record1 is created inside Category1 + NodeRef folder1 = recordFolderService.createRecordFolder(category1, GUID.generate()); + record1 = recordService.createRecordFromContent(folder1, GUID.generate(), TYPE_CONTENT, null, null); + + + // 4. Disposition schedule is created for the Category2: + // applied on Record + DispositionSchedule dispositionSchedule2 = dispositionService.createDispositionSchedule(category2, dsProps); + + // - cutoff immediatelly + Map dispositionAction2_1 = new HashMap(3); + dispositionAction2_1.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME); + dispositionAction2_1.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + dispositionAction2_1.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_1); + + // - Transfer Immediatelly + Map dispositionAction2_2 = new HashMap(4); + dispositionAction2_2.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME); + dispositionAction2_2.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate()); + dispositionAction2_2.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY); + dispositionAction2_2.put(PROP_DISPOSITION_LOCATION, StringUtils.EMPTY); + + dispositionService.addDispositionActionDefinition(dispositionSchedule2, dispositionAction2_2); + + // 5. Folder2 > Record2 is created inside Category2 + NodeRef folder2 = recordFolderService.createRecordFolder(category2, GUID.generate()); + record2 = recordService.createRecordFromContent(folder2, GUID.generate(), TYPE_CONTENT, null, null); + + // 6. Record1 and Record2 are completed + utils.completeRecord(record1); + utils.completeRecord(record2); + + // 7. Create Cross-Reference link from Record1 to Record2 + relationshipService.addRelationship(CUSTOM_REF_CROSSREFERENCE.getLocalName(), record1, record2); + + + } + + public void when() + { + // 8. Cut off and transfer Record2 + rmActionService.executeRecordsManagementAction(record2, CutOffAction.NAME, null); + NodeRef transferFolder = (NodeRef) rmActionService.executeRecordsManagementAction(record2, TransferAction.NAME).getValue(); + rmActionService.executeRecordsManagementAction(transferFolder, TransferCompleteAction.NAME); + + } + + public void then() + { + // 9. Verify Record1 + assertTrue(dispositionService.isNextDispositionActionEligible(record1)); + + } + }); + } +}