using javax.ws.rs.core.Response.Status instead of apache.http.HttpStatus

This commit is contained in:
Francesco Mangiacrapa 2024-05-07 11:59:06 +02:00
parent eb56afabd6
commit 4ccfc78791
8 changed files with 42 additions and 36 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -29,7 +30,8 @@
<wb-module deploy-name="uri-resolver-2.10.0-SNAPSHOT">
@ -59,7 +61,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -89,7 +92,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -119,7 +123,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -149,16 +154,14 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="uri-resolver-manager-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager/uri-resolver-manager">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-data-common-2.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="geoportal-client-1.2.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -188,7 +191,8 @@
<property name="context-root" value="uri-resolver"/>
@ -218,7 +222,8 @@
<property name="java-output-path" value="/uri-resolver/target/classes"/>
@ -248,7 +253,8 @@
</wb-module>

View File

@ -295,6 +295,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>eu.trentorise.opendata</groupId>
<artifactId>jackan</artifactId>
<version>0.4.2</version>
</dependency>
<!-- END GIS RESOLVER DEPENDENCIES -->
<dependency>

View File

@ -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);
}

View File

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

View File

@ -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;
/**

View File

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

View File

@ -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;
/**
*

View File

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