cancel
Showing results for 
Search instead for 
Did you mean: 

get the role in java backed webscript

anusk
Champ in-the-making
Champ in-the-making
Hi all,
I am implementing a java backed webscript to get all coordinators from repository.
With this I mean, if any user has been invited as the role "Coordinator" to any space should appear in that list.
I managed to get al the authorities of the users, but the roles don't appear.

I invited the user "Cris" to a space with the role Coordinator, and to another with the role "Editor". Restart the server.
With this code in the java class:
Set<NodeRef> people =    personService.getAllPeople();
      
      Iterator<NodeRef> users = people.iterator();
      
      while (users.hasNext()) {
         NodeRef usu = users.next();
         String username = nodeService.getProperty(usu,
               ContentModel.PROP_USERNAME).toString();
         Set<String> auth=authorityService.getAuthoritiesForUser(username);
         Iterator<String> authorities = auth.iterator();
         System.out.println(username);
         while(authorities.hasNext()){
            String authority = authorities.next();
         System.out.println(authority);
         }
      }

The output is:
Cris
GROUP_EVERYONE
Guest
ROLE_GUEST
feli
GROUP_EVERYONE
admin
GROUP_EVERYONE
ROLE_ADMINISTRATOR
GROUP_ALFRESCO_ADMINISTRATOR
GROUP_EMAIL_CONTRIBUTORS


Why aren't  the ROLE_COORDINATOR and the ROLE_EDITOR in the authorities of the user "Cris"????

Kind regards,
Ana
1 REPLY 1

anusk
Champ in-the-making
Champ in-the-making
It seems I approach this incorrectly.
What I need to do is get the authorities from the spaces, not the users.

Regards,
Ana