Fixed URL path

This commit is contained in:
Luca Frosini 2020-11-24 15:39:09 +01:00
parent 251d239773
commit 64b0c49771
1 changed files with 46 additions and 46 deletions

View File

@ -26,94 +26,94 @@ import org.slf4j.LoggerFactory;
@Path(SharingPath.SHARING_PATH_PART) @Path(SharingPath.SHARING_PATH_PART)
public class SharingManagement { public class SharingManagement {
private static Logger logger = LoggerFactory.getLogger(SharingManagement.class); private static Logger logger = LoggerFactory.getLogger(SharingManagement.class);
/* /*
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type) { * protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type) {
List<String> list = new ArrayList<>(); * List<String> list = new ArrayList<>();
list.add(SharingPath.SHARING_PATH_PART); * list.add(SharingPath.SHARING_PATH_PART); list.add(type); list.add("{" +
list.add(type); * AccessPath.UUID_PATH_PARAM + "}"); list.add(SharingPath.CONTEXTS_PATH_PART);
list.add("{" + AccessPath.UUID_PATH_PARAM + "}"); * list.add("{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}");
list.add(SharingPath.CONTEXTS_PATH_PART); * Access.setRESTCalledMethod(httpMethod, list, null); }
list.add("{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}"); */
Access.setRESTCalledMethod(httpMethod, list, null);
}
*/
/* /*
* GET /sharing/{TYPE_NAME}/{UUID}/contexts/ * GET /sharing/{TYPE_NAME}/{UUID}/contexts/ e.g GET
* e.g GET /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/contexts * /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/
* Where 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID * contexts Where 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID
* *
* Return a list of UUID identifying the context the instance belongs to. * Return a list of UUID identifying the context the instance belongs to.
*/ */
@GET @GET
@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 getInstanceContexts(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId, public String getInstanceContexts(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId) @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId,
@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException { throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId); logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
CalledMethodProvider.instance.set("getInstanceContexts"); CalledMethodProvider.instance.set("getInstanceContexts");
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type); ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setUUID(UUID.fromString(instanceId)); erManagement.setUUID(UUID.fromString(instanceId));
return erManagement.getContexts(); return erManagement.getContexts();
} }
/* /*
* PUT /sharing/{TYPE_NAME}/{UUID}/contexts/{CONTEXT_UUID} * PUT /sharing/{TYPE_NAME}/{UUID}/contexts/{CONTEXT_UUID} e.g PUT
* e.g PUT * /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/
* /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/contexts/67062c11-9c3a-4906-870d-7df6a43408b0 * contexts/67062c11-9c3a-4906-870d-7df6a43408b0 Where
* Where 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID * 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID and
* and 67062c11-9c3a-4906-870d-7df6a43408b0/ is the Context UUID * 67062c11-9c3a-4906-870d-7df6a43408b0/ is the Context UUID
* *
*/ */
@PUT @PUT
@Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}" + @Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}/"
SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" ) + SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}")
public boolean add(@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId, public boolean add(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
@PathParam(AccessPath.UUID_PATH_PARAM) String instanceId,
@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId) @PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException { throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME, contextId); logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME, contextId);
// setRESTCalledMethod(HTTPMETHOD.PUT, type); // setRESTCalledMethod(HTTPMETHOD.PUT, type);
CalledMethodProvider.instance.set("addToContext"); CalledMethodProvider.instance.set("addToContext");
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type); ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
elementManagement.setUUID(UUID.fromString(instanceId)); elementManagement.setUUID(UUID.fromString(instanceId));
return elementManagement.addToContext(UUID.fromString(contextId)); return elementManagement.addToContext(UUID.fromString(contextId));
} }
/* /*
* DELETE /sharing/{TYPE_NAME}/{UUID}/contexts/{CONTEXT_UUID} * DELETE /sharing/{TYPE_NAME}/{UUID}/contexts/{CONTEXT_UUID} e.g DELETE
* e.g DELETE * /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/
* /resource-registry/sharing/HostingNode/16032d09-3823-444e-a1ff-a67de4f350a8/contexts/67062c11-9c3a-4906-870d-7df6a43408b0 * contexts/67062c11-9c3a-4906-870d-7df6a43408b0 Where
* Where 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID * 16032d09-3823-444e-a1ff-a67de4f350a8 is the HostingNode UUID and
* and 67062c11-9c3a-4906-870d-7df6a43408b0 is the Context UUID * 67062c11-9c3a-4906-870d-7df6a43408b0 is the Context UUID
* *
*/ */
@DELETE @DELETE
@Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}" + @Path("{" + AccessPath.TYPE_PATH_PARAM + "}" + "/{" + AccessPath.UUID_PATH_PARAM + "}/"
SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}" ) + SharingPath.CONTEXTS_PATH_PART + "/{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}")
public Response remove(@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String instanceId, public Response remove(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
@PathParam(AccessPath.UUID_PATH_PARAM) String instanceId,
@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId) @PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String contextId)
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException { throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
logger.info("Requested to remove {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME, contextId); logger.info("Requested to remove {} with UUID {} to {} with UUID {}", type, instanceId, Context.NAME,
contextId);
// setRESTCalledMethod(HTTPMETHOD.DELETE, type); // setRESTCalledMethod(HTTPMETHOD.DELETE, type);
CalledMethodProvider.instance.set("removeFromContext"); CalledMethodProvider.instance.set("removeFromContext");
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
ElementManagement elementManagement = ElementManagementUtility.getERManagement(type); ElementManagement elementManagement = ElementManagementUtility.getERManagement(type);
elementManagement.setUUID(UUID.fromString(instanceId)); elementManagement.setUUID(UUID.fromString(instanceId));
elementManagement.removeFromContext(UUID.fromString(contextId)); elementManagement.removeFromContext(UUID.fromString(contextId));
return Response.status(Status.NO_CONTENT).build(); return Response.status(Status.NO_CONTENT).build();
} }
} }