diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e2a056..1263b60 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v4.1.0-SNAPSHOT]
- Enhanced gcube-bom version
+- Added usage of common-utility to overcome issues with different Smartgears version (i.e. 3 and 4)
## [v4.0.1]
diff --git a/pom.xml b/pom.xml
index b471842..da0375d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,10 +50,15 @@
org.gcube.common
gxHTTP
+
+ org.gcube.common
+ common-utility
+
org.slf4j
slf4j-api
+
junit
diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ResourceRegistryContextClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ResourceRegistryContextClientImpl.java
index 6d90f1e..a225737 100644
--- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ResourceRegistryContextClientImpl.java
+++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ResourceRegistryContextClientImpl.java
@@ -6,8 +6,10 @@ import java.util.List;
import java.util.UUID;
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
+import org.gcube.common.context.ContextUtility;
import org.gcube.common.gxhttp.reference.GXConnection;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
+import org.gcube.common.http.GXHTTPUtility;
import org.gcube.informationsystem.contexts.reference.entities.Context;
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
import org.gcube.informationsystem.model.reference.properties.Header;
@@ -18,7 +20,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
-import org.gcube.informationsystem.resourceregistry.api.rest.ServiceInstance;
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPUtility;
import org.gcube.informationsystem.serialization.ElementMapper;
import org.slf4j.Logger;
@@ -61,7 +62,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
protected List getAllContextFromServer() throws ResourceRegistryException {
try {
logger.trace("Going to read {} with UUID {}", Context.NAME);
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(ContextPath.CONTEXTS_PATH_PART);
@@ -100,7 +101,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
logger.trace("Going to create {}", contextString);
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
@@ -155,7 +156,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
public boolean existFromServer(String uuid) throws ContextNotFoundException, ResourceRegistryException {
try {
logger.trace("Going to read {} with UUID {}", Context.NAME, uuid);
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(ContextPath.CONTEXTS_PATH_PART);
@@ -220,7 +221,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
@Override
public Context readCurrentContext() throws ContextNotFoundException, ResourceRegistryException {
- String contextFullName = ServiceInstance.getCurrentContextFullName();
+ String contextFullName = ContextUtility.getCurrentContextFullName();
ContextCache contextCache = ContextCache.getInstance();
UUID uuid = contextCache.getUUIDByFullName(contextFullName);
Context context = null;
@@ -261,7 +262,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
public String readFromServer(String uuid) throws ContextNotFoundException, ResourceRegistryException {
try {
logger.trace("Going to read {} with UUID {}", Context.NAME, uuid);
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(ContextPath.CONTEXTS_PATH_PART);
@@ -288,7 +289,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
UUID uuid = context.getHeader().getUUID();
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
@@ -354,7 +355,7 @@ public class ResourceRegistryContextClientImpl implements ResourceRegistryContex
public boolean delete(String uuid) throws ContextNotFoundException, ResourceRegistryException {
try {
logger.trace("Going to delete {} with UUID {}", Context.NAME, uuid);
- GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
+ GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryContextClient.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(ContextPath.CONTEXTS_PATH_PART);