From c7e62e273423beb3536ae40750b92f48f41b03a5 Mon Sep 17 00:00:00 2001 From: Konstantinos Triantafyllou Date: Fri, 22 Jan 2021 16:12:44 +0000 Subject: [PATCH] [Users | Trunk]: Fix exception when a user is not yer registered to openaire --- .../openaire/usermanagement/utils/RegistryCalls.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/dnetlib/openaire/usermanagement/utils/RegistryCalls.java b/src/main/java/eu/dnetlib/openaire/usermanagement/utils/RegistryCalls.java index 60f650f..20857ce 100644 --- a/src/main/java/eu/dnetlib/openaire/usermanagement/utils/RegistryCalls.java +++ b/src/main/java/eu/dnetlib/openaire/usermanagement/utils/RegistryCalls.java @@ -62,7 +62,13 @@ public class RegistryCalls { params.put("coid", coid); params.put("mail", email); JsonElement response = httpUtils.get("co_people.json", params); - return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null; + if(response != null) { + JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray(); + if(coPeople.size() > 0) { + return coPeople.get(0).getAsJsonObject().get("Id").getAsInt(); + } + } + return null; } /**