add entity-type to message when no UUID is found for a DB ID (#5163)

* add entity-type to message

* Update server/src/main/java/com/cloud/uuididentity/UUIDManagerImpl.java

* update for review comments

* syntax

* Avoid NPE when entity type is null, and throw appropriate exception

Co-authored-by: Daan Hoogland <dahn@onecht.net>
Co-authored-by: Suresh Kumar Anaparti <suresh.anaparti@shapeblue.com>
This commit is contained in:
dahn 2021-07-21 13:01:08 +02:00 committed by GitHub
parent 84e52c9263
commit 1f8b34f5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -117,12 +117,16 @@ public class UUIDManagerImpl implements UUIDManager {
if (customId == null) {
return null;
}
if (entityType == null ) {
throw new InvalidParameterValueException("Unknown entity type");
}
Identity identity = (Identity) this._entityMgr.findById(entityType, customId);
if (identity == null) {
throw new InvalidParameterValueException("Unable to find UUID for id " + customId);
throw new InvalidParameterValueException(String.format("Unable to find UUID for id [%s] of type [%s]",
customId, entityType.getSimpleName()));
}
return identity.getUuid();
}
}