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
This commit is contained in:
Roy Wetherall
2011-01-19 20:07:26 +00:00
parent 8c500a3cd8
commit 46c89b3789
3 changed files with 46 additions and 7 deletions

View File

@@ -1218,6 +1218,9 @@
<property name="versionService">
<ref bean="versionService" />
</property>
<property name="ruleService">
<ref bean="ruleService" />
</property>
<property name="lockService">
<ref bean="LockService" />
</property>

View File

@@ -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<QName, Serializable> workingCopyProperties = new HashMap<QName, Serializable>(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<QName, Serializable> workingCopyProperties = new HashMap<QName, Serializable>(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);

View File

@@ -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();
}
}