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();
}
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());
}
}
}
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());
}
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");
}
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());
}
}
}
Aggregations