Refactored to use Element getTypeName() function

This commit is contained in:
Luca Frosini 2023-04-27 11:13:35 +02:00
parent 83deeb649b
commit af2ef0ccb5
1 changed files with 8 additions and 8 deletions

View File

@ -328,7 +328,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
protected <ERElem extends ERElement> String internalCreate(ERElem er)
throws SchemaViolationException, AlreadyPresentException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
String json = ElementMapper.marshal(er);
UUID uuid = er.getUUID();
if (uuid == null) {
@ -379,7 +379,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <ERElem extends ERElement> boolean exist(ERElem er)
throws AvailableInAnotherContextException, ResourceRegistryException {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID uuid = er.getUUID();
return exist(type, uuid);
}
@ -428,7 +428,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public <ERElem extends ERElement> ERElem read(ERElem er)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID uuid = er.getUUID();
String ret = read(type, uuid);
return (ERElem) ElementMapper.unmarshal(ERElement.class, ret);
@ -488,7 +488,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public <ERElem extends ERElement> ERElem update(ERElem er)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
String json = ElementMapper.marshal(er);
UUID uuid = er.getUUID();
String ret = update(type, json, uuid);
@ -564,7 +564,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public <ERElem extends ERElement> boolean delete(ERElem er)
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID uuid = er.getUUID();
return delete(type, uuid);
} catch (ResourceRegistryException e) {
@ -840,7 +840,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public List<ERElement> addToContext(ERElement er, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID instanceUUID = er.getUUID();
return addToContext(type, instanceUUID, contextUUID, dryRun);
} catch (ResourceRegistryException e) {
@ -907,7 +907,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public List<ERElement> removeFromContext(ERElement er, UUID contextUUID, Boolean dryRun)
throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException {
try {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID instanceUUID = er.getUUID();
return removeFromContext(type, instanceUUID, contextUUID, dryRun);
} catch (ResourceRegistryException e) {
@ -966,7 +966,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <ERElem extends ERElement> Map<UUID, String> getElementContexts(ERElem er)
throws NotFoundException, ResourceRegistryException {
String type = TypeUtility.getTypeName(er);
String type = er.getTypeName();
UUID instanceUUID = er.getUUID();
return getElementContexts(type, instanceUUID);
}