I am working with the Java api to implement a class which implements custom behaviors for VersionServicePolicies.CalculateVersionLabelPolicy and VersionServicePolicies.OnCreateVersionPolicy.
I can get my onCreateVersionPolicy implementation registered and working without issue, however, I am not having success with the CalculateVersionLabelPolicy policy implementation.
Here is a snippet of the error I recieve when trying to deploy the war containing my class:
Caused by: org.alfresco.error.AlfrescoRuntimeException: 00250020 Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.content.ContentServicePolicies$OnContentUpdatePolicy.onContentUpdate(org.alfresco.service.cmr.repository.NodeRef,boolean) in transaction dd3e3520-1a78-4eaa-8a70-87538118cdca Caused by: org.alfresco.service.cmr.version.VersionServiceException: 00250019 More than one CalculateVersionLabelPolicy behaviour has been registered for the type {http://www.somesite.com/somepage/model/1.0}configuration"}}Below is my class which implements these two policies:
public class CustomVersionServiceBehavior
implements VersionServicePolicies.CalculateVersionLabelPolicy,
VersionServicePolicies.OnCreateVersionPolicy {
private PolicyComponent policyComponent;
private Behaviour calculateVersionLabel;
private Behaviour onCreateVersion;
public void setPolicyComponent(PolicyComponent policyComponent) {
this.policyComponent = policyComponent;
}
public PolicyComponent getPolicyComponent() {
return this.policyComponent;
}
public void init() {
this.calculateVersionLabel = new JavaBehaviour(this, "calculateVersionLabel", NotificationFrequency.EVERY_EVENT);
this.onCreateVersion = new JavaBehaviour(this, "onCreateVersion", NotificationFrequency.EVERY_EVENT);
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "calculateVersionLabel"),
ContentModel.TYPE_CONTENT, this.calculateVersionLabel);
this.policyComponent.bindClassBehaviour(VersionServicePolicies.OnCreateVersionPolicy.QNAME,
ContentModel.TYPE_CONTENT, this.onCreateVersion);
}
@Override
public String calculateVersionLabel(QName arg0, Version arg1, int arg2, Map<String, Serializable> arg3) {
System.out.println("Hello from calculateVersionLabel()");
return null;
}
@Override
public void onCreateVersion(QName arg0, NodeRef arg1, Map<String, Serializable> arg2, PolicyScope arg3) {
System.out.println("Hello from onCreateVersionPolicy()");
}
}What am I missing?