diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 76a80080bd..b218ff1e2f 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -2937,6 +2937,8 @@ + + diff --git a/source/java/org/alfresco/repo/admin/patch/impl/CopiedFromAspectPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/CopiedFromAspectPatch.java index 09500940ec..765dcb0368 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/CopiedFromAspectPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/CopiedFromAspectPatch.java @@ -40,10 +40,12 @@ import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeDAO.NodeRefQueryCallback; import org.alfresco.repo.domain.patch.PatchDAO; +import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; +import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; @@ -87,6 +89,8 @@ public class CopiedFromAspectPatch extends AbstractPatch private PatchDAO patchDAO; private NodeDAO nodeDAO; private DictionaryService dictionaryService; + private BehaviourFilter behaviourFilter; + private RuleService ruleService; private int batchThreads = 2; private int batchSize = 1000; @@ -123,6 +127,22 @@ public class CopiedFromAspectPatch extends AbstractPatch this.dictionaryService = dictionaryService; } + /** + * @param behaviourFilter used to switch off cm:auditable behaviour + */ + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + /** + * @param ruleService used to disable rules + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + /** * @param batchThreads the number of threads that will write child association changes */ @@ -235,12 +255,25 @@ public class CopiedFromAspectPatch extends AbstractPatch @Override public void beforeProcess() throws Throwable { + // Run as the correct user AuthenticationUtil.setRunAsUser(user); } @Override public void process(Pair entry) throws Throwable { - CopiedFromAspectPatch.this.process(file, entry); + // Disable auditable aspect + behaviourFilter.disableAllBehaviours(); + // Disable rules + ruleService.disableRules(); + try + { + CopiedFromAspectPatch.this.process(file, entry); + } + finally + { + ruleService.enableRules(); + behaviourFilter.enableAllBehaviours(); + } } @Override public void afterProcess() throws Throwable