Merged V1.3 to HEAD (3247:3249, 3250:3280, 3281:3324)

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3247 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3249 .
   svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3250 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3280 .
   svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3281 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3324 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3411 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-07-26 11:19:55 +00:00
parent 6168aac2cc
commit dcb735c5e3
10 changed files with 208 additions and 49 deletions

View File

@@ -21,7 +21,9 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.alfresco.repo.rule.RuleServiceImpl;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionServiceException; import org.alfresco.service.cmr.action.ActionServiceException;
@@ -105,11 +107,14 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
* org.alfresco.service.cmr.action.Action, boolean, * org.alfresco.service.cmr.action.Action, boolean,
* org.alfresco.service.cmr.repository.NodeRef) * org.alfresco.service.cmr.repository.NodeRef)
*/ */
@SuppressWarnings("unchecked")
public void executeAction(RuntimeActionService actionService, Action action, NodeRef actionedUponNodeRef, public void executeAction(RuntimeActionService actionService, Action action, NodeRef actionedUponNodeRef,
boolean checkConditions, Set<String> actionChain, NodeRef actionExecutionHistoryNodeRef) boolean checkConditions, Set<String> actionChain, NodeRef actionExecutionHistoryNodeRef)
{ {
Set<RuleServiceImpl.ExecutedRuleData> executedRules =
(Set<RuleServiceImpl.ExecutedRuleData>) AlfrescoTransactionSupport.getResource("RuleServiceImpl.ExecutedRules");
execute(new ActionExecutionWrapper(actionService, transactionService, authenticationComponent, action, execute(new ActionExecutionWrapper(actionService, transactionService, authenticationComponent, action,
actionedUponNodeRef, checkConditions, actionExecutionHistoryNodeRef, actionChain)); actionedUponNodeRef, checkConditions, actionExecutionHistoryNodeRef, actionChain, executedRules));
} }
/** /**
@@ -177,6 +182,11 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
*/ */
private Set<String> actionChain; private Set<String> actionChain;
/**
* List of executed list, helps to prevent loop scenarios with async rules
*/
private Set<RuleServiceImpl.ExecutedRuleData> executedRules;
/** /**
* Constructor * Constructor
* *
@@ -190,7 +200,7 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
*/ */
public ActionExecutionWrapper(RuntimeActionService actionService, TransactionService transactionService, public ActionExecutionWrapper(RuntimeActionService actionService, TransactionService transactionService,
AuthenticationComponent authenticationComponent, Action action, NodeRef actionedUponNodeRef, AuthenticationComponent authenticationComponent, Action action, NodeRef actionedUponNodeRef,
boolean checkConditions, NodeRef actionExecutionHistoryNodeRef, Set<String> actionChain) boolean checkConditions, NodeRef actionExecutionHistoryNodeRef, Set<String> actionChain, Set<RuleServiceImpl.ExecutedRuleData> executedRules)
{ {
this.actionService = actionService; this.actionService = actionService;
this.transactionService = transactionService; this.transactionService = transactionService;
@@ -200,6 +210,7 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
this.checkConditions = checkConditions; this.checkConditions = checkConditions;
this.actionExecutionHistoryNodeRef = actionExecutionHistoryNodeRef; this.actionExecutionHistoryNodeRef = actionExecutionHistoryNodeRef;
this.actionChain = actionChain; this.actionChain = actionChain;
this.executedRules = executedRules;
} }
/** /**
@@ -277,6 +288,11 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
{ {
public Object doWork() public Object doWork()
{ {
if (ActionExecutionWrapper.this.executedRules != null)
{
AlfrescoTransactionSupport.bindResource("RuleServiceImpl.ExecutedRules", ActionExecutionWrapper.this.executedRules);
}
ActionExecutionWrapper.this.actionService.executeActionImpl( ActionExecutionWrapper.this.actionService.executeActionImpl(
ActionExecutionWrapper.this.action, ActionExecutionWrapper.this.action,
ActionExecutionWrapper.this.actionedUponNodeRef, ActionExecutionWrapper.this.actionedUponNodeRef,

View File

@@ -216,7 +216,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
{ {
if (personService.personExists(userAuth) == true) if (personService.personExists(userAuth) == true)
{ {
NodeRef person = personService.getPerson(authority); NodeRef person = personService.getPerson(userAuth);
String address = (String)nodeService.getProperty(person, ContentModel.PROP_EMAIL); String address = (String)nodeService.getProperty(person, ContentModel.PROP_EMAIL);
if (address != null && address.length() != 0) if (address != null && address.length() != 0)
{ {

View File

@@ -307,9 +307,9 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true) if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
{ {
// Disable versionable behaviours since we don't want the auto version policy behaviour to execute when we check-in // Disable versionable behaviours since we don't want the auto version policy behaviour to execute when we check-in
this.versionableAspect.disableAutoVersion(); //this.versionableAspect.disableAutoVersion();
try //try
{ //{
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef); Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
// Try and get the original node reference // Try and get the original node reference
nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE); nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
@@ -371,11 +371,11 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
// Re-lock the original node // Re-lock the original node
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK); this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
} }
} //}
finally //finally
{ //{
this.versionableAspect.enableAutoVersion(); // this.versionableAspect.enableAutoVersion();
} //}
} }
else else

View File

@@ -43,8 +43,8 @@
name="accessControlList" name="accessControlList"
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl" class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"
column="acl_id" column="acl_id"
lazy="false" lazy="proxy"
fetch="join" fetch="select"
unique="false" unique="false"
not-null="false" not-null="false"
cascade="delete" /> cascade="delete" />

View File

@@ -1547,4 +1547,90 @@ public class RuleServiceCoverageTest extends TestCase
throw new RuntimeException(exception); throw new RuntimeException(exception);
} }
} }
public void testAsyncExecutionWithPotentialLoop()
{
if (this.transformerRegistry.getTransformer(MimetypeMap.MIMETYPE_EXCEL, MimetypeMap.MIMETYPE_TEXT_PLAIN) != null)
{
try
{
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(TransformActionExecuter.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_TEXT_PLAIN);
params.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, this.nodeRef);
params.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME, ContentModel.ASSOC_CONTAINS);
params.put(TransformActionExecuter.PARAM_ASSOC_QNAME, QName.createQName(TEST_NAMESPACE, "transformed"));
Rule rule = createRule(
RuleType.INBOUND,
TransformActionExecuter.NAME,
params,
NoConditionEvaluator.NAME,
null);
rule.setExecuteAsynchronously(true);
rule.setTitle("Transform document to text");
UserTransaction tx0 = transactionService.getUserTransaction();
tx0.begin();
this.ruleService.saveRule(this.nodeRef, rule);
tx0.commit();
UserTransaction tx = transactionService.getUserTransaction();
tx.begin();
Map<QName, Serializable> props =new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_NAME, "test.xls");
// Create the node at the root
NodeRef newNodeRef = this.nodeService.createNode(
this.nodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(TEST_NAMESPACE, "origional"),
ContentModel.TYPE_CONTENT,
props).getChildRef();
// Set some content on the origional
ContentWriter contentWriter = this.contentService.getWriter(newNodeRef, ContentModel.PROP_CONTENT, true);
contentWriter.setMimetype(MimetypeMap.MIMETYPE_EXCEL);
File testFile = AbstractContentTransformerTest.loadQuickTestFile("xls");
contentWriter.putContent(testFile);
tx.commit();
Thread.sleep(10000);
//System.out.println(NodeStoreInspector.dumpNodeStore(this.nodeService, this.testStoreRef));
//AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
//authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
// Check that the created node is still there
//List<ChildAssociationRef> origRefs = this.nodeService.getChildAssocs(
// this.nodeRef,
// RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, "origional"));
//assertNotNull(origRefs);
//assertEquals(1, origRefs.size());
//NodeRef origNodeRef = origRefs.get(0).getChildRef();
//assertEquals(newNodeRef, origNodeRef);
// Check that the created node has been copied
//List<ChildAssociationRef> copyChildAssocRefs = this.nodeService.getChildAssocs(
// this.rootNodeRef,
// RegexQNamePattern.MATCH_ALL, QName.createQName(TEST_NAMESPACE, "transformed"));
//assertNotNull(copyChildAssocRefs);
//assertEquals(1, copyChildAssocRefs.size());
//NodeRef copyNodeRef = copyChildAssocRefs.get(0).getChildRef();
//assertTrue(this.nodeService.hasAspect(copyNodeRef, ContentModel.ASPECT_COPIEDFROM));
//NodeRef source = (NodeRef)this.nodeService.getProperty(copyNodeRef, ContentModel.PROP_COPY_REFERENCE);
//assertEquals(newNodeRef, source);
// Check the transformed content
//ContentData contentData = (ContentData) nodeService.getProperty(copyNodeRef, ContentModel.PROP_CONTENT);
//assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentData.getMimetype());
}
catch (Exception exception)
{
throw new RuntimeException(exception);
}
}
}
} }

View File

@@ -653,12 +653,18 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
} }
} }
/**
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule)
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule) public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule)
{ {
addRulePendingExecution(actionableNodeRef, actionedUponNodeRef, rule, false); addRulePendingExecution(actionableNodeRef, actionedUponNodeRef, rule, false);
} }
/**
* @see org.alfresco.repo.rule.RuntimeRuleService#addRulePendingExecution(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.rule.Rule, boolean)
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd) public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule, boolean executeAtEnd)
{ {
@@ -684,7 +690,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
} }
} }
// Prevent hte same rule being executed more than one in the same transaction // Prevent the same rule being executed more than once in the same transaction
pendingRules.add(pendingRuleData); pendingRules.add(pendingRuleData);
} }
else else
@@ -707,7 +713,10 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
{ {
logger.debug("Creating the executed rules list"); logger.debug("Creating the executed rules list");
} }
if (AlfrescoTransactionSupport.getResource(KEY_RULES_EXECUTED) == null)
{
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>()); AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
}
try try
{ {
List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>(); List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>();
@@ -719,11 +728,11 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
} }
finally finally
{ {
AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED); //AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
if (logger.isDebugEnabled() == true) //if (logger.isDebugEnabled() == true)
{ //{
logger.debug("Unbinding resource"); // logger.debug("Unbinding resource");
} // }
} }
} }
@@ -900,7 +909,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
* *
* @author Roy Wetherall * @author Roy Wetherall
*/ */
private class ExecutedRuleData public class ExecutedRuleData
{ {
protected NodeRef actionableNodeRef; protected NodeRef actionableNodeRef;

View File

@@ -373,6 +373,9 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl
ContentModel.PROP_VERSION_LABEL, ContentModel.PROP_VERSION_LABEL,
version.getVersionLabel()); version.getVersionLabel());
// Invoke the policy behaviour
invokeAfterCreateVersion(nodeRef, version);
// Return the data object representing the newly created version // Return the data object representing the newly created version
return version; return version;
} }

