Fixing REST path
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@131072 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8891ab4fe4
commit
8096b1cddc
|
@ -5,7 +5,6 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.AccessRESTPath;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
|
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.Query;
|
import org.gcube.informationsystem.resourceregistry.api.Query;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
|
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
|
||||||
|
@ -14,6 +13,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.EntityManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.EntityManagementImpl;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.QueryImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.QueryImpl;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
|
||||||
|
@ -24,11 +24,14 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
@Path(AccessRESTPath.ACCESS_PATH_PART)
|
@Path(AccessPath.ACCESS_PATH_PART)
|
||||||
public class Access {
|
public class Access {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(Access.class);
|
private static Logger logger = LoggerFactory.getLogger(Access.class);
|
||||||
|
|
||||||
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
public static final String TYPE_PATH_PARAM = "type";
|
||||||
|
|
||||||
protected Query queryManager = new QueryImpl();
|
protected Query queryManager = new QueryImpl();
|
||||||
protected EntityManagement entityManager = new EntityManagementImpl();
|
protected EntityManagement entityManager = new EntityManagementImpl();
|
||||||
protected SchemaManagement schemaManager = new SchemaManagementImpl();
|
protected SchemaManagement schemaManager = new SchemaManagementImpl();
|
||||||
|
@ -41,62 +44,64 @@ public class Access {
|
||||||
* @throws InvalidQueryException
|
* @throws InvalidQueryException
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
public String query(@QueryParam(AccessRESTPath.QUERY_PARAM) String query,
|
public String query(@QueryParam(AccessPath.QUERY_PARAM) String query,
|
||||||
@QueryParam(AccessRESTPath.FETCH_PLAN_PARAM) String fetchPlan)
|
@QueryParam(AccessPath.FETCH_PLAN_PARAM) String fetchPlan)
|
||||||
throws InvalidQueryException {
|
throws InvalidQueryException {
|
||||||
logger.info("Requested query (fetch plan {}):\n{}", fetchPlan, query);
|
logger.info("Requested query (fetch plan {}):\n{}", fetchPlan, query);
|
||||||
return queryManager.execute(query, fetchPlan);
|
return queryManager.execute(query, fetchPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. /resource-registry/access/facetInstance/4d28077b-566d-4132-b073-f4edaf61dcb9
|
* e.g. /resource-registry/access/facet/instance/4d28077b-566d-4132-b073-f4edaf61dcb9
|
||||||
* @param facetId
|
* @param facetId
|
||||||
* @return
|
* @return
|
||||||
* @throws FacetNotFoundException
|
* @throws FacetNotFoundException
|
||||||
* @throws ResourceRegistryException
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
@GET @Path(AccessRESTPath.FACET_INSTANCE_PATH_PART + "/{" + AccessRESTPath.FACET_ID_PATH_PART + "}")
|
@GET
|
||||||
public String getFacet(@PathParam(AccessRESTPath.FACET_ID_PATH_PART) String facetId)
|
@Path(AccessPath.FACET_PATH_PART + "/" + AccessPath.INSTANCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public String getFacet(@PathParam(ID_PATH_PARAM) String facetId)
|
||||||
throws FacetNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
logger.info("Requested Facet with id {}", facetId);
|
logger.info("Requested Facet with id {}", facetId);
|
||||||
return entityManager.readFacet(facetId);
|
return entityManager.readFacet(facetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. /resource-registry/access/facetSchema/ContactFacet
|
* e.g. /resource-registry/access/facet/schema/ContactFacet
|
||||||
* @param facetType
|
* @param facetType
|
||||||
* @return
|
* @return
|
||||||
* @throws SchemaNotFoundException
|
* @throws SchemaNotFoundException
|
||||||
*/
|
*/
|
||||||
@GET @Path(AccessRESTPath.FACET_SCHEMA_PATH_PART + "/{" + AccessRESTPath.FACET_TYPE_PATH_PART + "}")
|
@GET
|
||||||
public String getFacetSchema(@PathParam(AccessRESTPath.FACET_TYPE_PATH_PART) String facetType)
|
@Path(AccessPath.FACET_PATH_PART + "/" + AccessPath.SCHEMA_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
|
||||||
|
public String getFacetSchema(@PathParam(TYPE_PATH_PARAM) String facetType)
|
||||||
throws SchemaNotFoundException {
|
throws SchemaNotFoundException {
|
||||||
logger.info("Requested Facet Schema for type {}", facetType);
|
logger.info("Requested Facet Schema for type {}", facetType);
|
||||||
return schemaManager.getFacetSchema(facetType);
|
return schemaManager.getFacetSchema(facetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. /resource-registry/access/resourceInstance/cc132a2c-d0b0-45a8-92fa-7451f6a44b6d
|
* e.g. /resource-registry/access/resource/instance/cc132a2c-d0b0-45a8-92fa-7451f6a44b6d
|
||||||
* @param resourceId
|
* @param resourceId
|
||||||
* @return
|
* @return
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
* @throws ResourceRegistryException
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
@GET @Path(AccessRESTPath.RESOURCE_INSTANCE_PATH_PART + "/{" + AccessRESTPath.RESOURCE_ID_PATH_PART + "}")
|
@GET @Path(AccessPath.RESOURCE_PATH_PART + "/" + AccessPath.INSTANCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
public String getResource(@PathParam(AccessRESTPath.RESOURCE_ID_PATH_PART) String resourceId)
|
public String getResource(@PathParam(ID_PATH_PARAM) String resourceId)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
logger.info("Requested Resource with id {}", resourceId);
|
logger.info("Requested Resource with id {}", resourceId);
|
||||||
return entityManager.readResource(resourceId);
|
return entityManager.readResource(resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e.g. /resource-registry/access/resourceSchema/HostingNode
|
* e.g. /resource-registry/access/resource/schema/HostingNode
|
||||||
* @param resourceType
|
* @param resourceType
|
||||||
* @return
|
* @return
|
||||||
* @throws SchemaNotFoundException
|
* @throws SchemaNotFoundException
|
||||||
*/
|
*/
|
||||||
@GET @Path(AccessRESTPath.RESOURCE_SCHEMA_PATH_PART + "/{" + AccessRESTPath.RESOURCE_TYPE_PATH_PART + "}")
|
@GET @Path(AccessPath.RESOURCE_PATH_PART + "/" + AccessPath.SCHEMA_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
|
||||||
public String getResourceSchema(@PathParam(AccessRESTPath.RESOURCE_TYPE_PATH_PART) String resourceType)
|
public String getResourceSchema(@PathParam(TYPE_PATH_PARAM) String resourceType)
|
||||||
throws SchemaNotFoundException {
|
throws SchemaNotFoundException {
|
||||||
logger.info("Requested Resource Schema for type {}", resourceType);
|
logger.info("Requested Resource Schema for type {}", resourceType);
|
||||||
return schemaManager.getResourceSchema(resourceType);
|
return schemaManager.getResourceSchema(resourceType);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.resources;
|
package org.gcube.informationsystem.resourceregistry.resources;
|
||||||
|
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
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;
|
||||||
|
@ -12,6 +13,7 @@ import javax.ws.rs.QueryParam;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
|
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.ContextManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.ContextManagementImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -20,44 +22,56 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
@Path("context")
|
@Path(ContextPath.CONTEXT_PATH_PART)
|
||||||
public class ContextManager {
|
public class ContextManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger
|
* Logger
|
||||||
*/
|
*/
|
||||||
private static Logger logger = LoggerFactory.getLogger(ContextManager.class);
|
private static Logger logger = LoggerFactory
|
||||||
|
.getLogger(ContextManager.class);
|
||||||
|
|
||||||
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
|
||||||
protected ContextManagement contextManager = new ContextManagementImpl();
|
protected ContextManagement contextManager = new ContextManagementImpl();
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("create")
|
public String create(
|
||||||
public String create(@QueryParam("parentContextId") String parentContextId, @QueryParam("name") String name) throws Exception {
|
@QueryParam(ContextPath.PARENT_CONTEXT_ID_PARAM) String parentUUID,
|
||||||
|
@QueryParam(ContextPath.NAME_PARAM) String name)
|
||||||
|
throws Exception {
|
||||||
logger.trace("requested to create context with name : {} ", name);
|
logger.trace("requested to create context with name : {} ", name);
|
||||||
return contextManager.create(parentContextId, name);
|
return contextManager.create(parentUUID, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@DELETE
|
||||||
@Path("rename/{contextId}")
|
@Path("{" + ID_PATH_PARAM + "}")
|
||||||
public String rename(@PathParam("contextId") String uuid, @QueryParam("name") String name)
|
public String delete(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ContextNotFoundException, ContextException{
|
throws ContextException {
|
||||||
|
logger.trace("requested to delete context with id {} ", uuid);
|
||||||
|
return contextManager.delete(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path(ContextPath.RENAME_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public String rename(@PathParam(ID_PATH_PARAM) String uuid,
|
||||||
|
@QueryParam("name") String name) throws ContextNotFoundException,
|
||||||
|
ContextException {
|
||||||
logger.trace("requested to rename context id {} with {} ", uuid, name);
|
logger.trace("requested to rename context id {} with {} ", uuid, name);
|
||||||
return contextManager.rename(uuid, name);
|
return contextManager.rename(uuid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@POST
|
||||||
@Path("move/{contextId}")
|
@Path(ContextPath.MOVE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
public String move(@PathParam("contextId") String uuid, @QueryParam("newParentId") String newParentId)
|
public String move(
|
||||||
throws ContextNotFoundException , ContextException{
|
@PathParam(ID_PATH_PARAM) String uuid,
|
||||||
logger.trace("requested to move context id {} with new parend id {} ", uuid, newParentId);
|
@QueryParam(ContextPath.PARENT_CONTEXT_ID_PARAM) String newParentUUID)
|
||||||
return contextManager.move(newParentId, uuid);
|
throws ContextNotFoundException, ContextException {
|
||||||
|
logger.trace("requested to move context id {} with new parend id {} ",
|
||||||
|
uuid, newParentUUID);
|
||||||
|
return contextManager.move(newParentUUID, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("delete/{contextId}")
|
|
||||||
public String delete(@PathParam("contextId") String uuid) throws ContextException {
|
|
||||||
logger.trace("requested to delete context with id {} ",uuid);
|
|
||||||
return contextManager.delete(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.EntityPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.EntityManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.EntityManagementImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -22,110 +23,130 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
@Path("entity")
|
@Path(EntityPath.ENTITY_PATH_PART)
|
||||||
public class EntityManager {
|
public class EntityManager {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
|
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
|
||||||
|
|
||||||
|
public static final String ID_PATH_PARAM = "id";
|
||||||
|
public static final String TYPE_PATH_PARAM = "type";
|
||||||
|
|
||||||
|
public static final String SOURCE_ID_PATH_PARAM = "sourceId";
|
||||||
|
public static final String TARGET_ID_PATH_PARAM = "targetId";
|
||||||
|
|
||||||
|
public static final String TYPE_PARAM = "type";
|
||||||
|
public static final String PROPERTIES_PARAM = "properties";
|
||||||
|
|
||||||
protected EntityManagement entityManager = new EntityManagementImpl();
|
protected EntityManagement entityManager = new EntityManagementImpl();
|
||||||
|
|
||||||
/* Facets Methods */
|
/* Facets Methods */
|
||||||
|
|
||||||
@Path("facet/{facetType}")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String createFacet(@PathParam("facetType") String facetType,
|
@Path(EntityPath.FACET_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
|
||||||
String jsonRepresentation) throws EntityException,
|
public String createFacet(
|
||||||
ResourceRegistryException {
|
@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
logger.trace("requested facet creation for type {} with json {} ",
|
@QueryParam(EntityPath.DEFINITION_PARAM) String definition)
|
||||||
facetType, jsonRepresentation);
|
throws EntityException, ResourceRegistryException {
|
||||||
return entityManager.createFacet(facetType, jsonRepresentation);
|
logger.trace("requested facet creation for type {} defined by {} ",
|
||||||
|
type, definition);
|
||||||
|
return entityManager.createFacet(type, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("facet/{facetId}")
|
|
||||||
@POST
|
@POST
|
||||||
public String updateFacet(@PathParam("facetId") String facetId,
|
@Path(EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
String jsonRepresentation) throws FacetNotFoundException,
|
public String updateFacet(
|
||||||
ResourceRegistryException {
|
@PathParam(ID_PATH_PARAM) String uuid,
|
||||||
logger.trace("requested facet update for id {} with json", facetId,
|
@QueryParam(EntityPath.DEFINITION_PARAM) String definition)
|
||||||
jsonRepresentation);
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
return entityManager.updateFacet(facetId, jsonRepresentation);
|
logger.trace("requested facet update for id {} with {}", uuid,
|
||||||
|
definition);
|
||||||
|
return entityManager.updateFacet(uuid, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("facet/{facetId}")
|
|
||||||
@DELETE
|
@DELETE
|
||||||
public boolean deleteFacet(@PathParam("facetId") String facetId)
|
@Path(EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public boolean deleteFacet(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws FacetNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
logger.trace("requested facet deletion for id {}", facetId);
|
logger.trace("Requested to delete Facet with id {}", uuid);
|
||||||
return entityManager.deleteFacet(facetId);
|
return entityManager.deleteFacet(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resources Methods */
|
/* Resources Methods */
|
||||||
|
|
||||||
@Path("resource/{resourceType}")
|
|
||||||
@PUT
|
@PUT
|
||||||
|
@Path(EntityPath.RESOURCE_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
|
||||||
public String createResource(
|
public String createResource(
|
||||||
@PathParam("resourceType") String resourceType,
|
@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
String jsonRepresentation) throws FacetNotFoundException,
|
@QueryParam(EntityPath.DEFINITION_PARAM) String definition)
|
||||||
ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
logger.trace("requested resource creation for type {} with json {}",
|
logger.trace("requested resource creation for type {} with json {}",
|
||||||
resourceType, jsonRepresentation);
|
type, definition);
|
||||||
return entityManager.createResource(resourceType, jsonRepresentation);
|
return entityManager.createResource(type, definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("resource/{resourceId}")
|
|
||||||
@DELETE
|
@DELETE
|
||||||
public boolean deleteResource(@PathParam("resourceId") String resourceId)
|
@Path(EntityPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
|
public boolean deleteResource(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ResourceNotFoundException, Exception {
|
throws ResourceNotFoundException, Exception {
|
||||||
logger.trace("requested resource deletion for id {}", resourceId);
|
logger.trace("requested resource deletion for id {}", uuid);
|
||||||
return entityManager.deleteResource(resourceId);
|
return entityManager.deleteResource(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Relations Methods */
|
/* Relations Methods */
|
||||||
|
|
||||||
@Path("consistOf/source/{resourceId}/target/{facetId}")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String attachFacet(@PathParam("resourceId") String resourceUUID,
|
@Path(EntityPath.CONSIST_OF_PATH_PART + "/"
|
||||||
@PathParam("facetId") String facetUUID,
|
+ EntityPath.SOURCE_PATH_PART + "/{"
|
||||||
@QueryParam("consistOfType") String consistOfType,
|
+ SOURCE_ID_PATH_PARAM + "}/"
|
||||||
@QueryParam("jsonProperties") String jsonProperties)
|
+ EntityPath.TARGET_PATH_PART + "/{"
|
||||||
|
+ TARGET_ID_PATH_PARAM + "}")
|
||||||
|
public String attachFacet(
|
||||||
|
@PathParam(SOURCE_ID_PATH_PARAM) String resourceUUID,
|
||||||
|
@PathParam(TARGET_ID_PATH_PARAM) String facetUUID,
|
||||||
|
@QueryParam(TYPE_PARAM) String type,
|
||||||
|
@QueryParam(PROPERTIES_PARAM) String properties)
|
||||||
throws FacetNotFoundException, ResourceNotFoundException,
|
throws FacetNotFoundException, ResourceNotFoundException,
|
||||||
ResourceRegistryException {
|
ResourceRegistryException {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"requested to attach resource {} to facet {} ({} Type {}) with properties {}",
|
"requested to attach resource {} to facet {} ({} Type {}) with properties {}",
|
||||||
resourceUUID, facetUUID, ConsistsOf.class.getSimpleName(),
|
resourceUUID, facetUUID, ConsistsOf.class.getSimpleName(),
|
||||||
consistOfType, jsonProperties);
|
type, properties);
|
||||||
return entityManager.attachFacet(resourceUUID, facetUUID,
|
return entityManager.attachFacet(resourceUUID, facetUUID, type,
|
||||||
consistOfType, jsonProperties);
|
properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("consistOf/{consistOfId}")
|
|
||||||
@DELETE
|
@DELETE
|
||||||
public boolean detachFacet(@PathParam("consistOfId") String consistOfUUID)
|
@Path(EntityPath.CONSIST_OF_PATH_PART + "/{" + ID_PATH_PARAM
|
||||||
|
+ "}")
|
||||||
|
public boolean detachFacet(@PathParam(ID_PATH_PARAM) String consistOfUUID)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
logger.trace("requested to detach {}", consistOfUUID);
|
logger.trace("requested to detach {}", consistOfUUID);
|
||||||
return entityManager.detachFacet(consistOfUUID);
|
return entityManager.detachFacet(consistOfUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("relatedTo/source/{sourceResourceId}/target/{targetResourceId}")
|
|
||||||
@PUT
|
@PUT
|
||||||
|
@Path(EntityPath.RELATED_TO_PATH_PART + "/"
|
||||||
|
+ EntityPath.SOURCE_PATH_PART + "/{"
|
||||||
|
+ SOURCE_ID_PATH_PARAM + "}/"
|
||||||
|
+ EntityPath.TARGET_PATH_PART + "/{"
|
||||||
|
+ TARGET_ID_PATH_PARAM + "}")
|
||||||
public String attachResource(
|
public String attachResource(
|
||||||
@PathParam("sourceResourceId") String sourceResourceUuid,
|
@PathParam(SOURCE_ID_PATH_PARAM) String sourceResourceUUID,
|
||||||
@PathParam("targetResourceId") String targetResourceUuid,
|
@PathParam(TARGET_ID_PATH_PARAM) String targetResourceUUID,
|
||||||
@QueryParam("relatedToType") String relatedToType,
|
@QueryParam(TYPE_PARAM) String type,
|
||||||
@QueryParam("jsonProperties") String jsonProperties)
|
@QueryParam(PROPERTIES_PARAM) String properties)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
"requested to attach source resource {} and target resource {} ({} Type {}) with properties {}",
|
"requested to attach source resource {} and target resource {} ({} Type {}) with properties {}",
|
||||||
sourceResourceUuid, targetResourceUuid,
|
sourceResourceUUID, targetResourceUUID,
|
||||||
IsRelatedTo.class.getSimpleName(), relatedToType, jsonProperties);
|
IsRelatedTo.class.getSimpleName(), type, properties);
|
||||||
return entityManager.attachResource(sourceResourceUuid,
|
return entityManager.attachResource(sourceResourceUUID,
|
||||||
targetResourceUuid, relatedToType, jsonProperties);
|
targetResourceUUID, type, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("relatedTo/{relatedToId}")
|
|
||||||
@DELETE
|
@DELETE
|
||||||
public boolean detachResource(
|
@Path(EntityPath.RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM
|
||||||
@PathParam("relatedToId") String relatedToUUID)
|
+ "}")
|
||||||
|
public boolean detachResource(@PathParam(ID_PATH_PARAM) String relatedToUUID)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
logger.trace("requested to detach {}", relatedToUUID);
|
logger.trace("requested to detach {}", relatedToUUID);
|
||||||
return entityManager.detachResource(relatedToUUID);
|
return entityManager.detachResource(relatedToUUID);
|
||||||
|
|
|
@ -3,9 +3,11 @@ package org.gcube.informationsystem.resourceregistry.resources;
|
||||||
import javax.ws.rs.ApplicationPath;
|
import javax.ws.rs.ApplicationPath;
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.QueryParam;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
|
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.rest.SchemaPath;
|
||||||
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
|
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -14,7 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
* @author Lucio Lelii (lucio.lelii@isti.cnr.it)
|
||||||
*/
|
*/
|
||||||
@ApplicationPath("schema")
|
@ApplicationPath(SchemaPath.SCHEMA_PATH_PART)
|
||||||
public class SchemaManager {
|
public class SchemaManager {
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,37 +24,40 @@ public class SchemaManager {
|
||||||
|
|
||||||
protected SchemaManagement schemaManager = new SchemaManagementImpl();
|
protected SchemaManagement schemaManager = new SchemaManagementImpl();
|
||||||
|
|
||||||
@Path("embedded")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String registerEmbeddedTypeSchema(String jsonSchema) throws SchemaException {
|
@Path(SchemaPath.EMBEDDED_PATH_PART)
|
||||||
logger.trace("Requested Embedded registration with schema {} ",jsonSchema);
|
public String registerEmbeddedTypeSchema(@QueryParam(SchemaPath.SCHEMA_PARAM) String jsonSchema) throws SchemaException {
|
||||||
|
logger.trace("Requested Embedded registration with schema {}",jsonSchema);
|
||||||
return schemaManager.registerEmbeddedTypeSchema(jsonSchema);
|
return schemaManager.registerEmbeddedTypeSchema(jsonSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("facet")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String registerFacetSchema(String jsonSchema) throws SchemaException {
|
@Path(SchemaPath.FACET_PATH_PART)
|
||||||
logger.trace("Requested Facet registration with schema {} ",jsonSchema);
|
public String registerFacetSchema(@QueryParam(SchemaPath.SCHEMA_PARAM) String jsonSchema) throws SchemaException {
|
||||||
|
logger.trace("Requested Facet registration with schema {}",jsonSchema);
|
||||||
return schemaManager.registerFacetSchema(jsonSchema);
|
return schemaManager.registerFacetSchema(jsonSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("resource")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String registerResourceSchema(String jsonSchema) throws SchemaException {
|
@Path(SchemaPath.RESOURCE_PATH_PART)
|
||||||
logger.trace("Requested Resource registration with schema {} ",jsonSchema);
|
public String registerResourceSchema(@QueryParam(SchemaPath.SCHEMA_PARAM) String jsonSchema) throws SchemaException {
|
||||||
|
logger.trace("Requested Resource registration with schema {}",jsonSchema);
|
||||||
return schemaManager.registerResourceSchema(jsonSchema);
|
return schemaManager.registerResourceSchema(jsonSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("consistof")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String registerConsistOfSchema(String jsonSchema) throws SchemaException {
|
@Path(SchemaPath.CONSIST_OF_PATH_PART)
|
||||||
|
public String registerConsistOfSchema(@QueryParam(SchemaPath.SCHEMA_PARAM) String jsonSchema) throws SchemaException {
|
||||||
logger.trace("Requested ConsistOf registration with schema {} ",jsonSchema);
|
logger.trace("Requested ConsistOf registration with schema {} ",jsonSchema);
|
||||||
return schemaManager.registerConsistOfSchema(jsonSchema);
|
return schemaManager.registerConsistOfSchema(jsonSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("relatedto")
|
|
||||||
@PUT
|
@PUT
|
||||||
public String registerRelatedToSchema(String jsonSchema) throws SchemaException {
|
@Path(SchemaPath.RELATED_TO_PATH_PART)
|
||||||
|
public String registerRelatedToSchema(@QueryParam(SchemaPath.SCHEMA_PARAM) String jsonSchema) throws SchemaException {
|
||||||
logger.trace("Requested RelatedTo registration with schema {} ",jsonSchema);
|
logger.trace("Requested RelatedTo registration with schema {} ",jsonSchema);
|
||||||
return schemaManager.registerRelatedToSchema(jsonSchema);
|
return schemaManager.registerRelatedToSchema(jsonSchema);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class ContextManagementImplTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void devContextTest() throws ContextNotFoundException, ContextException {
|
public void devContextTest() throws ContextNotFoundException, ContextException {
|
||||||
String gcube = contextManagementImpl.create(null, "gcube");
|
String gcube = contextManagementImpl.create(null, "gcube");
|
||||||
logger.trace("/gcube : {}", gcube);
|
logger.trace("/gcube : {}", gcube);
|
||||||
|
|
Loading…
Reference in New Issue