final String commentContent =
comment.getString(Comment.COMMENT_CONTENT).
replaceAll(SoloServletListener.ENTER_ESC, "<br/>");
final String commentSharpURL =
comment.getString(Comment.COMMENT_SHARP_URL);
final Message message = new Message();
message.setFrom(adminEmail);
message.addRecipient(originalCommentEmail);
final JSONObject replyNotificationTemplate =
preferenceQueryService.getReplyNotificationTemplate();
final String mailSubject = replyNotificationTemplate.getString(
"subject").replace("${blogTitle}", blogTitle);
message.setSubject(mailSubject);
final String articleTitle = article.getString(Article.ARTICLE_TITLE);
final String blogHost = preference.getString(Preference.BLOG_HOST);
final String articleLink = "http://" + blogHost + article.getString(
Article.ARTICLE_PERMALINK);
final String commentName = comment.getString(Comment.COMMENT_NAME);
final String commentURL = comment.getString(Comment.COMMENT_URL);
String commenter = null;
if (!"http://".equals(commentURL)) {
commenter = "<a target=\"_blank\" " + "href=\"" + commentURL
+ "\">" + commentName + "</a>";
} else {
commenter = commentName;
}
final String mailBody = replyNotificationTemplate.getString("body").
replace("${postLink}", articleLink).
replace("${postTitle}", articleTitle).
replace("${replier}", commenter).
replace("${replyURL}", "http://" + blogHost
+ commentSharpURL).
replace("${replyContent}", commentContent);
message.setHtmlBody(mailBody);
LOGGER.log(Level.FINER,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
new Object[]{mailSubject, mailBody,
originalCommentEmail});
mailService.send(message);