Fix the application path (was clashing with jersey) and move the declaration to the io module.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@160249 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
83ad08446c
commit
34bb1f57ff
|
@ -8,6 +8,8 @@ package org.gcube.resourcemanagement.manager.io.rs;
|
|||
*/
|
||||
public class RMContextPath {
|
||||
|
||||
public static final String APPLICATION_PATH = "/resource-manager";
|
||||
|
||||
public static final String CONTEXT_ROOT = "context";
|
||||
|
||||
public static final String CREATE_PATH_PART = "create";
|
||||
|
|
|
@ -3,13 +3,14 @@ package org.gcube.resourcemanagement.manager.webapp;
|
|||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.resourcemanagement.manager.io.rs.RMContextPath;
|
||||
import org.gcube.resourcemanagement.manager.webapp.rs.RMContext;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
/**
|
||||
* @author Manuele Simi (ISTI - CNR)
|
||||
*/
|
||||
@ApplicationPath("/")
|
||||
@ApplicationPath(RMContextPath.APPLICATION_PATH)
|
||||
public class ResourceInitializer extends ResourceConfig {
|
||||
|
||||
public static final String APPLICATION_JSON_CHARSET_UTF_8 = MediaType.APPLICATION_JSON + ";charset=UTF-8";
|
||||
|
|
|
@ -35,17 +35,16 @@ public class RMContext {
|
|||
*/
|
||||
@POST
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public Response create(String json) throws JsonParseException, JsonMappingException, IOException, IllegalArgumentException
|
||||
{
|
||||
logger.info("Requested to create context {} with json {}",
|
||||
Context.NAME, json);
|
||||
public Response create(String json)
|
||||
throws JsonParseException, JsonMappingException, IOException, IllegalArgumentException {
|
||||
logger.info("Requested to create context {} with json {}", Context.NAME, json);
|
||||
Context inputContext = ISMapper.unmarshal(Context.class, json);
|
||||
if (Objects.nonNull(inputContext.getParent()))
|
||||
return Response.status(Status.BAD_REQUEST).build();
|
||||
String response = "All good";
|
||||
//TODO
|
||||
return Response.status(Status.CREATED).entity(response).
|
||||
type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
||||
// TODO
|
||||
return Response.status(Status.CREATED).entity(response).type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public class RMContextTest extends JerseyTest {
|
|||
public void step1_Create() {
|
||||
Context newContext = new ContextImpl(contextName);
|
||||
try {
|
||||
System.out.print(ISMapper.marshal(newContext));
|
||||
Response create = target("context").request()
|
||||
.post(Entity.entity(ISMapper.marshal(newContext), MediaType.APPLICATION_JSON + ";charset=UTF-8"));
|
||||
|
||||
|
|
Reference in New Issue