use of org.orcid.jaxb.model.record_rc2.Email in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallPerson.
@Test
public void testUnmarshallPerson() throws SAXException, URISyntaxException {
Person person = (Person) unmarshallFromPath("/record_2.1/samples/read_samples/person-2.1.xml", Person.class, "/record_2.1/person-2.1.xsd");
assertNotNull(person);
assertNotNull(person.getName());
assertEquals("give-names", person.getName().getGivenNames().getContent());
assertEquals("family-name", person.getName().getFamilyName().getContent());
assertEquals("credit-name", person.getName().getCreditName().getContent());
assertEquals(Visibility.PUBLIC, person.getName().getVisibility());
assertNotNull(person.getOtherNames());
assertNotNull(person.getOtherNames().getOtherNames());
assertEquals(1, person.getOtherNames().getOtherNames().size());
OtherName otherName = person.getOtherNames().getOtherNames().get(0);
assertEquals("other-name-1", otherName.getContent());
assertNotNull(otherName.getCreatedDate());
assertNotNull(otherName.getCreatedDate().getValue());
assertEquals(2001, otherName.getCreatedDate().getValue().getYear());
assertEquals(12, otherName.getCreatedDate().getValue().getMonth());
assertEquals(31, otherName.getCreatedDate().getValue().getDay());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals(2001, otherName.getLastModifiedDate().getValue().getYear());
assertEquals(12, otherName.getLastModifiedDate().getValue().getMonth());
assertEquals(31, otherName.getLastModifiedDate().getValue().getDay());
assertNotNull(otherName.getSource());
validateSourceInHttps(otherName.getSource());
assertEquals("8888-8888-8888-8880", otherName.getSource().retrieveSourcePath());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
assertEquals("biography", person.getBiography().getContent());
assertNotNull(person.getResearcherUrls());
assertNotNull(person.getResearcherUrls().getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
assertEquals(Long.valueOf(1248), rUrl.getPutCode());
assertEquals("url-name-1", rUrl.getUrlName());
assertNotNull(rUrl.getUrl());
assertEquals("http://url.com/", rUrl.getUrl().getValue());
assertNotNull(rUrl.getCreatedDate());
assertEquals(2001, rUrl.getCreatedDate().getValue().getYear());
assertEquals(12, rUrl.getCreatedDate().getValue().getMonth());
assertEquals(31, rUrl.getCreatedDate().getValue().getDay());
assertNotNull(rUrl.getLastModifiedDate());
assertEquals(2001, rUrl.getLastModifiedDate().getValue().getYear());
assertEquals(12, rUrl.getLastModifiedDate().getValue().getMonth());
assertEquals(31, rUrl.getLastModifiedDate().getValue().getDay());
assertNotNull(rUrl.getSource());
validateSourceInHttps(rUrl.getSource());
assertEquals("8888-8888-8888-8880", rUrl.getSource().retrieveSourcePath());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getEmails());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertEquals("user1@email.com", email.getEmail());
assertNotNull(email.getCreatedDate());
assertNotNull(email.getCreatedDate().getValue());
assertEquals(2001, email.getCreatedDate().getValue().getYear());
assertEquals(12, email.getCreatedDate().getValue().getMonth());
assertEquals(31, email.getCreatedDate().getValue().getDay());
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals(2001, email.getLastModifiedDate().getValue().getYear());
assertEquals(12, email.getLastModifiedDate().getValue().getMonth());
assertEquals(31, email.getLastModifiedDate().getValue().getDay());
assertNotNull(email.getSource());
validateSourceInHttps(email.getSource());
assertEquals("8888-8888-8888-8880", email.retrieveSourcePath());
assertNotNull(person.getAddresses());
assertNotNull(person.getAddresses().getAddress());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Visibility.PUBLIC, address.getVisibility());
assertEquals(Long.valueOf(1), address.getPutCode());
assertNotNull(address.getCountry());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertNotNull(address.getCreatedDate());
assertNotNull(address.getCreatedDate().getValue());
assertEquals(2001, address.getCreatedDate().getValue().getYear());
assertEquals(12, address.getCreatedDate().getValue().getMonth());
assertEquals(31, address.getCreatedDate().getValue().getDay());
assertNotNull(address.getLastModifiedDate());
assertNotNull(address.getLastModifiedDate().getValue());
assertEquals(2001, address.getLastModifiedDate().getValue().getYear());
assertEquals(12, address.getLastModifiedDate().getValue().getMonth());
assertEquals(31, address.getLastModifiedDate().getValue().getDay());
assertNotNull(address.getSource());
validateSourceInHttps(address.getSource());
assertEquals("8888-8888-8888-8880", address.getSource().retrieveSourcePath());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getKeywords());
assertEquals(1, person.getKeywords().getKeywords().size());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertEquals("keyword1", keyword.getContent());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getCreatedDate().getValue());
assertEquals(2001, keyword.getCreatedDate().getValue().getYear());
assertEquals(12, keyword.getCreatedDate().getValue().getMonth());
assertEquals(31, keyword.getCreatedDate().getValue().getDay());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(2001, keyword.getLastModifiedDate().getValue().getYear());
assertEquals(12, keyword.getLastModifiedDate().getValue().getMonth());
assertEquals(31, keyword.getLastModifiedDate().getValue().getDay());
assertNotNull(keyword.getSource());
validateSourceInHttps(keyword.getSource());
assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertEquals(Visibility.PUBLIC, extId.getVisibility());
assertEquals(Long.valueOf(1), extId.getPutCode());
assertEquals("type-1", extId.getType());
assertEquals("value-1", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://url.com/1", extId.getUrl().getValue());
assertNotNull(extId.getCreatedDate());
assertNotNull(extId.getCreatedDate().getValue());
assertEquals(2001, extId.getCreatedDate().getValue().getYear());
assertEquals(12, extId.getCreatedDate().getValue().getMonth());
assertEquals(31, extId.getCreatedDate().getValue().getDay());
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(2001, extId.getLastModifiedDate().getValue().getYear());
assertEquals(12, extId.getLastModifiedDate().getValue().getMonth());
assertEquals(31, extId.getLastModifiedDate().getValue().getDay());
assertNotNull(extId.getSource());
validateSourceInHttps(extId.getSource());
assertEquals("8888-8888-8888-8880", extId.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc2.Email in project ORCID-Source by ORCID.
the class AdminManagerImpl method startDelegationProcess.
public AdminDelegatesRequest startDelegationProcess(AdminDelegatesRequest request, String trusted, String managed) {
boolean haveErrors = false;
// The permission should not already exist
if (givenPermissionToDao.findByGiverAndReceiverOrcid(managed, trusted) != null) {
request.getErrors().add(localeManager.resolveMessage("admin.delegate.error.permission_already_exists", trusted, managed));
haveErrors = true;
}
// Restriction #1: Both accounts must be claimed
boolean isTrustedClaimed = profileEntityManager.isProfileClaimed(trusted);
boolean isManagedClaimed = profileEntityManager.isProfileClaimed(managed);
if (!isTrustedClaimed || !isManagedClaimed) {
if (!isTrustedClaimed && !isManagedClaimed) {
request.getErrors().add(localeManager.resolveMessage("admin.delegate.error.not_claimed.both", trusted, request.getManaged().getValue()));
} else if (!isTrustedClaimed) {
request.getTrusted().getErrors().add(localeManager.resolveMessage("admin.delegate.error.not_claimed", request.getTrusted().getValue()));
} else {
request.getManaged().getErrors().add(localeManager.resolveMessage("admin.delegate.error.not_claimed", request.getManaged().getValue()));
}
haveErrors = true;
}
// address
if (!emailManager.isPrimaryEmailVerified(trusted)) {
request.getTrusted().getErrors().add(localeManager.resolveMessage("admin.delegate.error.primary_email_not_verified", request.getTrusted().getValue()));
haveErrors = true;
}
// Restriction #3: They cant be the same account
if (trusted.equalsIgnoreCase(managed)) {
request.getErrors().add(localeManager.resolveMessage("admin.delegate.error.cant_be_the_same", request.getTrusted().getValue(), request.getManaged().getValue()));
haveErrors = true;
}
if (haveErrors)
return request;
// Generate link
String link = generateEncryptedLink(trusted, managed);
// Send email to managed account
notificationManager.sendDelegationRequestEmail(managed, trusted, link);
Email primaryEmail = emailManager.findPrimaryEmail(managed);
request.setSuccessMessage(localeManager.resolveMessage("admin.delegate.admin.success", primaryEmail.getEmail()));
return request;
}
use of org.orcid.jaxb.model.record_rc2.Email 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_rc2.Email in project ORCID-Source by ORCID.
the class RecordManagerReadOnlyImpl method getHistory.
private History getHistory(String orcid) {
History history = new History();
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
history.setClaimed(profile.getClaimed());
if (profile.getCompletedDate() != null) {
history.setCompletionDate(new CompletionDate(DateUtils.convertToXMLGregorianCalendar(profile.getCompletedDate())));
}
if (!PojoUtil.isEmpty(profile.getCreationMethod())) {
history.setCreationMethod(CreationMethod.fromValue(profile.getCreationMethod()));
}
if (profile.getDeactivationDate() != null) {
history.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(profile.getDeactivationDate())));
}
if (profile.getLastModified() != null) {
history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(profile.getLastModified())));
}
if (profile.getSubmissionDate() != null) {
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(profile.getSubmissionDate())));
}
if (profile.getSource() != null) {
history.setSource(new Source(profile.getSource().getSourceId()));
}
boolean verfiedEmail = false;
boolean verfiedPrimaryEmail = false;
Emails emails = emailManager.getEmails(orcid, profile.getLastModified().getTime());
if (emails != null) {
for (Email email : emails.getEmails()) {
if (email.isVerified()) {
verfiedEmail = true;
if (email.isPrimary()) {
verfiedPrimaryEmail = true;
break;
}
}
}
}
history.setVerifiedEmail(verfiedEmail);
history.setVerifiedPrimaryEmail(verfiedPrimaryEmail);
return history;
}
use of org.orcid.jaxb.model.record_rc2.Email in project ORCID-Source by ORCID.
the class OrcidSecurityManager_EmailTest method testEmail_ReadLimited.
@Test
public void testEmail_ReadLimited() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Email e1 = createEmail(Visibility.PUBLIC, CLIENT_2);
Email e2 = createEmail(Visibility.LIMITED, CLIENT_2);
Email e3 = createEmail(Visibility.PRIVATE, CLIENT_2);
List<Email> emails = new ArrayList<Email>(Arrays.asList(e1, e2, e3));
orcidSecurityManager.checkAndFilter(ORCID_1, emails, ScopePathType.ORCID_BIO_READ_LIMITED);
assertEquals(2, emails.size());
assertTrue(emails.contains(e1));
assertTrue(emails.contains(e2));
assertFalse(emails.contains(e3));
}
Aggregations