diff --git a/.classpath b/.classpath
index 953de0b..b8c44f6 100644
--- a/.classpath
+++ b/.classpath
@@ -6,20 +6,11 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -27,7 +18,7 @@
-
+
diff --git a/src/main/java/org/gcube/resources/discovery/icclient/ICClient.java b/src/main/java/org/gcube/resources/discovery/icclient/ICClient.java
index 57680fd..214a7b0 100644
--- a/src/main/java/org/gcube/resources/discovery/icclient/ICClient.java
+++ b/src/main/java/org/gcube/resources/discovery/icclient/ICClient.java
@@ -17,6 +17,7 @@ import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.api.DiscoveryException;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.icclient.stubs.CollectorStub;
+import org.gcube.resources.discovery.icclient.stubs.CollectorStubRestImpl;
import org.gcube.resources.discovery.icclient.stubs.MalformedQueryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,10 +32,10 @@ public class ICClient implements DiscoveryClient {
//result split pattern
private static final Pattern pattern = Pattern.compile("(.*?)", Pattern.DOTALL);
-
-
+
+
public List submit(Query query) throws DiscoveryException {
-
+
try {
CollectorStub stub = getStub();
String results = callService(query, stub);
@@ -46,44 +47,47 @@ public class ICClient implements DiscoveryClient {
catch(SOAPFaultException e) {
throw new RuntimeException(JAXWSUtils.remoteCause(e));
}
-
+
}
-
+
//helper
private String callService(Query query, CollectorStub stub) {
-
+
String expression = query.expression();
-
+
log.info("executing query {}",expression);
-
+
long time = System.currentTimeMillis();
-
+
String submittedExpression = Helper.queryAddAuthenticationControl(expression);
-
+
String response = stub.execute(submittedExpression);
-
+
log.info("executed query {} in {} ms",expression,System.currentTimeMillis()-time);
-
+
return response;
}
-
+
//helper
private CollectorStub getStub() {
+
+ ServiceMap serviceMap = ServiceMap.instance;
+ String address = serviceMap.endpoint(localname);
+ log.info("connecting to {}",address);
+ if (serviceMap.version().equals("2.0.0"))
+ return new CollectorStubRestImpl(address);
+ else
+ return stubFor(collector).at(URI.create(address));
- //find endpoint address in service map currently in scope
- String address = ServiceMap.instance.endpoint(localname);
- log.info("connectinfg to "+address);
- //obtain a JAXWS stub configured for gCube calls
- return stubFor(collector).at(URI.create(address));
}
-
+
//helper
private List splitIntoList(String response) {
-
+
List results = new ArrayList();
-
+
Matcher m = pattern.matcher(response);
-
+
while (m.find())
results.add(m.group(1).trim());