isArticle = false;
}
final String commentSharpURL =
comment.getString(Comment.COMMENT_SHARP_URL);
final Message message = new Message();
message.setFrom(adminEmail);
message.addRecipient(preference.getString(Preference.ADMIN_EMAIL));
String mailSubject = null;
String articleOrPageURL = null;
String mailBody = null;
if (isArticle) {
mailSubject = blogTitle + ": New comment on article ["
+ title + "]";
articleOrPageURL = "http://" + blogHost + articleOrPage.getString(
Article.ARTICLE_PERMALINK);
mailBody = AddArticleCommentAction.COMMENT_MAIL_HTML_BODY.replace(
"{articleOrPage}", "Article");
} else {
mailSubject = blogTitle + ": New comment on page ["
+ title + "]";
articleOrPageURL = "http://" + blogHost + "/page.do?oId="
+ articleOrPage.getString(Keys.OBJECT_ID);
mailBody = AddArticleCommentAction.COMMENT_MAIL_HTML_BODY.replace(
"{articleOrPage}", "Page");
}
message.setSubject(mailSubject);
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;
}
mailBody = mailBody.replace(
"{articleOrPageURL}", articleOrPageURL).
replace("{title}", title).
replace("{commentContent}", commentContent).
replace("{commentSharpURL}", blogHost + commentSharpURL).
replace("{commenter}", commenter);
message.setHtmlBody(mailBody);
LOGGER.log(Level.FINER,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to admins",
new Object[]{mailSubject, mailBody});
mailService.send(message);
}