From 7ebdfacee99ceb65ad3e44800d15f30413af24b4 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Thu, 5 Nov 2020 16:30:36 +0100 Subject: [PATCH] removed commented code and added documentation to new method --- .../dhp/common/api/ZenodoAPIClient.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java index 634336c461..1f267733d1 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/common/api/ZenodoAPIClient.java @@ -59,8 +59,6 @@ public class ZenodoAPIClient implements Serializable { String json = "{}"; OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - // RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, json); - RequestBody body = RequestBody.create(json, MEDIA_TYPE_JSON); Request request = new Request.Builder() @@ -128,7 +126,6 @@ public class ZenodoAPIClient implements Serializable { OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); - // RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, metadata); RequestBody body = RequestBody.create(metadata, MEDIA_TYPE_JSON); Request request = new Request.Builder() @@ -166,7 +163,6 @@ public class ZenodoAPIClient implements Serializable { Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/publish") .addHeader("Authorization", "Bearer " + access_token) - // .post(RequestBody.create(MEDIA_TYPE_JSON, json)) .post(body) .build(); @@ -202,7 +198,6 @@ public class ZenodoAPIClient implements Serializable { Request request = new Request.Builder() .url(urlString + "/" + deposition_id + "/actions/newversion") .addHeader("Authorization", "Bearer " + access_token) - // .post(RequestBody.create(MEDIA_TYPE_JSON, json)) .post(body) .build(); @@ -220,18 +215,26 @@ public class ZenodoAPIClient implements Serializable { } } + /** + * To finish uploading a version or new deposition not published + * It sets the deposition_id and the bucket to be used + * + * + * @param deposition_id the deposition id of the not yet published upload + * concept_rec_id = 656930 + * @return response code + * @throws IOException + * @throws MissingConceptDoiException + */ public int uploadOpenDeposition(String deposition_id) throws IOException, MissingConceptDoiException { this.deposition_id = deposition_id; - String json = "{}"; - OkHttpClient httpClient = new OkHttpClient.Builder().connectTimeout(600, TimeUnit.SECONDS).build(); Request request = new Request.Builder() .url(urlString + "/" + deposition_id) .addHeader("Authorization", "Bearer " + access_token) - // .post(RequestBody.create(MEDIA_TYPE_JSON, json)) .build(); try (Response response = httpClient.newCall(request).execute()) {