From e9a31f367a6580a5605bd525f4da4207cfd3e22c Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Tue, 23 Mar 2021 13:15:22 +0100 Subject: [PATCH] files as json arrays --- .../src/main/java/eu/dnetlib/broker/BrokerUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd-line-apps/dhp-broker-client/src/main/java/eu/dnetlib/broker/BrokerUtils.java b/cmd-line-apps/dhp-broker-client/src/main/java/eu/dnetlib/broker/BrokerUtils.java index ee909746..73095bbf 100644 --- a/cmd-line-apps/dhp-broker-client/src/main/java/eu/dnetlib/broker/BrokerUtils.java +++ b/cmd-line-apps/dhp-broker-client/src/main/java/eu/dnetlib/broker/BrokerUtils.java @@ -84,7 +84,9 @@ public class BrokerUtils { String url = baseUrl + "/scroll/notifications/bySubscriptionId/" + URLEncoder.encode(subscrId, StandardCharsets.UTF_8.name()); boolean notCompleted = false; + boolean first = true; + file.append("[\n"); do { log.info("Performing HTTP GET for notifications: " + url); final HttpGet request = new HttpGet(url); @@ -95,8 +97,12 @@ public class BrokerUtils { final JSONArray values = data.getJSONArray("values"); for (int i = 0; i < values.length(); i++) { + if (first) { + first = false; + } else { + file.append(",\n"); + } file.append(values.getJSONObject(i).toString()); - file.append("\n"); } notCompleted = !data.getBoolean("completed"); @@ -105,6 +111,8 @@ public class BrokerUtils { System.out.print("."); System.out.flush(); } while (notCompleted); + + file.append("\n]\n"); } private String extractDsName(final JSONArray conds) {