Added usage of common-utility

This commit is contained in:
Luca Frosini 2023-02-22 15:15:11 +01:00
parent cdeeae7bda
commit 7401c46e4d
3 changed files with 18 additions and 13 deletions

View File

@ -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]

View File

@ -49,6 +49,10 @@
<groupId>org.gcube.common</groupId>
<artifactId>gxHTTP</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-utility</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>

View File

@ -9,6 +9,7 @@ import java.util.UUID;
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.ERElement;
@ -41,7 +42,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaV
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.ServiceInstance;
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath;
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath.SharingOperation;
import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPUtility;
@ -132,7 +132,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public List<Context> 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(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
@ -166,7 +166,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
protected Context getContextFromServer(String id) throws ContextNotFoundException, ResourceRegistryException {
try {
logger.info("Going to get current {} ", Context.NAME);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
@ -213,7 +213,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@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;
@ -256,7 +256,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
public String list(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(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(AccessPath.INSTANCES_PATH_PART);
@ -285,7 +285,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throws SchemaViolationException, AlreadyPresentException, ResourceRegistryException {
try {
logger.trace("Going to create {} : {}", type, json);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
@ -382,7 +382,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
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(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
@ -447,7 +447,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
try {
logger.trace("Going to read {} with UUID {}", type, uuid);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(InstancePath.INSTANCES_PATH_PART);
@ -527,7 +527,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
try {
logger.trace("Going to create {} : {}", type, json);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.header("Content-type", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
@ -573,7 +573,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throws SchemaViolationException, NotFoundException, ResourceRegistryException {
try {
logger.trace("Going to delete {} with UUID {}", type, uuid);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.header("Accept", GXConnection.APPLICATION_JSON_CHARSET_UTF_8);
gxHTTPStringRequest.path(InstancePath.INSTANCES_PATH_PART);
@ -796,7 +796,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
try {
logger.trace("Going to add {} with UUID {} to {} with UUID {} ", type, instanceUUID, Context.NAME,
contextUUID);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.path(SharingPath.SHARING_PATH_PART);
gxHTTPStringRequest.path(SharingPath.CONTEXTS_PATH_PART);
@ -867,7 +867,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
try {
logger.trace("Going to add {} with UUID {} to {} with UUID {} ", type, instanceUUID, Context.NAME,
contextUUID);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.path(SharingPath.SHARING_PATH_PART);
gxHTTPStringRequest.path(SharingPath.CONTEXTS_PATH_PART);
@ -936,7 +936,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throws NotFoundException, ResourceRegistryException {
try {
logger.trace("Going to get contexts of {} with UUID {}", type, instanceUUID);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPStringRequest.newRequest(address);
GXHTTPStringRequest gxHTTPStringRequest = GXHTTPUtility.getGXHTTPStringRequest(address);
gxHTTPStringRequest.from(ResourceRegistryPublisher.class.getSimpleName());
gxHTTPStringRequest.path(InstancePath.INSTANCES_PATH_PART);
gxHTTPStringRequest.path(type);