Skip to content

Commit

Permalink
add null check when fetching emails
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Nov 5, 2024
1 parent 85cfb05 commit 62cd783
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,14 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
}
org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains);
// Old emails are missing the source name and id -- assign the user as the source
for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
String orcid = getCurrentUserOrcid();
String displayName = getPersonDetails(orcid, true).getDisplayName();
email.setSource(orcid);
email.setSourceName(displayName);
if (emails.getEmails() != null) {
for (org.orcid.pojo.ajaxForm.Email email : emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
String orcid = getCurrentUserOrcid();
String displayName = getPersonDetails(orcid, true).getDisplayName();
email.setSource(orcid);
email.setSourceName(displayName);
}
}
}
return emails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,15 @@ PublicRecord getRecord(String orcid) {

org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains);
// Old emails are missing the source name and id -- assign the user as the source
for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
email.setSource(orcid);
email.setSourceName(publicRecord.getDisplayName());
if (emails.getEmails() != null) {
for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
email.setSource(orcid);
email.setSourceName(publicRecord.getDisplayName());
}
}
}

publicRecord.setEmails(emails);

// Fill external identifiers
Expand Down

0 comments on commit 62cd783

Please sign in to comment.