Reputation: 7403
I'm trying to add a behaviour to all users in a group (i.e. add an aspect to user if added and removed when not in group) however I get an exception at the point of binding within the init method:
public void init() {
this.policyComponent.bindClassBehaviour(OnUpdateNodePolicy.QNAME, ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(this, "onUpdateNode"));
this.policyComponent.bindClassBehaviour(BeforeUpdateNodePolicy.QNAME, ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(this, "beforeUpdateNode"));
}
Any other way I can get around this if this isn't possible?
Upvotes: 1
Views: 233
Reputation: 6159
If you want to act on users as they are added and removed from a group, you should be using the ChildAssociation policies. Have a look at http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/repo/policy/AssociationPolicy.html to pick the ones which apply for you.
That said, it may be smarter to just extend AuthorityService and wrap calls to
public void addAuthority(String parentName, String childName);
public void removeAuthority(String parentName, String childName);
adding your custom logic.
Upvotes: 3