cancel
Showing results for 
Search instead for 
Did you mean: 

getting list of subgroups

gokceng
Champ in-the-making
Champ in-the-making
I know it mustn't be so hard but I couldn't find a way to get subgroup list of a group.
It is like that:

GROUP1
   SubGroup1
   SubGroup2
   SubGroup3
   SubGroup4
GROUP2
   SubGroup5
   SubGroup6
   SubGroup7

var activegroup = people.getGroup("GROUP_GROUP1");

and then my problem begins. I need a list of subgroups under GROUP1. How can I get that information?
Alfresco must have a way to do this.
6 REPLIES 6

mrogers
Star Contributor
Star Contributor
Either use the AuthorityService from Java or the groups API in Java Script.

gokceng
Champ in-the-making
Champ in-the-making
Thanks for the reply.
What exactly do you mean by saying groups api?
3.3 JavaScript Services API has some useful functions about this issue but when i use them i'm getting error.
3.3 JavaScript API has no function about that.
Where can i find groups api?

gokceng
Champ in-the-making
Champ in-the-making
thank you,
as always there is no answer…

mrogers
Star Contributor
Star Contributor
Perhaps if you posted clearer questions you would get better answers.   It looked like you found the right document but I couldn't answer your vague statement about "i'm getting error."     Perhaps if you had bothered to explain what was happening I could have replied?

gokceng
Champ in-the-making
Champ in-the-making
Let me talk about "vague statement":

http://lmgtfy.com/?q=alfresco+javascript+%22groups+api%22

Is there anything named groups api? No..

Anyway, I'm using 3.0 Stable and this webscript was working 2 years ago:

var memberlist = new Array();
var activegroup = people.getGroup("GROUP_ActiveUsers");
var grouplist = activegroup.childAssocs["usr:member"];
var agroup;
for(i = 0; i<grouplist.length; i++)
{
   agroup = people.getGroup(grouplist[i].properties["usr:authorityName"]);
   memberlist[i] = people.getMembers(agroup);
}
model.grouplist= grouplist;
model.memberlist = memberlist;

I've tried to upgrade it to 3.3 and it didn't worked, I tried 3.2 and at last I tried 3.0 Stable again. But I couldn't manage to run it again.
grouplist is null whenever I run it.

I was getting the error I was talking about when I was trying 3.2 or 3.3, I couldn't remember.
The function was getAllGroups() from Javascript Services API. Also I don't know what is the difference between JS Services API and JS API.
But there is nothing about what I'm looking for in JS API.

So I tried to implement it in Java. I tried both:


authorityService.getContainedAuthorities(AuthorityType.GROUP, "ActiveUsers", true);
authorityService.getContainedAuthorities(AuthorityType.GROUP, "GROUP_ActiveUsers", true);

One of these must return the subgroups, but they return nothing. They don't give error but they just return empty sets.

Does it make sense now?
If there is anything "vague", let me know.

vidhipanchal
Star Contributor
Star Contributor

Hi,

By Using following Code, You can able to get all the subgroup and user of specific group.

Set<String> subGroup = serviceRegistory.getAuthorityService().getContainedAuthorities(AuthorityType.GROUP, "GROUP_ActiveUsers", true);

You have to register ServiceRegistory  in your spring configuration.

Thanks,

Contcentric

Regards,
Vidhi