AnsweredAssumed Answered

Getting a list of groups attached to a folder.

Question asked by zezom on Jan 8, 2010
Latest reply on Jan 12, 2010 by zezom
Hi, I've been trying to get a list of groups that are attached to a folder.

I have tried many approaches and one even works for the admin, but the whole web script returns an error 500 when a normal user tries it. I will list this method now:

folder = search.findNode(args.nodeRef);
if(folder != null)
//   if(folder.permissions != null)
   if(folder.hasPermission("_ReadPermissions") == true);
      for each (var record in folder.permissions)  //This is the line that fails. I have also tried using folder.getPermissions(); with the same result.
         record = "GROUP_FOF_Approvers";
         fields = record.split(";");
         var group = fields[1];
         if (/^GROUP_(.*?)Approvers?$/i.test(group))
            for each (approver in people.getMembers(people.getGroup(group)))
               if( ==
                  model.approver = "true";

I have also tried a number of other methods to retrieve the group list from the folder with no success.

folder.getGroup(); // Errors['cm:group'];'cm:group'); // Errors
search.luceneSearch('+@cm\\:Group:"GROUP_FOF_Approvers"'); //Returns no matches.
folder.hasPermission("ReadPermissions"); //This works as a test but still errors when I try to access the permissions with a non admin user. _ReadPermissions also works.
AuthorityService.searchGroups(); //AuthorityService does not exist.
AuthorityService.getAllAuthorities(AuthorityType.GROUP); //AuthorityService does not exist.
search.luceneSearch("user://alfrescoUserStore", "TYPE:\"usr:authorityContainer\"")  //Cant use usr:authorityContainer
folder.searchGroups(); //Does not work
groups.searchGroups("*"); //This returns a list of groups but not specific to the folder, only all groups.
folder.permissions; //Works fine for admin but not for any other user.

The error that I receive when using a normal user is:

500 Description: An error inside the HTTP server which prevented it from fulfilling the request.

Exception:    org.alfresco.web.scripts.WebScriptException - 00080232 Wrapped Exception (with status template): 00080231 Failed to execute script '/mincom/submitKB/theDocuments.get.js (in repository store workspace://SpacesStore/Company Home/dictionary/Web Scripts)': 00080230 Access Denied. You do not have the appropriate permissions to perform this operation.
Server: Alfresco Community v3.2.0 (@build-number@) schema 2,019
If any one needs the full debug output please let me know, I didn't want to flood the page.

It's possible I just need a more accurate folder.hasPermission("ReadPermissions"); test but I have no idea what that would be. Any help would be greatly appreciated as I have spent days on this already.

Thank you,
Ryan Thorburn