cancel
Showing results for 
Search instead for 
Did you mean: 

space users

califa198
Champ in-the-making
Champ in-the-making
hello,

I have been developing on Alfresco for a couple weeks, i am making a couple java files to customize alfresco. i havent been able to find any info regarding this, so how do i do to get a map or a list of the users that have permission to access that space? i need to include that list on one of the properties of the new spaces created so i can show them in the properties page.

Thanks in advance.
3 REPLIES 3

zaizi
Champ in-the-making
Champ in-the-making
Hi,

I did this the other day this way. You might just want to use 
permissionService.getAllSetPermissions(nodeRef);
.


        // check if current authenticated user can read the permissions on the current node
      AccessStatus readPermissions = permissionService.hasPermission(nodeRef, PermissionService.READ_PERMISSIONS);
        if (readPermissions.equals(AccessStatus.ALLOWED))
        {
      // get all the permissions set on the node
           Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
      
         // loop through the permissions and filter for users and groups with access
         for (AccessPermission permission : permissions)
         {
            if (permission.getAccessStatus().equals(AccessStatus.ALLOWED) &&
                  (permission.getAuthorityType().equals(AuthorityType.USER) ||
                  permission.getAuthorityType().equals(AuthorityType.GROUP)))
            {

               // check if the authority is a group or user
               String authority = permission.getAuthority();
               AuthorityType authType = AuthorityType.getAuthorityType(authority);
               
               // If user check they exist and do something
               if (authType.equals(AuthorityType.USER))
               {
                  if(this.personService.personExists(authority))
                  {
                     // do something here
                  }
               }
               
               // If group get all members and check if they exist
               if (authType.equals(AuthorityType.GROUP))
               {
                  Set<String> users = this.authorityService.getContainedAuthorities(AuthorityType.USER, authority, false);
                  for (String userAuth : users)
                  {
                     if (this.personService.personExists(userAuth) == true)
                     {
                        // do something here
                     }
                  }
               }
               
            }
            
         }
        }

califa198
Champ in-the-making
Champ in-the-making
thanks, ill give it a try

califa198
Champ in-the-making
Champ in-the-making
Mentaldaze, thanks for your post but i dont know if it will help in my case. i am using a heavy java client, and i am using webservices to communicate with alfresco. I dont seem to be able to retrieve the users this way. Any ideas?

Thanks

califa