cancel
Showing results for 
Search instead for 
Did you mean: 

not able to fetch the members of the group

Bhagat__Singh
Champ in-the-making
Champ in-the-making

Hi Nuxeo

i was trying to get the member of the group but it is not working it is returning null in all cases code is

Group group = new Group(); group.setGroupName(groupRequest.GroupName); group.setGroupLabel(groupRequest.GroupLable); group.setMemberUsers(groupRequest.userNameList); // group.setParentGroups(parentGroups); //group.setParentGroups(Arrays.asList("members")); Group groupnew = client.userManager().createGroup(group); groupnew = client.userManager().fetchGroup("New"); System.out.println(groupnew.getGroupName()); List a = groupnew.getMemberUsers(); if (a != null) { for (String item : a) { System.out.println(item); } }

	another way which i was trying is 
	
	Groups g = client.userManager().searchGroup("*");
	System.out.println("size " + g.getTotalSize());
	for (Group Gelement : g.getGroups()) {
		System.out.println("lable " + Gelement.getGroupLabel());
		System.out.println("Name " + Gelement.getGroupName());

		System.out.println("ParentGroups");
		for (Group iterable_element : Gelement.fetchMemberGroups().getGroups()) { // Returns null 
			System.out.println("lable " + iterable_element.getGroupLabel());
			System.out.println("Name " + iterable_element.getGroupName());
		}

		System.out.println("MemberGroups");
		Groups mg = Gelement.fetchMemberGroups(); // Returns null 
		for (Group iterable_element : mg.getGroups()) {
			System.out.println("lable " + iterable_element.getGroupLabel());
			System.out.println("Name " + iterable_element.getGroupName());
		}
	  
	  }
	
	
2 REPLIES 2

Rodri_
Star Contributor
Star Contributor

Hello,

why aren't you using the fetchMemberUsers() method as explained here: https://doc.nuxeo.com/client-java/3.2/user-group/#fetch

This is a very simple example, but it worked:

NuxeoClient nuxeoClient = new NuxeoClient.Builder()
	.url(url)
       .authentication(username, password)
       .connect();
	
UserManager userManager = nuxeoClient.userManager();
Group group = userManager.fetchGroup("administrators");
String label = group.getGroupLabel();
System.out.println("Group: " + label);
Users users = group.fetchMemberUsers();
for(User u: users.getEntries()) {
	System.out.println("User: " + u.getUserName() + "\n");
}

Result:

Group: Administrators group
User: Administrator

Regards.

Jackie_A
Confirmed Champ
Confirmed Champ

You may need to wait for the next transaction, see TransactionalFeature nextTransaction()