use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class OrcidSecurityManager_PersonTest method testPerson_When_AllPrivate_NoSource_ReadPublicToken.
@Test
public void testPerson_When_AllPrivate_NoSource_ReadPublicToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PRIVATE);
Address a1 = createAddress(Visibility.PRIVATE, CLIENT_2);
Address a2 = createAddress(Visibility.PRIVATE, CLIENT_2);
Address a3 = createAddress(Visibility.PRIVATE, CLIENT_2);
Addresses addresses = new Addresses();
addresses.setAddress(new ArrayList<Address>(Arrays.asList(a1, a2, a3)));
Email e1 = createEmail(Visibility.PRIVATE, CLIENT_2);
Email e2 = createEmail(Visibility.PRIVATE, CLIENT_2);
Email e3 = createEmail(Visibility.PRIVATE, CLIENT_2);
Emails emails = new Emails();
emails.setEmails(new ArrayList<Email>(Arrays.asList(e1, e2, e3)));
Keyword k1 = createKeyword(Visibility.PRIVATE, CLIENT_2);
Keyword k2 = createKeyword(Visibility.PRIVATE, CLIENT_2);
Keyword k3 = createKeyword(Visibility.PRIVATE, CLIENT_2);
Keywords keywords = new Keywords();
keywords.setKeywords(new ArrayList<Keyword>(Arrays.asList(k1, k2, k3)));
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonExternalIdentifier ext1 = createPersonExternalIdentifier(Visibility.PRIVATE, CLIENT_2);
PersonExternalIdentifier ext2 = createPersonExternalIdentifier(Visibility.PRIVATE, CLIENT_2);
PersonExternalIdentifier ext3 = createPersonExternalIdentifier(Visibility.PRIVATE, CLIENT_2);
PersonExternalIdentifiers extIds = new PersonExternalIdentifiers();
extIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(Arrays.asList(ext1, ext2, ext3)));
ResearcherUrl r1 = createResearcherUrl(Visibility.PRIVATE, CLIENT_2);
ResearcherUrl r2 = createResearcherUrl(Visibility.PRIVATE, CLIENT_2);
ResearcherUrl r3 = createResearcherUrl(Visibility.PRIVATE, CLIENT_2);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(Arrays.asList(r1, r2, r3)));
Person p = new Person();
p.setBiography(bio);
p.setName(name);
p.setAddresses(addresses);
p.setEmails(emails);
p.setExternalIdentifiers(extIds);
p.setKeywords(keywords);
p.setOtherNames(otherNames);
p.setResearcherUrls(researcherUrls);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertNull(p.getName());
assertNull(p.getBiography());
// Check addresses
assertEquals(0, p.getAddresses().getAddress().size());
// Check emails
assertEquals(0, p.getEmails().getEmails().size());
// Check ext ids
assertEquals(0, p.getExternalIdentifiers().getExternalIdentifiers().size());
// Check keywords
assertEquals(0, p.getKeywords().getKeywords().size());
// Check other names
assertEquals(0, p.getOtherNames().getOtherNames().size());
// Check researcher urls
assertEquals(0, p.getResearcherUrls().getResearcherUrls().size());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class EmailManagerTest method getEmailsTest.
@Test
public void getEmailsTest() {
Emails emails = emailManager.getEmails("0000-0000-0000-0003");
assertNotNull(emails);
assertNotNull(emails.getEmails());
assertEquals(5, emails.getEmails().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (Email email : emails.getEmails()) {
if (email.getEmail().equals("public_0000-0000-0000-0003@test.orcid.org")) {
found1 = true;
} else if (email.getEmail().equals("limited_0000-0000-0000-0003@test.orcid.org")) {
found2 = true;
} else if (email.getEmail().equals("private_0000-0000-0000-0003@test.orcid.org")) {
found3 = true;
} else if (email.getEmail().equals("self_limited_0000-0000-0000-0003@test.orcid.org")) {
found4 = true;
} else if (email.getEmail().equals("self_private_0000-0000-0000-0003@test.orcid.org")) {
found5 = true;
} else {
fail("Invalid email found: " + email.getEmail());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class EmailManagerTest method moveEmailToOtherAccountTest.
@Test
public void moveEmailToOtherAccountTest() {
String email = "public@email.com";
String from = "4444-4444-4444-4441";
String to = "4444-4444-4444-4499";
ProfileEntity destinationBefore = profileDao.find(to);
Date beforeLastModified = destinationBefore.getLastModified();
Map<String, String> map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map);
assertEquals(from, map.get(email));
emailManager.moveEmailToOtherAccount(email, from, to);
ProfileEntity destinationAfter = profileDao.find(to);
Date afterLastModified = destinationAfter.getLastModified();
assertFalse(beforeLastModified.equals(afterLastModified));
assertTrue(afterLastModified.getTime() > beforeLastModified.getTime());
// Assert the email was moved
map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
assertNotNull(map);
assertEquals(to, map.get(email));
// Assert the email is not anymore in the from record
Emails emails = emailManager.getEmails(from);
for (Email e : emails.getEmails()) {
assertFalse(email.equals(e.getEmail()));
}
// Assert the email belongs to the to record
emails = emailManager.getEmails(to);
boolean found = false;
for (Email e : emails.getEmails()) {
if (email.equals(e.getEmail())) {
found = true;
}
}
assertTrue(found);
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class EmailManagerTest method getPublicEmailsTest.
@Test
public void getPublicEmailsTest() {
Emails emails = emailManager.getPublicEmails("0000-0000-0000-0003");
assertNotNull(emails);
assertNotNull(emails.getEmails());
assertEquals(1, emails.getEmails().size());
assertEquals("public_0000-0000-0000-0003@test.orcid.org", emails.getEmails().get(0).getEmail());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewEmails.
@Override
public Response viewEmails(String orcid) {
Emails emails = null;
try {
// return all emails if client has /email/read-private scope
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE);
emails = emailManagerReadOnly.getEmails(orcid);
// 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);
// 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);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(emails);
sourceUtils.setSourceName(emails);
return Response.ok(emails).build();
}
Aggregations