onContentReadPolicy is being executed automatically withouth actually reading any node or document.

cancel
Showing results for 
Search instead for 
Did you mean: 
santiagoposadag
Member II

onContentReadPolicy is being executed automatically withouth actually reading any node or document.

I created a custom behaviour that extends the onContentRead policy so that i couls execute an action every time an especific type of document is requested.

The thing is that this behaviour is being executed atomatically for all the documents that matches the type but without the necesity of actually requesting the document or documents.

How can i limit the execution of this behaviour to the scenario in which the action of requesting the document to be displayed in share is executed.

This is my code:

private PolicyComponent eventManager;
private ServiceRegistry serviceRegistry;


public void registerEventHandlers() {
eventManager.bindClassBehaviour(
ContentServicePolicies.OnContentReadPolicy.QNAME,
MNContentModel.TYPE_MN_GENERAL,
new JavaBehaviour(this, "onContentRead",
Behaviour.NotificationFrequency.FIRST_EVENT));

}

public void onContentRead(NodeRef docNodeRef) {
AuthenticationUtil.runAsSystem(()-> {
try{
updateCount(docNodeRef);
}catch (Exception e){
System.out.println(e.getMessage());
}
return null;
});


}
1 Reply
davidzuluaga5
Member II

Re: onContentReadPolicy is being executed automatically withouth actually reading any node or docume

Hi, i am having same issue. Did you find a solution for this?