diff --git a/pom.xml b/pom.xml
index 5c3b8f7..58c3dc9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,10 @@
org.gcube.common
gcube-jackson-databind
+
+ org.gcube.common
+ common-utility
+
diff --git a/src/main/java/org/gcube/gcat/client/GCatClient.java b/src/main/java/org/gcube/gcat/client/GCatClient.java
index 7b6c44f..eb0d06b 100644
--- a/src/main/java/org/gcube/gcat/client/GCatClient.java
+++ b/src/main/java/org/gcube/gcat/client/GCatClient.java
@@ -22,6 +22,7 @@ import javax.ws.rs.core.MediaType;
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
+import org.gcube.common.http.GXHTTPUtility;
import org.gcube.gcat.api.GCatConstants;
/**
@@ -104,7 +105,7 @@ abstract class GCatClient {
}
protected void initRequest() throws UnsupportedEncodingException {
- gxhttpStringRequest = GXHTTPStringRequest.newRequest(serviceURL.toString());
+ gxhttpStringRequest = GXHTTPUtility.getGXHTTPStringRequest(serviceURL.toString());
for(String name : headers.keySet()) {
gxhttpStringRequest.header(name, headers.get(name));
}
diff --git a/src/main/java/org/gcube/gcat/client/GCatClientDiscovery.java b/src/main/java/org/gcube/gcat/client/GCatClientDiscovery.java
index 8d4ffe2..ae6179b 100644
--- a/src/main/java/org/gcube/gcat/client/GCatClientDiscovery.java
+++ b/src/main/java/org/gcube/gcat/client/GCatClientDiscovery.java
@@ -8,10 +8,9 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
-import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
+import org.gcube.common.context.ContextUtility;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint;
-import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.gcat.api.GCatConstants;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
@@ -33,7 +32,7 @@ public class GCatClientDiscovery {
protected static void forceToURL(String adddress) throws MalformedURLException {
if(adddress!=null && adddress.compareTo("")!=0) {
- String context = getContext();
+ String context = ContextUtility.getCurrentContextFullName();
URL url = new URL(adddress);
clients.put(context, url);
}
@@ -88,24 +87,8 @@ public class GCatClientDiscovery {
return addresses;
}
-
- protected static String getContext() {
- String context = null;
- if (SecurityTokenProvider.instance.get() == null) {
- if (ScopeProvider.instance.get() == null) {
- throw new RuntimeException(
- "Null Token and Scope. Please set your token first.");
- }
- context = ScopeProvider.instance.get();
- } else {
- context = SecurityTokenProvider.instance.get();
- }
- return context;
- }
-
public static URL getServiceURL() throws MalformedURLException {
-
- String context = getContext();
+ String context = ContextUtility.getCurrentContextFullName();
URL url = clients.get(context);
if(url==null){