Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ORCID/ORCID-Source
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Jul 30, 2024
2 parents c85de91 + e4ca907 commit 3132245
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 65 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v2.62.5 - 2024-07-24

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.62.4...v2.62.5)

## v2.62.4 - 2024-07-24

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.62.3...v2.62.4)

## v2.62.3 - 2024-07-22

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.62.2...v2.62.3)

## v2.62.2 - 2024-07-18

[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.62.1...v2.62.2)
Expand Down
5 changes: 5 additions & 0 deletions orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Date implements ErrorsInterface, Required, Serializable, Comparable
private String month;
private String day;
private String year;
private Long timestamp;

private boolean required = true;
private String getRequiredMessage;
Expand Down Expand Up @@ -171,6 +172,10 @@ public void setYear(String year) {
this.year = year;
}

public Long getTimestamp() { return timestamp; }

public void setTimestamp(Long timestamp) { this.timestamp = timestamp; }

@Override
public int hashCode() {
final int prime = 31;
Expand Down
18 changes: 2 additions & 16 deletions orcid-core/src/main/java/org/orcid/pojo/ajaxForm/Email.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.orcid.pojo.ajaxForm;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -43,22 +44,6 @@ public static Email valueOf(org.orcid.jaxb.model.v3.release.record.Email e) {
email.setVerified(e.isVerified());
email.setVisibility(e.getVisibility());

if (e.getCreatedDate() != null) {
Date createdDate = new Date();
createdDate.setYear(String.valueOf(e.getCreatedDate().getValue().getYear()));
createdDate.setMonth(String.valueOf(e.getCreatedDate().getValue().getMonth()));
createdDate.setDay(String.valueOf(e.getCreatedDate().getValue().getDay()));
email.setCreatedDate(createdDate);
}

if (e.getLastModifiedDate() != null) {
Date lastModifiedDate = new Date();
lastModifiedDate.setYear(String.valueOf(e.getLastModifiedDate().getValue().getYear()));
lastModifiedDate.setMonth(String.valueOf(e.getLastModifiedDate().getValue().getMonth()));
lastModifiedDate.setDay(String.valueOf(e.getLastModifiedDate().getValue().getDay()));
email.setLastModified(lastModifiedDate);
}

if (e.getSource().getSourceName() != null) {
email.setSourceName(e.getSource().getSourceName().getContent());
}
Expand All @@ -80,6 +65,7 @@ public static Email valueOf(org.orcid.jaxb.model.v3.release.record.Email e) {
createdDate.setYear(String.valueOf(e.getCreatedDate().getValue().getYear()));
createdDate.setMonth(String.valueOf(e.getCreatedDate().getValue().getMonth()));
createdDate.setDay(String.valueOf(e.getCreatedDate().getValue().getDay()));
createdDate.setTimestamp(e.getCreatedDate().getValue().toGregorianCalendar().getTimeInMillis());
email.setCreatedDate(createdDate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ private void recordFailure(GroupIdRecordEntity issnEntity, String notes) {

private void updateIssnEntity(GroupIdRecordEntity issnEntity, IssnData issnData) {
String currentGroupName = issnEntity.getGroupName();
String updatedGroupName = issnData.getMainTitle();

String updatedGroupName = issnData.getMainTitle();

// Clear the fail count and reason
issnEntity.setIssnLoaderFailCount(0);
issnEntity.setFailReason(null);

if(!StringUtils.equals(currentGroupName, updatedGroupName)) {
issnEntity.setGroupName(updatedGroupName);
issnEntity.setClientSourceId(orcidSource.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,35 +228,6 @@ public void sendReactivationEmail(String submittedEmail, String userOrcid) {
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reactivation", locale), body, htmlBody);
}

public void sendEmailAddressChangedNotification(String currentUserOrcid, String newEmail, String oldEmail) {
ProfileEntity profile = profileEntityCacheManager.retrieve(currentUserOrcid);
Locale userLocale = getUserLocaleFromProfileEntity(profile);

// build up old template
Map<String, Object> templateParams = new HashMap<String, Object>();

String subject = verifyEmailUtils.getSubject("email.subject.email_removed", userLocale);
String emailFriendlyName = recordNameManager.deriveEmailFriendlyName(currentUserOrcid);
templateParams.put("emailName", emailFriendlyName);
String verificationUrl = verifyEmailUtils.createVerificationUrl(newEmail, orcidUrlManager.getBaseUrl());
templateParams.put("verificationUrl", verificationUrl);
templateParams.put("oldEmail", oldEmail);
templateParams.put("newEmail", newEmail);
templateParams.put("orcid", currentUserOrcid);
templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp());
templateParams.put("subject", subject);

verifyEmailUtils.addMessageParams(templateParams, userLocale);

// Generate body from template
String body = templateManager.processTemplate("email_removed.ftl", templateParams);
// Generate html from template
String html = templateManager.processTemplate("email_removed_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, oldEmail, subject, body, html);
}

public void sendClaimReminderEmail(String userOrcid, int daysUntilActivation, String email) {
ProfileEntity record = profileEntityCacheManager.retrieve(userOrcid);
String primaryEmail = emailManager.findPrimaryEmail(userOrcid).getEmail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
List<Email> newEmails = new ArrayList<Email>();
String orcid = getCurrentUserOrcid();
List<String> errors = new ArrayList<String>();

for (org.orcid.pojo.ajaxForm.Email newJsonEmail : newEmailSet.getEmails()) {
boolean isNewEmail = true;
for (org.orcid.jaxb.model.v3.release.record.Email oldJsonEmail: oldEmailSet.getEmails()) {
Expand Down Expand Up @@ -646,7 +645,6 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
Map<String, String> keys = emailManager.addEmail(currentUserOrcid, email.toV3Email());
if(!keys.isEmpty()) {
request.getSession().setAttribute(EmailConstants.CHECK_EMAIL_VALIDATED, false);
recordEmailSender.sendEmailAddressChangedNotification(currentUserOrcid, keys.get("new"), keys.get("old"));
}
recordEmailSender.sendVerificationEmail(currentUserOrcid, OrcidStringUtils.filterEmailAddress(email.getValue()), email.isPrimary());
} else {
Expand Down Expand Up @@ -736,13 +734,12 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
public @ResponseBody org.orcid.pojo.ajaxForm.Email setPrimary(HttpServletRequest request, @RequestBody org.orcid.pojo.ajaxForm.Email email) {
String orcid = getCurrentUserOrcid();
String owner = emailManager.findOrcidIdByEmail(email.getValue());
if(orcid.equals(owner)) {
if(orcid.equals(owner)) {
// Sets the given email as primary
Map<String, String> keys = emailManager.setPrimary(orcid, email.getValue().trim(), request);
if(keys.containsKey("new")) {
String newPrimary = keys.get("new");
String oldPrimary = keys.get("old");
recordEmailSender.sendEmailAddressChangedNotification(orcid, newPrimary, oldPrimary);
if(keys.containsKey("sendVerification")) {
recordEmailSender.sendVerificationEmail(orcid, newPrimary, true);
request.getSession().setAttribute(EmailConstants.CHECK_EMAIL_VALIDATED, false);
Expand Down Expand Up @@ -788,11 +785,6 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
String original = editEmail.getOriginal();
String edited = editEmail.getEdited();
Map<String, String> keys = emailManager.editEmail(orcid, original, edited, request);
if(keys.containsKey("new")) {
String newPrimary = keys.get("new");
String oldPrimary = keys.get("old");
recordEmailSender.sendEmailAddressChangedNotification(orcid, newPrimary, oldPrimary);
}
String verifyAddress = keys.get("verifyAddress");
boolean isPrimaryEmail = keys.containsKey("new") ? true : false;
recordEmailSender.sendVerificationEmail(orcid, verifyAddress, isPrimaryEmail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public void testChangeEmailAddress() throws Exception {

for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
profile.setLocale(locale.name());
recordEmailSender.sendEmailAddressChangedNotification(orcid, "[email protected]", "[email protected]");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ public void testAddEmail_noPrimaryEmailChange() {
when(mockEmailManager.emailExists(eq("[email protected]"))).thenReturn(false);

controller.addEmails(mockRequest, newEmail);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());

verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1009,7 +1008,6 @@ public void testAddEmail_primaryEmailChange() {

controller.addEmails(mockRequest, newEmail);

verify(mockRecordEmailSender, Mockito.times(1)).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1030,7 +1028,6 @@ public void testSetPrimary_nothingChange() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());
verify(mockRecordEmailSender, Mockito.never()).sendVerificationEmail(any(), any(), any());
}

Expand All @@ -1051,7 +1048,6 @@ public void testSetPrimary_primaryEmailChange() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.times(1)).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.never()).sendVerificationEmail(any(), any(), any());
}

Expand All @@ -1075,7 +1071,6 @@ public void testSetPrimary_primaryEmailChangeAndPrimaryIsNotVerified() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.times(1)).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(true));
}

Expand All @@ -1099,7 +1094,6 @@ public void testEditEmail_noPrimaryChange() {

controller.editEmail(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1120,7 +1114,6 @@ public void testEditEmail_primaryEmailChange() {
when(mockEmailManager.editEmail(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"), any())).thenReturn(Map.of("verifyAddress", "[email protected]", "new", "[email protected]", "old", "[email protected]"));
controller.editEmail(mockRequest, email);

verify(mockRecordEmailSender, Mockito.times(1)).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(true));
}

Expand Down

0 comments on commit 3132245

Please sign in to comment.