use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class EmailManagerTest method verifySetCurrentAndPrimaryTest.
@Test
public void verifySetCurrentAndPrimaryTest() {
String email = "public_0000-0000-0000-0004@test.orcid.org";
String orcid = "0000-0000-0000-0004";
Emails emails = emailManager.getEmails(orcid);
Email element = null;
for (Email e : emails.getEmails()) {
if (email.equals(e.getEmail())) {
element = e;
break;
}
}
assertNotNull(element);
assertFalse(element.isCurrent());
assertFalse(element.isPrimary());
assertFalse(element.isVerified());
emailManager.verifySetCurrentAndPrimary(orcid, email);
emails = emailManager.getEmails(orcid);
element = null;
for (Email e : emails.getEmails()) {
if (email.equals(e.getEmail())) {
element = e;
break;
}
}
assertNotNull(element);
assertTrue(element.isCurrent());
assertTrue(element.isPrimary());
assertTrue(element.isVerified());
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class NotificationManagerImpl method sendAcknowledgeMessage.
@Override
public void sendAcknowledgeMessage(String userOrcid, String clientId) throws UnsupportedEncodingException {
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(userOrcid);
ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
Locale userLocale = (profileEntity.getLocale() == null || profileEntity.getLocale().value() == null) ? Locale.ENGLISH : LocaleUtils.toLocale(profileEntity.getLocale().value());
String subject = getSubject("email.subject.institutional_sign_in", userLocale);
String authorizationUrl = buildAuthorizationUrlForInstitutionalSignIn(clientDetails);
// Create map of template params
Map<String, Object> templateParams = new HashMap<String, Object>();
templateParams.put("emailName", deriveEmailFriendlyName(profileEntity));
templateParams.put("orcid", userOrcid);
templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
templateParams.put("subject", subject);
templateParams.put("clientName", clientDetails.getClientName());
templateParams.put("authorization_url", authorizationUrl);
addMessageParams(templateParams, userLocale);
// Generate body from template
String body = templateManager.processTemplate("authenticate_request_email.ftl", templateParams);
// Generate html from template
String html = templateManager.processTemplate("authenticate_request_email_html.ftl", templateParams);
boolean notificationsEnabled = profileEntity.getEnableNotifications();
if (notificationsEnabled) {
NotificationInstitutionalConnection notification = new NotificationInstitutionalConnection();
notification.setNotificationType(NotificationType.INSTITUTIONAL_CONNECTION);
notification.setAuthorizationUrl(new AuthorizationUrl(authorizationUrl));
NotificationInstitutionalConnectionEntity notificationEntity = (NotificationInstitutionalConnectionEntity) notificationAdapter.toNotificationEntity(notification);
notificationEntity.setProfile(new ProfileEntity(userOrcid));
notificationEntity.setClientSourceId(clientId);
notificationEntity.setAuthenticationProviderId(clientDetails.getAuthenticationProviderId());
notificationDao.persist(notificationEntity);
} else {
Emails emails = emailManager.getEmails(userOrcid);
String primaryEmail = null;
if (emails == null || emails.getEmails() == null) {
throw new IllegalArgumentException("Unable to find primary email for: " + userOrcid);
}
for (org.orcid.jaxb.model.v3.dev1.record.Email email : emails.getEmails()) {
if (email.isPrimary()) {
primaryEmail = email.getEmail();
}
}
mailGunManager.sendEmail(UPDATE_NOTIFY_ORCID_ORG, primaryEmail, subject, body, html);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method testMarshallEmails.
@Test
public void testMarshallEmails() throws JAXBException, SAXException, URISyntaxException {
Emails object = (Emails) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/emails-3.0_dev1.xml", Emails.class);
marshall(object, "/record_3.0_dev1/email-3.0_dev1.xsd");
}
use of org.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method testUnmarshallEmails.
@Test
public void testUnmarshallEmails() throws SAXException, URISyntaxException {
Emails emails = (Emails) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/emails-3.0_dev1.xml", Emails.class, "/record_3.0_dev1/email-3.0_dev1.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_3.0_dev1/samples/read_samples/email-3.0_dev1.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.orcid.jaxb.model.v3.dev1.record.Emails in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(Person person) {
if (person == null) {
return;
}
if (person.getAddresses() != null) {
Addresses addresses = person.getAddresses();
setSourceName(addresses);
}
if (person.getEmails() != null) {
Emails emails = person.getEmails();
setSourceName(emails);
}
if (person.getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = person.getExternalIdentifiers();
setSourceName(extIds);
}
if (person.getKeywords() != null) {
Keywords keywords = person.getKeywords();
setSourceName(keywords);
}
if (person.getOtherNames() != null) {
OtherNames otherNames = person.getOtherNames();
setSourceName(otherNames);
}
if (person.getResearcherUrls() != null) {
ResearcherUrls researcherUrls = person.getResearcherUrls();
setSourceName(researcherUrls);
}
}
Aggregations