use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method updateExternalIdentifier.
@Override
public Response updateExternalIdentifier(String orcid, Long putCode, PersonExternalIdentifier externalIdentifier) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_BIO_EXTERNAL_IDENTIFIERS_CREATE);
if (!putCode.equals(externalIdentifier.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(externalIdentifier.getPutCode()));
throw new MismatchedPutCodeException(params);
}
clearSource(externalIdentifier);
PersonExternalIdentifier extId = externalIdentifierManager.updateExternalIdentifier(orcid, externalIdentifier, true);
ElementUtils.setPathToExternalIdentifier(extId, orcid);
sourceUtils.setSourceName(extId);
return Response.ok(extId).build();
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExaternalIdentifierYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateExaternalIdentifierYouAreNotTheSourceOf() {
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());
extId.setType("other-common-name");
extId.setValue("other-reference");
extId.setUrl(new Url("http://otherUrl.com"));
serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 3L, extId);
fail();
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PersonDetailsManagerReadOnlyImpl method getPublicPersonDetails.
@Override
public Person getPublicPersonDetails(String orcid) {
long lastModifiedTime = getLastModified(orcid);
Person person = new Person();
Name name = recordNameManager.getRecordName(orcid, lastModifiedTime);
if (Visibility.PUBLIC.equals(name.getVisibility())) {
person.setName(name);
}
Biography bio = biographyManager.getPublicBiography(orcid, lastModifiedTime);
if (bio != null) {
person.setBiography(bio);
}
Addresses addresses = addressManager.getPublicAddresses(orcid, lastModifiedTime);
if (addresses.getAddress() != null) {
Addresses filteredAddresses = new Addresses();
filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
person.setAddresses(filteredAddresses);
}
PersonExternalIdentifiers extIds = externalIdentifierManager.getPublicExternalIdentifiers(orcid, lastModifiedTime);
if (extIds.getExternalIdentifiers() != null) {
PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
person.setExternalIdentifiers(filteredExtIds);
}
Keywords keywords = profileKeywordManager.getPublicKeywords(orcid, lastModifiedTime);
if (keywords.getKeywords() != null) {
Keywords filteredKeywords = new Keywords();
filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
person.setKeywords(filteredKeywords);
}
OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid, lastModifiedTime);
if (otherNames.getOtherNames() != null) {
OtherNames filteredOtherNames = new OtherNames();
filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
person.setOtherNames(filteredOtherNames);
}
ResearcherUrls rUrls = researcherUrlManager.getPublicResearcherUrls(orcid, lastModifiedTime);
if (rUrls.getResearcherUrls() != null) {
ResearcherUrls filteredRUrls = new ResearcherUrls();
filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
person.setResearcherUrls(filteredRUrls);
}
Emails emails = emailManager.getPublicEmails(orcid, lastModifiedTime);
if (emails.getEmails() != null) {
Emails filteredEmails = new Emails();
filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
person.setEmails(filteredEmails);
}
return person;
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createPersonExternalIdentifier.
protected PersonExternalIdentifier createPersonExternalIdentifier(Visibility v, String sourceId) {
PersonExternalIdentifier p = new PersonExternalIdentifier();
p.setValue("ext-id-" + System.currentTimeMillis());
p.setVisibility(v);
setSource(p, sourceId);
return p;
}
Aggregations