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; } });
/** * Create an instance of {@link Email } * */ public Email createEmail() { return new Email(); }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
private void createOpportunityContact(Contact contact, String opportunityId) { String accountId = contact.getAccountId(); String contactOrcid = contact.getOrcid(); if (StringUtils.isBlank(contact.getEmail())) { Email primaryEmail = emailManager.getEmails(contactOrcid).getEmails().stream().filter(e -> e.isPrimary()).findFirst().get(); contact.setEmail(primaryEmail.getEmail()); } List<Contact> existingContacts = salesForceDao.retrieveAllContactsByAccountId(accountId); Optional<Contact> existingContact = existingContacts.stream().filter(c -> { if ((contact.getOrcid() != null && contact.getOrcid().equals(c.getOrcid())) || (contact.getEmail() != null && contact.getEmail().equals(c.getEmail()))) { return true; } return false; }).findFirst(); String contactId = existingContact.isPresent() ? existingContact.get().getId() : salesForceDao.createContact(contact); OpportunityContactRole contactRole = new OpportunityContactRole(); contactRole.setContactId(contactId); contactRole.setRoleType(ContactRoleType.MAIN_CONTACT); contactRole.setOpportunityId(opportunityId); salesForceDao.createOpportunityContactRole(contactRole); addSalesForceConnection(accountId, contact); }
if (emails != null) { for (Email email : emails.getEmails()) { if (email.isVerified()) { verfiedEmail = true; if (email.isPrimary()) { verfiedPrimaryEmail = true; break;
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); } }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
@Override public String getQRCode(String orcid) { if (userUsing2FA(orcid)) { // don't allow generation of new code if user already using throw new UserAlreadyUsing2FAException(); } // generate secret but don't switch on using2FA - user may abort process String secret = Base32.random(); profileEntityManager.update2FASecret(orcid, encryptionManager.encryptForInternalUse(secret)); Email email = emailManagerReadOnly.findPrimaryEmail(orcid); try { return QR_PREFIX + URLEncoder.encode(String.format("otpauth://totp/%s:%s?secret=%s&issuer=%s", APP_NAME, email.getEmail(), secret, APP_NAME), "UTF-8"); } catch (UnsupportedEncodingException e) { LOG.error("Error generating QR code", e); return null; } }
@Override public void sendOrcidDeactivateEmail(String userOrcid) { ProfileEntity profile = profileEntityCacheManager.retrieve(userOrcid); Locale userLocale = getUserLocaleFromProfileEntity(profile); org.orcid.jaxb.model.record_v2.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); }
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());
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);
request.setSuccessMessage(localeManager.resolveMessage("admin.delegate.admin.success", primaryEmail.getEmail()));