WebsiteData website = entry.getWebsite();
// Construct our Comment object from the submitted data
WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
CommentFormEx cf = new CommentFormEx();
CommentData comment = new CommentData();
RequestUtils.populate(cf, request);
cf.copyTo(comment, request.getLocale());
comment.setWeblogEntry(entry);
comment.setRemoteHost(request.getRemoteHost());
comment.setPostTime(new java.sql.Timestamp(System.currentTimeMillis()));
cf.setWeblogEntry(entry);
cf.setPostTime(new java.sql.Timestamp(System.currentTimeMillis()));
request.setAttribute("commentForm", cf);
request.setAttribute("blogEntry", entry);
if (preview) {
message = "This is a comment preview only";
// If comment contains blacklisted text, warn commenter
SpamChecker checker = new SpamChecker();
if (checker.checkComment(comment)) {
error = bundle.getString("commentServlet.previewMarkedAsSpam");
mLogger.debug("Comment marked as spam");
}
request.setAttribute("previewComments", "dummy");
mLogger.debug("Comment is a preview");
} else {
if (this.authenticator.authenticate(comment, request)) {
mLogger.debug("Comment passed authentication");
// If comment contains blacklisted text, mark as spam
SpamChecker checker = new SpamChecker();
if (checker.checkComment(comment)) {
comment.setSpam(Boolean.TRUE);
error = bundle.getString("commentServlet.commentMarkedAsSpam");
mLogger.debug("Comment marked as spam");
}
// If comment moderation is on, set comment as pending
if (website.getCommentModerationRequired()) {
comment.setPending(Boolean.TRUE);
comment.setApproved(Boolean.FALSE);
//message = bundle.getString("commentServlet.submittedToModerator");
} else {
comment.setPending(Boolean.FALSE);
comment.setApproved(Boolean.TRUE);
}
mgr.saveComment(comment);
RollerFactory.getRoller().flush();
reindexEntry(entry);