GUACAMOLE-220: Clarify group rename validation logic.

This commit is contained in:
Michael Jumper
2018-09-27 20:06:18 -07:00
parent fedccebb93
commit a552d88c54

View File

@@ -162,19 +162,15 @@ public class UserGroupService extends ModeledDirectoryObjectService<ModeledUserG
super.beforeUpdate(user, object, model); super.beforeUpdate(user, object, model);
// Username must not be blank // Group names must not be blank
if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty()) if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())
throw new GuacamoleClientException("The group name must not be blank."); throw new GuacamoleClientException("The group name must not be blank.");
// Check whether such a group is already present // Do not allow groups to be renamed if the name collides with that of
// another, existing group
UserGroupModel existing = userGroupMapper.selectOne(model.getIdentifier()); UserGroupModel existing = userGroupMapper.selectOne(model.getIdentifier());
if (existing != null) { if (existing != null && !existing.getObjectID().equals(model.getObjectID()))
throw new GuacamoleClientException("Group \"" + model.getIdentifier() + "\" already exists.");
// Do not rename to existing user group
if (!existing.getObjectID().equals(model.getObjectID()))
throw new GuacamoleClientException("Group \"" + model.getIdentifier() + "\" already exists.");
}
} }