09-28-2016 01:16 PM
Hi.
I have some content within an excel file that i also want as Metadata. When a value in the content changes I want the Metadata to update too. I have attempted to do this in a java behavior and it works using the onUpdateProperties policy. The problem with this is that it runs when any property is updated.
To solve this I tried using the onContentUpdated policy but when I try to get a content reader on the node so I can read the value in the content stream null is returned, a content reader isn't returned.
Is there a different policy I should use or is there a better solution to update Metadata based on content data. Thanks
09-28-2016 02:21 PM
The onContentPropertyUpdate or onContentUpdate policies are both valid candidates for this use case. One potential issue you may be facing may be related to the notification frequency of the policy / behaviour. I.e. if you react to TRANSACTION_COMMIT there is a delay between the trigger of the policy and its execution (within the transaction) - some code can potentially mess with your content / node before you get a chance to retrieve the reader. You might want to try EVERY_EVENT instead to avoid this kind of problem.
Of course this is only one potential reason for the behaviour - it is just one I have seen more often than others.
There is also another alternative: metadata extractors. These are components that are explicitly called when anything from the file content should be extracted as properties, which happens automatically e.g. when you upload or update content via Share. It can also be triggered by simple rules as there is a default action for this particular functionality. You can register metadata extractors per mimetype and they already get the ContentReader provided as a parameter of the operation defined by the interface.
09-28-2016 02:21 PM
The onContentPropertyUpdate or onContentUpdate policies are both valid candidates for this use case. One potential issue you may be facing may be related to the notification frequency of the policy / behaviour. I.e. if you react to TRANSACTION_COMMIT there is a delay between the trigger of the policy and its execution (within the transaction) - some code can potentially mess with your content / node before you get a chance to retrieve the reader. You might want to try EVERY_EVENT instead to avoid this kind of problem.
Of course this is only one potential reason for the behaviour - it is just one I have seen more often than others.
There is also another alternative: metadata extractors. These are components that are explicitly called when anything from the file content should be extracted as properties, which happens automatically e.g. when you upload or update content via Share. It can also be triggered by simple rules as there is a default action for this particular functionality. You can register metadata extractors per mimetype and they already get the ContentReader provided as a parameter of the operation defined by the interface.
10-25-2016 06:06 AM
Thanks Axel, changing the transaction commit frequency fixed the issue. I will have a look into the metadata extractors, they sound useful.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.