Aligned code with the same APIs exposed in ACCESS port type
This commit is contained in:
parent
2ce233c694
commit
9c8633d8e1
|
@ -52,23 +52,15 @@ public class SharingManagement {
|
||||||
@Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}" +
|
@Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}" +
|
||||||
SharingPath.CONTEXTS_PATH_PART )
|
SharingPath.CONTEXTS_PATH_PART )
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@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)
|
@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId)
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
|
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
|
||||||
logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME, contextId);
|
CalledMethodProvider.instance.set("getInstanceContexts");
|
||||||
// setRESTCalledMethod(HTTPMETHOD.PUT, type);
|
|
||||||
CalledMethodProvider.instance.set("listInstanceContexts");
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||||
UUID uuid = null;
|
erManagement.setUUID(UUID.fromString(instanceId));
|
||||||
try {
|
|
||||||
uuid = UUID.fromString(instanceId);
|
|
||||||
} catch(Exception e) {
|
|
||||||
throw new ResourceRegistryException(e);
|
|
||||||
}
|
|
||||||
erManagement.setUUID(uuid);
|
|
||||||
return erManagement.getContexts();
|
return erManagement.getContexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,22 +86,8 @@ public class SharingManagement {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
UUID uuid = null;
|
elementManagement.setUUID(UUID.fromString(instanceId));
|
||||||
try {
|
return elementManagement.addToContext(UUID.fromString(contextId));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -132,24 +110,8 @@ public class SharingManagement {
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
UUID uuid = null;
|
elementManagement.setUUID(UUID.fromString(instanceId));
|
||||||
|
elementManagement.removeFromContext(UUID.fromString(contextId));
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
return Response.status(Status.NO_CONTENT).build();
|
return Response.status(Status.NO_CONTENT).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue