Search in sources :

Example 26 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class EmailManagerTest method verifySetCurrentAndPrimaryTest.

@Test
public void verifySetCurrentAndPrimaryTest() {
    String email = "public_0000-0000-0000-0004@test.orcid.org";
    String orcid = "0000-0000-0000-0004";
    Emails emails = emailManager.getEmails(orcid);
    Email element = null;
    for (Email e : emails.getEmails()) {
        if (email.equals(e.getEmail())) {
            element = e;
            break;
        }
    }
    assertNotNull(element);
    assertFalse(element.isCurrent());
    assertFalse(element.isPrimary());
    assertFalse(element.isVerified());
    emailManager.verifySetCurrentAndPrimary(orcid, email);
    emails = emailManager.getEmails(orcid);
    element = null;
    for (Email e : emails.getEmails()) {
        if (email.equals(e.getEmail())) {
            element = e;
            break;
        }
    }
    assertNotNull(element);
    assertTrue(element.isCurrent());
    assertTrue(element.isPrimary());
    assertTrue(element.isVerified());
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 27 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class NotificationManagerImpl method sendAcknowledgeMessage.

@Override
public void sendAcknowledgeMessage(String userOrcid, String clientId) throws UnsupportedEncodingException {
    ProfileEntity profileEntity = profileEntityCacheManager.retrieve(userOrcid);
    ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
    Locale userLocale = (profileEntity.getLocale() == null || profileEntity.getLocale().value() == null) ? Locale.ENGLISH : LocaleUtils.toLocale(profileEntity.getLocale().value());
    String subject = getSubject("email.subject.institutional_sign_in", userLocale);
    String authorizationUrl = buildAuthorizationUrlForInstitutionalSignIn(clientDetails);
    // Create map of template params
    Map<String, Object> templateParams = new HashMap<String, Object>();
    templateParams.put("emailName", deriveEmailFriendlyName(profileEntity));
    templateParams.put("orcid", userOrcid);
    templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
    templateParams.put("subject", subject);
    templateParams.put("clientName", clientDetails.getClientName());
    templateParams.put("authorization_url", authorizationUrl);
    addMessageParams(templateParams, userLocale);
    // Generate body from template
    String body = templateManager.processTemplate("authenticate_request_email.ftl", templateParams);
    // Generate html from template
    String html = templateManager.processTemplate("authenticate_request_email_html.ftl", templateParams);
    boolean notificationsEnabled = profileEntity.getEnableNotifications();
    if (notificationsEnabled) {
        NotificationInstitutionalConnection notification = new NotificationInstitutionalConnection();
        notification.setNotificationType(NotificationType.INSTITUTIONAL_CONNECTION);
        notification.setAuthorizationUrl(new AuthorizationUrl(authorizationUrl));
        NotificationInstitutionalConnectionEntity notificationEntity = (NotificationInstitutionalConnectionEntity) notificationAdapter.toNotificationEntity(notification);
        notificationEntity.setProfile(new ProfileEntity(userOrcid));
        notificationEntity.setClientSourceId(clientId);
        notificationEntity.setAuthenticationProviderId(clientDetails.getAuthenticationProviderId());
        notificationDao.persist(notificationEntity);
    } else {
        Emails emails = emailManager.getEmails(userOrcid);
        String primaryEmail = null;
        if (emails == null || emails.getEmails() == null) {
            throw new IllegalArgumentException("Unable to find primary email for: " + userOrcid);
        }
        for (org.orcid.jaxb.model.v3.dev1.record.Email email : emails.getEmails()) {
            if (email.isPrimary()) {
                primaryEmail = email.getEmail();
            }
        }
        mailGunManager.sendEmail(UPDATE_NOTIFY_ORCID_ORG, primaryEmail, subject, body, html);
    }
}
Also used : Locale(java.util.Locale) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) NotificationInstitutionalConnection(org.orcid.model.v3.dev1.notification.institutional_sign_in.NotificationInstitutionalConnection) HashMap(java.util.HashMap) NotificationInstitutionalConnectionEntity(org.orcid.persistence.jpa.entities.NotificationInstitutionalConnectionEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) AuthorizationUrl(org.orcid.jaxb.model.v3.dev1.notification.permission.AuthorizationUrl) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails)

Example 28 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testMarshallEmails.

@Test
public void testMarshallEmails() throws JAXBException, SAXException, URISyntaxException {
    Emails object = (Emails) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/emails-3.0_dev1.xml", Emails.class);
    marshall(object, "/record_3.0_dev1/email-3.0_dev1.xsd");
}
Also used : Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Test(org.junit.Test)

Example 29 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testUnmarshallEmails.

@Test
public void testUnmarshallEmails() throws SAXException, URISyntaxException {
    Emails emails = (Emails) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/emails-3.0_dev1.xml", Emails.class, "/record_3.0_dev1/email-3.0_dev1.xsd");
    assertNotNull(emails);
    assertNotNull(emails.getEmails());
    assertEquals(2, emails.getEmails().size());
    for (Email email : emails.getEmails()) {
        assertNotNull(email.getPutCode());
        assertNotNull(email.getCreatedDate());
        assertNotNull(email.getLastModifiedDate());
        if (email.getPutCode().equals(Long.valueOf(1))) {
            assertEquals(Visibility.PUBLIC, email.getVisibility());
            assertEquals("user1@email.com", email.getEmail());
        } else {
            assertEquals(Visibility.PUBLIC, email.getVisibility());
            assertEquals("user2@email.com", email.getEmail());
        }
    }
    Email email = (Email) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/email-3.0_dev1.xml", Email.class);
    assertNotNull(email);
    assertNotNull(email.getPutCode());
    assertNotNull(email.getCreatedDate());
    assertNotNull(email.getLastModifiedDate());
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertEquals("user1@email.com", email.getEmail());
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Test(org.junit.Test)

Example 30 with Emails

use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.

the class SourceUtils method setSourceName.

public void setSourceName(Person person) {
    if (person == null) {
        return;
    }
    if (person.getAddresses() != null) {
        Addresses addresses = person.getAddresses();
        setSourceName(addresses);
    }
    if (person.getEmails() != null) {
        Emails emails = person.getEmails();
        setSourceName(emails);
    }
    if (person.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers extIds = person.getExternalIdentifiers();
        setSourceName(extIds);
    }
    if (person.getKeywords() != null) {
        Keywords keywords = person.getKeywords();
        setSourceName(keywords);
    }
    if (person.getOtherNames() != null) {
        OtherNames otherNames = person.getOtherNames();
        setSourceName(otherNames);
    }
    if (person.getResearcherUrls() != null) {
        ResearcherUrls researcherUrls = person.getResearcherUrls();
        setSourceName(researcherUrls);
    }
}
Also used : Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails)

Aggregations

Email (org.orcid.jaxb.model.v3.dev1.record.Email)59 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)56 Test (org.junit.Test)54 Address (org.orcid.jaxb.model.v3.dev1.record.Address)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)32 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)32 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)32 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)32 Person (org.orcid.jaxb.model.v3.dev1.record.Person)32 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)32 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)32 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)31 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)31 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 ArrayList (java.util.ArrayList)13 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13