I have OnCreateNodePolicy implementation and I’m thinking about adding conditions in binding initialization (some optimalizations for speed), is it possible?
What do I mean? Let’s have definition similar to this:
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
ContentModel.TYPE_CONTENT, onCreateNode);
Now when node is created, mine onCreateNode() is called. First thing I do is to check, if my parent has some aspect. Isn’t it possible to add this condition into binding definition? So onCreateNode() is called only when this condition is met?
You can not add conditions to the binding definition but in your case you could consider using the
OnCreateChildAssociationPolicyinstead of theOnCreateNodePolicy. The advantage is that you could bind it to your custom aspect. It would look something like this:You have to keep in mind though that child associations are also created when you move a node to a new folder, not only when you create it. Also you now have to check the type of the child node (
ContentModel.TYPE_CONTENT) in your Java code.