Reorganizing components

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@141385 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-12-22 16:27:26 +00:00
parent 152b844b0a
commit e34bc1a10f
33 changed files with 263 additions and 304 deletions

View File

@ -2,6 +2,7 @@ package org.gcube.informationsystem.resourceregistry;
import javax.ws.rs.ApplicationPath;
import org.gcube.informationsystem.resourceregistry.rest.Access;
import org.glassfish.jersey.server.ResourceConfig;
/**
@ -11,7 +12,7 @@ import org.glassfish.jersey.server.ResourceConfig;
public class ResourceInitializer extends ResourceConfig {
public ResourceInitializer(){
packages("org.gcube.informationsystem.resourceregistry.resources");
packages(Access.class.getPackage().toString());
}
}

View File

@ -0,0 +1,29 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.context;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public interface ContextManagement {
public String create(UUID parentContext, String name) throws ContextCreationException, ResourceRegistryException;
public String read(UUID context) throws ContextNotFoundException, ContextException;
public String rename(UUID context, String newName) throws ContextNotFoundException, ContextException;
public String move(UUID newParent, UUID contextToMove) throws ContextNotFoundException, ContextException;
public boolean delete(UUID context) throws ContextNotFoundException, ContextException;
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.impl;
package org.gcube.informationsystem.resourceregistry.context;
import java.util.Iterator;
import java.util.UUID;
@ -9,16 +9,13 @@ import java.util.UUID;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.Context;
import org.gcube.informationsystem.model.relation.IsParentOf;
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.context.SecurityContext;
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper;
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper.PermissionMode;
import org.gcube.informationsystem.resourceregistry.resources.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -112,7 +112,7 @@ public class DatabaseIntializator {
public static void createEntitiesAndRelations() throws Exception {
ERDiscovery erDiscovery = Entities.getErdiscovery();
EntityRegistrationAction entityRegistrationAction = new EntityRegistrationAction();
SchemaActionImpl entityRegistrationAction = new SchemaActionImpl();
entityRegistrationAction.manageEmbeddedClass(Embedded.class);
entityRegistrationAction.manageEmbeddedClass(ValueSchema.class);
erDiscovery.manageDiscoveredERTypes(entityRegistrationAction);

View File

@ -3,7 +3,7 @@
*/
package org.gcube.informationsystem.resourceregistry.dbinitialization;
import org.gcube.informationsystem.impl.utils.discovery.ERAction;
import org.gcube.informationsystem.impl.utils.discovery.SchemaAction;
import org.gcube.informationsystem.model.embedded.Embedded;
import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.model.entity.Facet;
@ -11,8 +11,8 @@ import org.gcube.informationsystem.model.entity.Resource;
import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.gcube.informationsystem.types.TypeBinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,14 +21,14 @@ import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class EntityRegistrationAction implements ERAction {
public class SchemaActionImpl implements SchemaAction {
private static Logger logger = LoggerFactory.getLogger(EntityRegistrationAction.class);
private static Logger logger = LoggerFactory.getLogger(SchemaActionImpl.class);
protected SchemaManagement schemaManagement;
public EntityRegistrationAction(){
public SchemaActionImpl(){
this.schemaManagement = new SchemaManagementImpl();
}

View File

@ -11,8 +11,8 @@ import org.gcube.informationsystem.model.embedded.Embedded;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.resources.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -24,10 +24,10 @@ import org.gcube.informationsystem.resourceregistry.context.SecurityContextMappe
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper.PermissionMode;
import org.gcube.informationsystem.resourceregistry.ermanagement.ERManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.RelationManagement;
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -9,7 +9,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.ermanagement.ERManagement;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;

View File

@ -18,7 +18,7 @@ import org.gcube.informationsystem.resourceregistry.ermanagement.ERManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.ConsistsOfManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.IsRelatedToManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.RelationManagement;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -31,10 +31,10 @@ import org.gcube.informationsystem.resourceregistry.ermanagement.ERManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.entity.EntityManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.entity.FacetManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.entity.ResourceManagement;
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -0,0 +1,25 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.query;
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
/**
* @author Luca Frosini (ISTI - CNR)
*
*/
public interface Query {
/**
* @param query
* @param limit
* @param fetchPlan
* @return
* @throws InvalidQueryException
* http://orientdb.com/docs/last/OrientDB-REST.html#query
*/
public String query(String query, int limit, String fetchPlan)
throws InvalidQueryException;
}

View File

@ -1,17 +1,16 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.impl;
package org.gcube.informationsystem.resourceregistry.query;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import org.gcube.informationsystem.resourceregistry.api.Query;
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper.PermissionMode;
import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.resources.utils.Utility;
import org.gcube.informationsystem.resourceregistry.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.utils.Utility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.resourceregistry.resources;
package org.gcube.informationsystem.resourceregistry.rest;
import java.util.UUID;
@ -9,18 +9,19 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.gcube.informationsystem.resourceregistry.api.Query;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
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.ermanagement.entity.FacetManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.entity.ResourceManagement;
import org.gcube.informationsystem.resourceregistry.resources.impl.QueryImpl;
import org.gcube.informationsystem.resourceregistry.resources.impl.SchemaManagementImpl;
import org.gcube.informationsystem.resourceregistry.query.Query;
import org.gcube.informationsystem.resourceregistry.query.QueryImpl;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -101,7 +102,8 @@ public class Access {
SchemaManagement schemaManager = new SchemaManagementImpl();
return schemaManager.getFacetSchema(facetType);
}
/**
* e.g. GET /resource-registry/access/resource/instance/cc132a2c-d0b0-45a8-92fa-7451f6a44b6d
* @param resourceId
@ -136,4 +138,26 @@ public class Access {
return schemaManager.getResourceSchema(resourceType);
}
public String getResourceTypes(String resourceType, boolean includeSchema) throws SchemaNotFoundException, SchemaException {
throw new UnsupportedOperationException("Not Yet implemented");
}
public String getEmbeddedTypes(String embeddedType, boolean includeSchema) throws SchemaNotFoundException, SchemaException {
throw new UnsupportedOperationException("Not Yet implemented");
}
public String getRelationTypes(String relationType, boolean includeSchema) throws SchemaNotFoundException, SchemaException {
throw new UnsupportedOperationException("Not Yet implemented");
}
public String getConsistsOfTypes(String consistsOfType, boolean includeSchema) throws SchemaNotFoundException, SchemaException {
throw new UnsupportedOperationException("Not Yet implemented");
}
public String getIsRelatedToTypes(String isRelatedToType, boolean includeSchema) throws SchemaNotFoundException, SchemaException {
throw new UnsupportedOperationException("Not Yet implemented");
}
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources;
package org.gcube.informationsystem.resourceregistry.rest;
import java.util.UUID;
@ -14,13 +14,13 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
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.context.ContextManagement;
import org.gcube.informationsystem.resourceregistry.context.ContextManagementImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.resourceregistry.resources;
package org.gcube.informationsystem.resourceregistry.rest;
import java.util.UUID;
@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.ermanagement.entity.FacetMan
import org.gcube.informationsystem.resourceregistry.ermanagement.entity.ResourceManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.ConsistsOfManagement;
import org.gcube.informationsystem.resourceregistry.ermanagement.relation.IsRelatedToManagement;
import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility;
import org.gcube.informationsystem.resourceregistry.utils.ContextUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
* @author Lucio Lelii (ISTI - CNR)
*/
@Path(EntityPath.ENTITY_PATH_PART)
public class EntityManager {
public class ERManager {
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.resourceregistry.resources;
package org.gcube.informationsystem.resourceregistry.rest;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.resourceregistry.resources;
package org.gcube.informationsystem.resourceregistry.rest;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Consumes;
@ -12,10 +12,10 @@ import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.model.entity.Resource;
import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
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.schema.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -131,5 +131,8 @@ public class SchemaManager {
IsRelatedTo.NAME, jsonSchema);
return schemaManager.registerIsRelatedToSchema(jsonSchema);
}
}

View File

@ -0,0 +1,97 @@
package org.gcube.informationsystem.resourceregistry.schema;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
/**
* Service Endpoint Interface
* @author Luca Frosini (ISTI - CNR)
*
* For JSON schema see
* http://orientdb.com/docs/last/OrientDB-REST.html#class
*
*/
public interface SchemaManagement {
public String registerEntitySchema(String jsonSchema) throws SchemaException;
public String getEntitySchema(String entityType) throws SchemaNotFoundException;
public String updateEntitySchema(String entityType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteEntitySchema(String entityType) throws SchemaNotFoundException;
public String getEntityTypes(String entityType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerFacetSchema(String jsonSchema) throws SchemaException;
public String getFacetSchema(String facetType) throws SchemaNotFoundException;
public String updateFacetSchema(String facetType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteFacetSchema(String facetType) throws SchemaNotFoundException;
public String getFacetTypes(String facetType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerResourceSchema(String jsonSchema) throws SchemaException;
public String getResourceSchema(String resourceType) throws SchemaNotFoundException;
public String updateResourceSchema(String resourceType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteResourceSchema(String resourceType) throws SchemaNotFoundException;
public String getResourceTypes(String resourceType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerEmbeddedTypeSchema(String jsonSchema) throws SchemaException;
public String getEmbeddedTypeSchema(String embeddedType) throws SchemaNotFoundException;
public String updateEmbeddedTypeSchema(String embeddedType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteEmbeddedTypeSchema(String embeddedType) throws SchemaNotFoundException;
public String getEmbeddedTypes(String embeddedType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerRelationSchema(String jsonSchema) throws SchemaException;
public String getRelationSchema(String relationType) throws SchemaNotFoundException;
public String updateRelationSchema(String relationType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteRelationSchema(String relationType) throws SchemaNotFoundException;
public String getRelationTypes(String relationType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerConsistsOfSchema(String jsonSchema) throws SchemaException;
public String getConsistsOfSchema(String consistsOfType) throws SchemaNotFoundException;
public String updateConsistsOfSchema(String consistsOfType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteConsistsOfSchema(String consistsOfType) throws SchemaException;
public String getConsistsOfTypes(String consistsOfType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
public String registerIsRelatedToSchema(String jsonSchema) throws SchemaException;
public String getIsRelatedToSchema(String isRelatedToType) throws SchemaNotFoundException;
public String updateIsRelatedToSchema(String isRelatedToType, String jsonSchema) throws SchemaNotFoundException, SchemaException;
public String deleteIsRelatedToSchema(String isRelatedToType) throws SchemaException;
public String getIsRelatedToTypes(String isRelatedToType, boolean includeSchema) throws SchemaNotFoundException, SchemaException;
}

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.impl;
package org.gcube.informationsystem.resourceregistry.schema;
import java.util.ArrayList;
import java.util.Collection;
@ -18,7 +18,6 @@ import org.gcube.informationsystem.model.entity.Resource;
import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.utils;
package org.gcube.informationsystem.resourceregistry.utils;
import java.util.Iterator;
import java.util.UUID;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.utils;
package org.gcube.informationsystem.resourceregistry.utils;
import java.util.Date;
import java.util.UUID;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.utils;
package org.gcube.informationsystem.resourceregistry.utils;
import java.io.IOException;
import java.text.SimpleDateFormat;

View File

@ -1,7 +1,7 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.utils;
package org.gcube.informationsystem.resourceregistry.utils;
import java.util.HashSet;
import java.util.Iterator;

View File

@ -1,20 +1,20 @@
package org.gcube.informationsystem.resourceregistry;
import org.gcube.informationsystem.resourceregistry.api.Query;
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.rest.Access;
import org.glassfish.hk2.api.Factory;
public class QueryManagerFactory implements Factory<Query>{
public class AccessManagerFactory implements Factory<Access>{
@Override
public void dispose(Query arg0) {
public void dispose(Access arg0) {
// TODO Auto-generated method stub
}
@Override
public Query provide() {
return new Query() {
public Access provide() {
return new Access() {
@Override
public String query(String query, int limit, String fetchPlan) throws InvalidQueryException {

View File

@ -2,10 +2,10 @@ package org.gcube.informationsystem.resourceregistry;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.context.ContextManagement;
import org.glassfish.hk2.api.Factory;
public class ContextManagerFactory implements Factory<ContextManagement> {

View File

@ -1,151 +0,0 @@
package org.gcube.informationsystem.resourceregistry;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
import org.glassfish.hk2.api.Factory;
public class EntityManagementFactory implements Factory<EntityManagement> {
@Override
public void dispose(EntityManagement arg0) {
// TODO Auto-generated method stub
}
@Override
public EntityManagement provide() {
return new EntityManagement() {
@Override
public String updateFacet(UUID uuid, String jsonRepresentation)
throws FacetNotFoundException {
return null;
}
@Override
public String readResource(UUID uuid)
throws ResourceNotFoundException {
return "resource";
}
@Override
public String readFacet(UUID uuid) throws FacetNotFoundException {
return "facet";
}
@Override
public boolean deleteResource(UUID uuid)
throws ResourceNotFoundException, ResourceRegistryException {
return false;
}
@Override
public boolean deleteFacet(UUID uuid)
throws FacetNotFoundException, ResourceRegistryException {
return false;
}
@Override
public String createResource(String resourceType,
String jsonRepresentation) throws ResourceRegistryException {
return null;
}
@Override
public String createFacet(String facetType,
String jsonRepresentation) throws ResourceRegistryException {
return null;
}
@Override
public String attachResource(UUID sourceResourceUuid,
UUID targetResourceUuid, String relatedToType,
String jsonProperties) throws ResourceNotFoundException,
ResourceRegistryException {
return null;
}
@Override
public String attachFacet(UUID resourceUuid, UUID facetUuid,
String consistOfType, String jsonProperties)
throws FacetNotFoundException, ResourceNotFoundException,
ResourceRegistryException {
return null;
}
@Override
public String readFacet(UUID uuid, String facetType)
throws FacetNotFoundException, ResourceRegistryException {
// TODO Auto-generated method stub
return null;
}
@Override
public String readResource(UUID uuid, String resourceType)
throws ResourceNotFoundException, ResourceRegistryException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean detachFacet(UUID consistOfUUID)
throws ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean detachResource(UUID relatedToUUID)
throws ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addResourceToContext(UUID uuid)
throws ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean addFacetToContext(UUID uuid)
throws FacetNotFoundException, ContextNotFoundException,
ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
@Override
public String updateResource(UUID resourceUUID,
String jsonRepresentation)
throws ResourceNotFoundException, ResourceRegistryException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean removeResourceFromContext(UUID uuid)
throws ResourceNotFoundException, ContextNotFoundException,
ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean removeFacetFromContext(UUID uuid)
throws FacetNotFoundException, ContextNotFoundException,
ResourceRegistryException {
// TODO Auto-generated method stub
return false;
}
};
}
}

View File

@ -1,11 +1,11 @@
package org.gcube.informationsystem.resourceregistry;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
import org.glassfish.hk2.api.Factory;
public class EntityRegistrationFactory implements Factory<SchemaManagement>{
public class SchemaManagerFactory implements Factory<SchemaManagement>{
@Override
public void dispose(SchemaManagement arg0) {

View File

@ -3,14 +3,13 @@ package org.gcube.informationsystem.resourceregistry.access;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import org.gcube.informationsystem.resourceregistry.EntityManagementFactory;
import org.gcube.informationsystem.resourceregistry.EntityRegistrationFactory;
import org.gcube.informationsystem.resourceregistry.QueryManagerFactory;
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
import org.gcube.informationsystem.resourceregistry.api.Query;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.resources.Access;
import org.gcube.informationsystem.resourceregistry.resources.ResourceRegistryExceptionMapper;
import org.gcube.informationsystem.resourceregistry.AccessManagerFactory;
import org.gcube.informationsystem.resourceregistry.ContextManagerFactory;
import org.gcube.informationsystem.resourceregistry.SchemaManagerFactory;
import org.gcube.informationsystem.resourceregistry.context.ContextManagement;
import org.gcube.informationsystem.resourceregistry.rest.Access;
import org.gcube.informationsystem.resourceregistry.rest.ResourceRegistryExceptionMapper;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
@ -25,9 +24,9 @@ public class AccessTest extends JerseyTest{
AbstractBinder binder = new AbstractBinder() {
@Override
protected void configure() {
bindFactory(EntityManagementFactory.class).to(EntityManagement.class);
bindFactory(QueryManagerFactory.class).to(Query.class);
bindFactory(EntityRegistrationFactory.class).to(SchemaManagement.class);
bindFactory(ContextManagerFactory.class).to(ContextManagement.class);
bindFactory(AccessManagerFactory.class).to(Access.class);
bindFactory(SchemaManagerFactory.class).to(SchemaManagement.class);
}
};
ResourceConfig config = new ResourceConfig(Access.class, ResourceRegistryExceptionMapper.class);

View File

@ -5,9 +5,8 @@ import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import org.gcube.informationsystem.resourceregistry.ContextManagerFactory;
import org.gcube.informationsystem.resourceregistry.api.ContextManagement;
import org.gcube.informationsystem.resourceregistry.resources.ContextManager;
import org.gcube.informationsystem.resourceregistry.resources.ResourceRegistryExceptionMapper;
import org.gcube.informationsystem.resourceregistry.rest.ContextManager;
import org.gcube.informationsystem.resourceregistry.rest.ResourceRegistryExceptionMapper;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;

View File

@ -1,78 +0,0 @@
package org.gcube.informationsystem.resourceregistry.entitymanager;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import org.gcube.informationsystem.resourceregistry.EntityManagementFactory;
import org.gcube.informationsystem.resourceregistry.api.EntityManagement;
import org.gcube.informationsystem.resourceregistry.resources.EntityManager;
import org.gcube.informationsystem.resourceregistry.resources.ResourceRegistryExceptionMapper;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Assert;
import org.junit.Test;
public class EntityManagementTest extends JerseyTest{
@Override
protected Application configure() {
AbstractBinder binder = new AbstractBinder() {
@Override
protected void configure() {
bindFactory(EntityManagementFactory.class).to(EntityManagement.class);
}
};
ResourceConfig config = new ResourceConfig(EntityManager.class, ResourceRegistryExceptionMapper.class);
config.register(binder);
return config;
}
@Test
public void createFacet(){
Response response = target("entity").path("facet").path("facetType").request().put(Entity.text(new String("{fake facet creation}")), Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void createResource(){
Response response = target("entity").path("resource").path("resourceType").request().put(Entity.text(new String("{fake resource creation}")), Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void deleteFacet(){
Response response = target("entity").path("facet").path("facetId").request().delete(Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void deleteResource(){
Response response = target("entity").path("resource").path("resourceId").request().delete(Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void attachFacet(){
Response response = target("entity").path("resource").path("resourceId").path("facet").path("facetId").request().put(Entity.text(new String("{Relation Properties}")), Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void attachResource(){
Response response = target("entity").path("resource/source").path("sourceResourceId").path("target").path("targetResourceId").request().put(Entity.text(new String("{Relation Properties}")), Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void detachFacet(){
Response response = target("entity").path("resource").path("resourceId").path("facet").path("facetId").request().delete(Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
@Test
public void detachResource(){
Response response = target("entity").path("resource/source").path("sourceResourceId").path("target").path("targetResourceId").request().delete(Response.class);
Assert.assertEquals(Response.Status.OK.getFamily(), response.getStatusInfo().getFamily());
}
}

View File

@ -11,6 +11,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.context.ContextManagementImpl;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;

View File

@ -5,6 +5,7 @@ package org.gcube.informationsystem.resourceregistry.resources.impl;
import org.gcube.informationsystem.resourceregistry.ScopedTest;
import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.query.QueryImpl;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -3,6 +3,8 @@
*/
package org.gcube.informationsystem.resourceregistry.resources.impl;
import java.util.List;
import org.gcube.informationsystem.model.embedded.AccessPolicy;
import org.gcube.informationsystem.model.embedded.Embedded;
import org.gcube.informationsystem.model.embedded.Header;
@ -15,12 +17,17 @@ import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
import org.gcube.informationsystem.resourceregistry.api.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.schema.SchemaManagementImpl;
import org.gcube.informationsystem.types.TypeBinder;
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@ -55,6 +62,8 @@ public class SchemaManagementImplTest {
public void getFacetSchema() throws Exception{
String json = new SchemaManagementImpl().getFacetSchema(ContactFacet.NAME);
logger.trace(json);
TypeDefinition typeDefinition = TypeBinder.deserializeTypeDefinition(json);
logger.trace(typeDefinition.toString());
}
@Test
@ -99,6 +108,11 @@ public class SchemaManagementImplTest {
String list = schemaManagement.getEmbeddedTypes(Embedded.NAME, includeSchema);
logger.debug("{} list : {}", Embedded.NAME, list);
ObjectMapper mapper = new ObjectMapper();
List<TypeDefinition> typeDefinitions = mapper.readValue(list, new TypeReference<List<TypeDefinition>>(){});
logger.debug("{}", typeDefinitions);
list = schemaManagement.getEntityTypes(Entity.NAME, includeSchema);
logger.debug("{} list : {}", Entity.NAME, list);