From 4ccfc787910ea4a30dd9180d30ec8164981aa3ab Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 7 May 2024 11:59:06 +0200 Subject: [PATCH] using javax.ws.rs.core.Response.Status instead of apache.http.HttpStatus --- .settings/org.eclipse.wst.common.component | 30 +++++++++++-------- pom.xml | 6 ++++ .../resolver/services/StorageIDResolver.java | 6 ++-- src/test/java/gis/GeonetworkQueryTest.java | 1 - src/test/java/gis/LayersMatchingGN_CKAN.java | 9 +++--- src/test/java/gis/RuntimeResourceReader.java | 2 +- src/test/java/gis/SE_Harvester_from_IS.java | 10 ++----- src/test/java/rest/TestResolvers.java | 14 +++++---- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 9857039..8fa0242 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -29,7 +30,8 @@ - + + @@ -59,7 +61,8 @@ - + + @@ -89,7 +92,8 @@ - + + @@ -119,7 +123,8 @@ - + + @@ -149,16 +154,14 @@ - - uses - uses uses - + + @@ -188,7 +191,8 @@ - + + @@ -218,7 +222,8 @@ - + + @@ -248,7 +253,8 @@ - + + diff --git a/pom.xml b/pom.xml index 5462a74..e6aade9 100644 --- a/pom.xml +++ b/pom.xml @@ -295,6 +295,12 @@ compile + + eu.trentorise.opendata + jackan + 0.4.2 + + diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index edc1fae..2b57600 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -14,10 +14,10 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.ResponseBuilder; +import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; import org.apache.commons.io.IOUtils; -import org.apache.http.HttpStatus; import org.gcube.contentmanagement.blobstorage.resource.MyFile; import org.gcube.contentmanagement.blobstorage.service.IClient; import org.gcube.contentmanager.storageclient.wrapper.AccessType; @@ -222,7 +222,7 @@ public class StorageIDResolver { //THIS IS FOR HPROXY CHECK if(hproxycheck){ LOG.trace("returning status 200 for Hproxy check"); - ResponseBuilder response = Response.status(HttpStatus.SC_OK); + ResponseBuilder response = Response.status(Status.OK); return response.build(); } @@ -313,7 +313,7 @@ public class StorageIDResolver { if(c>0){ LOG.info("at least 1 byte read, returning status 200"); IOUtils.closeQuietly(streamToWrite); - response = Response.status(HttpStatus.SC_OK); + response = Response.status(Status.OK); }else throw ExceptionManager.notFoundException(httpRequest, "The file with id: "+storageId+" is missing in the storage", StorageIDResolver.class, help); } diff --git a/src/test/java/gis/GeonetworkQueryTest.java b/src/test/java/gis/GeonetworkQueryTest.java index 08d3dda..6ed577f 100644 --- a/src/test/java/gis/GeonetworkQueryTest.java +++ b/src/test/java/gis/GeonetworkQueryTest.java @@ -12,7 +12,6 @@ import org.gcube.spatial.data.geonetwork.LoginLevel; import org.gcube.spatial.data.geonetwork.configuration.Configuration; import org.gcube.spatial.data.geonetwork.model.Account; import org.gcube.spatial.data.geonetwork.model.Account.Type; -import org.junit.Test; import it.geosolutions.geonetwork.util.GNSearchRequest; import it.geosolutions.geonetwork.util.GNSearchResponse; diff --git a/src/test/java/gis/LayersMatchingGN_CKAN.java b/src/test/java/gis/LayersMatchingGN_CKAN.java index 29b57c3..d97b17b 100644 --- a/src/test/java/gis/LayersMatchingGN_CKAN.java +++ b/src/test/java/gis/LayersMatchingGN_CKAN.java @@ -3,10 +3,6 @@ */ package gis; -import it.geosolutions.geonetwork.util.GNSearchRequest; -import it.geosolutions.geonetwork.util.GNSearchResponse; -import resources.GetAllInfrastructureScopes; - import java.io.BufferedWriter; import java.io.FileWriter; import java.io.PrintWriter; @@ -18,7 +14,10 @@ import org.gcube.common.scope.api.ScopeProvider; import org.gcube.spatial.data.geonetwork.GeoNetwork; import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher; import org.gcube.spatial.data.geonetwork.LoginLevel; -import org.junit.Test; + +import it.geosolutions.geonetwork.util.GNSearchRequest; +import it.geosolutions.geonetwork.util.GNSearchResponse; +import resources.GetAllInfrastructureScopes; /** diff --git a/src/test/java/gis/RuntimeResourceReader.java b/src/test/java/gis/RuntimeResourceReader.java index ebec3fd..9085eef 100644 --- a/src/test/java/gis/RuntimeResourceReader.java +++ b/src/test/java/gis/RuntimeResourceReader.java @@ -7,9 +7,9 @@ import java.util.ArrayList; import java.util.List; import org.gcube.common.encryption.StringEncrypter; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; +import org.gcube.common.scope.api.ScopeProvider; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.slf4j.Logger; diff --git a/src/test/java/gis/SE_Harvester_from_IS.java b/src/test/java/gis/SE_Harvester_from_IS.java index 74434d4..99d5476 100644 --- a/src/test/java/gis/SE_Harvester_from_IS.java +++ b/src/test/java/gis/SE_Harvester_from_IS.java @@ -3,10 +3,6 @@ */ package gis; -import it.geosolutions.geonetwork.util.GNSearchRequest; -import it.geosolutions.geonetwork.util.GNSearchResponse; -import resources.GetAllInfrastructureScopes; - import java.io.BufferedWriter; import java.io.FileWriter; import java.io.PrintWriter; @@ -16,11 +12,9 @@ import java.util.List; import java.util.Map; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; -import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.spatial.data.geonetwork.GeoNetwork; -import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher; import org.gcube.spatial.data.geonetwork.LoginLevel; -import org.junit.Test; + +import resources.GetAllInfrastructureScopes; /** * diff --git a/src/test/java/rest/TestResolvers.java b/src/test/java/rest/TestResolvers.java index f5a4ac5..77387f9 100644 --- a/src/test/java/rest/TestResolvers.java +++ b/src/test/java/rest/TestResolvers.java @@ -15,11 +15,13 @@ import java.nio.file.StandardCopyOption; import java.util.List; import java.util.Map; +import javax.ws.rs.core.Response.Status; + import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; -import org.apache.http.HttpStatus; import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader; import org.gcube.datatransfer.resolver.util.HTTPCallsUtils; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +61,7 @@ public class TestResolvers { System.out.println("header fields: "+con.getHeaderFields()); String fileName = getFilename(con.getHeaderFields()); System.out.println("Response status is: "+status); - if(status==HttpStatus.SC_OK){ + if(status==Status.OK.getStatusCode()){ Path target = Files.createTempFile(FilenameUtils.getBaseName(fileName), "."+FilenameUtils.getExtension(fileName)); try (InputStream in = con.getInputStream()) { Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING); @@ -103,7 +105,7 @@ public class TestResolvers { //printHeaders(con.getHeaderFields()); String fileName = getFilename(con.getHeaderFields()); System.out.println("Response status is: "+status); - if(status==HttpStatus.SC_OK){ + if(status==Status.OK.getStatusCode()){ Path target = Files.createTempFile(FilenameUtils.getBaseName(fileName), "."+FilenameUtils.getExtension(fileName)); try (InputStream in = con.getInputStream()) { Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING); @@ -146,7 +148,7 @@ public class TestResolvers { status = con.getResponseCode(); //printHeaders(con.getHeaderFields()); System.out.println("Response status is: "+status); - if(status==HttpStatus.SC_OK){ + if(status==Status.OK.getStatusCode()){ System.out.println("\nFile to URL: "+url +" is reachable via doHEAD"); System.out.println(IOUtils.toString(con.getInputStream())); }else{ @@ -187,7 +189,7 @@ public class TestResolvers { con.connect(); status = con.getResponseCode(); System.out.println("Response status is: "+status); - if(status==HttpStatus.SC_OK){ + if(status==Status.OK.getStatusCode()){ System.out.println("Response: \n"+getContentReponse(con.getInputStream())); }else{ System.out.println("\nError on resolving the Catalogue URL: "+toURL); @@ -323,7 +325,7 @@ public class TestResolvers { status = con.getResponseCode(); //printHeaders(con.getHeaderFields()); System.out.println("Response status is: "+status); - if(status==HttpStatus.SC_SEE_OTHER){ + if(status==Status.SEE_OTHER.getStatusCode()){ System.out.println("\nResponse to URL: "+url); System.out.println(IOUtils.toString(con.getInputStream())); }else{