private <T extends DummyObject> void renameObject(Class<T> type, Map<String,T> map, String id, String oldName, String newName) throws ObjectDoesNotExistException, ObjectAlreadyExistsException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException {
checkBlockOperations();
recordWriteOperation("modify");
breakIt(modifyBreakMode, "modify");
delayOperation();
T existingObject;
if (enforceUniqueName) {
String normalOldName = normalize(oldName);
String normalNewName = normalize(newName);
existingObject = map.get(normalOldName);
if (existingObject == null) {
throw new ObjectDoesNotExistException("Cannot rename, "+type.getSimpleName()+" with username '"+normalOldName+"' does not exist");
}
if (map.containsKey(normalNewName)) {
throw new ObjectAlreadyExistsException("Cannot rename, "+type.getSimpleName()+" with username '"+normalNewName+"' already exists");
}
map.put(normalNewName, existingObject);
map.remove(normalOldName);
} else {
existingObject = (T) allObjects.get(id);
}
existingObject.setName(newName);
if (existingObject instanceof DummyAccount) {
changeDescriptionIfNeeded((DummyAccount) existingObject);
}
}