use of org.orcid.jaxb.model.v3.dev1.record.Name 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);
if (Visibility.PUBLIC.equals(name.getVisibility())) {
person.setName(name);
}
Biography bio = biographyManager.getPublicBiography(orcid);
if (bio != null) {
person.setBiography(bio);
}
Addresses addresses = addressManager.getPublicAddresses(orcid);
if (addresses.getAddress() != null) {
Addresses filteredAddresses = new Addresses();
filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
person.setAddresses(filteredAddresses);
}
PersonExternalIdentifiers extIds = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
if (extIds.getExternalIdentifiers() != null) {
PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
person.setExternalIdentifiers(filteredExtIds);
}
Keywords keywords = profileKeywordManager.getPublicKeywords(orcid);
if (keywords.getKeywords() != null) {
Keywords filteredKeywords = new Keywords();
filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
person.setKeywords(filteredKeywords);
}
OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid);
if (otherNames.getOtherNames() != null) {
OtherNames filteredOtherNames = new OtherNames();
filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
person.setOtherNames(filteredOtherNames);
}
ResearcherUrls rUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
if (rUrls.getResearcherUrls() != null) {
ResearcherUrls filteredRUrls = new ResearcherUrls();
filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
person.setResearcherUrls(filteredRUrls);
}
Emails emails = emailManager.getPublicEmails(orcid);
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.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class PersonalDetailsManagerReadOnlyImpl method getPublicPersonalDetails.
@Override
public PersonalDetails getPublicPersonalDetails(String orcid) {
Date lastModified = getLastModifiedDate(orcid);
PersonalDetails personalDetails = new PersonalDetails();
Biography bio = biographyManager.getPublicBiography(orcid);
if (bio != null) {
personalDetails.setBiography(bio);
}
Name name = recordNameManager.getRecordName(orcid);
if (name != null && !Visibility.PUBLIC.equals(name.getVisibility())) {
personalDetails.setName(null);
} else {
personalDetails.setName(name);
}
OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid);
OtherNames filteredOtherNames = new OtherNames();
personalDetails.setOtherNames(filteredOtherNames);
if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
// Lets copy the list so we don't modify the cached collection
List<OtherName> filteredList = new ArrayList<OtherName>(otherNames.getOtherNames());
filteredOtherNames.setOtherNames(filteredList);
}
if (personalDetails.getLastModifiedDate() == null || personalDetails.getLastModifiedDate().getValue() == null) {
personalDetails.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified)));
}
return personalDetails;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class PersonalDetailsManagerReadOnlyImpl method getPersonalDetails.
@Override
public PersonalDetails getPersonalDetails(String orcid) {
Date lastModified = getLastModifiedDate(orcid);
PersonalDetails personalDetails = new PersonalDetails();
Name name = recordNameManager.getRecordName(orcid);
if (name != null) {
personalDetails.setName(name);
}
Biography bio = biographyManager.getBiography(orcid);
if (bio != null) {
personalDetails.setBiography(bio);
}
OtherNames otherNames = otherNameManager.getOtherNames(orcid);
OtherNames filteredOtherNames = new OtherNames();
personalDetails.setOtherNames(filteredOtherNames);
if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
// Lets copy the list so we don't modify the cached collection
List<OtherName> filteredList = new ArrayList<OtherName>(otherNames.getOtherNames());
filteredOtherNames.setOtherNames(filteredList);
}
if (personalDetails.getLastModifiedDate() == null || personalDetails.getLastModifiedDate().getValue() == null) {
personalDetails.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified)));
}
return personalDetails;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class MemberV3Dev1Test method createViewUpdateAndDeleteEmployment.
@Test
public void createViewUpdateAndDeleteEmployment() throws JSONException, InterruptedException, URISyntaxException {
Employment employment = (Employment) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/employment-3.0_dev1.xml", Employment.class);
employment.setPutCode(null);
employment.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV3Dev1ApiClientImpl.createEmploymentXml(this.getUser1OrcidId(), employment, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/employment/\\d+"));
ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Employment gotEmployment = getResponse.getEntity(Employment.class);
assertEquals("department-name", gotEmployment.getDepartmentName());
assertEquals("role-title", gotEmployment.getRoleTitle());
// Save the original visibility
Visibility originalVisibility = gotEmployment.getVisibility();
Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
// Verify you cant update the visibility
gotEmployment.setVisibility(updatedVisibility);
ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), accessToken, gotEmployment);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
OrcidError error = putResponse.getEntity(OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9035), error.getErrorCode());
// Set the visibility again to the initial one
gotEmployment.setVisibility(originalVisibility);
gotEmployment.setDepartmentName("updated dept. name");
gotEmployment.setRoleTitle("updated role title");
putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), accessToken, gotEmployment);
assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Employment gotAfterUpdateEmployment = getAfterUpdateResponse.getEntity(Employment.class);
assertEquals("updated dept. name", gotAfterUpdateEmployment.getDepartmentName());
assertEquals("updated role title", gotAfterUpdateEmployment.getRoleTitle());
ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteEmploymentXml(this.getUser1OrcidId(), gotEmployment.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class MemberV3Dev1Test method testUpdateEmploymentWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdateEmploymentWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
Employment employment = (Employment) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/employment-3.0_dev1.xml", Employment.class);
employment.setPutCode(null);
employment.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV3Dev1ApiClientImpl.createEmploymentXml(this.getUser1OrcidId(), employment, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/employment/\\d+"));
ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Employment gotEmployment = getResponse.getEntity(Employment.class);
assertEquals("department-name", gotEmployment.getDepartmentName());
assertEquals("role-title", gotEmployment.getRoleTitle());
gotEmployment.setDepartmentName("updated dept. name");
gotEmployment.setRoleTitle("updated role title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEmployment);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Employment gotAfterUpdateEmployment = getAfterUpdateResponse.getEntity(Employment.class);
assertEquals("department-name", gotAfterUpdateEmployment.getDepartmentName());
assertEquals("role-title", gotAfterUpdateEmployment.getRoleTitle());
ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteEmploymentXml(this.getUser1OrcidId(), gotEmployment.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations