Fixing profile
This commit is contained in:
parent
816effa271
commit
bcd4038932
|
@ -24,7 +24,7 @@ public class BaseREST {
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
protected HttpHeaders headers;
|
protected HttpHeaders httpHeaders;
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
protected UriInfo uriInfo;
|
protected UriInfo uriInfo;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.DefaultValue;
|
import javax.ws.rs.DefaultValue;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HeaderParam;
|
|
||||||
import javax.ws.rs.HttpMethod;
|
import javax.ws.rs.HttpMethod;
|
||||||
import javax.ws.rs.InternalServerErrorException;
|
import javax.ws.rs.InternalServerErrorException;
|
||||||
import javax.ws.rs.NotAllowedException;
|
import javax.ws.rs.NotAllowedException;
|
||||||
|
@ -16,12 +15,10 @@ import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.Context;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.core.UriInfo;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
//import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
//import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||||
|
@ -63,9 +60,6 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
||||||
PROFILE_VALIDATION_ERROR = validationError.toString();
|
PROFILE_VALIDATION_ERROR = validationError.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Context
|
|
||||||
private UriInfo uriInfo;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not used as REST method, implemented to respect {@link org.gcube.gcat.api.interfaces.Item} interface
|
* Not used as REST method, implemented to respect {@link org.gcube.gcat.api.interfaces.Item} interface
|
||||||
*/
|
*/
|
||||||
|
@ -137,11 +131,12 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
||||||
/**
|
/**
|
||||||
* This API allow to read a profile definition.<br/>
|
* This API allow to read a profile definition.<br/>
|
||||||
*
|
*
|
||||||
* @param accept This API return by default the content in XML.
|
* This API return by default the content in XML.
|
||||||
* <p>
|
* <p>
|
||||||
* It is possible reading a profile in JSON by specifing the HTTP Header:<br/>
|
* It is possible reading a profile in JSON by specifing the HTTP Header:<br/>
|
||||||
* <code>Accept: application/json</code>
|
* <code>Accept: application/json</code>
|
||||||
* </p>
|
*</p>
|
||||||
|
*
|
||||||
* @param name the name of the profile
|
* @param name the name of the profile
|
||||||
* @return the profile definition
|
* @return the profile definition
|
||||||
*
|
*
|
||||||
|
@ -158,8 +153,8 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
||||||
@Path("/{" + PROFILE_NAME_PARAMETER + "}")
|
@Path("/{" + PROFILE_NAME_PARAMETER + "}")
|
||||||
@Consumes({MediaType.APPLICATION_XML, GCatConstants.APPLICATION_JSON_CHARSET_UTF_8})
|
@Consumes({MediaType.APPLICATION_XML, GCatConstants.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
@Produces({MediaType.APPLICATION_XML, GCatConstants.APPLICATION_JSON_CHARSET_UTF_8})
|
@Produces({MediaType.APPLICATION_XML, GCatConstants.APPLICATION_JSON_CHARSET_UTF_8})
|
||||||
public String read(@PathParam(PROFILE_NAME_PARAMETER) String name,
|
@Override
|
||||||
@DefaultValue(MediaType.APPLICATION_XML) @HeaderParam("Accept") String accept) {
|
public String read(@PathParam(PROFILE_NAME_PARAMETER) String name) { // @DefaultValue(MediaType.APPLICATION_XML) @HeaderParam("Accept") String accept) {
|
||||||
setCalledMethod("GET /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}");
|
setCalledMethod("GET /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}");
|
||||||
try {
|
try {
|
||||||
// If the name is SCHEMA
|
// If the name is SCHEMA
|
||||||
|
@ -167,6 +162,8 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
||||||
return DataCalogueMetadataFormatReader.getProfileSchemaString();
|
return DataCalogueMetadataFormatReader.getProfileSchemaString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String accept = httpHeaders.getHeaderString("Accept");
|
||||||
|
|
||||||
ISProfile isProfile = new ISProfile();
|
ISProfile isProfile = new ISProfile();
|
||||||
boolean xml = true;
|
boolean xml = true;
|
||||||
if(accept.startsWith(MediaType.APPLICATION_JSON)) {
|
if(accept.startsWith(MediaType.APPLICATION_JSON)) {
|
||||||
|
@ -239,11 +236,6 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String read(String name) {
|
|
||||||
return read(name, MediaType.APPLICATION_XML);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String update(String name, String xml) {
|
public String update(String name, String xml) {
|
||||||
return createOrUpdate(name, xml).getEntity().toString();
|
return createOrUpdate(name, xml).getEntity().toString();
|
||||||
|
|
Loading…
Reference in New Issue