public org.orcid.jaxb.model.v3.rc2.record.Email toV3Email() { org.orcid.jaxb.model.v3.rc2.record.Email email = new org.orcid.jaxb.model.v3.rc2.record.Email(); email.setCurrent(current); email.setEmail(value); email.setLastModifiedDate(null); email.setPrimary(primary); email.setVerified(verified); email.setVisibility(visibility); return email; }
public static Email valueOf(org.orcid.jaxb.model.v3.rc2.record.Email e) { Email email = new Email(); if (e != null) { email.setCurrent(e.isCurrent()); email.setPrimary(e.isPrimary()); email.setSource(e.retrieveSourcePath()); email.setValue(e.getEmail()); email.setVerified(e.isVerified()); email.setVisibility(e.getVisibility()); } return email; }
public static void calculateLastModified(Emails emails) { if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) { LastModifiedDate latest = null; for (Email email : emails.getEmails()) { if (email.getLastModifiedDate() != null && email.getLastModifiedDate().after(latest)) { latest = email.getLastModifiedDate(); } } emails.setLastModifiedDate(latest); } }
@Override public void mapBtoA(org.orcid.jaxb.model.v3.rc2.record.Email b, Email a, MappingContext context) { a.setCurrent(b.isCurrent()); a.setPrimary(b.isPrimary()); a.setVerified(b.isVerified()); }
protected void doInTransactionWithoutResult(TransactionStatus status) { if (emails != null && !emails.getEmails().isEmpty()) { for (Email email : emails.getEmails()) { emailDao.updateEmail(orcid, email.getEmail().trim(), email.isCurrent(), email.getVisibility().name()); } } } });
@Override @Transactional public void addEmail(HttpServletRequest request, String orcid, Email email) { SourceEntity sourceEntity = sourceManager.retrieveActiveSourceEntity(); String sourceId = sourceEntity.getSourceProfile() == null ? null : sourceEntity.getSourceProfile().getId(); String clientSourceId = sourceEntity.getSourceClient() == null ? null : sourceEntity.getSourceClient().getId(); Email currentPrimaryEmail = findPrimaryEmail(orcid); // Create the new email emailDao.addEmail(orcid, email.getEmail(), encryptionManager.getEmailHash(email.getEmail()), email.getVisibility().name(), sourceId, clientSourceId); // if primary email changed send notification. if (email.isPrimary() && !StringUtils.equals(currentPrimaryEmail.getEmail(), email.getEmail())) { request.getSession().setAttribute(EmailConstants.CHECK_EMAIL_VALIDATED, false); notificationManager.sendEmailAddressChangedNotification(orcid, email.getEmail(), currentPrimaryEmail.getEmail()); } // send verifcation email for new address notificationManager.sendVerificationEmail(orcid, email.getEmail()); }
@Override public void setPrimary(String orcid, String email, HttpServletRequest request) { Email currentPrimaryEmail = this.findPrimaryEmail(orcid); EmailEntity newPrimary = emailDao.findByEmail(email); if(newPrimary != null && !currentPrimaryEmail.getEmail().equals(email)) { emailDao.updatePrimary(orcid, email); notificationManager.sendEmailAddressChangedNotification(orcid, email, currentPrimaryEmail.getEmail()); if (!newPrimary.getVerified()) { notificationManager.sendVerificationEmail(orcid, email); request.getSession().setAttribute(EmailConstants.CHECK_EMAIL_VALIDATED, false); } } }
if (emails != null) { for (Email email : emails.getEmails()) { if (email.isVerified()) { verfiedEmail = true; if (email.isPrimary()) { verfiedPrimaryEmail = true; break;
public Boolean doInTransaction(TransactionStatus status) { boolean wasDeprecated = profileDao.deprecateProfile(deprecatedOrcid, primaryOrcid, deprecatedMethod, adminUser); // If it was successfully deprecated if (wasDeprecated) { LOGGER.info("Account {} was deprecated to primary account: {}", deprecatedOrcid, primaryOrcid); clearRecord(deprecatedOrcid, false); // Move all email's to the primary record Emails deprecatedAccountEmails = emailManager.getEmails(deprecatedOrcid); if (deprecatedAccountEmails != null) { // For each email in the deprecated profile for (Email email : deprecatedAccountEmails.getEmails()) { // Delete each email from the deprecated // profile LOGGER.info("About to move email {} from profile {} to profile {}", new Object[] { email.getEmail(), deprecatedOrcid, primaryOrcid }); emailManager.moveEmailToOtherAccount(email.getEmail(), deprecatedOrcid, primaryOrcid); } } profileDao.updateLastModifiedDateAndIndexingStatus(deprecatedOrcid, IndexingStatus.REINDEX); return true; } return false; } });
@Override public void sendOrcidDeactivateEmail(String userOrcid) { ProfileEntity profile = profileEntityCacheManager.retrieve(userOrcid); Locale userLocale = getUserLocaleFromProfileEntity(profile); org.orcid.jaxb.model.v3.rc2.record.Email primaryEmail = emailManager.findPrimaryEmail(userOrcid); Map<String, Object> templateParams = new HashMap<String, Object>(); String subject = getSubject("email.subject.deactivate", userLocale); String email = primaryEmail.getEmail(); String encryptedEmail = encryptionManager.encryptForExternalUse(email); String base64EncodedEmail = Base64.encodeBase64URLSafeString(encryptedEmail.getBytes()); String deactivateUrlEndpointPath = "/account/confirm-deactivate-orcid"; String emailFriendlyName = deriveEmailFriendlyName(profile); templateParams.put("emailName", emailFriendlyName); templateParams.put("orcid", userOrcid); templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp()); templateParams.put("deactivateUrlEndpoint", deactivateUrlEndpointPath + "/" + base64EncodedEmail); templateParams.put("deactivateUrlEndpointUrl", deactivateUrlEndpointPath); templateParams.put("subject", subject); addMessageParams(templateParams, userLocale); // Generate body from template String body = templateManager.processTemplate("deactivate_orcid_email.ftl", templateParams); // Generate html from template String html = templateManager.processTemplate("deactivate_orcid_email_html.ftl", templateParams); mailGunManager.sendEmail(DEACTIVATE_NOTIFY_ORCID_ORG, email, subject, body, html); }
@Override public void sendOrcidLockedEmail(String orcidToLock) { ProfileEntity profile = profileEntityCacheManager.retrieve(orcidToLock); Locale userLocale = getUserLocaleFromProfileEntity(profile); String subject = getSubject("email.subject.locked", userLocale); String email = emailManager.findPrimaryEmail(orcidToLock).getEmail(); String emailFriendlyName = deriveEmailFriendlyName(profile); Map<String, Object> templateParams = new HashMap<String, Object>(); templateParams.put("emailName", emailFriendlyName); templateParams.put("orcid", orcidToLock); templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp()); templateParams.put("subject", subject); addMessageParams(templateParams, userLocale); // Generate body from template String body = templateManager.processTemplate("locked_orcid_email.ftl", templateParams); // Generate html from template String html = templateManager.processTemplate("locked_orcid_email_html.ftl", templateParams); mailGunManager.sendEmail(LOCKED_NOTIFY_ORCID_ORG, email, subject, body, html); }
@Override public void sendPasswordResetEmail(String submittedEmail, String userOrcid) { ProfileEntity record = profileEntityCacheManager.retrieve(userOrcid); String primaryEmail = emailManager.findPrimaryEmail(userOrcid).getEmail(); Locale locale = getUserLocaleFromProfileEntity(record); // Create map of template params Map<String, Object> templateParams = new HashMap<String, Object>(); templateParams.put("emailName", deriveEmailFriendlyName(record)); templateParams.put("submittedEmail", submittedEmail); templateParams.put("orcid", userOrcid); templateParams.put("subject", getSubject("email.subject.reset", getUserLocaleFromProfileEntity(record))); templateParams.put("baseUri", orcidUrlManager.getBaseUrl()); templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp()); // Generate body from template String resetUrl = createResetEmail(primaryEmail, orcidUrlManager.getBaseUrl()); templateParams.put("passwordResetUrl", resetUrl); addMessageParams(templateParams, locale); // Generate body from template String body = templateManager.processTemplate("reset_password_email.ftl", templateParams); String htmlBody = templateManager.processTemplate("reset_password_email_html.ftl", templateParams); mailGunManager.sendEmail(RESET_NOTIFY_ORCID_ORG, submittedEmail, getSubject("email.subject.reset", locale), body, htmlBody); }
private void processVerificationEmail(String userOrcid, String email, boolean isVerificationReminder) { ProfileEntity profile = profileEntityCacheManager.retrieve(userOrcid); Locale locale = getUserLocaleFromProfileEntity(profile); String primaryEmail = emailManager.findPrimaryEmail(userOrcid).getEmail(); String emailFriendlyName = deriveEmailFriendlyName(profile); String subject = createSubjectForVerificationEmail(email, primaryEmail, locale); Map<String, Object> templateParams = createParamsForVerificationEmail(subject, emailFriendlyName, userOrcid, email, primaryEmail, locale); templateParams.put("isReminder", isVerificationReminder); // Generate body from template String body = templateManager.processTemplate("verification_email_v2.ftl", templateParams); String htmlBody = templateManager.processTemplate("verification_email_html_v2.ftl", templateParams); mailGunManager.sendEmail(SUPPORT_VERIFY_ORCID_ORG, email, subject, body, htmlBody); }
String creatorName = record.getSource() == null ? null : SourceEntityUtils.getSourceName(record.getSource()); Locale userLocale = getUserLocaleFromProfileEntity(record); String email = emailManager.findPrimaryEmail(orcid).getEmail(); String emailName = deriveEmailFriendlyName(record); String verificationUrl = createClaimVerificationUrl(email, orcidUrlManager.getBaseUrl());
String grantingOrcidEmail = primaryEmail.getEmail(); String emailNameForDelegate = deriveEmailFriendlyName(delegateProfileEntity); String assetsUrl = getAssetsUrl();
templateParams.put("managedOrcidValue", managedOrcid); String primaryEmail = emailManager.findPrimaryEmail(managedOrcid).getEmail(); if (primaryEmail == null) { LOGGER.info("Cant send admin delegate email if primary email is null: {}", managedOrcid);
@Override public void sendClaimReminderEmail(String userOrcid, int daysUntilActivation) { ProfileEntity record = profileEntityCacheManager.retrieve(userOrcid); String primaryEmail = emailManager.findPrimaryEmail(userOrcid).getEmail(); Locale locale = getUserLocaleFromProfileEntity(record);