use of org.orcid.jaxb.model.record_rc3.Emails in project ORCID-Source by ORCID.
the class ManageProfileController method validateDeprecateProfile.
@RequestMapping(value = "/validate-deprecate-profile.json", method = RequestMethod.POST)
@ResponseBody
public DeprecateProfile validateDeprecateProfile(@RequestBody DeprecateProfile deprecateProfile) {
validateFormData(deprecateProfile);
if (!deprecateProfile.getErrors().isEmpty()) {
return deprecateProfile;
}
String currentUserOrcid = getCurrentUserOrcid();
ProfileEntity primaryEntity = profileEntityCacheManager.retrieve(currentUserOrcid);
ProfileEntity deprecatingEntity = getDeprecatingEntity(deprecateProfile);
validateDeprecatingEntity(deprecatingEntity, primaryEntity, deprecateProfile);
if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
return deprecateProfile;
}
validateDeprecateAccountRequest(deprecateProfile, deprecatingEntity);
if (deprecateProfile.getErrors() != null && !deprecateProfile.getErrors().isEmpty()) {
return deprecateProfile;
}
Emails deprecatingEmails = emailManager.getEmails(deprecatingEntity.getId(), 0l);
Emails primaryEmails = emailManager.getEmails(primaryEntity.getId(), 0l);
String primaryAccountName = RecordNameUtils.getPublicName(primaryEntity.getRecordNameEntity());
String deprecatingAccountName = RecordNameUtils.getPublicName(deprecatingEntity.getRecordNameEntity());
deprecateProfile.setPrimaryAccountName(primaryAccountName);
deprecateProfile.setPrimaryOrcid(currentUserOrcid);
deprecateProfile.setDeprecatingAccountName(deprecatingAccountName);
deprecateProfile.setDeprecatingOrcid(deprecatingEntity.getId());
if (deprecatingEmails != null) {
deprecateProfile.setDeprecatingEmails(deprecatingEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
}
if (primaryEmails != null) {
deprecateProfile.setPrimaryEmails(primaryEmails.getEmails().stream().map(e -> e.getEmail()).collect(Collectors.toList()));
}
return deprecateProfile;
}
use of org.orcid.jaxb.model.record_rc3.Emails in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewEmails.
@Override
public Response viewEmails(String orcid) {
Emails emails = null;
long lastModified = getLastModifiedTime(orcid);
try {
// return all emails if client has /email/read-private scope
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE);
emails = emailManagerReadOnly.getEmails(orcid, lastModified);
// Lets copy the list so we don't modify the cached collection
List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
emails = new Emails();
emails.setEmails(filteredList);
} catch (OrcidAccessControlException e) {
emails = emailManagerReadOnly.getEmails(orcid, lastModified);
// Lets copy the list so we don't modify the cached collection
List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
emails = new Emails();
emails.setEmails(filteredList);
// Filter just in case client doesn't have the /email/read-private
// scope
orcidSecurityManager.checkAndFilter(orcid, emails.getEmails(), ScopePathType.ORCID_BIO_READ_LIMITED);
}
ElementUtils.setPathToEmail(emails, orcid);
Api2_0_LastModifiedDatesHelper.calculateLastModified(emails);
sourceUtils.setSourceName(emails);
return Response.ok(emails).build();
}
use of org.orcid.jaxb.model.record_rc3.Emails in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testMarshallEmails.
@Test
public void testMarshallEmails() throws JAXBException, SAXException, URISyntaxException {
Emails object = (Emails) unmarshallFromPath("/record_2.0_rc2/samples/emails-2.0_rc2.xml", Emails.class);
marshall(object, "/record_2.0_rc2/email-2.0_rc2.xsd");
}
use of org.orcid.jaxb.model.record_rc3.Emails in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testMarshallEmails.
@Test
public void testMarshallEmails() throws JAXBException, SAXException, URISyntaxException {
Emails object = (Emails) unmarshallFromPath("/record_2.1/samples/read_samples/emails-2.1.xml", Emails.class);
marshall(object, "/record_2.1/email-2.1.xsd");
}
use of org.orcid.jaxb.model.record_rc3.Emails 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;
}
Aggregations