Add or remove group members
The following example displays
the code to add or remove the group
members. Before modifying, ensure that you fetch the user.
// Fetch the group
String groupId = “testgroup”;
RgyGroup rgyGroup = null;
try {
rgyGroup = rgyRegistry.getGroup(“Default”, groupId);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}
// Ensure the group was found
if (rgyGroup == null) {
System.out.println(“Group does not exist”);
System.exit(1);
}
// Create a List of user IDs and add to group
List userIds = new ArrayList();
userIds.add(“testuser”);
try {
rgyGroup.addMembers(userIds);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}
// Remove List of user IDs from the group
try {
rgyGroup.removeMembers(userIds);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}