Dark Star1
Dark Star1

Reputation: 7403

Is it possible to bind a policy to a Group in alfresco?

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

Answers (1)

Andreas Steffan
Andreas Steffan

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

Related Questions