} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
} // end of catch
SimpleEmail email = new SimpleEmail();
String login = (String) profileInfo.get("login");
String to = login;
String from = (String) context.
getInitParameter("moderation.mail.from.address");
String subject = (String) context.
getInitParameter("moderated.mail.subject");
String baseurl = (String) context.
getInitParameter("main.baseurl");
String fromDisplayName = (String) context.
getInitParameter("moderation.mail.from.displayName");
if (to == null || to.trim().length() == 0) {
// assert !(empty to)
throw new RuntimeException("Invalid profile info, no 'login': " +
to);
} // end of if
if (from == null || from.trim().length() == 0) {
// assert !(empty from)
throw new RuntimeException("No 'from' parameter: " + from);
} // end of if
if (subject == null || subject.trim().length() == 0) {
// assert !(empty subject)
throw new RuntimeException("No 'subject' parameter: " + subject);
} // end of if
if (baseurl == null || baseurl.trim().length() == 0) {
// assert !(empty baseurl)
throw new RuntimeException("No 'baseurl' parameter: " + baseurl);
} // end of if
if (fromDisplayName == null || fromDisplayName.trim().length() == 0) {
// assert !(empty fromDisplayName)
throw new RuntimeException("No 'formDisplayName' parameter: " +
fromDisplayName);
} // end of if
// ---
try {
String toPattern = bundle.getString("mail.to.pattern");
String contentPattern = bundle.getString("mail.content.pattern");
String toDisplayName = MessageFormat.
format(toPattern,
new Object[] {
(String) profileInfo.get("firstName"),
(String) profileInfo.get("lastName")
});
String content = MessageFormat.
format(contentPattern,
new Object[] {
login,
baseurl,
fromDisplayName
});
email.setMailSession(session);
email.addTo(to, toDisplayName);
email.setFrom(from, fromDisplayName);
email.setSubject(subject);
email.setCharset("UTF-8");
email.setMsg(content);
email.send();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
} // end of catch
} // end of sendModerationConfirmation