(1);
- props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK, Boolean.FALSE);
+ props.put(RMDispositionActionExecuterAbstractBase.PARAM_NO_ERROR_CHECK,
+ Boolean.FALSE);
try
{
// execute disposition action
- recordsManagementActionService.executeRecordsManagementAction(parent.getParentRef(), dispAction, props);
+ recordsManagementActionService.executeRecordsManagementAction(
+ parent.getParentRef(), dispAction, props);
if (logger.isDebugEnabled())
{
@@ -236,4 +240,14 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
}
}
}
+
+ public AuthenticationService getAuthenticationService()
+ {
+ return authenticationService;
+ }
+
+ public void setAuthenticationService(AuthenticationService authenticationService)
+ {
+ this.authenticationService = authenticationService;
+ }
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java
index 409a0f0d32..a1dc0c3a65 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/RecordsManagementJob.java
@@ -46,8 +46,7 @@ import org.quartz.JobExecutionException;
/**
* Base records management job implementation.
*
- * Delegates job execution and ensures locking
- * is enforced.
+ * Delegates job execution and ensures locking is enforced.
*
* @author Roy Wetherall
*/
@@ -55,11 +54,14 @@ public class RecordsManagementJob implements Job
{
private static Log logger = LogFactory.getLog(RecordsManagementJob.class);
+ /** which user should be used to log audit */
+ private String runAuditAs = AuthenticationUtil.getSystemUserName();
+
private static final long DEFAULT_TIME = 30000L;
private JobLockService jobLockService;
- private RecordsManagementJobExecuter jobExecuter;
+ private RecordsManagementJobExecuter jobExecuter = null;
private String jobName;
@@ -67,17 +69,17 @@ public class RecordsManagementJob implements Job
{
return QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, jobName);
}
-
+
private class LockCallback implements JobLockRefreshCallback
{
final AtomicBoolean running = new AtomicBoolean(true);
-
+
@Override
public boolean isActive()
{
return running.get();
}
-
+
@Override
public void lockReleased()
{
@@ -85,11 +87,10 @@ public class RecordsManagementJob implements Job
}
}
-
/**
- * Attempts to get the lock. If the lock couldn't be taken, then null is returned.
+ * Attempts to get the lock. If the lock couldn't be taken, then null is returned.
*
- * @return Returns the lock token or null
+ * @return Returns the lock token or null
*/
private String getLock()
{
@@ -103,31 +104,54 @@ public class RecordsManagementJob implements Job
}
}
- @Override
+ /**
+ * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
+ */
public void execute(JobExecutionContext context) throws JobExecutionException
{
+
// get the job lock service
- jobLockService = (JobLockService)context.getJobDetail().getJobDataMap().get("jobLockService");
- if (jobLockService == null)
- {
- throw new AlfrescoRuntimeException("Job lock service has not been specified.");
- }
+ jobLockService = (JobLockService) context.getJobDetail().getJobDataMap().get("jobLockService");
+ if (jobLockService == null) { throw new AlfrescoRuntimeException("Job lock service has not been specified."); }
// get the job executer
- jobExecuter = (RecordsManagementJobExecuter)context.getJobDetail().getJobDataMap().get("jobExecuter");
- if (jobExecuter == null)
- {
- throw new AlfrescoRuntimeException("Job executer has not been specified.");
- }
+ jobExecuter = (RecordsManagementJobExecuter) context.getJobDetail().getJobDataMap().get("jobExecuter");
+ if (jobExecuter == null) { throw new AlfrescoRuntimeException("Job executer has not been specified."); }
// get the job name
- jobName = (String)context.getJobDetail().getJobDataMap().get("jobName");
- if (jobName == null)
+ jobName = (String) context.getJobDetail().getJobDataMap().get("jobName");
+
+ if (jobName == null) { throw new AlfrescoRuntimeException("Job name has not been specified."); }
+
+ if (jobName.compareTo("dispositionLifecycle") == 0)
{
- throw new AlfrescoRuntimeException("Job name has not been specified.");
+ //RM-3293 - set user for audit
+ if (jobExecuter instanceof DispositionLifecycleJobExecuter)
+ {
+ String auditUser = (String) context.getJobDetail().getJobDataMap().get("runAuditAs");
+ if (((DispositionLifecycleJobExecuter) jobExecuter).getAuthenticationService()
+ .authenticationExists(auditUser))
+ {
+
+ setRunAuditAs(auditUser);
+ }
+ else
+ {
+ setRunAuditAs(AuthenticationUtil.getSystemUserName());
+ }
+
+ }
+
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("DispositionLifecycleJobExecuter() logged audit history with user: " + getRunAuditAs());
+
+ }
+
}
final LockCallback lockCallback = new LockCallback();
+
AuthenticationUtil.runAs(new RunAsWork()
{
public Void doWork()
@@ -154,7 +178,8 @@ public class RecordsManagementJob implements Job
// Ignore
if (logger.isDebugEnabled())
{
- logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "(" + e.getMessage() + ")");
+ logger.debug("Lock release failed: " + getLockQName() + ": " + lockToken + "("
+ + e.getMessage() + ")");
}
}
}
@@ -163,6 +188,18 @@ public class RecordsManagementJob implements Job
// return
return null;
}
- }, AuthenticationUtil.getSystemUserName());
+ }, getRunAuditAs());
}
+
+ public String getRunAuditAs()
+ {
+ return runAuditAs;
+ }
+
+ public void setRunAuditAs(String runAuditAs)
+ {
+
+ this.runAuditAs = runAuditAs;
+ }
+
}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java
new file mode 100644
index 0000000000..e924d66670
--- /dev/null
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314Test.java
@@ -0,0 +1,80 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * 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 .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+
+/**
+ * Test for https://issues.alfresco.com/jira/browse/RM-3114
+ *
+ * @author Roy Wetherall
+ * @since 2.2.1.5
+ */
+public class RM3314Test extends BaseRMTestCase
+{
+ /** Application context */
+ protected String[] getConfigLocations()
+ {
+ return new String[]
+ {
+ "classpath:alfresco/application-context.xml",
+ "classpath:test-context.xml",
+ "classpath:test-rm3314-context.xml"
+ };
+ }
+
+ /** registry to record callback from test beans "test.rm3114.1" and "test.rm3114.2" */
+ public static Map callback = new HashMap(2);
+
+ /**
+ * Given that the custom model hasn't been initialised
+ * When an aspect is added
+ * Then nothing happens
+ *
+ * Given that the custom model has been initialised
+ * When an aspect is added
+ * Then something happens
+ */
+ public void testListenersExecutedInTheCorrectOrder()
+ {
+ /**
+ * The related test beans will call back into the callback map showing
+ * whether at the end of their execution whether the custom model has been
+ * initialised or not. Given the order in which these test beans are executed
+ * on spring context load, we would expect that .1 executes with the custom
+ * map unloaded, and the .2 with it loaded.
+ */
+
+ assertFalse(callback.isEmpty());
+ assertFalse(callback.get("test.rm3314.1"));
+ assertTrue(callback.get("test.rm3314.2"));
+ }
+}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java
new file mode 100644
index 0000000000..d54d6f585c
--- /dev/null
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/rm3314/RM3314TestListener.java
@@ -0,0 +1,147 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * 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 .
+ * #L%
+ */
+
+package org.alfresco.module.org_alfresco_module_rm.test.integration.issue.rm3314;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminServiceImpl;
+import org.alfresco.repo.model.Repository;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.core.Ordered;
+import org.springframework.jdbc.BadSqlGrammarException;
+
+/**
+ * Simple bean used to test RM-3314
+ *
+ * @author rwetherall
+ * @since 2.2.1.5
+ */
+public class RM3314TestListener implements ApplicationListener,
+ Ordered,
+ BeanNameAware
+{
+ private RecordsManagementAdminServiceImpl recordsManagementAdminService;
+ private NodeService nodeService;
+ private FileFolderService fileFolderService;
+ private Repository repository;
+
+ private String name;
+ private int order = Ordered.LOWEST_PRECEDENCE;
+
+ public void setRecordsManagementAdminService(RecordsManagementAdminServiceImpl recordsManagementAdminService)
+ {
+ this.recordsManagementAdminService = recordsManagementAdminService;
+ }
+
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ public void setFileFolderService(FileFolderService fileFolderService)
+ {
+ this.fileFolderService = fileFolderService;
+ }
+
+ public void setRepository(Repository repository)
+ {
+ this.repository = repository;
+ }
+
+ @Override
+ public void setBeanName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setOrder(int order)
+ {
+ this.order = order;
+ }
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent event)
+ {
+ // call back to show whether the custom map is initialised or not
+ RM3314Test.callback.put(name, recordsManagementAdminService.isCustomMapInit());
+
+ // Do some work on a node to show that reguardless of whether the custom map is
+ // init or not, things still work.
+ // Note: using public services to ensure new transaction for each service call
+ AuthenticationUtil.runAsSystem(new RunAsWork()
+ {
+ public Void doWork() throws Exception
+ {
+ try
+ {
+ NodeRef companyHome = repository.getCompanyHome();
+
+ if (fileFolderService.searchSimple(companyHome, name) == null)
+ {
+ // create node
+ NodeRef folder = fileFolderService.create(
+ repository.getCompanyHome(),
+ name,
+ ContentModel.TYPE_FOLDER).getNodeRef();
+ try
+ {
+ // add aspect
+ nodeService.addAspect(folder, ContentModel.ASPECT_CLASSIFIABLE, null);
+
+ // remove aspect
+ nodeService.removeAspect(folder, ContentModel.ASPECT_CLASSIFIABLE);
+ }
+ finally
+ {
+ // delete node
+ nodeService.deleteNode(folder);
+ }
+ }
+ }
+ catch (BadSqlGrammarException e)
+ {
+ // ignore and carry on
+ }
+
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public int getOrder()
+ {
+ return order;
+ }
+}
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
index 0d35057d2f..b359887c37 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/recordfolder/MoveRecordFolderTest.java
@@ -34,6 +34,7 @@ import java.util.Map;
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.action.impl.DestroyAction;
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;
@@ -48,31 +49,31 @@ import net.sf.acegisecurity.vote.AccessDecisionVoter;
/**
* Move record folder 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.
- *
+ * 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(null, false)
- {
- NodeRef recordFolder;
+ {
+ NodeRef recordFolder;
NodeRef destinationRecordCategory;
-
+
public void given()
{
doTestInTransaction(new VoidTest()
@@ -82,43 +83,44 @@ public class MoveRecordFolderTest extends BaseRMTestCase
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));
+ 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());
- }
- });
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
}
-
+
public void then()
{
doTestInTransaction(new VoidTest()
@@ -127,34 +129,35 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
// 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));
+
+ // 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(null, false)
- {
- NodeRef recordFolder;
+ {
+ NodeRef recordFolder;
NodeRef destinationRecordCategory;
-
+
public void given()
{
doTestInTransaction(new VoidTest()
@@ -164,43 +167,44 @@ public class MoveRecordFolderTest extends BaseRMTestCase
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));
+ 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());
- }
- });
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
}
-
+
public void then()
{
doTestInTransaction(new VoidTest()
@@ -209,29 +213,29 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
// 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));
+
+ // check the search aspect properties
+ assertFalse(nodeService.hasAspect(recordFolder, ASPECT_RM_SEARCH));
}
- });
+ });
}
- });
+ });
}
-
+
/**
- *
+ *
*/
public void testMoveRecordFolderWithRecordsBeforeCutOffRecordLevelDisposition() throws Exception
{
doBehaviourDrivenTest(new BehaviourDrivenTest(null, false)
- {
- NodeRef record;
+ {
+ NodeRef record;
NodeRef recordFolder;
NodeRef destinationRecordCategory;
-
+
public void given()
{
doTestInTransaction(new VoidTest()
@@ -242,11 +246,11 @@ public class MoveRecordFolderTest extends BaseRMTestCase
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);
@@ -254,33 +258,34 @@ public class MoveRecordFolderTest extends BaseRMTestCase
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));
+ 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());
- }
- });
+ fileFolderService.move(recordFolder, destinationRecordCategory, GUID.generate());
+ }
+ });
}
-
+
public void then()
{
doTestInTransaction(new VoidTest()
@@ -290,7 +295,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
// 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);
@@ -298,20 +303,21 @@ public class MoveRecordFolderTest extends BaseRMTestCase
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));
+
+ // 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
@@ -333,7 +339,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
{
assertNotNull(result);
assertNull(dispositionService.getDispositionSchedule(result));
- assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
+ assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
}
});
@@ -394,7 +400,6 @@ public class MoveRecordFolderTest extends BaseRMTestCase
});
}
-
// try and move a cutoff folder
public void testMoveCutoffRecordFolder() throws Exception
{
@@ -426,7 +431,7 @@ public class MoveRecordFolderTest extends BaseRMTestCase
return testFolder;
}
-
+
@Override
public void test(NodeRef testFolder) throws Exception
{
@@ -446,11 +451,66 @@ public class MoveRecordFolderTest extends BaseRMTestCase
});
}
-
+ // try and move a destroyed folder
+ public void testMoveDestroyedRecordFolder() 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 & destroy folder
+ rmActionService.executeRecordsManagementAction(testFolder, CutOffAction.NAME);
+ rmActionService.executeRecordsManagementAction(testFolder, DestroyAction.NAME);
+
+ return testFolder;
+ }
+
+ });
+
+ doTestInTransaction(new Test()
+ {
+ @Override
+ public NodeRef run() throws Exception
+ {
+ Capability moveCapability = capabilityService.getCapability("MoveRecordFolder");
+ assertEquals(AccessDecisionVoter.ACCESS_GRANTED, moveCapability.evaluate(testFolder, destination));
+
+ return fileFolderService.move(testFolder, destination, null).getNodeRef();
+ }
+
+ @Override
+ public void test(NodeRef result) throws Exception
+ {
+ assertNotNull(result);
+ }
+ });
+
+ }
+
private NodeRef createRecordCategory(boolean recordLevel)
{
NodeRef rc = filePlanService.createRecordCategory(filePlan, GUID.generate());
- DispositionSchedule dis = utils.createBasicDispositionSchedule(rc, GUID.generate(), GUID.generate(), recordLevel, false);
+ 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());
diff --git a/rm-community/rm-community-repo/test/resources/test-context.xml b/rm-community/rm-community-repo/test/resources/test-context.xml
index f00d3e56b6..1035796f12 100644
--- a/rm-community/rm-community-repo/test/resources/test-context.xml
+++ b/rm-community/rm-community-repo/test/resources/test-context.xml
@@ -4,7 +4,7 @@
-
+
test-model.xml
@@ -245,5 +245,5 @@
-
+
\ No newline at end of file
diff --git a/rm-community/rm-community-repo/test/resources/test-rm3314-context.xml b/rm-community/rm-community-repo/test/resources/test-rm3314-context.xml
new file mode 100644
index 0000000000..5b72399d04
--- /dev/null
+++ b/rm-community/rm-community-repo/test/resources/test-rm3314-context.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file