diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java
index 7b71044cce..fae38b1c05 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java
@@ -666,7 +666,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
{
// For every event create an entry on the action
da.addEventCompletionDetails(event);
- // createEvent(event, dispositionActionNodeRef);
}
}
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java
index 30f11af6ff..db3dce550f 100644
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordCategoryType.java
@@ -104,9 +104,11 @@ public class RecordCategoryType extends BaseBehaviourBean
throw new AlfrescoRuntimeException("Operation failed, because you can't place content directly into a record category.");
}
- // setup the record folder
- // TODO review
- recordFolderService.setupRecordFolder(nodeRef);
+ if (bNew)
+ {
+ // setup the record folder
+ recordFolderService.setupRecordFolder(nodeRef);
+ }
}
/**
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
index f5cdd8dfab..69c50049a1 100755
--- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderType.java
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
@@ -134,33 +135,22 @@ public class RecordFolderType extends BaseBehaviourBean
{
public Object doWork()
{
- behaviourFilter.disableBehaviour();
- try
+ // clean record folder
+ cleanDisposableItem(nodeService, newNodeRef);
+
+ // re-initialise the record folder
+ recordFolderService.setupRecordFolder(newNodeRef);
+
+ // sort out the child records
+ for (NodeRef record : recordService.getRecords(newNodeRef))
{
- // Remove unwanted aspects
- removeUnwantedAspects(nodeService, newNodeRef);
+ // clean record
+ cleanDisposableItem(nodeService, record);
- // reinitialise the record folder
- recordFolderService.setupRecordFolder(newNodeRef);
-
- // reinitialise the record folder disposition action details
- dispositionService.refreshDispositionAction(newNodeRef);
-
- // Sort out the child records
- for (NodeRef record : recordService.getRecords(newNodeRef))
- {
- // Remove unwanted aspects
- removeUnwantedAspects(nodeService, record);
-
- // Re-initiate the records in the new folder.
- recordService.file(record);
- }
+ // Re-initiate the records in the new folder.
+ recordService.file(record);
}
- finally
- {
- behaviourFilter.enableBehaviour();
- }
-
+
return null;
}
}, AuthenticationUtil.getSystemUserName());
@@ -290,7 +280,7 @@ public class RecordFolderType extends BaseBehaviourBean
* @param nodeService
* @param nodeRef
*/
- private void removeUnwantedAspects(NodeService nodeService, NodeRef nodeRef)
+ private void cleanDisposableItem(NodeService nodeService, NodeRef nodeRef)
{
// Remove unwanted aspects
for (QName aspect : unwantedAspects)
@@ -300,5 +290,12 @@ public class RecordFolderType extends BaseBehaviourBean
nodeService.removeAspect(nodeRef, aspect);
}
}
+
+ // remove the current disposition action (if there is one)
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef);
+ if (dispositionAction != null)
+ {
+ nodeService.deleteNode(dispositionAction.getNodeRef());
+ }
}
}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java
index 08f6f2afb1..ce88a9bce4 100755
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/IntegrationTestSuite.java
@@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015Te
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
import org.alfresco.module.org_alfresco_module_rm.test.integration.record.RejectRecordTest;
+import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.RecordFolderTestSuite;
import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -43,7 +44,8 @@ import org.junit.runners.Suite.SuiteClasses;
EventTestSuite.class,
ReportTestSuite.class,
DispositionTestSuite.class,
- RejectRecordTest.class
+ RejectRecordTest.class,
+ RecordFolderTestSuite.class
})
public class IntegrationTestSuite
{
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 a5c3eb4f92..68c94d1e80 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
@@ -34,7 +34,6 @@ import org.junit.runners.Suite.SuiteClasses;
RM1008Test.class,
RM1027Test.class,
RM1030Test.class,
- RM1039Test.class,
RM1424Test.class,
RM1429Test.class,
RM1463Test.class,
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java
deleted file mode 100644
index 9162a98591..0000000000
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM1039Test.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.HashMap;
-import java.util.Map;
-
-import net.sf.acegisecurity.vote.AccessDecisionVoter;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
-import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
-import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
-import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
-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.cmr.security.AccessStatus;
-
-
-/**
- * Unit test for RM-1039 ... can't move a folder into a category with a disposition schedule
- *
- * @author Roy Wetherall
- * @since 2.1
- */
-public class RM1039Test extends BaseRMTestCase
-{
- @Override
- protected boolean isRecordTest()
- {
- return true;
- }
-
- // try and move a folder from no disposition schedule to a disposition schedule
- public void testMoveRecordFolderFromNoDisToDis() throws Exception
- {
- final NodeRef recordFolder = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record category (no disposition schedule)
- NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
-
- // create a record folder
- return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNull(dispositionService.getDispositionSchedule(result));
- assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
- assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
- }
- });
-
- final NodeRef record = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record
- return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNull(dispositionService.getDispositionSchedule(result));
- assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
- assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
- }
- });
-
- doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run() throws Exception
- {
- Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders");
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder));
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer));
-
- // take a look at the move capability
- Capability moveCapability = capabilityService.getCapability("Move");
- assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer));
-
- // move the node
- return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef();
- }
-
- @Override
- public void test(NodeRef result) throws Exception
- {
- assertNotNull(result);
- assertNotNull(dispositionService.getDispositionSchedule(result));
- assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
-
- DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result);
- assertNotNull(dispositionAction);
-
- assertNull(dispositionAction.getAsOfDate());
- assertEquals("cutoff", dispositionAction.getName());
- assertEquals(1, dispositionAction.getEventCompletionDetails().size());
-
- // take a look at the record and check things are as we would expect
- assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
- }
- });
- }
-
- // move from a disposition schedule to another .. both record folder level
-
- // move from a disposition schedule to another .. from record to folder level
-
-
- // try and move a cutoff folder
- public void testMoveCutoffRecordFolder() throws Exception
- {
- final NodeRef destination = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create a record category (no disposition schedule)
- return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
- }
- });
-
- final NodeRef testFolder = doTestInTransaction(new Test()
- {
- @Override
- public NodeRef run()
- {
- // create folder
- NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
-
- // complete event
- Map params = new HashMap(1);
- params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
- rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
-
- // cutoff folder
- rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
-
- // take a look at the move capability
- Capability moveCapability = capabilityService.getCapability("Move");
- assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination));
-
- return testFolder;
- }
- });
-
- doTestInTransaction(new FailureTest()
- {
- @Override
- public void run() throws Exception
- {
- fileFolderService.move(testFolder, destination, null).getNodeRef();
- }
- });
- }
-}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java
index 3bee784152..1d0e78f33a 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RejectRecordTest.java
@@ -64,7 +64,7 @@ public class RejectRecordTest extends BaseRMTestCase
/**
*
*/
- public void testRejectedRecordInCorrectState()
+ public void testRejectedRecordInCorrectState() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{
@@ -111,7 +111,7 @@ public class RejectRecordTest extends BaseRMTestCase
/**
*
*/
- public void testRevertAfterReject()
+ public void testRevertAfterReject() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest()
{;
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
new file mode 100644
index 0000000000..74791abb4b
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
@@ -0,0 +1,448 @@
+/*
+ * 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.recordfolder;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sf.acegisecurity.vote.AccessDecisionVoter;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
+import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
+import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
+import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
+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.cmr.security.AccessStatus;
+import org.alfresco.service.namespace.QName;
+import org.springframework.extensions.webscripts.GUID;
+
+/**
+ * Move record tests.
+ *
+ * @author Roy Wetherall
+ * @since 2.2
+ */
+public class MoveRecordFolderTest extends BaseRMTestCase
+{
+ @Override
+ protected boolean isRecordTest()
+ {
+ return true;
+ }
+
+ /**
+ * Given two categories, both with cut off immediately schedules, when the record is move
+ * then all the parts of the record should be correct based on the new schedule.
+ *
+ * @see https://issues.alfresco.com/jira/browse/RM-1345
+ */
+ public void testMoveRecordFolderBeforeCutOffFolderLevelDisposition() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest(false)
+ {
+ NodeRef recordFolder;
+ NodeRef destinationRecordCategory;
+
+ public void given()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ NodeRef rcOne = createRecordCategory(false);
+ destinationRecordCategory = createRecordCategory(false);
+ recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
+
+ // check for the lifecycle aspect
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
+ assertNotNull(dispositionAction);
+ assertNotNull(CutOffAction.NAME, dispositionAction.getName());
+ assertNotNull(dispositionAction.getAsOfDate());
+ assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
+ }
+ });
+
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check the search aspect properties
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
+ assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
+ assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
+ }
+ });
+ }
+
+ public void when() throws Exception
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // move record folder
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
+ }
+
+ public void then()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check for the lifecycle aspect
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
+ assertNotNull(dispositionAction);
+ assertNotNull(CutOffAction.NAME, dispositionAction.getName());
+ assertNotNull(dispositionAction.getAsOfDate());
+ assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
+
+ // check the search aspect properties
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
+ assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
+ assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ public void testMoveRecordFolderBeforeCutOffIntoAFolderWithNoDisposition() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest(false)
+ {
+ NodeRef recordFolder;
+ NodeRef destinationRecordCategory;
+
+ public void given()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ NodeRef rcOne = createRecordCategory(false);
+ destinationRecordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
+ recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
+
+ // check for the lifecycle aspect
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
+ assertNotNull(dispositionAction);
+ assertNotNull(CutOffAction.NAME, dispositionAction.getName());
+ assertNotNull(dispositionAction.getAsOfDate());
+ assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
+ }
+ });
+
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check the search aspect properties
+ assertTrue(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
+ assertEquals(CutOffAction.NAME, nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_NAME));
+ assertNotNull(nodeService.getProperty(recordFolder, PROP_RS_DISPOSITION_ACTION_AS_OF));
+ }
+ });
+ }
+
+ public void when() throws Exception
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // move record folder
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
+ }
+
+ public void then()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check for the lifecycle aspect
+ assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ assertNull(dispositionService.getNextDispositionAction(recordFolder));
+
+ // check the search aspect properties
+ assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception
+ {
+ doBehaviourDrivenTest(new BehaviourDrivenTest(false)
+ {
+ NodeRef record;
+ NodeRef recordFolder;
+ NodeRef destinationRecordCategory;
+
+ public void given()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ NodeRef rcOne = createRecordCategory(true);
+ destinationRecordCategory = createRecordCategory(true);
+ recordFolder = recordFolderService.createRecordFolder(rcOne, GUID.generate());
+ record = utils.createRecord(recordFolder, GUID.generate());
+
+ // check for the lifecycle aspect
+ assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+ assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ assertNull(dispositionService.getNextDispositionAction(recordFolder));
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
+ assertNotNull(dispositionAction);
+ assertNotNull(CutOffAction.NAME, dispositionAction.getName());
+ assertNotNull(dispositionAction.getAsOfDate());
+ assertTrue(dispositionService.isNextDispositionActionEligible(record));
+ }
+ });
+
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check the search aspect properties
+ assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
+ assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
+ assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
+ }
+ });
+ }
+
+ public void when() throws Exception
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // move record folder
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
+ }
+
+ public void then()
+ {
+ doTestInTransaction(new VoidTest()
+ {
+ public void runImpl() throws Exception
+ {
+ // check for the lifecycle aspect
+ assertFalse(nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE));
+ assertTrue(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
+
+ // check the disposition action details
+ assertNull(dispositionService.getNextDispositionAction(recordFolder));
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
+ assertNotNull(dispositionAction);
+ assertNotNull(CutOffAction.NAME, dispositionAction.getName());
+ assertNotNull(dispositionAction.getAsOfDate());
+ assertTrue(dispositionService.isNextDispositionActionEligible(record));
+
+ // check the search aspect properties
+ assertTrue(nodeService.hasAspect(record, ASPECT_RM_SEARCH));
+ assertEquals(CutOffAction.NAME, nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_NAME));
+ assertNotNull(nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF));
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Try and move a folder from no disposition schedule to a disposition schedule
+ *
+ * @see https://issues.alfresco.com/jira/browse/RM-1039
+ */
+ public void testMoveRecordFolderFromNoDisToDis() throws Exception
+ {
+ final NodeRef recordFolder = doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run()
+ {
+ // create a record category (no disposition schedule)
+ NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
+
+ // create a record folder
+ return recordFolderService.createRecordFolder(recordCategory, "Grace Wetherall");
+ }
+
+ @Override
+ public void test(NodeRef result) throws Exception
+ {
+ assertNotNull(result);
+ assertNull(dispositionService.getDispositionSchedule(result));
+ assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
+ assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
+ }
+ });
+
+ final NodeRef record = doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run()
+ {
+ // create a record
+ return fileFolderService.create(recordFolder, "mytest.txt", ContentModel.TYPE_CONTENT).getNodeRef();
+ }
+
+ @Override
+ public void test(NodeRef result) throws Exception
+ {
+ assertNotNull(result);
+ assertNull(dispositionService.getDispositionSchedule(result));
+ assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
+ assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
+ }
+ });
+
+ doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run() throws Exception
+ {
+ Capability capability = capabilityService.getCapability("CreateModifyDestroyFolders");
+ assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder));
+ assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(recordFolder, rmContainer));
+
+ // take a look at the move capability
+ Capability moveCapability = capabilityService.getCapability("Move");
+ assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(recordFolder, rmContainer));
+
+ // move the node
+ return fileFolderService.move(recordFolder, rmContainer, null).getNodeRef();
+ }
+
+ @Override
+ public void test(NodeRef result) throws Exception
+ {
+ assertNotNull(result);
+ assertNotNull(dispositionService.getDispositionSchedule(result));
+ assertTrue(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
+
+ DispositionAction dispositionAction = dispositionService.getNextDispositionAction(result);
+ assertNotNull(dispositionAction);
+
+ assertNull(dispositionAction.getAsOfDate());
+ assertEquals("cutoff", dispositionAction.getName());
+ assertEquals(1, dispositionAction.getEventCompletionDetails().size());
+
+ // take a look at the record and check things are as we would expect
+ assertFalse(nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE));
+ }
+ });
+ }
+
+
+ // try and move a cutoff folder
+ public void testMoveCutoffRecordFolder() throws Exception
+ {
+ final NodeRef destination = doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run()
+ {
+ // create a record category (no disposition schedule)
+ return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
+ }
+ });
+
+ final NodeRef testFolder = doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run()
+ {
+ // create folder
+ NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
+
+ // complete event
+ Map params = new HashMap(1);
+ params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
+ rmActionService.executeRecordsManagementAction(testFolder, CompleteEventAction.NAME, params);
+
+ // cutoff folder
+ rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
+
+ // take a look at the move capability
+ Capability moveCapability = capabilityService.getCapability("Move");
+ assertEquals(AccessDecisionVoter.ACCESS_DENIED, moveCapability.evaluate(testFolder, destination));
+
+ return testFolder;
+ }
+ });
+
+ doTestInTransaction(new FailureTest()
+ {
+ @Override
+ public void run() throws Exception
+ {
+ fileFolderService.move(testFolder, destination, null).getNodeRef();
+ }
+ });
+ }
+
+
+ private NodeRef createRecordCategory(boolean recordLevel)
+ {
+ NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
+ DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false);
+ Map adParams = new HashMap(3);
+ adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
+ adParams.put(PROP_DISPOSITION_DESCRIPTION, GUID.generate());
+ adParams.put(PROP_DISPOSITION_PERIOD, CommonRMTestUtils.PERIOD_IMMEDIATELY);
+ dispositionService.addDispositionActionDefinition(dis, adParams);
+ return rc;
+ }
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java
new file mode 100644
index 0000000000..0dd120ab7a
--- /dev/null
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/RecordFolderTestSuite.java
@@ -0,0 +1,39 @@
+/*
+ * 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.recordfolder;
+
+import org.alfresco.module.org_alfresco_module_rm.test.integration.recordfolder.MoveRecordFolderTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Record folder integration test suite
+ *
+ * @author Roy Wetherall
+ * @since 2.2
+ */
+@RunWith(Suite.class)
+@SuiteClasses(
+{
+ MoveRecordFolderTest.class
+})
+public class RecordFolderTestSuite
+{
+}
diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java
index 06394620ae..454a2f3deb 100644
--- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java
+++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java
@@ -796,7 +796,14 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
*/
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
{
- test.run();
+ try
+ {
+ test.run();
+ }
+ catch (Exception exception)
+ {
+ throw new RuntimeException(exception);
+ }
}
/**
@@ -807,6 +814,8 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
*/
protected abstract class BehaviourDrivenTest
{
+ protected boolean runInTransactionTests = true;
+
protected Class> expectedException;
public BehaviourDrivenTest()
@@ -817,47 +826,67 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
{
this.expectedException = expectedException;
}
+
+ public BehaviourDrivenTest(boolean runInTransactionTests)
+ {
+ this.runInTransactionTests = runInTransactionTests;
+ }
- public void given() { /** empty implementation */ }
+ public void given() throws Exception { /** empty implementation */ }
- public void when() { /** empty implementation */ }
+ public void when() throws Exception { /** empty implementation */ }
- public void then() { /** empty implementation */ }
+ public void then() throws Exception { /** empty implementation */ }
- public void after() { /** empty implementation */ }
+ public void after() throws Exception { /** empty implementation */ }
- public void run()
+ public void run() throws Exception
{
try
{
- doTestInTransaction(new VoidTest()
+ if (runInTransactionTests)
{
- @Override
- public void runImpl() throws Exception
+ doTestInTransaction(new VoidTest()
{
- given();
- }
- });
+ @Override
+ public void runImpl() throws Exception
+ {
+ given();
+ }
+ });
+ }
+ else
+ {
+ given();
+ }
if (expectedException == null)
{
- doTestInTransaction(new VoidTest()
+ if (runInTransactionTests)
{
- @Override
- public void runImpl() throws Exception
+ doTestInTransaction(new VoidTest()
{
- when();
- }
- });
-
- doTestInTransaction(new VoidTest()
+ @Override
+ public void runImpl() throws Exception
+ {
+ when();
+ }
+ });
+
+ doTestInTransaction(new VoidTest()
+ {
+ @Override
+ public void runImpl() throws Exception
+ {
+ then();
+ }
+ });
+ }
+ else
{
- @Override
- public void runImpl() throws Exception
- {
- then();
- }
- });
+ when();
+ then();
+ }
}
else
{
@@ -873,14 +902,21 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
}
finally
{
- doTestInTransaction(new VoidTest()
+ if (runInTransactionTests)
{
- @Override
- public void runImpl() throws Exception
+ doTestInTransaction(new VoidTest()
{
- after();
- }
- });
+ @Override
+ public void runImpl() throws Exception
+ {
+ after();
+ }
+ });
+ }
+ else
+ {
+ after();
+ }
}
}
}