commit c5d0bac028e291fb97d0b6cc9999b98ab531b506 Author: Luca Frosini Date: Mon Jul 18 09:58:09 2016 +0000 Creating Trunk Branch git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@130465 82a268e6-3cf1-43bd-a215-b396298e98cf diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..e43402f --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..4c175e0 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + resource-registry-publisher + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..262c6b7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,113 @@ + + 4.0.0 + + org.gcube.tools + maven-parent + 1.0.0 + + org.gcube.information-system + resource-registry-publisher + 1.0.0-SNAPSHOT + Resource Registry Publisher + Contains Non Idempotent API for Resource Registry + + + + + org.gcube.distribution + gcube-bom + 1.0.0-SNAPSHOT + pom + import + + + + + + + org.gcube.core + common-generic-clients + + + org.gcube.core + common-gcube-calls + + + org.gcube.core + common-fw-clients + + + + org.gcube.information-system + resource-registry-api + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + + + + org.slf4j + slf4j-api + + + + + junit + junit + 4.11 + test + + + ch.qos.logback + logback-classic + 1.0.13 + test + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/AbstractPlugin.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/AbstractPlugin.java new file mode 100644 index 0000000..a2fcfc9 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/AbstractPlugin.java @@ -0,0 +1,33 @@ +package org.gcube.informationsystem.resourceregistry.publisher.plugin; + +import org.gcube.common.clients.Plugin; +import org.gcube.informationsystem.resourceregistry.Constants; + +/** + * + * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ + * + * @param + * @param

+ */ +public abstract class AbstractPlugin implements Plugin { + + public final String name; + + public AbstractPlugin(String name) { + this.name = name; + } + + public String serviceClass() { + return Constants.SERVICE_CLASS; + } + + public String serviceName() { + return Constants.SERVICE_NAME; + } + + public String name() { + return name; + } + +} diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/ResourceRegistryRegistryPlugin.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/ResourceRegistryRegistryPlugin.java new file mode 100644 index 0000000..9b25f4e --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/plugin/ResourceRegistryRegistryPlugin.java @@ -0,0 +1,55 @@ +/** + * + */ +package org.gcube.informationsystem.resourceregistry.publisher.plugin; + +import org.gcube.common.clients.GCubeEndpoint; +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; +import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher; + +/** + * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ + * + */ +public class ResourceRegistryRegistryPlugin extends AbstractPlugin{ + + public ResourceRegistryRegistryPlugin(){ + super(ResourceRegistryRegistryPlugin.class.getSimpleName()); + } + + @Override + public String namespace() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Exception convert(Exception fault, ProxyConfig config) { + // The Jersey client wraps the exception. So we need to get the wrapped + // exception thrown by ResourceRegistry Service. + + Throwable throwable = fault.getCause(); + if(throwable != null && throwable instanceof ResourceRegistryException){ + return (Exception) throwable; + } + + return fault; + + } + + @Override + public GCubeEndpoint resolve(GCubeEndpoint address, ProxyConfig config) + throws Exception { + // TODO Auto-generated method stub + return null; + } + + @Override + public ResourceRegistryPublisher newProxy( + ProxyDelegate delegate) { + return new ResourceRegistryPublisher(delegate); + } + +} diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/proxy/ResourceRegistryPublisher.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/proxy/ResourceRegistryPublisher.java new file mode 100644 index 0000000..f1721d3 --- /dev/null +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/proxy/ResourceRegistryPublisher.java @@ -0,0 +1,461 @@ +/** + * + */ +package org.gcube.informationsystem.resourceregistry.publisher.proxy; + +import org.gcube.common.clients.Call; +import org.gcube.common.clients.GCubeEndpoint; +import org.gcube.common.clients.delegates.AsyncProxyDelegate; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.common.clients.exceptions.ServiceException; +import org.gcube.informationsystem.resourceregistry.api.ContextManagement; +import org.gcube.informationsystem.resourceregistry.api.EntityManagement; +import org.gcube.informationsystem.resourceregistry.api.SchemaManagement; +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.exceptions.entity.FacetNotFoundException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; + +/** + * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ + */ +public class ResourceRegistryPublisher implements ContextManagement, SchemaManagement, EntityManagement { + + private final AsyncProxyDelegate delegate; + + public ResourceRegistryPublisher(ProxyDelegate config) { + this.delegate = new AsyncProxyDelegate(config); + } + + @Override + public String createFacet(String facetType, String jsonRepresentation) + throws ResourceRegistryException { + Call call = new Call() { + + public String call(GCubeEndpoint endpoint) throws Exception { + // TODO + return null; + }; + + }; + + try { + return delegate.make(call); + } catch (Exception e) { + throw new ServiceException(e); + } + } + + @Override + public String readFacet(String uuid) throws FacetNotFoundException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String updateFacet(String uuid, String jsonRepresentation) + throws FacetNotFoundException, ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean deleteFacet(String uuid) throws FacetNotFoundException, + ResourceRegistryException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String createResource(String resourceType, String jsonRepresentation) + throws ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String readResource(String uuid) throws ResourceNotFoundException { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean deleteResource(String uuid) + throws ResourceNotFoundException, ResourceRegistryException { + // TODO Auto-generated method stub + return false; + } + + @Override + public String registerFacetSchema(String jsonSchema) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getFacetSchema(String facetType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String registerResourceSchema(String jsonSchema) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getResourceSchema(String resourceType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String create(final String parentContextUUID,final String jsonRepresentation) + throws ContextCreationException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String rename(String contextUUID, String newName) + throws ContextNotFoundException, ContextException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String move(String newParentUUID, String contextToMoveUUID) + throws ContextNotFoundException, ContextException { + // TODO Auto-generated method stub + return null; + } + + @Override + public String delete(String uuid) throws ContextNotFoundException, + ContextException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#readFacet(java.lang.String, java.lang.String) + */ + @Override + public String readFacet(String uuid, String facetType) + throws FacetNotFoundException, ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#readResource(java.lang.String, java.lang.String) + */ + @Override + public String readResource(String uuid, String resourceType) + throws ResourceNotFoundException, ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#attachFacet(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public String attachFacet(String resourceUUID, String facetUUID, + String consistOfType, String jsonProperties) + throws FacetNotFoundException, ResourceNotFoundException, + ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#detachFacet(java.lang.String) + */ + @Override + public boolean detachFacet(String consistOfUUID) + throws ResourceRegistryException { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#attachResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public String attachResource(String sourceResourceUUID, + String targetResourceUUID, String relatedToType, + String jsonProperties) throws ResourceNotFoundException, + ResourceRegistryException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.EntityManagement#detachResource(java.lang.String) + */ + @Override + public boolean detachResource(String relatedToUUID) + throws ResourceRegistryException { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#registerEntitySchema(java.lang.String) + */ + @Override + public String registerEntitySchema(String jsonSchema) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#getEntitySchema(java.lang.String) + */ + @Override + public String getEntitySchema(String entityType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateEntitySchema(java.lang.String, java.lang.String) + */ + @Override + public String updateEntitySchema(String entityType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteEntitySchema(java.lang.String) + */ + @Override + public String deleteEntitySchema(String entityType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateFacetSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateFacetSchema(String facetType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteFacetSchema(java.lang.String) + */ + @Override + public String deleteFacetSchema(String facetType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateResourceSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateResourceSchema(String resourceType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteResourceSchema(java.lang.String) + */ + @Override + public String deleteResourceSchema(String resourceType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#registerEmbeddedTypeSchema(java.lang.String) + */ + @Override + public String registerEmbeddedTypeSchema(String jsonSchema) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#getEmbeddedTypeSchema(java.lang.String) + */ + @Override + public String getEmbeddedTypeSchema(String embeddedType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateEmbeddedTypeSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateEmbeddedTypeSchema(String embeddedType, + String jsonSchema) throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteEmbeddedTypeSchema(java.lang.String) + */ + @Override + public String deleteEmbeddedTypeSchema(String embeddedType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#registerRelationSchema(java.lang.String) + */ + @Override + public String registerRelationSchema(String jsonSchema) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#getRelationSchema(java.lang.String) + */ + @Override + public String getRelationSchema(String relationType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateRelationSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateRelationSchema(String relationType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteRelationSchema(java.lang.String) + */ + @Override + public String deleteRelationSchema(String relationType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#registerConsistOfSchema(java.lang.String) + */ + @Override + public String registerConsistOfSchema(String jsonSchema) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#getConsistOfSchema(java.lang.String) + */ + @Override + public String getConsistOfSchema(String consistOfType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateConsistOfSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateConsistOfSchema(String consistOfType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteConsistOfSchema(java.lang.String) + */ + @Override + public String deleteConsistOfSchema(String consistOfType) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#registerRelatedToSchema(java.lang.String) + */ + @Override + public String registerRelatedToSchema(String jsonSchema) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#getRelatedToSchema(java.lang.String) + */ + @Override + public String getRelatedToSchema(String relatedToType) + throws SchemaNotFoundException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#updateRelatedToSchema(java.lang.String, java.lang.String) + */ + @Override + public String updateRelatedToSchema(String relatedToType, String jsonSchema) + throws SchemaNotFoundException, SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.SchemaManagement#deleteRelatedToSchema(java.lang.String) + */ + @Override + public String deleteRelatedToSchema(String relatedToType) + throws SchemaException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.gcube.informationsystem.resourceregistry.api.ContextManagement#read(java.lang.String) + */ + @Override + public String read(String contextUUID) throws ContextNotFoundException, + ContextException { + // TODO Auto-generated method stub + return null; + } + +}