cancel
Showing results for 
Search instead for 
Did you mean: 

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

santiagoposadag
Champ in-the-making
Champ in-the-making

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 1

davidzuluaga5
Champ in-the-making
Champ in-the-making

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