Aligned code with the same APIs exposed in ACCESS port type

This commit is contained in:
Luca Frosini 2020-11-11 14:17:28 +01:00
parent 2ce233c694
commit 9c8633d8e1
1 changed files with 8 additions and 46 deletions

View File

@ -52,23 +52,15 @@ public class SharingManagement {
@Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}" +
SharingPath.CONTEXTS_PATH_PART )
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String listContexts(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
public String getInstanceContexts(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId,
@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME, contextId);
// setRESTCalledMethod(HTTPMETHOD.PUT, type);
CalledMethodProvider.instance.set("listInstanceContexts");
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
CalledMethodProvider.instance.set("getInstanceContexts");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
UUID uuid = null;
try {
uuid = UUID.fromString(instanceId);
} catch(Exception e) {
throw new ResourceRegistryException(e);
}
erManagement.setUUID(uuid);
erManagement.setUUID(UUID.fromString(instanceId));
return erManagement.getContexts();
}
@ -94,22 +86,8 @@ public class SharingManagement {
@SuppressWarnings("rawtypes")
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
UUID uuid = null;
try {
uuid = UUID.fromString(instanceId);
} catch(Exception e) {
throw new ResourceRegistryException(e);
}
elementManagement.setUUID(uuid);
UUID contextUUID = null;
try {
contextUUID = UUID.fromString(contextId);
} catch(Exception e) {
throw new ResourceRegistryException(e);
}
return elementManagement.addToContext(contextUUID);
elementManagement.setUUID(UUID.fromString(instanceId));
return elementManagement.addToContext(UUID.fromString(contextId));
}
/*
@ -132,24 +110,8 @@ public class SharingManagement {
@SuppressWarnings("rawtypes")
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
UUID uuid = null;
try {
uuid = UUID.fromString(instanceId);
} catch(Exception e) {
throw new ResourceRegistryException(e);
}
elementManagement.setUUID(uuid);
UUID contextUUID = null;
try {
contextUUID = UUID.fromString(contextId);
} catch(Exception e) {
throw new ResourceRegistryException(e);
}
elementManagement.removeFromContext(contextUUID);
elementManagement.setUUID(UUID.fromString(instanceId));
elementManagement.removeFromContext(UUID.fromString(contextId));
return Response.status(Status.NO_CONTENT).build();
}