Fixed Jersey REST paths
This commit is contained in:
parent
eca3d130c8
commit
a52f8980e8
|
@ -5,13 +5,16 @@ import java.util.Iterator;
|
|||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
@ -39,6 +42,8 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(Configuration.class);
|
||||
|
||||
public static final String CONTEXT_FULLNAME_PARAMETER = "CONTEXT_FULLNAME_PARAMETER";
|
||||
|
||||
protected String checkContext(String context) throws WebServiceException {
|
||||
if(context==null || context.compareTo("")==0) {
|
||||
throw new BadRequestException("Please provide a valid context as path parameter");
|
||||
|
@ -106,8 +111,9 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
}
|
||||
|
||||
@GET
|
||||
@Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}")
|
||||
@Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public Response read(String context) throws WebServiceException {
|
||||
public Response read(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context) throws WebServiceException {
|
||||
try {
|
||||
checkContext(context);
|
||||
return read();
|
||||
|
@ -137,9 +143,10 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}")
|
||||
@Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
@Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String createOrUpdate(String context, String json) throws WebServiceException {
|
||||
public String createOrUpdate(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context, String json) throws WebServiceException {
|
||||
try {
|
||||
ServiceCatalogueConfiguration catalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json);
|
||||
checkContext(context, catalogueConfiguration);
|
||||
|
@ -172,9 +179,10 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}")
|
||||
@Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
@Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public Response patch(String context, String json) throws WebServiceException {
|
||||
public Response patch(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context, String json) throws WebServiceException {
|
||||
try {
|
||||
checkContext(context);
|
||||
return patch(json);
|
||||
|
@ -226,7 +234,9 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
}
|
||||
|
||||
@DELETE
|
||||
public Response delete(String context, Boolean purge) throws WebServiceException {
|
||||
@PathParam(CONTEXT_FULLNAME_PARAMETER)
|
||||
public Response delete(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context,
|
||||
@QueryParam(GCatConstants.PURGE_QUERY_PARAMETER) @DefaultValue("false") Boolean purge) throws WebServiceException {
|
||||
try {
|
||||
checkContext(context);
|
||||
if(purge) {
|
||||
|
@ -255,7 +265,8 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
|
|||
}
|
||||
|
||||
@PURGE
|
||||
public Response purge(String context) throws WebServiceException {
|
||||
@PathParam(CONTEXT_FULLNAME_PARAMETER)
|
||||
public Response purge(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context) throws WebServiceException {
|
||||
try {
|
||||
checkContext(context);
|
||||
return purge();
|
||||
|
|
Loading…
Reference in New Issue