Skip to content

Commit

Permalink
add null check for datasetAuthor.getAffiliation() IQSS#4330
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Nov 30, 2017
1 parent 0f36aa0 commit fff836c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -1236,13 +1236,18 @@ public String getJsonLd() {
for (DatasetAuthor datasetAuthor : this.getDatasetAuthors()) {
JsonObjectBuilder author = Json.createObjectBuilder();
String name = datasetAuthor.getName().getValue();
String affiliation = datasetAuthor.getAffiliation().getValue();
DatasetField authorAffiliation = datasetAuthor.getAffiliation();
String affiliation = null;
if (authorAffiliation != null) {
affiliation = datasetAuthor.getAffiliation().getValue();
}
// We are aware of "givenName" and "familyName" but instead of a person it might be an organization such as "Gallup Organization".
//author.add("@type", "Person");
author.add("name", name);
// We are aware that the following error is thrown by https://search.google.com/structured-data/testing-tool
// "The property affiliation is not recognized by Google for an object of type Thing."
// Someone at Google has said this is ok.
// This logic could be moved into the `if (authorAffiliation != null)` block above.
if (!StringUtil.isEmpty(affiliation)) {
author.add("affiliation", affiliation);
}
Expand Down

0 comments on commit fff836c

Please sign in to comment.