mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -21,7 +21,9 @@ import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.repo.rule.RuleServiceImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
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.repository.NodeRef)
|
||||
*/
|
||||
public void executeAction(RuntimeActionService actionService, Action action, NodeRef actionedUponNodeRef,
|
||||
@SuppressWarnings("unchecked")
|
||||
public void executeAction(RuntimeActionService actionService, Action action, NodeRef actionedUponNodeRef,
|
||||
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,
|
||||
actionedUponNodeRef, checkConditions, actionExecutionHistoryNodeRef, actionChain));
|
||||
actionedUponNodeRef, checkConditions, actionExecutionHistoryNodeRef, actionChain, executedRules));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,6 +181,11 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
|
||||
* The action chain
|
||||
*/
|
||||
private Set<String> actionChain;
|
||||
|
||||
/**
|
||||
* List of executed list, helps to prevent loop scenarios with async rules
|
||||
*/
|
||||
private Set<RuleServiceImpl.ExecutedRuleData> executedRules;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -190,7 +200,7 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
|
||||
*/
|
||||
public ActionExecutionWrapper(RuntimeActionService actionService, TransactionService transactionService,
|
||||
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.transactionService = transactionService;
|
||||
@@ -200,6 +210,7 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
|
||||
this.checkConditions = checkConditions;
|
||||
this.actionExecutionHistoryNodeRef = actionExecutionHistoryNodeRef;
|
||||
this.actionChain = actionChain;
|
||||
this.executedRules = executedRules;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,7 +287,12 @@ public class AsynchronousActionExecutionQueueImpl extends ThreadPoolExecutor imp
|
||||
new TransactionUtil.TransactionWork<Object>()
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
{
|
||||
if (ActionExecutionWrapper.this.executedRules != null)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindResource("RuleServiceImpl.ExecutedRules", ActionExecutionWrapper.this.executedRules);
|
||||
}
|
||||
|
||||
ActionExecutionWrapper.this.actionService.executeActionImpl(
|
||||
ActionExecutionWrapper.this.action,
|
||||
ActionExecutionWrapper.this.actionedUponNodeRef,
|
||||
|
@@ -216,7 +216,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
{
|
||||
if (personService.personExists(userAuth) == true)
|
||||
{
|
||||
NodeRef person = personService.getPerson(authority);
|
||||
NodeRef person = personService.getPerson(userAuth);
|
||||
String address = (String)nodeService.getProperty(person, ContentModel.PROP_EMAIL);
|
||||
if (address != null && address.length() != 0)
|
||||
{
|
||||
|
@@ -307,9 +307,9 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
||||
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
|
||||
this.versionableAspect.disableAutoVersion();
|
||||
try
|
||||
{
|
||||
//this.versionableAspect.disableAutoVersion();
|
||||
//try
|
||||
//{
|
||||
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
|
||||
// Try and get the original node reference
|
||||
nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
|
||||
@@ -371,11 +371,11 @@ public class CheckOutCheckInServiceImpl implements CheckOutCheckInService
|
||||
// Re-lock the original node
|
||||
this.lockService.lock(nodeRef, LockType.READ_ONLY_LOCK);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.versionableAspect.enableAutoVersion();
|
||||
}
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// this.versionableAspect.enableAutoVersion();
|
||||
//}
|
||||
|
||||
}
|
||||
else
|
||||
|
@@ -43,8 +43,8 @@
|
||||
name="accessControlList"
|
||||
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"
|
||||
column="acl_id"
|
||||
lazy="false"
|
||||
fetch="join"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
unique="false"
|
||||
not-null="false"
|
||||
cascade="delete" />
|
||||
|
@@ -1547,4 +1547,90 @@ public class RuleServiceCoverageTest extends TestCase
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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")
|
||||
public void addRulePendingExecution(NodeRef actionableNodeRef, NodeRef actionedUponNodeRef, Rule rule)
|
||||
{
|
||||
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")
|
||||
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);
|
||||
}
|
||||
else
|
||||
@@ -707,7 +713,10 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
{
|
||||
logger.debug("Creating the executed rules list");
|
||||
}
|
||||
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
||||
if (AlfrescoTransactionSupport.getResource(KEY_RULES_EXECUTED) == null)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindResource(KEY_RULES_EXECUTED, new HashSet<ExecutedRuleData>());
|
||||
}
|
||||
try
|
||||
{
|
||||
List<PendingRuleData> executeAtEndRules = new ArrayList<PendingRuleData>();
|
||||
@@ -719,11 +728,11 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
}
|
||||
finally
|
||||
{
|
||||
AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Unbinding resource");
|
||||
}
|
||||
//AlfrescoTransactionSupport.unbindResource(KEY_RULES_EXECUTED);
|
||||
//if (logger.isDebugEnabled() == true)
|
||||
//{
|
||||
// logger.debug("Unbinding resource");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -900,7 +909,7 @@ public class RuleServiceImpl implements RuleService, RuntimeRuleService
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
private class ExecutedRuleData
|
||||
public class ExecutedRuleData
|
||||
{
|
||||
|
||||
protected NodeRef actionableNodeRef;
|
||||
|
@@ -373,6 +373,9 @@ public class VersionServiceImpl extends AbstractVersionServiceImpl
|
||||
ContentModel.PROP_VERSION_LABEL,
|
||||
version.getVersionLabel());
|
||||
|
||||
// Invoke the policy behaviour
|
||||
invokeAfterCreateVersion(nodeRef, version);
|
||||
|
||||
// Return the data object representing the newly created version
|
||||
return version;
|
||||
}
|
||||
|
@@ -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
|
||||
*/
|
||||
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(
|
||||
QName classRef,
|
||||
NodeRef versionableNode,
|
||||
|
@@ -46,14 +46,15 @@ import org.alfresco.service.namespace.QName;
|
||||
public class VersionableAspect implements ContentServicePolicies.OnContentUpdatePolicy,
|
||||
NodeServicePolicies.OnAddAspectPolicy,
|
||||
NodeServicePolicies.OnRemoveAspectPolicy,
|
||||
NodeServicePolicies.OnDeleteNodePolicy
|
||||
NodeServicePolicies.OnDeleteNodePolicy,
|
||||
VersionServicePolicies.AfterCreateVersionPolicy
|
||||
{
|
||||
/** The i18n'ized messages */
|
||||
private static final String MSG_INITIAL_VERSION = "create_version.initial_version";
|
||||
private static final String MSG_AUTO_VERSION = "create_version.auto_version";
|
||||
|
||||
/** Transaction resource key */
|
||||
private static final String KEY_INITIAL_VERSION = "initial_version_";
|
||||
private static final String KEY_VERSIONED_NODEREFS = "versioned_noderefs";
|
||||
|
||||
/** The policy component */
|
||||
private PolicyComponent policyComponent;
|
||||
@@ -114,6 +115,10 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"),
|
||||
ContentModel.ASPECT_VERSIONABLE,
|
||||
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);
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
@@ -189,9 +194,6 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
||||
Map<String, Serializable> versionDetails = new HashMap<String, Serializable>(1);
|
||||
versionDetails.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_INITIAL_VERSION));
|
||||
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
|
||||
*/
|
||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onContentUpdate(NodeRef nodeRef, boolean newContent)
|
||||
{
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
|
||||
{
|
||||
// Determine whether we have already created an initial version during this transaction
|
||||
if (AlfrescoTransactionSupport.getResource(KEY_INITIAL_VERSION + nodeRef.toString()) == null)
|
||||
if (this.nodeService.exists(nodeRef) == true && this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
|
||||
{
|
||||
Map<NodeRef, NodeRef> versionedNodeRefs = (Map)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
|
||||
if (versionedNodeRefs == null || versionedNodeRefs.containsKey(nodeRef) == false)
|
||||
{
|
||||
// Determine whether the node is auto versionable or not
|
||||
boolean autoVersion = false;
|
||||
@@ -237,22 +240,19 @@ 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()
|
||||
{
|
||||
this.autoVersionBehaviour.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the auto version behaviour
|
||||
*
|
||||
*/
|
||||
public void disableAutoVersion()
|
||||
{
|
||||
this.autoVersionBehaviour.disable();
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public void afterCreateVersion(NodeRef versionableNode, Version version)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.PolicyScope;
|
||||
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.CalculateVersionLabelPolicy;
|
||||
import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy;
|
||||
@@ -68,6 +69,7 @@ public abstract class AbstractVersionServiceImpl
|
||||
* Policy delegates
|
||||
*/
|
||||
private ClassPolicyDelegate<BeforeCreateVersionPolicy> beforeCreateVersionDelegate;
|
||||
private ClassPolicyDelegate<AfterCreateVersionPolicy> afterCreateVersionDelegate;
|
||||
private ClassPolicyDelegate<OnCreateVersionPolicy> onCreateVersionDelegate;
|
||||
private ClassPolicyDelegate<CalculateVersionLabelPolicy> calculateVersionLabelDelegate;
|
||||
|
||||
@@ -108,6 +110,7 @@ public abstract class AbstractVersionServiceImpl
|
||||
{
|
||||
// Register the policies
|
||||
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.calculateVersionLabelDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.CalculateVersionLabelPolicy.class);
|
||||
}
|
||||
@@ -127,6 +130,22 @@ public abstract class AbstractVersionServiceImpl
|
||||
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
|
||||
*
|
||||
|
Reference in New Issue
Block a user