Refs #10244: Expose getSchema() API through Schema port type in addition to Access port type
Task-Url: https://support.d4science.org/issues/10244 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158261 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d12160248c
commit
bc2fdf8afd
|
@ -2,10 +2,13 @@ package org.gcube.informationsystem.resourceregistry.rest;
|
||||||
|
|
||||||
import javax.ws.rs.ApplicationPath;
|
import javax.ws.rs.ApplicationPath;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DefaultValue;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
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.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
|
@ -14,6 +17,8 @@ import org.gcube.informationsystem.model.AccessType;
|
||||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.SchemaPath;
|
import org.gcube.informationsystem.resourceregistry.api.rest.SchemaPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
|
||||||
|
@ -43,9 +48,7 @@ public class SchemaManager {
|
||||||
@Path("{" + TYPE_PATH_PARAM + "}")
|
@Path("{" + TYPE_PATH_PARAM + "}")
|
||||||
@Consumes({ MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8 })
|
@Consumes({ MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8 })
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public Response create(
|
public Response create(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
||||||
@PathParam(TYPE_PATH_PARAM) String type,
|
|
||||||
String json)
|
|
||||||
throws SchemaException, ResourceRegistryException {
|
throws SchemaException, ResourceRegistryException {
|
||||||
logger.info("Requested {} registration with schema {}", type, json);
|
logger.info("Requested {} registration with schema {}", type, json);
|
||||||
|
|
||||||
|
@ -79,7 +82,23 @@ public class SchemaManager {
|
||||||
|
|
||||||
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||||
String ret = schemaManagement.create(json, accessType);
|
String ret = schemaManagement.create(json, accessType);
|
||||||
return Response.status(Status.CREATED).entity(ret).type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
return Response.status(Status.CREATED).entity(ret).type(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* e.g. GET /resource-registry/schema/ContactFacet?polymorphic=true
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("{" + TYPE_PATH_PARAM + "}")
|
||||||
|
@Consumes({ MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8 })
|
||||||
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
|
public String read(@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
|
@QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
|
||||||
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
|
logger.info("Requested Schema for type {}", type);
|
||||||
|
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||||
|
return schemaManagement.read(type, polymorphic);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue