12-21-2017 01:16 AM
Hello,
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.
Thank you.
12-21-2017 02:58 AM
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.
12-21-2017 03:14 AM
Hello Krutik,
Thanks for your time.
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?
Thank you.
12-21-2017 03:26 AM
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.
Spring MVC Interceptor HandlerInterceptorAdapter, HandlerInterceptor Example - JournalDev
12-21-2017 03:29 AM
Oh thank you Krutik, I will try that.
Explore our Alfresco products with the links below. Use labels to filter content by product module.