From d81b7fdfac97769b042d114ef1ed7c0007270b64 Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Wed, 20 Sep 2023 18:28:37 -0500 Subject: [PATCH 1/2] fix: Validate that availability and documentStyle are included --- .../v3/identifiers/resolvers/PubMedResolver.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java index c2ca1adf5fb..7a8620686bf 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java @@ -206,8 +206,15 @@ private WorkExtended getWork(JSONObject json) throws JSONException, ParseExcepti for (int i = 0; i < urls.length(); i++) { JSONObject url = urls.getJSONObject(i); // Look for html or doi links - String urlType = url.getString("documentStyle"); - String availability = url.getString("availability"); + String urlType = null; + if (url.has("documentStyle")) { + urlType = url.getString("documentStyle"); + } + String availability = null; + if (url.has("availability")) { + availability = url.getString("availability"); + } + // If we find the html link, use it and stop // searching if (urlType.equals("html")) { From aacb380244bc9689e28b94afa8f6ae9497a2f2f0 Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Thu, 21 Sep 2023 12:20:15 -0500 Subject: [PATCH 2/2] fix: Validate if urlType its not null --- .../v3/identifiers/resolvers/PubMedResolver.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java index 7a8620686bf..b7dfdbb567a 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/resolvers/PubMedResolver.java @@ -217,13 +217,15 @@ private WorkExtended getWork(JSONObject json) throws JSONException, ParseExcepti // If we find the html link, use it and stop // searching - if (urlType.equals("html")) { - if(availability == null || availability.equals("Free") || availability.equals("Open access")) { + if (urlType != null) { + if (urlType.equals("html")) { + if(availability == null || availability.equals("Free") || availability.equals("Open access")) { + work.setUrl(new Url(url.getString("url"))); + break; + } + } else if (urlType.equals("doi")) { work.setUrl(new Url(url.getString("url"))); - break; } - } else if (urlType.equals("doi")) { - work.setUrl(new Url(url.getString("url"))); } } }