Reimplemented HTTPCall to better suite new client and publisher implementation. Client and Publisher now does not uses FWS but ICClient to discover resource-registry.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@146531 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
85ea8432d6
commit
000fc10247
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.informationsystem.resourceregistry.api.Constants;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ResourceRegistryPublisherFactory {
|
||||
|
||||
protected static ResourceRegistryPublisher singleton;
|
||||
|
||||
private static String classFormat = "$resource/Profile/ServiceClass/text() eq '%1s'";
|
||||
private static String nameFormat = "$resource/Profile/ServiceName/text() eq '%1s'";
|
||||
private static String statusFormat = "$resource/Profile/DeploymentData/Status/text() eq 'ready'";
|
||||
private static String containsFormat = "$entry/@EntryName eq '%1s'";
|
||||
|
||||
private static SimpleQuery getQuery(){
|
||||
return ICFactory.queryFor(GCoreEndpoint.class)
|
||||
.addCondition(String.format(classFormat, Constants.SERVICE_CLASS))
|
||||
.addCondition(String.format(nameFormat, Constants.SERVICE_NAME))
|
||||
.addCondition(String.format(statusFormat))
|
||||
.addVariable("$entry","$resource/Profile/AccessPoint/RunningInstanceInterfaces/Endpoint")
|
||||
.addCondition(String.format(containsFormat, Constants.SERVICE_ENTRY_NAME))
|
||||
.setResult("$entry/text()");
|
||||
}
|
||||
|
||||
|
||||
public static ResourceRegistryPublisher create(){
|
||||
if(singleton==null){
|
||||
SimpleQuery query = getQuery();
|
||||
List<String> addresses = ICFactory.client().submit(query);
|
||||
|
||||
if(addresses==null || addresses.isEmpty()){
|
||||
String error = String.format("No %s:%s found in the current context", Constants.SERVICE_CLASS, Constants.SERVICE_NAME);
|
||||
throw new RuntimeException(error);
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
int index = random.nextInt(addresses.size());
|
||||
|
||||
singleton = new ResourceRegistryPublisherImpl(addresses.get(index));
|
||||
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,12 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.ws.EndpointReference;
|
||||
|
||||
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.clients.delegates.AsyncProxyDelegate;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
import org.gcube.common.clients.exceptions.ServiceException;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.impl.utils.ISMapper;
|
||||
|
@ -38,12 +35,20 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(ResourceRegistryPublisherImpl.class);
|
||||
|
||||
private final AsyncProxyDelegate<EndpointReference> delegate;
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
|
||||
public ResourceRegistryPublisherImpl(ProxyDelegate<EndpointReference> config) {
|
||||
this.delegate = new AsyncProxyDelegate<EndpointReference>(config);
|
||||
protected final String address;
|
||||
protected HTTPCall httpCall;
|
||||
|
||||
public ResourceRegistryPublisherImpl(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
protected HTTPCall getHTTPCall() throws MalformedURLException {
|
||||
if(httpCall==null){
|
||||
httpCall = new HTTPCall(address, ResourceRegistryPublisher.class.getSimpleName());
|
||||
}
|
||||
return httpCall;
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,13 +78,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
|
||||
String body = ISMapper.marshal(facet);
|
||||
|
||||
HTTPCall<F> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, null, body);
|
||||
|
||||
ResourceRegistryPublisherCall<F> call = new ResourceRegistryPublisherCall<>(
|
||||
facetClass, httpCall);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
F f= httpCall.call(facetClass, stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, body);
|
||||
|
||||
F f = delegate.make(call);
|
||||
logger.info("{} successfully created", f);
|
||||
return f;
|
||||
|
||||
|
@ -105,13 +108,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(facet.getHeader().getUUID().toString());
|
||||
|
||||
String body = ISMapper.marshal(facet);
|
||||
HTTPCall<F> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null, body);
|
||||
|
||||
ResourceRegistryPublisherCall<F> call = new ResourceRegistryPublisherCall<>(
|
||||
facetClass, httpCall);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
F f= httpCall.call(facetClass, stringWriter.toString(),
|
||||
HTTPMETHOD.POST, body);
|
||||
|
||||
F f = delegate.make(call);
|
||||
logger.info("{} successfully updated", f);
|
||||
return f;
|
||||
|
||||
|
@ -136,13 +137,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(facet.getHeader().getUUID().toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean deleted = delegate.make(call);
|
||||
logger.info("{} {}", facet, deleted ? " successfully deleted"
|
||||
: "was NOT deleted");
|
||||
return deleted;
|
||||
|
@ -172,13 +170,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
|
||||
String body = ISMapper.marshal(resource);
|
||||
|
||||
HTTPCall<R> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, null, body);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
R r = httpCall.call(resourceClass, stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, body);
|
||||
|
||||
ResourceRegistryPublisherCall<R> call = new ResourceRegistryPublisherCall<>(
|
||||
resourceClass, httpCall);
|
||||
|
||||
R r = delegate.make(call);
|
||||
logger.info("{} successfully created", r);
|
||||
return r;
|
||||
|
||||
|
@ -207,13 +202,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
|
||||
String body = ISMapper.marshal(resource);
|
||||
|
||||
HTTPCall<R> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null, body);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
R r = httpCall.call(resourceClass, stringWriter.toString(),
|
||||
HTTPMETHOD.POST, body);
|
||||
|
||||
ResourceRegistryPublisherCall<R> call = new ResourceRegistryPublisherCall<>(
|
||||
resourceClass, httpCall);
|
||||
|
||||
R r = delegate.make(call);
|
||||
logger.info("{} update created", r);
|
||||
return r;
|
||||
|
||||
|
@ -238,13 +230,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(resource.getHeader().getUUID().toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean deleted = delegate.make(call);
|
||||
logger.info("{} {}", resource, deleted ? " successfully deleted"
|
||||
: "was NOT deleted");
|
||||
return deleted;
|
||||
|
@ -284,13 +273,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
|
||||
String body = ISMapper.marshal(consistsOf);
|
||||
|
||||
HTTPCall<C> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, null, body);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
C c = httpCall.call(consistsOfClass, stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, body);
|
||||
|
||||
ResourceRegistryPublisherCall<C> call = new ResourceRegistryPublisherCall<>(
|
||||
consistsOfClass, httpCall);
|
||||
|
||||
C c = delegate.make(call);
|
||||
logger.info("{} successfully created", c);
|
||||
return c;
|
||||
|
||||
|
@ -322,13 +308,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean deleted = delegate.make(call);
|
||||
logger.info("{} with UUID {} {}", ConsistsOf.NAME, uuid, deleted ? " successfully deleted"
|
||||
: "was NOT deleted");
|
||||
return deleted;
|
||||
|
@ -369,13 +352,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
|
||||
String body = ISMapper.marshal(isRelatedTo);
|
||||
|
||||
HTTPCall<I> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, null, body);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
I i = httpCall.call(isRelatedToClass, stringWriter.toString(),
|
||||
HTTPMETHOD.PUT, body);
|
||||
|
||||
ResourceRegistryPublisherCall<I> call = new ResourceRegistryPublisherCall<>(
|
||||
isRelatedToClass, httpCall);
|
||||
|
||||
I i = delegate.make(call);
|
||||
logger.info("{} successfully created", i);
|
||||
return i;
|
||||
|
||||
|
@ -406,13 +386,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.DELETE);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean deleted = delegate.make(call);
|
||||
logger.info("{} with UUID {} {}", IsRelatedTo.NAME, uuid, deleted ? " successfully deleted"
|
||||
: "was NOT deleted");
|
||||
return deleted;
|
||||
|
@ -446,13 +423,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean added = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.POST);
|
||||
|
||||
boolean added = delegate.make(call);
|
||||
logger.info("{} with UUID {} was {} added to current {} : {}",
|
||||
Resource.NAME, uuid, added ? "successfully" : "NOT",
|
||||
Context.NAME, context);
|
||||
|
@ -495,13 +470,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean added = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.POST);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean added = delegate.make(call);
|
||||
logger.info("{} with UUID {} was {} added to current {} : {}",
|
||||
Facet.NAME, uuid, added ? "successfully" : "NOT",
|
||||
Context.NAME, context);
|
||||
|
@ -545,13 +517,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean removed = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.POST);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
|
||||
boolean removed = delegate.make(call);
|
||||
logger.info("{} with UUID {} was {} removed from current {} : {}",
|
||||
Resource.NAME, uuid, removed ? "successfully" : "NOT",
|
||||
Context.NAME, context);
|
||||
|
@ -596,13 +565,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
stringWriter.append(PATH_SEPARATOR);
|
||||
stringWriter.append(uuid.toString());
|
||||
|
||||
HTTPCall<Boolean> httpCall = new HTTPCall<>(stringWriter.toString(),
|
||||
HTTPMETHOD.POST, null);
|
||||
|
||||
ResourceRegistryPublisherCall<Boolean> call = new ResourceRegistryPublisherCall<>(
|
||||
Boolean.class, httpCall);
|
||||
HTTPCall httpCall = getHTTPCall();
|
||||
boolean removed = httpCall.call(Boolean.class, stringWriter.toString(),
|
||||
HTTPMETHOD.POST);
|
||||
|
||||
boolean removed = delegate.make(call);
|
||||
logger.info("{} with UUID {} was {} removed from current {} : {}",
|
||||
Facet.NAME, uuid, removed ? "successfully" : "NOT",
|
||||
Context.NAME, context);
|
|
@ -1,34 +0,0 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher.plugin;
|
||||
|
||||
|
||||
import org.gcube.common.clients.fw.plugin.Plugin;
|
||||
import org.gcube.informationsystem.resourceregistry.api.Constants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.publisher.plugin;
|
||||
|
||||
import javax.xml.ws.EndpointReference;
|
||||
|
||||
import org.gcube.common.clients.config.ProxyConfig;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
import org.gcube.informationsystem.resourceregistry.api.Constants;
|
||||
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)
|
||||
*
|
||||
*/
|
||||
public class ResourceRegistryPublisherPlugin extends AbstractPlugin<EndpointReference, ResourceRegistryPublisher>{
|
||||
|
||||
public ResourceRegistryPublisherPlugin(){
|
||||
super(Constants.SERVICE_ENTRY_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String namespace() {
|
||||
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 EndpointReference resolve(EndpointReference address,
|
||||
ProxyConfig<?, ?> config) throws Exception {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceRegistryPublisher newProxy(
|
||||
ProxyDelegate<EndpointReference> delegate) {
|
||||
return new ResourceRegistryPublisherImpl(delegate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
class JaxRSEndpointReference {
|
||||
|
||||
private static final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
|
||||
private static final String addressLocalName = "Address";
|
||||
|
||||
String address;
|
||||
|
||||
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,36 +0,0 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.ws.EndpointReference;
|
||||
|
||||
import org.gcube.common.clients.Call;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall;
|
||||
|
||||
class ResourceRegistryPublisherCall<C> implements Call<EndpointReference, C> {
|
||||
|
||||
protected final Class<C> clazz;
|
||||
protected final HTTPCall<C> httpInputs;
|
||||
|
||||
public ResourceRegistryPublisherCall(Class<C> clazz, HTTPCall<C> httpInputs) {
|
||||
this.clazz = clazz;
|
||||
this.httpInputs = httpInputs;
|
||||
}
|
||||
|
||||
protected String getURLStringFromEndpointReference(
|
||||
EndpointReference endpoint) throws IOException {
|
||||
JaxRSEndpointReference jaxRSEndpointReference = new JaxRSEndpointReference(
|
||||
endpoint);
|
||||
return jaxRSEndpointReference.toString();
|
||||
}
|
||||
@Override
|
||||
public C call(EndpointReference endpoint) throws Exception {
|
||||
String urlFromEndpointReference = getURLStringFromEndpointReference(endpoint);
|
||||
StringBuilder callUrl = new StringBuilder(urlFromEndpointReference);
|
||||
callUrl.append(httpInputs.getPath());
|
||||
URL url = new URL(callUrl.toString());
|
||||
return httpInputs.call(clazz, url, ResourceRegistryPublisher.class.getSimpleName());
|
||||
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
|
||||
|
||||
import javax.xml.ws.EndpointReference;
|
||||
|
||||
import org.gcube.common.clients.fw.builders.StatelessBuilderImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.plugin.ResourceRegistryPublisherPlugin;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ResourceRegistryPublisherFactory {
|
||||
|
||||
protected static ResourceRegistryPublisher singleton;
|
||||
|
||||
public static ResourceRegistryPublisher create(){
|
||||
if(singleton==null){
|
||||
ResourceRegistryPublisherPlugin plugin = new ResourceRegistryPublisherPlugin();
|
||||
singleton = new StatelessBuilderImpl<EndpointReference, ResourceRegistryPublisher>(plugin).build();
|
||||
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
}
|
|
@ -45,11 +45,11 @@ 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.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.Direction;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.client.Direction;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
|||
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -39,10 +39,10 @@ import org.gcube.informationsystem.model.relation.consistsof.HasPersistentMemory
|
|||
import org.gcube.informationsystem.model.relation.consistsof.HasVolatileMemory;
|
||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -19,10 +19,10 @@ import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
|||
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.client.proxy.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -51,8 +51,8 @@ import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
|||
import org.gcube.informationsystem.model.relation.consistsof.HasPersistentMemory;
|
||||
import org.gcube.informationsystem.model.relation.consistsof.HasVolatileMemory;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
Loading…
Reference in New Issue