diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ba295d..5a58abd 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.3.0-SNAPSHOT] - Enhanced gcube-bom version +- Added usage of common-utility to overcome issues with different Smartgears version (i.e. 3 and 4) ## [v4.2.0] diff --git a/pom.xml b/pom.xml index 91c7144..993df0a 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,10 @@ org.gcube.common gxHTTP + + org.gcube.common + common-utility + org.slf4j slf4j-api diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java index a3dfbfd..04a3588 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -13,6 +13,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.com.fasterxml.jackson.databind.ObjectMapper; import org.gcube.common.gxhttp.reference.GXConnection; import org.gcube.common.gxhttp.request.GXHTTPStringRequest; +import org.gcube.common.http.GXHTTPUtility; import org.gcube.informationsystem.base.reference.Direction; import org.gcube.informationsystem.contexts.reference.entities.Context; import org.gcube.informationsystem.model.reference.ERElement; @@ -37,7 +38,6 @@ import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath; import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath; import org.gcube.informationsystem.resourceregistry.api.rest.QueryTemplatePath; -import org.gcube.informationsystem.resourceregistry.api.rest.ServiceInstance; import org.gcube.informationsystem.resourceregistry.api.rest.TypePath; import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPUtility; import org.gcube.informationsystem.resourceregistry.api.utils.Utility; @@ -108,7 +108,6 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { return gxHTTPStringRequest.queryParams(queryParams); } - protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() { @Override @@ -129,7 +128,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { public List getAllContextFromServer() throws ResourceRegistryException { try { logger.info("Going to read all {}s", Context.NAME); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -165,7 +164,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { // TODO use cache logger.info("Going to get current {} ", Context.NAME); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -230,7 +229,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { @Override public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException { - String contextFullName = ServiceInstance.getCurrentContextFullName(); + String contextFullName = org.gcube.common.context.ContextUtility.getCurrentContextFullName(); ContextCache contextCache = ContextCache.getInstance(); UUID uuid = contextCache.getUUIDByFullName(contextFullName); Context context = null; @@ -259,7 +258,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { public boolean existType(String typeName) throws ResourceRegistryException { try { logger.info("Going to get {} schema", typeName); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -306,7 +305,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws SchemaNotFoundException, ResourceRegistryException { try { logger.info("Going to get {} schema", typeName); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -351,7 +350,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException { try { logger.info("Going to get all instances of {} ", type); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -389,7 +388,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws AvailableInAnotherContextException, ResourceRegistryException { try { logger.info("Going to check if {} with UUID {} exists", type, uuid); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -433,7 +432,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { logger.info("Going to get {} with UUID {}", type, uuid); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -469,7 +468,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { try { logger.info("Going to query. {}", query); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -501,7 +500,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws ResourceRegistryException { try { - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -732,7 +731,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { logger.trace("Going to get contexts of {} with UUID {}", type, uuid); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -761,7 +760,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { public List getAllQueryTemplates() throws ResourceRegistryException { try { logger.trace("Going to list {}s", QueryTemplate.NAME); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -795,7 +794,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws QueryTemplateNotFoundException, ResourceRegistryException { try { logger.trace("Going to read {} with name {}", QueryTemplate.NAME, queryTemplateName); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -839,7 +838,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throws QueryTemplateNotFoundException, ResourceRegistryException { try { logger.trace("Going to read {} with name {}", QueryTemplate.NAME, queryTemplateName); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); @@ -897,7 +896,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { logger.trace("Going to run {} with the following parameters {}", QueryTemplate.NAME, params); } - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); @@ -943,7 +942,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { try { logger.trace("Going to run the following JSON Query {}", query); - GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address); + GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address); gxHTTPStringRequest.from(ResourceRegistryClient.class.getSimpleName()); gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);