Search in sources :

Example 51 with OtherName

use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.

the class Api2_0_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(OtherNames otherNames) {
    if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
        LastModifiedDate latest = null;
        for (OtherName otherName : otherNames.getOtherNames()) {
            if (otherName.getLastModifiedDate() != null && otherName.getLastModifiedDate().after(latest)) {
                latest = otherName.getLastModifiedDate();
            }
        }
        otherNames.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) OtherName(org.orcid.jaxb.model.record_v2.OtherName)

Example 52 with OtherName

use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testCollection_When_SourceOfLimitedAndPrivate_ReadPublicScope.

@Test
public void testCollection_When_SourceOfLimitedAndPrivate_ReadPublicScope() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    List<OtherName> list = new ArrayList<OtherName>();
    OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_1);
    OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
    list.add(o1);
    list.add(o2);
    list.add(o3);
    orcidSecurityManager.checkAndFilter(ORCID_1, list, ScopePathType.ORCID_BIO_READ_LIMITED);
    assertEquals(3, list.size());
    assertTrue(list.contains(o1));
    assertTrue(list.contains(o2));
    assertTrue(list.contains(o3));
}
Also used : ArrayList(java.util.ArrayList) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Test(org.junit.Test)

Example 53 with OtherName

use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_SomePrivate_ReadPublicToken.

@Test
public void testPersonalDetails_When_SomePrivate_ReadPublicToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    Name name = createName(Visibility.PUBLIC);
    Biography bio = createBiography(Visibility.PRIVATE);
    OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertEquals(name, p.getName());
    assertNull(p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertEquals(1, p.getOtherNames().getOtherNames().size());
    assertFalse(p.getOtherNames().getOtherNames().contains(o1));
    assertFalse(p.getOtherNames().getOtherNames().contains(o2));
    assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 54 with OtherName

use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testCollection_When_SourceOfPrivate_ReadPublicScope.

@Test
public void testCollection_When_SourceOfPrivate_ReadPublicScope() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    List<OtherName> list = new ArrayList<OtherName>();
    OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
    list.add(o1);
    list.add(o2);
    list.add(o3);
    orcidSecurityManager.checkAndFilter(ORCID_1, list, ScopePathType.ORCID_BIO_READ_LIMITED);
    assertEquals(2, list.size());
    assertTrue(list.contains(o1));
    assertFalse(list.contains(o2));
    assertTrue(list.contains(o3));
}
Also used : ArrayList(java.util.ArrayList) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Test(org.junit.Test)

Example 55 with OtherName

use of org.apache.harmony.security.x509.OtherName in project ORCID-Source by ORCID.

the class OrcidSecurityManager_generalTest method testPersonalDetails_When_SomeLimited_NoSource_ReadLimitedToken.

@Test
public void testPersonalDetails_When_SomeLimited_NoSource_ReadLimitedToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
    Name name = createName(Visibility.LIMITED);
    Biography bio = createBiography(Visibility.LIMITED);
    OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
    OtherName o2 = createOtherName(Visibility.LIMITED, CLIENT_2);
    OtherName o3 = createOtherName(Visibility.LIMITED, CLIENT_2);
    OtherNames otherNames = new OtherNames();
    otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
    PersonalDetails p = new PersonalDetails();
    p.setBiography(bio);
    p.setName(name);
    p.setOtherNames(otherNames);
    orcidSecurityManager.checkAndFilter(ORCID_1, p);
    assertNotNull(p);
    assertEquals(name, p.getName());
    assertEquals(bio, p.getBiography());
    assertNotNull(p.getOtherNames());
    assertNotNull(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertTrue(p.getOtherNames().getOtherNames().contains(o1));
    assertTrue(p.getOtherNames().getOtherNames().contains(o2));
    assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Aggregations

OtherName (org.orcid.jaxb.model.record_v2.OtherName)114 Test (org.junit.Test)99 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)55 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)45 Biography (org.orcid.jaxb.model.record_v2.Biography)44 Address (org.orcid.jaxb.model.record_v2.Address)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 Name (org.orcid.jaxb.model.record_v2.Name)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)39 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Person (org.orcid.jaxb.model.record_v2.Person)30 ArrayList (java.util.ArrayList)23 DBUnitTest (org.orcid.test.DBUnitTest)22 Response (javax.ws.rs.core.Response)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18