Search in sources :

Example 41 with Emails

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

the class MemberV3ApiServiceDelegator_EmailsTest method testReadEmailPrivate.

@Test
public void testReadEmailPrivate() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.EMAIL_READ_PRIVATE);
    Response r = serviceDelegator.viewEmails("4444-4444-4444-4497");
    assertNotNull(r);
    assertEquals(Emails.class.getName(), r.getEntity().getClass().getName());
    Emails email = (Emails) r.getEntity();
    assertNotNull(email);
    assertEquals("/4444-4444-4444-4497/email", email.getPath());
    assertNotNull(email.getLastModifiedDate());
    assertEquals(3, email.getEmails().size());
    assertEquals("public_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(0).getEmail());
    assertEquals(Visibility.PUBLIC, email.getEmails().get(0).getVisibility());
    assertEquals("limited_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(1).getEmail());
    assertEquals(Visibility.LIMITED, email.getEmails().get(1).getVisibility());
    assertEquals("private_4444-4444-4444-4497@test.orcid.org", email.getEmails().get(2).getEmail());
    assertEquals(Visibility.PRIVATE, email.getEmails().get(2).getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 42 with Emails

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

the class PublicV3ApiServiceDelegatorTest method testViewEmails.

@Test
public void testViewEmails() {
    Response response = serviceDelegator.viewEmails(ORCID);
    assertNotNull(response);
    Emails emails = (Emails) response.getEntity();
    assertNotNull(emails);
    assertNotNull(emails.getLastModifiedDate());
    assertNotNull(emails.getLastModifiedDate().getValue());
    assertNotNull(emails.getEmails());
    assertEquals(1, emails.getEmails().size());
    Email email = emails.getEmails().get(0);
    assertNotNull(email.getLastModifiedDate());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
    assertTrue(email.isCurrent());
    assertTrue(email.isPrimary());
    assertTrue(email.isVerified());
    assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/email", emails.getPath());
    assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Email(org.orcid.jaxb.model.v3.dev1.record.Email) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 43 with Emails

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

the class PublicAPISecurityManagerV3Test method checkIsPublicRecordTest.

@Test
public void checkIsPublicRecordTest() {
    Record r = getRecordElement();
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - nothing filtered
    ActivitiesSummary as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - nothing filtered
    Person p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertAllArePublic(p.getAddresses().getAddress());
    assertEquals(3, p.getEmails().getEmails().size());
    assertAllArePublic(p.getEmails().getEmails());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertAllArePublic(p.getKeywords().getKeywords());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertAllArePublic(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter biography, name, educations and funding
    r = getRecordElement();
    r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
    r.getPerson().getName().setVisibility(Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - educations and funding filtered
    as = r.getActivitiesSummary();
    assertNotNull(as.getEducations());
    assertTrue(as.getEducations().getSummaries().isEmpty());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertTrue(as.getFundings().getFundingGroup().isEmpty());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - bio and name filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNull(p.getBiography());
    assertNull(p.getName());
    // Filter emails, external identifiers, peer reviews and works
    r = getRecordElement();
    setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - peer reviews and works filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
    assertTrue(as.getWorks().getWorkGroup().isEmpty());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - emails, external identifiers filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter keywords and other names
    r = getRecordElement();
    setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - nothing filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - keywords and other names filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
}
Also used : Record(org.orcid.jaxb.model.v3.dev1.record.Record) Person(org.orcid.jaxb.model.v3.dev1.record.Person) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Test(org.junit.Test)

Example 44 with Emails

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

the class PublicAPISecurityManagerV3Test method getEmailsElement.

private Emails getEmailsElement(Visibility... vs) {
    Emails elements = new Emails();
    for (Visibility v : vs) {
        Email element = new Email();
        element.setVisibility(v);
        if (elements.getEmails() == null) {
            elements.setEmails(new ArrayList<Email>());
        }
        elements.getEmails().add(element);
    }
    return elements;
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails)

Example 45 with Emails

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

the class PublicV3ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    Emails emails = emailManagerReadOnly.getPublicEmails(orcid);
    publicAPISecurityManagerV3.filter(emails);
    ElementUtils.setPathToEmail(emails, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtilsReadOnly.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : 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