Specification<UserGroup> hasUserIdAndProfile = where(UserGroupSpecs.hasProfile(Profile.Reviewer))
.and(UserGroupSpecs.hasUserId(userId));
List<Integer> groupIds = userGroupRepo.findGroupIds(hasUserIdAndProfile);
if (groupIds.isEmpty()) {
throw new ServiceNotAllowedEx("User can't set operation for group " + grpId + " because the user in not a "
+ "Reviewer of any group.");
}
} else {
String userGroupsOnly = settingMan.getValue("system/metadataprivs/usergrouponly");
if (userGroupsOnly.equals("true")) {
// If user is member of the group, user can set operation
if (userGroupRepo.exists(new UserGroupId().setGroupId(grpId).setUserId(userId))) {
throw new ServiceNotAllowedEx("User can't set operation for group " + grpId + " because the user in not"
+ " member of this group.");
}
}
}
}