diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 6a00b13c76..3e2907907c 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -132,6 +132,11 @@ wiremock 1.56 + + org.mockito + mockito-all + test + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java index ee60e787ad..01982b6665 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java @@ -168,8 +168,9 @@ public class ContentDestructionComponent // We want to remove the rn:renditioned aspect, but due to the possibility // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect // applied, we must consider removing it too. - if (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || - getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) + if (includeRenditions + && (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) + || getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED))) { // get the rendition assoc types Set childAssocTypes = dictionaryService.getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet(); @@ -179,6 +180,9 @@ public class ContentDestructionComponent { // destroy renditions content destroyContent(child.getChildRef(), false); + + //delete the rendition node + getNodeService().deleteNode(child.getChildRef()); } } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java index 94ada57f76..665c95910b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuter.java @@ -108,7 +108,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute * * @return job query string */ - private String getQuery() + protected String getQuery() { if (query == null) { @@ -133,8 +133,8 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute } sb.append("))"); - sb.append(" AND ISNULL:\"rma:dispositionActionCompletedAt\" "); - sb.append(" + ( "); + sb.append(" AND ISUNSET:\"rma:dispositionActionCompletedAt\" "); + sb.append(" AND ( "); sb.append("@rma\\:dispositionEventsEligible:true "); sb.append("OR @rma\\:dispositionAsOf:[MIN TO NOW] "); sb.append(") "); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java index db0fd4d67e..b53b82e9dc 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/repo/rule/ExtendedRuleServiceImpl.java @@ -228,24 +228,33 @@ public class ExtendedRuleServiceImpl extends RuleServiceImpl * @param typeQName * @return */ - private boolean shouldRuleBeAppliedToNode(Rule rule, NodeRef nodeRef, QName typeQName) + private boolean shouldRuleBeAppliedToNode(final Rule rule, final NodeRef nodeRef, final QName typeQName) { - boolean result = true; - NodeRef ruleNodeRef = getOwningNodeRef(rule); - if(filePlanService.isFilePlan(ruleNodeRef)) + return AuthenticationUtil.runAsSystem(new RunAsWork() { - // if this rule is defined at the root of the file plan then we do not want to apply - // it to holds/transfers/unfiled content... - result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) || - RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) || - RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER.equals(typeQName) || - RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_TRANSFERRING) || - nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) || - !recordService.isFiled(nodeRef)); - } - return result; + public Boolean doWork() throws Exception + { + boolean result = true; + NodeRef ruleNodeRef = getOwningNodeRef(rule); + if (filePlanService.isFilePlan(ruleNodeRef)) + { + // if this rule is defined at the root of the file plan then + // we do not want to apply + // it to holds/transfers/unfiled content... + result = !(RecordsManagementModel.TYPE_HOLD.equals(typeQName) + || RecordsManagementModel.TYPE_HOLD_CONTAINER.equals(typeQName) + || RecordsManagementModel.TYPE_TRANSFER.equals(typeQName) + || RecordsManagementModel.TYPE_TRANSFER_CONTAINER.equals(typeQName) + || RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER + .equals(typeQName) + || RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER.equals(typeQName) + || nodeService.hasAspect(nodeRef, + RecordsManagementModel.ASPECT_TRANSFERRING) + || nodeService.hasAspect(nodeRef, RecordsManagementModel.ASPECT_FROZEN) + || !recordService.isFiled(nodeRef)); + } + return result; + } + }); } } diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java index ccfd819a75..595737024b 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/job/DispositionLifecycleJobExecuterUnitTest.java @@ -19,6 +19,7 @@ package org.alfresco.module.org_alfresco_module_rm.job; import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateQName; +import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyMap; import static org.mockito.Matchers.anyString; @@ -229,4 +230,17 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest // ensure no more interactions verifyNoMoreInteractions(mockedNodeService, mockedRecordsManagementActionService); } + + /** + * Brittle unit test that simply checks the generated query is an exact string when the supplied disposition actions + * are "CUTOFF" and "RETAIN" (see {@link #before}). + */ + @Test + public void testGetQuery() + { + String actual = executer.getQuery(); + + String expected = "TYPE:\"rma:dispositionAction\" + (@rma\\:dispositionAction:(\"cutoff\" OR \"retain\")) AND ISUNSET:\"rma:dispositionActionCompletedAt\" AND ( @rma\\:dispositionEventsEligible:true OR @rma\\:dispositionAsOf:[MIN TO NOW] ) "; + assertEquals(expected, actual); + } }