001/*
002 * cilla - Blog Management System
003 *
004 * Copyright (C) 2012 Richard "Shred" Körber
005 *   http://cilla.shredzone.org
006 *
007 * This program is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU Affero General Public License as published
009 * by the Free Software Foundation, either version 3 of the License, or
010 * (at your option) any later version.
011 *
012 * This program is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU Affero General Public License
018 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
019 */
020package org.shredzone.cilla.web.comment;
021
022import javax.servlet.http.HttpServletRequest;
023
024import org.shredzone.cilla.core.model.is.Commentable;
025
026/**
027 * A service for handling comments related to a {@link Commentable}.
028 *
029 * @author Richard "Shred" Körber
030 */
031public interface CommentFormHandler {
032
033    /**
034     * Handles a comment form for a {@link Commentable}.
035     * <p>
036     * Checks if the user is allowed to post a comment and if the comment is valid and the
037     * captcha test was passed. Stores the comment in the database, then sends a
038     * notification to the moderators.
039     *
040     * @param commentable
041     *            {@link Commentable} to add the comment to
042     * @param req
043     *            {@link HttpServletRequest} with the comment form data
044     */
045    void handleComment(Commentable commentable, HttpServletRequest req);
046
047    /**
048     * Handles a comment form for a {@link Commentable}.
049     * <p>
050     * Checks if the user is allowed to post a comment and if the comment is valid and the
051     * captcha test was passed. Stores the comment in the database, then sends a
052     * notification to the moderators.
053     *
054     * @param commentable
055     *            {@link Commentable} to add the comment to
056     * @param req
057     *            {@link HttpServletRequest} with the comment form data
058     * @param enabled
059     *            if {@code false}, do not accept new comments
060     */
061    void handleComment(Commentable commentable, HttpServletRequest req, boolean enabled);
062
063}