AnsweredAssumed Answered

PolicyComponent - How to use bindPropertyBehaviour?

Question asked by filip on Oct 21, 2016
Latest reply on Oct 23, 2016 by filip

Hello everyone,

 

I am just wondering if bindPropertyBehaviour method is working or not. There are already several questions but no satisfying answer:

behaviour not triggered on property changed or bindPropertyBehaviour not functioning correctly

 

My example is:

public class ApprovedFilePolicy implements NodeServicePolicies.OnUpdatePropertiesPolicy {

    private Logger logger = Logger.getLogger(ApprovedFilePolicy.class);
    private PolicyComponent policyComponent;
    private NodeService nodeService;
    
    public void init() {
        logger.debug("ApprovedFilePolicy is registered");
        final Behaviour onUpdateProperties = new JavaBehaviour(this, NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME.getLocalName(), NotificationFrequency.TRANSACTION_COMMIT);
        policyComponent.bindPropertyBehaviour(NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, ContentModel.ASPECT_TITLED,ContentModel.PROP_TITLE, onUpdateProperties);
    }
    
    @Override
    public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) {
        logger.debug("ApprovedFilePolicy ||| for node " + nodeRef.toString());
    }
    // Setters for NodeService and PolicyComponent
}


 

Bean is properly registered in service-context.xml since I can see debug message (mentioned in init) during Alfresco startup. However, onUpdateProperties is not executed during title change.

Am I doing anything wrong?

 

As a workaround, I can still use bindClassBehaviour which works just fine. Btw, I am using 5.1.

 

Thanks for your comments,

Filip

Outcomes