removed unused utils classes
This commit is contained in:
parent
13ee1b5e91
commit
37d0426b77
|
@ -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 {
|
||||
}
|
|
@ -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 {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue