Implementing service

This commit is contained in:
Luca Frosini 2024-11-18 17:43:00 +01:00
parent f36f2c1334
commit f99b75aec2
1 changed files with 52 additions and 52 deletions

View File

@ -2,11 +2,11 @@ package org.gcube.resourcemanagement.rest;
import java.util.UUID;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import org.gcube.informationsystem.contexts.reference.entities.Context;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
@ -54,52 +54,52 @@ public class SharingManager extends BaseREST {
* The json contains the instantiation of templates
*
*/
// @POST
// @Path("/" + SharingPath.CONTEXTS_PATH_PART + "/{" + ContextManager.CONTEXT_UUID_PATH_PARAMETER + "}/"
// + "{" + TYPE_PATH_PARAMETER + "}" + "/{" + UUID_PATH_PARAMETER + "}")
// @Produces(BaseREST.APPLICATION_JSON_CHARSET_UTF_8)
// public String addRemove(
// @PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String contextId,
// @PathParam(TYPE_PATH_PARAMETER) String type,
// @PathParam(UUID_PATH_PARAMETER) String instanceId,
// @QueryParam(SharingPath.OPERATION_QUERY_PARAMETER) SharingOperation operation,
// @QueryParam(SharingPath.DRY_RUN_QUERY_QUERY_PARAMETER) @DefaultValue("false") Boolean dryRun,
// String json)
// throws WebApplicationException {
//
// StringBuffer calledMethod = new StringBuffer();
// if(dryRun==null) {
// dryRun = false;
// }
//
// if(dryRun) {
// calledMethod.append("dryRun");
// }
//
// if(operation == SharingOperation.ADD) {
// logger.info("Requested {} {} with UUID {} to {} with UUID {}", dryRun? "a dry run for adding": "to add", type, instanceId, Context.NAME, contextId);
// calledMethod.append("AddToContext");
// }else {
// logger.info("Requested {} {} with UUID {} from {} with UUID {}", dryRun? "a dry run for removing": "to remove", type, instanceId, Context.NAME, contextId);
// calledMethod.append("RemoveFromContext");
// }
// setAccountingMethod(calledMethod.toString());
//
//
// UUID instanceUUID = UUID.fromString(instanceId);
// UUID contextUUID = UUID.fromString(contextId);
//
// /*
// * This API should share the the logic of ServiceManager and PlanManager
// */
//
// if(operation == SharingOperation.ADD) {
//
// }else {
//
// }
//
// return "";
// }
@POST
@Path("/" + SharingPath.CONTEXTS_PATH_PART + "/{" + ContextManager.CONTEXT_UUID_PATH_PARAMETER + "}/"
+ "{" + TYPE_PATH_PARAMETER + "}" + "/{" + UUID_PATH_PARAMETER + "}")
@Produces(BaseREST.APPLICATION_JSON_CHARSET_UTF_8)
public String addRemove(
@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String contextId,
@PathParam(TYPE_PATH_PARAMETER) String type,
@PathParam(UUID_PATH_PARAMETER) String instanceId,
@QueryParam(SharingPath.OPERATION_QUERY_PARAMETER) SharingOperation operation,
@QueryParam(SharingPath.DRY_RUN_QUERY_QUERY_PARAMETER) @DefaultValue("false") Boolean dryRun,
String json)
throws WebApplicationException {
StringBuffer calledMethod = new StringBuffer();
if(dryRun==null) {
dryRun = false;
}
if(dryRun) {
calledMethod.append("dryRun");
}
if(operation == SharingOperation.ADD) {
logger.info("Requested {} {} with UUID {} to {} with UUID {}", dryRun? "a dry run for adding": "to add", type, instanceId, Context.NAME, contextId);
calledMethod.append("AddToContext");
}else {
logger.info("Requested {} {} with UUID {} from {} with UUID {}", dryRun? "a dry run for removing": "to remove", type, instanceId, Context.NAME, contextId);
calledMethod.append("RemoveFromContext");
}
setAccountingMethod(calledMethod.toString());
UUID instanceUUID = UUID.fromString(instanceId);
UUID contextUUID = UUID.fromString(contextId);
/*
* This API should share the the logic of ServiceManager and PlanManager
*/
if(operation == SharingOperation.ADD) {
}else {
}
return "";
}
}