use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method testUnmarshallEmails.
@Test
public void testUnmarshallEmails() throws SAXException, URISyntaxException {
Emails emails = (Emails) unmarshallFromPath("/record_2.0/samples/read_samples/emails-2.0.xml", Emails.class, "/record_2.0/email-2.0.xsd");
assertNotNull(emails);
assertNotNull(emails.getEmails());
assertEquals(2, emails.getEmails().size());
for (Email email : emails.getEmails()) {
assertNotNull(email.getPutCode());
assertNotNull(email.getCreatedDate());
assertNotNull(email.getLastModifiedDate());
if (email.getPutCode().equals(Long.valueOf(1))) {
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertEquals("user1@email.com", email.getEmail());
} else {
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertEquals("user2@email.com", email.getEmail());
}
}
Email email = (Email) unmarshallFromPath("/record_2.0/samples/read_samples/email-2.0.xml", Email.class);
assertNotNull(email);
assertNotNull(email.getPutCode());
assertNotNull(email.getCreatedDate());
assertNotNull(email.getLastModifiedDate());
assertEquals(Visibility.PUBLIC, email.getVisibility());
assertEquals("user1@email.com", email.getEmail());
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class OrcidSecurityManagerImpl method checkAndFilter.
private void checkAndFilter(String orcid, Collection<? extends VisibilityType> elements, ScopePathType requiredScope, boolean tokenAlreadyChecked) {
if (elements == null) {
return;
}
// Check the token
if (!tokenAlreadyChecked) {
isMyToken(orcid);
}
Iterator<? extends VisibilityType> it = elements.iterator();
while (it.hasNext()) {
VisibilityType element = it.next();
try {
if (element instanceof Email) {
Email email = (Email) element;
checkAndFilter(orcid, email, requiredScope, true);
} else {
checkAndFilter(orcid, element, requiredScope, true);
}
} catch (Exception e) {
it.remove();
}
}
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.
public static Date calculateLatest(Emails emails) {
Date latestAct = null;
if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
XMLGregorianCalendar latest = emails.getEmails().get(0).getLastModifiedDate().getValue();
for (Email email : emails.getEmails()) {
if (latest.compare(email.getLastModifiedDate().getValue()) == -1) {
latest = email.getLastModifiedDate().getValue();
}
}
latestAct = latest.toGregorianCalendar().getTime();
emails.setLastModifiedDate(new LastModifiedDate(latest));
}
return latestAct;
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Emails emails) {
if (emails != null && emails.getEmails() != null && !emails.getEmails().isEmpty()) {
LastModifiedDate latest = null;
for (Email email : emails.getEmails()) {
if (email.getLastModifiedDate() != null && email.getLastModifiedDate().after(latest)) {
latest = email.getLastModifiedDate();
}
}
emails.setLastModifiedDate(latest);
}
}
use of org.gluu.oxtrust.model.scim2.Email in project ORCID-Source by ORCID.
the class NotificationManagerTest method testSendDeactivateEmail.
@Test
public void testSendDeactivateEmail() throws JAXBException, IOException, URISyntaxException {
TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
final String orcid = "0000-0000-0000-0003";
ProfileEntity profile = new ProfileEntity(orcid);
RecordNameEntity recordName = new RecordNameEntity();
recordName.setCreditName("My credit name");
recordName.setVisibility(Visibility.PUBLIC);
profile.setRecordNameEntity(recordName);
Email email = new Email();
email.setEmail("test@email.com");
when(mockProfileEntityCacheManager.retrieve(orcid)).thenReturn(profile);
when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
profile.setLocale(locale);
notificationManager.sendOrcidDeactivateEmail(orcid);
}
}
Aggregations