Implementing Publisher
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@131349 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ddec0efa10
commit
0efff0d87f
23
pom.xml
23
pom.xml
|
@ -24,6 +24,7 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-generic-clients</artifactId>
|
<artifactId>common-generic-clients</artifactId>
|
||||||
|
@ -37,6 +38,28 @@
|
||||||
<artifactId>common-fw-clients</artifactId>
|
<artifactId>common-fw-clients</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>authorization-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-authorization</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-encryption</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.information-system</groupId>
|
||||||
|
<artifactId>information-system-model</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.information-system</groupId>
|
<groupId>org.gcube.information-system</groupId>
|
||||||
<artifactId>resource-registry-api</artifactId>
|
<artifactId>resource-registry-api</artifactId>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
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 <S>
|
|
||||||
* @param <P>
|
|
||||||
*/
|
|
||||||
public abstract class AbstractPlugin<S, P> implements Plugin<S, P> {
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -7,22 +7,22 @@ import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
import org.gcube.common.clients.config.ProxyConfig;
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.Constants;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ResourceRegistryRegistryPlugin extends AbstractPlugin<EndpointReference, ResourceRegistryPublisher>{
|
public class ResourceRegistryPublisherPlugin extends AbstractPlugin<EndpointReference, ResourceRegistryPublisherImpl>{
|
||||||
|
|
||||||
public ResourceRegistryRegistryPlugin(){
|
public ResourceRegistryPublisherPlugin(){
|
||||||
super(ResourceRegistryRegistryPlugin.class.getSimpleName());
|
super(Constants.SERVICE_ENTRY_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String namespace() {
|
public String namespace() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,27 +37,18 @@ public class ResourceRegistryRegistryPlugin extends AbstractPlugin<EndpointRefer
|
||||||
}
|
}
|
||||||
|
|
||||||
return fault;
|
return fault;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.clients.delegates.ProxyPlugin#resolve(java.lang.Object, org.gcube.common.clients.config.ProxyConfig)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public EndpointReference resolve(EndpointReference address,
|
public EndpointReference resolve(EndpointReference address,
|
||||||
ProxyConfig<?, ?> config) throws Exception {
|
ProxyConfig<?, ?> config) throws Exception {
|
||||||
// TODO Auto-generated method stub
|
return address;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.common.clients.delegates.ProxyPlugin#newProxy(org.gcube.common.clients.delegates.ProxyDelegate)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceRegistryPublisher newProxy(
|
public ResourceRegistryPublisherImpl newProxy(
|
||||||
ProxyDelegate<EndpointReference> delegate) {
|
ProxyDelegate<EndpointReference> delegate) {
|
||||||
// TODO Auto-generated method stub
|
return new ResourceRegistryPublisherImpl(delegate);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
|
class JaxRSEndpointReference {
|
||||||
|
|
||||||
|
private static final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
|
||||||
|
private static final String addressLocalName = "Address";
|
||||||
|
//private static final String keyLocalName = "ResourceKey";
|
||||||
|
|
||||||
|
String address;
|
||||||
|
//Element key;
|
||||||
|
|
||||||
|
static {
|
||||||
|
factory.setNamespaceAware(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JaxRSEndpointReference(EndpointReference reference) {
|
||||||
|
this(serialise(reference));
|
||||||
|
}
|
||||||
|
|
||||||
|
public JaxRSEndpointReference(String reference) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Document document = factory.newDocumentBuilder().parse(new InputSource(new StringReader(reference)));
|
||||||
|
|
||||||
|
NodeList addresses = document.getElementsByTagNameNS("*", addressLocalName);
|
||||||
|
|
||||||
|
if (addresses.getLength() == 0)
|
||||||
|
throw new RuntimeException("reference does not contain an address");
|
||||||
|
|
||||||
|
address = addresses.item(0).getTextContent();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IllegalArgumentException("reference is not a gCore reference", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper
|
||||||
|
private static String serialise(EndpointReference reference) {
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
reference.writeTo(new StreamResult(writer));
|
||||||
|
return writer.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,462 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
|
||||||
|
|
||||||
import javax.xml.ws.EndpointReference;
|
|
||||||
|
|
||||||
import org.gcube.common.clients.Call;
|
|
||||||
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<EndpointReference> delegate;
|
|
||||||
|
|
||||||
public ResourceRegistryPublisher(ProxyDelegate<EndpointReference> config) {
|
|
||||||
this.delegate = new AsyncProxyDelegate<EndpointReference>(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String createFacet(String facetType, String jsonRepresentation)
|
|
||||||
throws ResourceRegistryException {
|
|
||||||
Call<EndpointReference, String> call = new Call<EndpointReference, String>() {
|
|
||||||
|
|
||||||
public String call(EndpointReference 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||||
|
|
||||||
|
|
||||||
|
public class ResourceRegistryPublisherFactory {
|
||||||
|
|
||||||
|
private static ResourceRegistryPublisher singleton = new ResourceRegistryPublisherImpl();
|
||||||
|
|
||||||
|
public static ResourceRegistryPublisher create(){
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setPublisher(ResourceRegistryPublisher registryPublisher){
|
||||||
|
singleton = registryPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,192 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.client.Constants;
|
||||||
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||||
|
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.Endpoint;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.informationsystem.impl.utils.Entities;
|
||||||
|
import org.gcube.informationsystem.model.embedded.Embedded;
|
||||||
|
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.rest.EntityPath;
|
||||||
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||||
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||||
|
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryPublisher.class);
|
||||||
|
|
||||||
|
private static final Random random;
|
||||||
|
|
||||||
|
protected final List<GCoreEndpoint> endpoints;
|
||||||
|
|
||||||
|
static {
|
||||||
|
random = new Random();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static List<GCoreEndpoint> getServiceEndpoint(){
|
||||||
|
SimpleQuery query = ICFactory.queryFor(GCoreEndpoint.class);
|
||||||
|
query.addCondition(String.format("$resource/Profile/ServiceClass/text() eq '%s'", org.gcube.informationsystem.resourceregistry.Constants.SERVICE_CLASS));
|
||||||
|
query.addCondition(String.format("$resource/Profile/ServiceName/text() eq '%s'", org.gcube.informationsystem.resourceregistry.Constants.SERVICE_NAME));
|
||||||
|
query.setResult("$resource");
|
||||||
|
|
||||||
|
DiscoveryClient<GCoreEndpoint> client = ICFactory.clientFor(GCoreEndpoint.class);
|
||||||
|
return client.submit(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ResourceRegistryPublisherImpl(){
|
||||||
|
this.endpoints = getServiceEndpoint();
|
||||||
|
};
|
||||||
|
|
||||||
|
private static int randInt(int min, int max) {
|
||||||
|
int randomNum = random.nextInt((max - min) + 1) + min;
|
||||||
|
return randomNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected URL getBaseURL() throws MalformedURLException {
|
||||||
|
GCoreEndpoint gCoreEndpoint = endpoints.get(randInt(0, endpoints.size()-1));
|
||||||
|
Endpoint endpoint = gCoreEndpoint.profile().endpointMap().get(org.gcube.informationsystem.resourceregistry.Constants.SERVICE_ENTRY_NAME);
|
||||||
|
return endpoint.uri().toURL();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AuthorizationEntry getAuthorizationEntry() {
|
||||||
|
try{
|
||||||
|
AuthorizationEntry info = Constants.authorizationService().get(SecurityTokenProvider.instance.get());
|
||||||
|
logger.info("Context is {} ",info.getContext());
|
||||||
|
return info;
|
||||||
|
}catch(Exception e){
|
||||||
|
String error = "Error retreiving security token";
|
||||||
|
logger.warn(error,e);
|
||||||
|
throw new RuntimeException(error,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpURLConnection makeRequest(URL url, String method) throws Exception{
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
if (SecurityTokenProvider.instance.get()==null) {
|
||||||
|
if(ScopeProvider.instance.get()==null){
|
||||||
|
throw new RuntimeException("Null Token and Scope. Please set your token first.");
|
||||||
|
}
|
||||||
|
connection.setRequestProperty("gcube-scope", ScopeProvider.instance.get());
|
||||||
|
}else{
|
||||||
|
connection.setRequestProperty(Constants.TOKEN_HEADER_ENTRY, SecurityTokenProvider.instance.get());
|
||||||
|
}
|
||||||
|
connection.setRequestMethod(method);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HttpURLConnection getHttpURLConnection(String path, String method, Map<String,String> paramenter) throws Exception {
|
||||||
|
URL url = new URL(getBaseURL(), path);
|
||||||
|
HttpURLConnection connection = makeRequest(url, method);
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E extends Embedded> E createEmbedded(E embedded) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E extends Embedded> E updateEmbedded(E embedded) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E extends Embedded> E deleteEmbedded(E embedded) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <F extends Facet> F createFacet(F facet) {
|
||||||
|
String marshalledFacet = Entities.marshal(facet);
|
||||||
|
String path = EntityPath.ENTITY_PATH_PART + "/" + EntityPath.FACET_PATH_PART + "/" + facet.NAME + "?" + EntityPath.DEFINITION_PARAM + "=" + marshalledFacet;
|
||||||
|
HttpURLConnection connection = getHttpURLConnection(path,);
|
||||||
|
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <F extends Facet> F updateFacet(F facet) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <F extends Facet> F deleteFacet(F facet) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends Resource> R createResource(R resource) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <R extends Resource> R deleteResource(R resource) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <C extends ConsistsOf<Resource, Facet>> C createConsistsOf(
|
||||||
|
C consistsOf) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <C extends ConsistsOf<Resource, Facet>> C updateConsistsOf(
|
||||||
|
C consistsOf) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <C extends ConsistsOf<Resource, Facet>> C deleteConsistsOf(
|
||||||
|
C consistsOf) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends IsRelatedTo<Resource, Resource>> I create(I isRelatedTo) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends IsRelatedTo<Resource, Resource>> I update(I isRelatedTo) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <I extends IsRelatedTo<Resource, Resource>> I delete(I isRelatedTo) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue