Search in sources :

Example 1 with PersonExternalIdentifiers

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

the class MemberV3ApiServiceDelegatorImpl method viewExternalIdentifiers.

@Override
public Response viewExternalIdentifiers(String orcid) {
    PersonExternalIdentifiers extIds = externalIdentifierManagerReadOnly.getExternalIdentifiers(orcid);
    // Lets copy the list so we don't modify the cached collection
    if (extIds.getExternalIdentifiers() != null) {
        List<PersonExternalIdentifier> filteredList = new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers());
        extIds = new PersonExternalIdentifiers();
        extIds.setExternalIdentifiers(filteredList);
    }
    orcidSecurityManager.checkAndFilter(orcid, extIds.getExternalIdentifiers(), ScopePathType.ORCID_BIO_READ_LIMITED);
    ElementUtils.setPathToExternalIdentifiers(extIds, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(extIds);
    sourceUtils.setSourceName(extIds);
    return Response.ok(extIds).build();
}
Also used : PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) ArrayList(java.util.ArrayList) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)

Example 2 with PersonExternalIdentifiers

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testAddExternalIdentifier.

@Test
public void testAddExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4443");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(1, extIds.getExternalIdentifiers().size());
    assertEquals(Long.valueOf(1), extIds.getExternalIdentifiers().get(0).getPutCode());
    assertNotNull(extIds.getExternalIdentifiers().get(0).getUrl());
    assertEquals("http://www.facebook.com/d3clan", extIds.getExternalIdentifiers().get(0).getUrl().getValue());
    assertEquals("d3clan", extIds.getExternalIdentifiers().get(0).getValue());
    assertEquals(Visibility.PUBLIC, extIds.getExternalIdentifiers().get(0).getVisibility());
    response = serviceDelegator.createExternalIdentifier("4444-4444-4444-4443", Utils.getPersonExternalIdentifier());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4443");
    assertNotNull(response);
    extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(2, extIds.getExternalIdentifiers().size());
    for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
        Utils.verifyLastModified(extId.getLastModifiedDate());
        assertNotNull(extId.getUrl());
        if (extId.getPutCode() != 1L) {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("new-common-name", extId.getType());
            assertEquals("new-reference", extId.getValue());
            assertEquals("http://newUrl.com", extId.getUrl().getValue());
            assertEquals(putCode, extId.getPutCode());
        } else {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("Facebook", extId.getType());
            assertEquals("d3clan", extId.getValue());
            assertEquals("http://www.facebook.com/d3clan", extId.getUrl().getValue());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) List(java.util.List) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with PersonExternalIdentifiers

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testDeleteExternalIdentifier.

@Test
public void testDeleteExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4444");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertEquals(1, extIds.getExternalIdentifiers().size());
    assertEquals(Long.valueOf(6), extIds.getExternalIdentifiers().get(0).getPutCode());
    response = serviceDelegator.deleteExternalIdentifier("4444-4444-4444-4444", 6L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4444");
    assertNotNull(response);
    extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertNotNull(extIds.getExternalIdentifiers());
    assertTrue(extIds.getExternalIdentifiers().isEmpty());
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with PersonExternalIdentifiers

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testViewExternalIdentifiersReadPublic.

@Test
public void testViewExternalIdentifiersReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewExternalIdentifiers(ORCID);
    PersonExternalIdentifiers element = (PersonExternalIdentifiers) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/external-identifiers", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with PersonExternalIdentifiers

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testViewExternalIdentifiers.

@Test
public void testViewExternalIdentifiers() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4442");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertEquals("/4444-4444-4444-4442/external-identifiers", extIds.getPath());
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    List<PersonExternalIdentifier> extIdsList = extIds.getExternalIdentifiers();
    assertNotNull(extIdsList);
    assertEquals(3, extIdsList.size());
    for (PersonExternalIdentifier extId : extIdsList) {
        Utils.verifyLastModified(extId.getLastModifiedDate());
        assertThat(extId.getPutCode(), anyOf(is(2L), is(3L), is(5L)));
        assertThat(extId.getValue(), anyOf(is("abc123"), is("abc456"), is("abc012")));
        assertNotNull(extId.getUrl());
        assertThat(extId.getUrl().getValue(), anyOf(is("http://www.facebook.com/abc123"), is("http://www.facebook.com/abc456"), is("http://www.facebook.com/abc012")));
        assertEquals("Facebook", extId.getType());
        assertNotNull(extId.getSource());
        if (extId.getPutCode().equals(2L)) {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
        } else if (extId.getPutCode().equals(3L)) {
            assertEquals(Visibility.LIMITED, extId.getVisibility());
            assertEquals("4444-4444-4444-4442", extId.getSource().retrieveSourcePath());
        } else {
            assertEquals(Visibility.PRIVATE, extId.getVisibility());
            assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)50 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)43 Test (org.junit.Test)36 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)34 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)33 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)33 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)32 Address (org.orcid.jaxb.model.v3.dev1.record.Address)31 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)31 Email (org.orcid.jaxb.model.v3.dev1.record.Email)30 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)30 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)30 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)30 Name (org.orcid.jaxb.model.v3.dev1.record.Name)26 Person (org.orcid.jaxb.model.v3.dev1.record.Person)25 Record (org.orcid.jaxb.model.v3.dev1.record.Record)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)13