I have a requirement to be able to update a property on access of a document. I could not use the onContentRead behavior as it is called only when I read the content of the document. My requirement is a behavior or any other way I can update a property when the document is even accessed from the Share.
There is only one behavior in alfresco ,which is onContentRead , which is getting called when you read the content property of the document.This will even get called from share when you open document details of view in alfresco.
What i did not get is you need an event which gets fired when document is accessed from share.I think onContentRead should full fill your requirement.Can you explain the reason why it is not suitable for your requirement.
My requirement is to be able to update a property on document access. I tried using the onContentRead behavior, it is getting called only when I am viewing the whole content from browser and not just browsing the properties. My code is like this
this.onContentRead = new JavaBehaviour(this, OnContentReadPolicy.QNAME.getLocalName(), NotificationFrequency.TRANSACTION_COMMIT); this.policyComponentImpl.bindClassBehaviour(OnContentReadPolicy.QNAME, QName.createQName(MODEL_URI, MODEL_NAME), this.onContentRead);
The public void onContentRead(NodeRef nodeRef) is not getting called while accessing the properties. Is there any other configuration that I am missing?
In that case , you don't have choice, other writing the Spring method interceptor.
Using this you can intercept the method, meaning you can call your own method whenever the specified method in specified object is called.
In your case you need to intercept method of nodeService.Method names are getProperty and getProperties.Below link contains more information on Spring method interceptor.You can google it for more details.