View File

@@ -46,11 +46,37 @@ public interface VersionServicePolicies
} }
/**
* After create version policy interface
*
*/
public interface AfterCreateVersionPolicy extends ClassPolicy
{
/**
* Called after the version has been created
*
* @param versionableNode the node that has been versioned
* @param version the created version
*/
public void afterCreateVersion(NodeRef versionableNode, Version version);
}
/** /**
* On create version policy interface * On create version policy interface
*/ */
public interface OnCreateVersionPolicy extends ClassPolicy public interface OnCreateVersionPolicy extends ClassPolicy
{ {
/**
* Called during the creation of the version to determine what the versioning policy for a
* perticular type may be.
* WARNING: implementing behaviour for this policy effects the versioning behaviour of the
* type the behaviour is registered against.
*
* @param classRef
* @param versionableNode
* @param versionProperties
* @param nodeDetails
*/
public void onCreateVersion( public void onCreateVersion(
QName classRef, QName classRef,
NodeRef versionableNode, NodeRef versionableNode,

View File

@@ -46,14 +46,15 @@ import org.alfresco.service.namespace.QName;
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy, public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
NodeServicePolicies.OnAddAspectPolicy, NodeServicePolicies.OnAddAspectPolicy,
NodeServicePolicies.OnRemoveAspectPolicy, NodeServicePolicies.OnRemoveAspectPolicy,
NodeServicePolicies.OnDeleteNodePolicy NodeServicePolicies.OnDeleteNodePolicy,
VersionServicePolicies.AfterCreateVersionPolicy
{ {
/** The i18n'ized messages */ /** The i18n'ized messages */
private static final String MSG_INITIAL_VERSION = "create_version.initial_version"; private static final String MSG_INITIAL_VERSION = "create_version.initial_version";
private static final String MSG_AUTO_VERSION = "create_version.auto_version"; private static final String MSG_AUTO_VERSION = "create_version.auto_version";
/** Transaction resource key */ /** Transaction resource key */
private static final String KEY_INITIAL_VERSION = "initial_version_"; private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs";
/** The policy component */ /** The policy component */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
@@ -114,6 +115,10 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
ContentModel.ASPECT_VERSIONABLE, ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "onDeleteNode", Behaviour.NotificationFrequency.TRANSACTION_COMMIT)); new JavaBehaviour(this, "onDeleteNode", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "afterCreateVersion"),
ContentModel.ASPECT_VERSIONABLE,
new JavaBehaviour(this, "afterCreateVersion", Behaviour.NotificationFrequency.EVERY_EVENT));
autoVersionBehaviour = new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.TRANSACTION_COMMIT); autoVersionBehaviour = new JavaBehaviour(this, "onContentUpdate", Behaviour.NotificationFrequency.TRANSACTION_COMMIT);
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
@@ -189,9 +194,6 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
Map<String, Serializable> versionDetails = new HashMap<String, Serializable>(1); Map<String, Serializable> versionDetails = new HashMap<String, Serializable>(1);
versionDetails.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION)); versionDetails.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION));
this.versionService.createVersion(nodeRef, versionDetails); this.versionService.createVersion(nodeRef, versionDetails);
// Keep track of the fact that the initial version has been created
AlfrescoTransactionSupport.bindResource(KEY_INITIAL_VERSION + nodeRef.toString(), nodeRef);
} }
} }
} }
@@ -210,12 +212,13 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
* *
* @param nodeRef the node reference * @param nodeRef the node reference
*/ */
@SuppressWarnings("unchecked")
public void onContentUpdate(NodeRef nodeRef, boolean newContent) public void onContentUpdate(NodeRef nodeRef, boolean newContent)
{ {
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true) if (this.nodeService.exists(nodeRef) == true && this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
{ {
// Determine whether we have already created an initial version during this transaction Map<NodeRef, NodeRef> versionedNodeRefs = (Map)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
if (AlfrescoTransactionSupport.getResource(KEY_INITIAL_VERSION + nodeRef.toString()) == null) if (versionedNodeRefs == null || versionedNodeRefs.containsKey(nodeRef) == false)
{ {
// Determine whether the node is auto versionable or not // Determine whether the node is auto versionable or not
boolean autoVersion = false; boolean autoVersion = false;
@@ -239,20 +242,17 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
} }
/** /**
* Enable the auto version behaviour * @see org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy#onCreateVersion(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.util.Map, org.alfresco.repo.policy.PolicyScope)
*
*/ */
public void enableAutoVersion() @SuppressWarnings("unchecked")
public void afterCreateVersion(NodeRef versionableNode, Version version)
{ {
this.autoVersionBehaviour.enable(); Map<NodeRef, NodeRef> versionedNodeRefs = (Map<NodeRef, NodeRef>)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
if (versionedNodeRefs == null)
{
versionedNodeRefs = new HashMap<NodeRef, NodeRef>();
AlfrescoTransactionSupport.bindResource(KEY_VERSIONED_NODEREFS, versionedNodeRefs);
} }
versionedNodeRefs.put(versionableNode, versionableNode);
/**
* Disable the auto version behaviour
*
*/
public void disableAutoVersion()
{
this.autoVersionBehaviour.disable();
} }
} }

View File

@@ -26,6 +26,7 @@ import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope; import org.alfresco.repo.policy.PolicyScope;
import org.alfresco.repo.version.VersionServicePolicies; import org.alfresco.repo.version.VersionServicePolicies;
import org.alfresco.repo.version.VersionServicePolicies.AfterCreateVersionPolicy;
import org.alfresco.repo.version.VersionServicePolicies.BeforeCreateVersionPolicy; import org.alfresco.repo.version.VersionServicePolicies.BeforeCreateVersionPolicy;
import org.alfresco.repo.version.VersionServicePolicies.CalculateVersionLabelPolicy; import org.alfresco.repo.version.VersionServicePolicies.CalculateVersionLabelPolicy;
import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy; import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy;
@@ -68,6 +69,7 @@ public abstract class AbstractVersionServiceImpl
* Policy delegates * Policy delegates
*/ */
private ClassPolicyDelegate<BeforeCreateVersionPolicy> beforeCreateVersionDelegate; private ClassPolicyDelegate<BeforeCreateVersionPolicy> beforeCreateVersionDelegate;
private ClassPolicyDelegate<AfterCreateVersionPolicy> afterCreateVersionDelegate;
private ClassPolicyDelegate<OnCreateVersionPolicy> onCreateVersionDelegate; private ClassPolicyDelegate<OnCreateVersionPolicy> onCreateVersionDelegate;
private ClassPolicyDelegate<CalculateVersionLabelPolicy> calculateVersionLabelDelegate; private ClassPolicyDelegate<CalculateVersionLabelPolicy> calculateVersionLabelDelegate;
@@ -108,6 +110,7 @@ public abstract class AbstractVersionServiceImpl
{ {
// Register the policies // Register the policies
this.beforeCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.BeforeCreateVersionPolicy.class); this.beforeCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.BeforeCreateVersionPolicy.class);
this.afterCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.AfterCreateVersionPolicy.class);
this.onCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.OnCreateVersionPolicy.class); this.onCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.OnCreateVersionPolicy.class);
this.calculateVersionLabelDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.CalculateVersionLabelPolicy.class); this.calculateVersionLabelDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.CalculateVersionLabelPolicy.class);
} }
@@ -127,6 +130,22 @@ public abstract class AbstractVersionServiceImpl
this.beforeCreateVersionDelegate.get(nodeAspectQNames).beforeCreateVersion(nodeRef); this.beforeCreateVersionDelegate.get(nodeAspectQNames).beforeCreateVersion(nodeRef);
} }
/**
* Invoke the after create version policy bahaviour
*
* @param nodeRef the nodeRef versioned
* @param version the created version
*/
protected void invokeAfterCreateVersion(NodeRef nodeRef, Version version)
{
// invoke for node type
QName nodeTypeQName = nodeService.getType(nodeRef);
this.afterCreateVersionDelegate.get(nodeTypeQName).afterCreateVersion(nodeRef, version);
// invoke for node aspects
Set<QName> nodeAspectQNames = nodeService.getAspects(nodeRef);
this.afterCreateVersionDelegate.get(nodeAspectQNames).afterCreateVersion(nodeRef, version);
}
/** /**
* Invoke the on create version policy behaviour * Invoke the on create version policy behaviour
* *