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 634336c46..1f267733d 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()) { diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java index 23cd27449..fd8262544 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SendToZenodoHDFS.java @@ -98,8 +98,10 @@ public class SendToZenodoHDFS implements Serializable { } } + if (!metadata.equals("")) { + zenodoApiClient.sendMretadata(metadata); + } - zenodoApiClient.sendMretadata(metadata); if (publish) zenodoApiClient.publish(); diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml index baf9ae37a..161fd2dec 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml +++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/oozie_app/workflow.xml @@ -419,7 +419,7 @@ --metadata${metadata} --communityMapPath${workingDir}/communityMap --conceptRecordId${conceptRecordId} - --newDeposition${newDeposition} + --depositionType${depositionType}