if (!profileSet.contains(Profile.Administrator.name())) {
for (User user : all) {
int userId = user.getId();
Profile profile = user.getProfile();
// TODO is this already equivalent to ID?
if (user.getUsername().equals(context.getAuthentication().getName())) {
// user is permitted to access his/her own user information
continue;
}
Set<Integer> userGroups = getGroups(userId, profile);
// Is user belong to one of the current user admin group?
boolean isInCurrentUserAdminGroups = false;
for (Integer userGroup : userGroups) {
if (hsMyGroups.contains(userGroup)) {
isInCurrentUserAdminGroups = true;
break;
}
}
// if (!hsMyGroups.containsAll(userGroups))
if (!isInCurrentUserAdminGroups) {
usersToRemove.add(user.getId());
}
if (!profileSet.contains(profile.name())) {
usersToRemove.add(user.getId());
}
}
}
UserList res = new UserList();