From 1c9d631fcd8cbd1fcb531be9a73ae24c4ba5ba50 Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Tue, 27 Aug 2019 14:24:55 +0300 Subject: [PATCH] Fixes bug on Remote Fetcher when "source" field is null. --- .../logic/proxy/fetching/RemoteFetcher.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java index 47110fb0e..0ebd415e0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java @@ -190,11 +190,20 @@ public class RemoteFetcher { if (responseCode == HttpURLConnection.HTTP_OK) { // success //do here all the parsing DocumentContext jsonContext = JsonPath.parse(con.getInputStream()); - Results results = new Results(jsonContext.read(jsonDataPath.getPath() - + "[" + jsonDataPath.getFieldsUrlConfiguration().getName() + "," + jsonDataPath.getFieldsUrlConfiguration().getDescription() - + "," + jsonDataPath.getFieldsUrlConfiguration().getUri() + "," + jsonDataPath.getFieldsUrlConfiguration().getId() - + "," + jsonDataPath.getFieldsUrlConfiguration().getSource() + "]"), - jsonContext.read(jsonPaginationPath)); + Results results; + if (jsonDataPath.getFieldsUrlConfiguration().getSource() != null) { + results = new Results(jsonContext.read(jsonDataPath.getPath() + + "[" + jsonDataPath.getFieldsUrlConfiguration().getName() + "," + jsonDataPath.getFieldsUrlConfiguration().getDescription() + + "," + jsonDataPath.getFieldsUrlConfiguration().getUri() + "," + jsonDataPath.getFieldsUrlConfiguration().getId() + + "," + jsonDataPath.getFieldsUrlConfiguration().getSource() + "]"), + jsonContext.read(jsonPaginationPath)); + } + else { + results = new Results(jsonContext.read(jsonDataPath.getPath() + + "[" + jsonDataPath.getFieldsUrlConfiguration().getName() + "," + jsonDataPath.getFieldsUrlConfiguration().getDescription() + + "," + jsonDataPath.getFieldsUrlConfiguration().getUri() + "," + jsonDataPath.getFieldsUrlConfiguration().getId() + "]"), + jsonContext.read(jsonPaginationPath)); + } results.results = results.results.stream().map(e -> e.entrySet().stream().collect(Collectors.toMap(x -> this.transformKey(jsonDataPath,x.getKey()), Map.Entry::getValue))) .collect(Collectors.toList()); return results;