01-15-2020 01:03 AM
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
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());
}
}
01-16-2020 12:05 PM
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.
01-21-2020 11:24 AM
You may need to wait for the next transaction, see TransactionalFeature nextTransaction()
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.