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