From 46c89b378923a0bfb471d88ab18e47118bc9c884 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 19 Jan 2011 20:07:26 +0000 Subject: [PATCH] Merged V34 to HEAD: Merged V33 to V34: 24440: ALF-6114: Rules for updated items are triggered before users commit any changes. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@24938 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/core-services-context.xml | 3 ++ .../repo/coci/CheckOutCheckInServiceImpl.java | 34 +++++++++++++++---- .../alfresco/repo/jscript/ScriptUtils.java | 16 +++++++++ 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 5351d54630..3a2a8b77e4 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -1218,6 +1218,9 @@ + + + diff --git a/source/java/org/alfresco/repo/coci/CheckOutCheckInServiceImpl.java b/source/java/org/alfresco/repo/coci/CheckOutCheckInServiceImpl.java index 9a37642150..15b828822e 100644 --- a/source/java/org/alfresco/repo/coci/CheckOutCheckInServiceImpl.java +++ b/source/java/org/alfresco/repo/coci/CheckOutCheckInServiceImpl.java @@ -52,6 +52,7 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.CopyService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.security.AuthenticationService; @@ -129,6 +130,9 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService */ private AuthenticationService authenticationService; + /** Rule service */ + private RuleService ruleService; + /** * The versionable aspect behaviour implementation */ @@ -223,6 +227,14 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService this.policyComponent = policyComponent; } + /** + * @param ruleService rule service + */ + public void setRuleService(RuleService ruleService) + { + this.ruleService = ruleService; + } + /** * Initialise method */ @@ -432,17 +444,25 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService } }, AuthenticationUtil.getSystemUserName()); - // Update the working copy name - this.nodeService.setProperty(workingCopy, ContentModel.PROP_NAME, copyName); + ruleService.disableRules(); + try + { + // Update the working copy name + this.nodeService.setProperty(workingCopy, ContentModel.PROP_NAME, copyName); + + // Apply the working copy aspect to the working copy + Map workingCopyProperties = new HashMap(1); + workingCopyProperties.put(ContentModel.PROP_WORKING_COPY_OWNER, userName); + this.nodeService.addAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY, workingCopyProperties); + } + finally + { + ruleService.enableRules(); + } // Get the user String userName = getUserName(); - // Apply the working copy aspect to the working copy - Map workingCopyProperties = new HashMap(1); - workingCopyProperties.put(ContentModel.PROP_WORKING_COPY_OWNER, userName); - this.nodeService.addAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY, workingCopyProperties); - // Lock the original node this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK); diff --git a/source/java/org/alfresco/repo/jscript/ScriptUtils.java b/source/java/org/alfresco/repo/jscript/ScriptUtils.java index 8ed2059722..e3357ae46d 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptUtils.java +++ b/source/java/org/alfresco/repo/jscript/ScriptUtils.java @@ -199,4 +199,20 @@ public final class ScriptUtils extends BaseScopableProcessorExtension { return I18NUtil.getMessage(messageId, params); } + + /** + * Disable rule execution for this thread + */ + public void disableRules() + { + services.getRuleService().disableRules(); + } + + /** + * Enable rule execution for this thread + */ + public void enableRules() + { + services.getRuleService().enableRules(); + } }