From 37d0426b77803c4b6c155627dc3f5dcec521585e Mon Sep 17 00:00:00 2001 From: Alfredo Oliviero Date: Mon, 22 Apr 2024 17:24:06 +0200 Subject: [PATCH] removed unused utils classes --- .../gcube/service/rest/annotation/PATCH.java | 17 ------- .../gcube/service/rest/annotation/PURGE.java | 17 ------- .../gcube/service/rest/utils/HTTPUtility.java | 49 ------------------- 3 files changed, 83 deletions(-) delete mode 100644 src/main/java/org/gcube/service/rest/annotation/PATCH.java delete mode 100644 src/main/java/org/gcube/service/rest/annotation/PURGE.java delete mode 100644 src/main/java/org/gcube/service/rest/utils/HTTPUtility.java diff --git a/src/main/java/org/gcube/service/rest/annotation/PATCH.java b/src/main/java/org/gcube/service/rest/annotation/PATCH.java deleted file mode 100644 index aeb8195..0000000 --- a/src/main/java/org/gcube/service/rest/annotation/PATCH.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.gcube.service.rest.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import jakarta.ws.rs.HttpMethod; - -/** - * @author Luca Frosini (ISTI - CNR) - */ -@Target({ ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@HttpMethod("PATCH") -public @interface PATCH { -} \ No newline at end of file diff --git a/src/main/java/org/gcube/service/rest/annotation/PURGE.java b/src/main/java/org/gcube/service/rest/annotation/PURGE.java deleted file mode 100644 index ce7a09a..0000000 --- a/src/main/java/org/gcube/service/rest/annotation/PURGE.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.gcube.service.rest.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import jakarta.ws.rs.HttpMethod; - -/** - * @author Luca Frosini (ISTI - CNR) - */ -@Target({ ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@HttpMethod("PURGE") -public @interface PURGE { -} \ No newline at end of file diff --git a/src/main/java/org/gcube/service/rest/utils/HTTPUtility.java b/src/main/java/org/gcube/service/rest/utils/HTTPUtility.java deleted file mode 100644 index 3a96a08..0000000 --- a/src/main/java/org/gcube/service/rest/utils/HTTPUtility.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.gcube.service.rest.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; - -import jakarta.ws.rs.WebApplicationException; -import jakarta.ws.rs.core.Response.Status; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Luca Frosini (ISTI - CNR) - */ -public class HTTPUtility { - - private static final Logger logger = LoggerFactory.getLogger(HTTPUtility.class); - - public static StringBuilder getStringBuilder(InputStream inputStream) throws IOException { - StringBuilder result = new StringBuilder(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { - String line; - while ((line = reader.readLine()) != null) { - result.append(line); - } - } - - return result; - } - - public static String getResultAsString(HttpURLConnection httpURLConnection) throws IOException { - int responseCode = httpURLConnection.getResponseCode(); - if (responseCode >= Status.BAD_REQUEST.getStatusCode()) { - Status status = Status.fromStatusCode(responseCode); - InputStream inputStream = httpURLConnection.getErrorStream(); - StringBuilder result = getStringBuilder(inputStream); - logger.trace(result.toString()); - throw new WebApplicationException(result.toString(), status); - } - InputStream inputStream = httpURLConnection.getInputStream(); - String ret = getStringBuilder(inputStream).toString(); - logger.trace("Got Respose is {}", ret); - return ret; - } - -}