I couldn't find a way to do this :-(
There is "Items ar updated" but that triggers even if a property changes.
And there is "Items are created or enter this folder" which does NOT trigger when a new version is uploaded.
Is this correct?
Solved! Go to Solution.
You can implement a behavior.
Custom behavior can listen to onCreateVersion event or choose from below given available events on version policy and execute your custom logic from the implementation methods:
https://docs.alfresco.com/5.2/references/dev-extension-points-behaviors.html
org.alfresco.repo.version.VersionServicePolicies |
|
It could be something like:
public class ObjectVersionBehaviour implements VersionServicePolicies.OnCreateVersionPolicy { private final NodeService nodeService; private final PolicyComponent policyComponent; public ObjectVersionBehaviour(final ServiceRegistry serviceRegistry, final PolicyComponent policyComponent) { //TODO:: get the required service from serviceRegistry and this.nodeService = serviceRegistry.getNodeService(); this.policyComponent = policyComponent; //Binding on cm:content type createBindings(VersionServicePolicies.BeforeCreateVersionPolicy.QNAME, ContentModel.TYPE_CONTENT, Behaviour.NotificationFrequency.EVERY_EVENT); } private void createBindings(final QName policy, final QName type, final Behaviour.NotificationFrequency frequency) { policyComponent.bindClassBehaviour(policy, type, new JavaBehaviour(this, policy.getLocalName(), frequency)); } @Override public void onCreateVersion(final QName classRef, final NodeRef versionableNode, final Map<String, Serializable> versionProperties, final PolicyScope nodeDetails){ //Your custom logic on version creation } }
Refer this tutorial if want to learn more on implementing behaviors:
https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html
You can implement a behavior.
Custom behavior can listen to onCreateVersion event or choose from below given available events on version policy and execute your custom logic from the implementation methods:
https://docs.alfresco.com/5.2/references/dev-extension-points-behaviors.html
org.alfresco.repo.version.VersionServicePolicies |
|
It could be something like:
public class ObjectVersionBehaviour implements VersionServicePolicies.OnCreateVersionPolicy { private final NodeService nodeService; private final PolicyComponent policyComponent; public ObjectVersionBehaviour(final ServiceRegistry serviceRegistry, final PolicyComponent policyComponent) { //TODO:: get the required service from serviceRegistry and this.nodeService = serviceRegistry.getNodeService(); this.policyComponent = policyComponent; //Binding on cm:content type createBindings(VersionServicePolicies.BeforeCreateVersionPolicy.QNAME, ContentModel.TYPE_CONTENT, Behaviour.NotificationFrequency.EVERY_EVENT); } private void createBindings(final QName policy, final QName type, final Behaviour.NotificationFrequency frequency) { policyComponent.bindClassBehaviour(policy, type, new JavaBehaviour(this, policy.getLocalName(), frequency)); } @Override public void onCreateVersion(final QName classRef, final NodeRef versionableNode, final Map<String, Serializable> versionProperties, final PolicyScope nodeDetails){ //Your custom logic on version creation } }
Refer this tutorial if want to learn more on implementing behaviors:
https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html
Thank you!
As I already followed this helpful tutorial I was able to implement a custom behaviour that reacts on a change of the version.
Although I wonder why these events can not be populated to the rule definition site. That would make things easier for people not using an IDE. :-)
Please have a look at my "follow-up-problem" that I just posted here :
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.