Unmarshal the context in the create method.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@158883 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2017-11-29 04:41:59 +00:00
parent a4e32dd47a
commit 70e6b303b8
1 changed files with 12 additions and 2 deletions

View File

@ -1,18 +1,25 @@
package org.gcube.resourcemanagement.manager.webapp.rs;
import java.io.IOException;
import java.util.Objects;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.resourcemanagement.manager.io.rs.*;
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
/**
* Methods for {@link org.gcube.informationsystem.model.entity.Context} operations.
* Methods for manipulating {@link org.gcube.informationsystem.model.entity.Context}s.
*
* @author Manuele Simi (ISTI-CNR)
*
@ -27,10 +34,13 @@ public class Context {
*/
@POST
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public Response create(String json)
public Response create(String json) throws JsonParseException, JsonMappingException, IOException
{
logger.info("Requested to create context {} with json {}",
org.gcube.informationsystem.model.entity.Context.NAME, json);
org.gcube.informationsystem.model.entity.Context inputContext = ISMapper.unmarshal(org.gcube.informationsystem.model.entity.Context.class, json);
if (Objects.isNull(inputContext.getParent()))
throw new IllegalArgumentException("Unsupported parent context");
String response = "All good";
//TODO
return Response.status(Status.CREATED).entity(response).