use of org.opencastproject.kernel.mail.EmailAddress in project opencast by opencast.
the class MailService method toMimeMessage.
/**
* Message -> MimeMessage.
*/
private MimeMessage toMimeMessage(Mail mail) throws Exception {
final MimeMessage msg = smtpService.createMessage();
for (EmailAddress reply : mail.getReplyTo()) msg.setReplyTo(new Address[] { new InternetAddress(reply.getAddress(), reply.getName(), "UTF-8") });
// recipient
for (EmailAddress recipient : mail.getRecipients()) {
msg.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(recipient.getAddress(), recipient.getName(), "UTF-8"));
}
// subject
msg.setSubject(mail.getSubject());
EmailAddress from = mail.getSender();
msg.setFrom(new InternetAddress(from.getAddress(), from.getName(), "UTF-8"));
// body
msg.setText(mail.getBody(), "UTF-8");
return msg;
}
use of org.opencastproject.kernel.mail.EmailAddress in project opencast by opencast.
the class MessageSignatureDto method toMessageSignature.
/**
* Returns the business object of this message signature
*
* @return the business object model of this message signature
*/
public MessageSignature toMessageSignature(UserDirectoryService userDirectoryService) {
final Option<EmailAddress> reply;
if (replyTo != null && replyToName != null) {
reply = some(new EmailAddress(replyTo, replyToName));
} else {
reply = none();
}
User user = userDirectoryService.loadUser(creator);
return new MessageSignature(id, name, user, new EmailAddress(sender, senderName), reply, signature, creationDate);
}
use of org.opencastproject.kernel.mail.EmailAddress in project opencast by opencast.
the class UserSettingsTest method toJsonInputSettingAndSignatureExpectedAllInJson.
@Test
public void toJsonInputSettingAndSignatureExpectedAllInJson() throws Exception {
InputStream stream = SeriesEndpointTest.class.getResourceAsStream("/user_settings_test_example.json");
InputStreamReader reader = new InputStreamReader(stream);
JSONObject expected = (JSONObject) new JSONParser().parse(reader);
User creator = EasyMock.createMock(User.class);
EasyMock.expect(creator.getName()).andReturn("Users Name").anyTimes();
EasyMock.expect(creator.getUsername()).andReturn("username12").anyTimes();
EasyMock.expect(creator.getEmail()).andReturn("adam@fake.com").anyTimes();
EasyMock.replay(creator);
EmailAddress sender = new EmailAddress("adam@fake.com", "Other Name");
Option<EmailAddress> replyTo = none();
DateTime dateTime = new DateTime(1401465634101L);
dateTime.toDateTime(DateTimeZone.UTC);
// MessageSignature messageSignature = new MessageSignature(10L, "Adam McKenzie", creator, sender, replyTo,
// "This is the signature", dateTime.toDate(), nil(Comment.class));
Collection<MessageSignature> signatures = new LinkedList<MessageSignature>();
// signatures.add(messageSignature);
UserSetting userSetting = new UserSetting(98, "Test Key", "Test Value");
UserSettings userSettings = new UserSettings();
userSettings.setTotal(1);
userSettings.addUserSetting(userSetting);
assertThat(expected.toJSONString(), SameJSONAs.sameJSONAs(userSettings.toJson().toJson()));
}
Aggregations