Fix: Exception when editing group name to same name from WebUI
If the user edits the group name in the Web UI, the "Rename Group" button is enabled. If the name is then edited back to its original value, the button remains enabled. If the user then submits the edit, an exception occurs: JdbcSQLException: Unique index or primary key violation Add a check in the PutName REST view to prevent the rename from being executed with the same name. If the new name is the same, just return it. Change-Id: Ifba0ba646ee7895596cec22449abe8e2a466c375
This commit is contained in:
@@ -55,9 +55,14 @@ public class PutName implements RestModifyView<GroupResource, Input> {
|
||||
throw new BadRequestException("name is required");
|
||||
}
|
||||
|
||||
final String newName = input.name.trim();
|
||||
if (resource.toAccountGroup().getName().equals(newName)) {
|
||||
return newName;
|
||||
}
|
||||
|
||||
try {
|
||||
return performRenameGroupFactory.create().renameGroup(
|
||||
resource.toAccountGroup().getId(), input.name).group.getName();
|
||||
resource.toAccountGroup().getId(), newName).group.getName();
|
||||
} catch (NoSuchGroupException e) {
|
||||
throw new ResourceNotFoundException();
|
||||
} catch (InvalidNameException e) {
|
||||
|
||||
Reference in New Issue
Block a user