cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluating Document Library Actions based on User Attributes

vamirr
Champ on-the-rise
Champ on-the-rise
I'm attempting to restrict the availability of certain document library actions based on user attributes.  For example, if a user works for one company, show action A, if the user works for another company, show action B. 

I'm usually writing java code against the repository; doing so for Share is a learning curve.  Right now I have an empty custom class extending BaseEvaluator wired up for the two actions.  The context in BaseEvaluator seems a little sparse.  How can I go about accessing user attributes from the BaseEvaluator evaluate function?  If that's not possible, how can I go about adding the values I'm interested in to the JSON that is passed to the evaluate function?
1 REPLY 1

art99trash
Star Contributor
Star Contributor
I don't know if this will help. In an older Alfresco application, using Alfresco Explorer, we added users to different groups
and then checked the groups in the evaluators.
Like this:

AuthorityService authorityService = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getAuthorityService();
Set<String> authorities = authorityService.getAuthoritiesForUser(user);
for (String auth : authorities) {
  if (auth.equals(this.getNeededAuthGroup())) {
    isAuthorized = true;
    break;
  }
}

I hope that helps.