forked from D-Net/dnet-hadoop
refactoring
This commit is contained in:
parent
24c41806ac
commit
9fc8ebe98b
|
@ -9,13 +9,13 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.apache.http.HttpHeaders;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import eu.dnetlib.dhp.common.api.zenodo.ZenodoModel;
|
||||
import eu.dnetlib.dhp.common.api.zenodo.ZenodoModelList;
|
||||
import okhttp3.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZenodoAPIClient implements Serializable {
|
||||
|
||||
|
@ -155,7 +155,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("PUT");
|
||||
|
||||
|
||||
try (OutputStream os = conn.getOutputStream()) {
|
||||
byte[] input = metadata.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
|
@ -169,7 +168,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
|
||||
return responseCode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean checkOKStatus(int responseCode) {
|
||||
|
@ -233,7 +231,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
|
||||
|
||||
try (OutputStream os = conn.getOutputStream()) {
|
||||
byte[] input = json.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
|
@ -296,7 +293,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
ZenodoModel zenodoModel = new Gson().fromJson(body, ZenodoModel.class);
|
||||
bucket = zenodoModel.getLinks().getBucket();
|
||||
|
||||
|
||||
return responseCode;
|
||||
|
||||
}
|
||||
|
@ -331,8 +327,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("GET");
|
||||
|
||||
|
||||
|
||||
String body = getBody(conn);
|
||||
|
||||
int responseCode = conn.getResponseCode();
|
||||
|
@ -341,12 +335,8 @@ public class ZenodoAPIClient implements Serializable {
|
|||
if (!checkOKStatus(responseCode))
|
||||
throw new IOException("Unexpected code " + responseCode + body);
|
||||
|
||||
|
||||
|
||||
return body;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getBucket(String inputUurl) throws IOException {
|
||||
|
@ -370,8 +360,6 @@ public class ZenodoAPIClient implements Serializable {
|
|||
|
||||
return zenodoModel.getLinks().getBucket();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue