mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1345: Edit Disposition Date is not working for moved items
* behaviour now fires as expected so record folder data is updated correctly * general improvements to move record folder * addition and consolidation of move record folder integration tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@73870 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -666,7 +666,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
{
|
||||
// For every event create an entry on the action
|
||||
da.addEventCompletionDetails(event);
|
||||
// createEvent(event, dispositionActionNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -104,10 +104,12 @@ public class RecordCategoryType extends BaseBehaviourBean
|
||||
throw new AlfrescoRuntimeException("Operation failed, because you can't place content directly into a record category.");
|
||||
}
|
||||
|
||||
if (bNew)
|
||||
{
|
||||
// setup the record folder
|
||||
// TODO review
|
||||
recordFolderService.setupRecordFolder(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On transaction commit
|
||||
|
@@ -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,32 +135,21 @@ public class RecordFolderType extends BaseBehaviourBean
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
{
|
||||
// Remove unwanted aspects
|
||||
removeUnwantedAspects(nodeService, newNodeRef);
|
||||
// clean record folder
|
||||
cleanDisposableItem(nodeService, newNodeRef);
|
||||
|
||||
// reinitialise the record folder
|
||||
// re-initialise the record folder
|
||||
recordFolderService.setupRecordFolder(newNodeRef);
|
||||
|
||||
// reinitialise the record folder disposition action details
|
||||
dispositionService.refreshDispositionAction(newNodeRef);
|
||||
|
||||
// Sort out the child records
|
||||
// sort out the child records
|
||||
for (NodeRef record : recordService.getRecords(newNodeRef))
|
||||
{
|
||||
// Remove unwanted aspects
|
||||
removeUnwantedAspects(nodeService, record);
|
||||
// clean record
|
||||
cleanDisposableItem(nodeService, record);
|
||||
|
||||
// Re-initiate the records in the new folder.
|
||||
recordService.file(record);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -34,7 +34,6 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
RM1008Test.class,
|
||||
RM1027Test.class,
|
||||
RM1030Test.class,
|
||||
RM1039Test.class,
|
||||
RM1424Test.class,
|
||||
RM1429Test.class,
|
||||
RM1463Test.class,
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create a record category (no disposition schedule)
|
||||
return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
|
||||
}
|
||||
});
|
||||
|
||||
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create folder
|
||||
NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
|
||||
|
||||
// complete event
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -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()
|
||||
{;
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@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<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create a record category (no disposition schedule)
|
||||
return filePlanService.createRecordCategory(filePlan, "Caitlin Reed");
|
||||
}
|
||||
});
|
||||
|
||||
final NodeRef testFolder = doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef run()
|
||||
{
|
||||
// create folder
|
||||
NodeRef testFolder = recordFolderService.createRecordFolder(rmContainer, "Peter Edward Francis");
|
||||
|
||||
// complete event
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(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<QName, Serializable> adParams = new HashMap<QName, Serializable>(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;
|
||||
}
|
||||
}
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
{
|
||||
}
|
@@ -795,9 +795,16 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
* @param test
|
||||
*/
|
||||
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
|
||||
{
|
||||
try
|
||||
{
|
||||
test.run();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Behaviour driven test.
|
||||
@@ -807,6 +814,8 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
*/
|
||||
protected abstract class BehaviourDrivenTest
|
||||
{
|
||||
protected boolean runInTransactionTests = true;
|
||||
|
||||
protected Class<?> expectedException;
|
||||
|
||||
public BehaviourDrivenTest()
|
||||
@@ -818,17 +827,24 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
this.expectedException = expectedException;
|
||||
}
|
||||
|
||||
public void given() { /** empty implementation */ }
|
||||
public BehaviourDrivenTest(boolean runInTransactionTests)
|
||||
{
|
||||
this.runInTransactionTests = runInTransactionTests;
|
||||
}
|
||||
|
||||
public void when() { /** empty implementation */ }
|
||||
public void given() throws Exception { /** empty implementation */ }
|
||||
|
||||
public void then() { /** empty implementation */ }
|
||||
public void when() throws Exception { /** empty implementation */ }
|
||||
|
||||
public void after() { /** empty implementation */ }
|
||||
public void then() throws Exception { /** empty implementation */ }
|
||||
|
||||
public void run()
|
||||
public void after() throws Exception { /** empty implementation */ }
|
||||
|
||||
public void run() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
if (runInTransactionTests)
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@@ -838,8 +854,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
given();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
given();
|
||||
}
|
||||
|
||||
if (expectedException == null)
|
||||
{
|
||||
if (runInTransactionTests)
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@@ -860,6 +883,12 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
when();
|
||||
then();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doTestInTransaction(new FailureTest(expectedException)
|
||||
{
|
||||
@@ -872,6 +901,8 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (runInTransactionTests)
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@@ -882,6 +913,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
after();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user