|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package org.gcube.gcat.rest;
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.BadRequestException;
|
|
|
|
|
import javax.ws.rs.Consumes;
|
|
|
|
|
import javax.ws.rs.DELETE;
|
|
|
|
|
import javax.ws.rs.DefaultValue;
|
|
|
|
@ -18,6 +19,7 @@ import javax.ws.rs.core.Response.ResponseBuilder;
|
|
|
|
|
import javax.ws.rs.core.Response.Status;
|
|
|
|
|
import javax.ws.rs.core.UriInfo;
|
|
|
|
|
|
|
|
|
|
import org.gcube.datacatalogue.metadatadiscovery.DataCalogueMetadataFormatReader;
|
|
|
|
|
import org.gcube.gcat.ResourceInitializer;
|
|
|
|
|
import org.gcube.gcat.profile.ISProfile;
|
|
|
|
|
|
|
|
|
@ -31,6 +33,7 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
|
|
|
|
|
|
|
|
|
public static final String PROFILE_NAME_PARAMETER = "PROFILE_NAME";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Context
|
|
|
|
|
private UriInfo uriInfo;
|
|
|
|
|
|
|
|
|
@ -58,6 +61,11 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
|
|
|
|
@DefaultValue(MediaType.APPLICATION_XML) @HeaderParam("Accept") String accept) {
|
|
|
|
|
setCalledMethod("GET /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}");
|
|
|
|
|
try {
|
|
|
|
|
// If the name is SCHEMA
|
|
|
|
|
if(name.compareToIgnoreCase(SCHEMA)==0) {
|
|
|
|
|
return DataCalogueMetadataFormatReader.getProfileSchemaString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ISProfile isProfile = new ISProfile();
|
|
|
|
|
boolean xml = false;
|
|
|
|
|
if(accept.startsWith(MediaType.APPLICATION_XML)) {
|
|
|
|
@ -78,6 +86,9 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
|
|
|
|
public Response createOrUpdate(@PathParam(PROFILE_NAME_PARAMETER) String name, String xml) {
|
|
|
|
|
setCalledMethod("PUT /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}");
|
|
|
|
|
try {
|
|
|
|
|
if(name.compareToIgnoreCase(SCHEMA)==0) {
|
|
|
|
|
throw new BadRequestException("You cannot manage the profile schema");
|
|
|
|
|
}
|
|
|
|
|
ISProfile isProfile = new ISProfile();
|
|
|
|
|
boolean created = isProfile.createOrUpdate(name, xml);
|
|
|
|
|
ResponseBuilder responseBuilder = null;
|
|
|
|
@ -101,6 +112,9 @@ public class Profile extends BaseREST implements org.gcube.gcat.api.interfaces.P
|
|
|
|
|
public Response delete(@PathParam(PROFILE_NAME_PARAMETER) String name) {
|
|
|
|
|
setCalledMethod("DELETE /" + PROFILES + "/{" + PROFILE_NAME_PARAMETER + "}");
|
|
|
|
|
try {
|
|
|
|
|
if(name.compareToIgnoreCase(SCHEMA)==0) {
|
|
|
|
|
throw new BadRequestException("You cannot manage the profile schema");
|
|
|
|
|
}
|
|
|
|
|
ISProfile isProfile = new ISProfile();
|
|
|
|
|
isProfile.delete(name);
|
|
|
|
|
return Response.status(Status.NO_CONTENT).build();
|
|
|
|
|