if (name == null || name.trim().length() == 0) {
result.rejectValue("displayName", null, null, "This field cannot be blank");
return FIELD_ERROR;
}
Role databaseRole = loadRole(name.trim());
if (databaseRole != null && !databaseRole.getId().equals(role.getId())) {
result.rejectValue("displayName", MessageConstants.ERROR_NAMETAKEN);
return FIELD_ERROR;
}
if (name.length() > Role.NAME_LENGTH) {
return FIELD_ERROR;
}
if (databaseRole != null) {
if (databaseRole.getCanManageUsers() && !role.getCanManageUsers() &&
!userDao.canRemovePermissionFromRole(role.getId(), "canManageUsers")) {
return "You cannot remove the Manage Users privilege from this role.";
}
if (databaseRole.getCanManageRoles() && !role.getCanManageRoles() &&
!userDao.canRemovePermissionFromRole(role.getId(), "canManageRoles")) {
return "You cannot remove the Manage Roles privilege from this role.";
}
}