Search in sources :

Example 31 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallEmails.

@Test
public void testUnmarshallEmails() throws SAXException, URISyntaxException {
    Emails emails = (Emails) unmarshallFromPath("/record_2.0/samples/read_samples/emails-2.0.xml", Emails.class, "/record_2.0/email-2.0.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_2.0/samples/read_samples/email-2.0.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.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails) Test(org.junit.Test)

Example 32 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class OrcidSecurityManagerImpl method checkAndFilter.

private void checkAndFilter(String orcid, Collection<? extends VisibilityType> elements, ScopePathType requiredScope, boolean tokenAlreadyChecked) {
    if (elements == null) {
        return;
    }
    // Check the token
    if (!tokenAlreadyChecked) {
        isMyToken(orcid);
    }
    Iterator<? extends VisibilityType> it = elements.iterator();
    while (it.hasNext()) {
        VisibilityType element = it.next();
        try {
            if (element instanceof Email) {
                Email email = (Email) element;
                checkAndFilter(orcid, email, requiredScope, true);
            } else {
                checkAndFilter(orcid, element, requiredScope, true);
            }
        } catch (Exception e) {
            it.remove();
        }
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) VisibilityType(org.orcid.jaxb.model.common_v2.VisibilityType) NoResultException(javax.persistence.NoResultException) OrcidNotClaimedException(org.orcid.core.exception.OrcidNotClaimedException) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) WrongSourceException(org.orcid.core.exception.WrongSourceException) LockedException(org.orcid.core.security.aop.LockedException) AccessControlException(java.security.AccessControlException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException)

Example 33 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(Emails emails) {
    Date latestAct = null;
    if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
        XMLGregorianCalendar latest = emails.getEmails().get(0).getLastModifiedDate().getValue();
        for (Email email : emails.getEmails()) {
            if (latest.compare(email.getLastModifiedDate().getValue()) == -1) {
                latest = email.getLastModifiedDate().getValue();
            }
        }
        latestAct = latest.toGregorianCalendar().getTime();
        emails.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Email(org.orcid.jaxb.model.record_rc2.Email) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 34 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class Api2_0_LastModifiedDatesHelper method calculateLastModified.

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email)

Example 35 with Email

use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.

the class NotificationManagerTest method testSendDeactivateEmail.

@Test
public void testSendDeactivateEmail() throws JAXBException, IOException, URISyntaxException {
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
    TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
    final String orcid = "0000-0000-0000-0003";
    ProfileEntity profile = new ProfileEntity(orcid);
    RecordNameEntity recordName = new RecordNameEntity();
    recordName.setCreditName("My credit name");
    recordName.setVisibility(Visibility.PUBLIC);
    profile.setRecordNameEntity(recordName);
    Email email = new Email();
    email.setEmail("test@email.com");
    when(mockProfileEntityCacheManager.retrieve(orcid)).thenReturn(profile);
    when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
    for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
        profile.setLocale(locale);
        notificationManager.sendOrcidDeactivateEmail(orcid);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.record_v2.Email)82 Test (org.junit.Test)78 Emails (org.orcid.jaxb.model.record_v2.Emails)49 Address (org.orcid.jaxb.model.record_v2.Address)41 Keyword (org.orcid.jaxb.model.record_v2.Keyword)41 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)41 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)41 OtherName (org.orcid.jaxb.model.record_v2.OtherName)39 Person (org.orcid.jaxb.model.record_v2.Person)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)30 Record (org.orcid.jaxb.model.record_v2.Record)19 ArrayList (java.util.ArrayList)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18