Skip to content

Commit

Permalink
Merge pull request #6892 from ORCID/8851-prod-import-by-pubmed-id-is-…
Browse files Browse the repository at this point in the history
…broken-for-some-identifiers

fix: Validate that availability and documentStyle exist
  • Loading branch information
amontenegro authored Sep 21, 2023
2 parents 38a14a3 + aacb380 commit f8854db
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,26 @@ 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")) {
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")));
}
}
}
Expand Down

0 comments on commit f8854db

Please sign in to comment.