Skip to content

Commit fc21f65

Browse files
committed
Check that the available titles are not empty
1 parent a59028e commit fc21f65

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

orcid-core/src/main/java/org/orcid/core/groupIds/issn/IssnClient.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ private IssnData extractIssnData(String issn, String json) throws JSONException
7070

7171
// 1. Try to get mainTitle directly from the root
7272
if (rootObj.has("mainTitle")) {
73-
String title = rootObj.getString("mainTitle");
74-
String cleanTitle = cleanText(title);
75-
issnData.setMainTitle(cleanTitle);
76-
LOG.debug("Found mainTitle for '" + issn + "' " + cleanTitle);
77-
return issnData;
73+
String title = cleanText(rootObj.getString("mainTitle"));
74+
if(StringUtils.isNotBlank(title)) {
75+
issnData.setMainTitle(title);
76+
LOG.debug("Found mainTitle for '" + issn + "' " + title);
77+
return issnData;
78+
}
7879
}
7980

8081
// 2. Try to get the KeyTitle from the identifiedBy block
@@ -83,11 +84,12 @@ private IssnData extractIssnData(String issn, String json) throws JSONException
8384
if (identifiedBy.has("#KeyTitle")) {
8485
JSONObject keyTitleObj = identifiedBy.getJSONObject("#KeyTitle");
8586
if (keyTitleObj.has("value")) {
86-
String title = keyTitleObj.getString("value");
87-
String cleanTitle = cleanText(title);
88-
issnData.setMainTitle(cleanTitle);
89-
LOG.debug("Found KeyTitle for '" + issn + "' " + cleanTitle);
90-
return issnData;
87+
String title = cleanText(keyTitleObj.getString("value"));
88+
if(StringUtils.isNotBlank(title)) {
89+
issnData.setMainTitle(title);
90+
LOG.debug("Found KeyTitle for '" + issn + "' " + title);
91+
return issnData;
92+
}
9193
}
9294
}
9395
}
@@ -109,9 +111,11 @@ private IssnData extractIssnData(String issn, String json) throws JSONException
109111

110112
if (title != null && !title.isEmpty()) {
111113
String cleanTitle = cleanText(title);
112-
issnData.setMainTitle(cleanTitle);
113-
LOG.debug("Found name for '" + issn + "' " + cleanTitle);
114-
return issnData;
114+
if(StringUtils.isNotBlank(cleanTitle)) {
115+
issnData.setMainTitle(cleanTitle);
116+
LOG.debug("Found name for '" + issn + "' " + cleanTitle);
117+
return issnData;
118+
}
115119
}
116120
}
117121

orcid-core/src/test/resources/issn-response-use-key-title.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"status": "recordStatus:Register",
4949
"type": "schema:CreativeWork"
5050
},
51+
"mainTitle": "",
5152
"name": [
5253
"Nature chemistry.",
5354
"Nature chemistry"

orcid-core/src/test/resources/issn-response-use-name-array.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"status": "recordStatus:Register",
3333
"type": "schema:CreativeWork"
3434
},
35+
"mainTitle": "",
3536
"name": [
3637
"Journal of food engineering - Array"
3738
],

orcid-scheduler-web/src/main/java/org/orcid/scheduler/loader/source/issn/IssnLoadSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ private void updateIssnGroupIdRecords() {
140140
} catch(JSONException e) {
141141
LOG.warn("JSONException for issn {}", issn);
142142
recordFailure(issnEntity, "JSONException");
143+
} catch (IllegalArgumentException e) {
144+
LOG.warn("IllegalArgumentException for issn {}", issn);
145+
recordFailure(issnEntity, "IllegalArgumentException");
143146
}
144147
} else {
145148
LOG.info("Issn for group record {} not valid: {}", issnEntity.getId(), issnEntity.getGroupId());

0 commit comments

Comments
 (0)