@Override
public CommentEntity addComment(String name, String content,
PageEntity page) {
ConfigEntity config = VosaoContext.getInstance().getConfig();
CommentEntity comment = new CommentEntity(name, content,
new Date(), page.getFriendlyURL());
getDao().getCommentDao().save(comment);
getBusiness().getSystemService().getPageCache().remove(
page.getFriendlyURL());
List<String> toAddresses = StrUtil.fromCSV(config.getCommentsEmail());
if (toAddresses.size() == 0) {
toAddresses.add(config.getSiteEmail());
}
for (String email : toAddresses) {
EmailUtil.sendEmail(createCommentLetter(comment, page),
COMMENT_LETTER_SUBJECT,
config.getSiteEmail(),
config.getSiteDomain() + " admin",
StringUtils.strip(email));
logger.debug("New comment letter was sent to " + email);
}
return comment;
}