Search in sources :

Example 1 with PersonExternalIdentifier

use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier 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 PersonExternalIdentifier

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testViewPublicExternalIdentifier.

@Test
public void testViewPublicExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    assertEquals("/4444-4444-4444-4442/external-identifiers/2", extId.getPath());
    Utils.verifyLastModified(extId.getLastModifiedDate());
    assertEquals("Facebook", extId.getType());
    assertEquals(Long.valueOf(2), extId.getPutCode());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertNotNull(extId.getSource());
    assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
    assertNotNull(extId.getCreatedDate());
    Utils.verifyLastModified(extId.getLastModifiedDate());
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with PersonExternalIdentifier

use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier 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 4 with PersonExternalIdentifier

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExternalIdentifier.

@Test
public void testUpdateExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    Utils.verifyLastModified(extId.getLastModifiedDate());
    LastModifiedDate before = extId.getLastModifiedDate();
    assertEquals("Facebook", extId.getType());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    extId.setType("updated-common-name");
    extId.setValue("updated-reference");
    extId.setUrl(new Url("http://updatedUrl.com"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier updatedExtId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(updatedExtId);
    Utils.verifyLastModified(updatedExtId.getLastModifiedDate());
    assertTrue(updatedExtId.getLastModifiedDate().after(before));
    assertEquals("updated-common-name", updatedExtId.getType());
    assertEquals("updated-reference", updatedExtId.getValue());
    assertNotNull(updatedExtId.getUrl());
    assertEquals("http://updatedUrl.com", updatedExtId.getUrl().getValue());
    // Revert changes so other tests still works
    extId.setType("Facebook");
    extId.setValue("abc123");
    extId.setUrl(new Url("http://www.facebook.com/abc123"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with PersonExternalIdentifier

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

the class MemberV3ApiServiceDelegator_ExternalIdentifiersTest method testDeleteExternalIdentifierYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testDeleteExternalIdentifierYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 3L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    assertEquals("Facebook", extId.getType());
    assertEquals("abc456", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc456", extId.getUrl().getValue());
    serviceDelegator.deleteExternalIdentifier("4444-4444-4444-4442", 3L);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)93 Test (org.junit.Test)68 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)42 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)40 Address (org.orcid.jaxb.model.v3.dev1.record.Address)39 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)39 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)38 Email (org.orcid.jaxb.model.v3.dev1.record.Email)36 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)31 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)31 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)30 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)30 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)30 Person (org.orcid.jaxb.model.v3.dev1.record.Person)28 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)19 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15