001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.comment.web;
021
022import java.util.List;
023
024import javax.faces.event.ActionEvent;
025
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.platform.actions.Action;
028
029/**
030 * Provides comment manager related operations.
031 *
032 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
033 */
034public interface CommentManagerActions {
035
036    String CHILDREN_COMMENT_LIST = "CHILDREN_COMMENT_LIST";
037
038    /**
039     * @return available action for COMMENTS_ACTIONS
040     */
041    List<Action> getActionsForComment();
042
043    /**
044     * @return available action for given category
045     */
046    List<Action> getActionsForComment(String category);
047
048    /**
049     * Bean initialization method.
050     */
051    void initialize();
052
053    /**
054     * Clean all the bean's context variables.
055     */
056    void documentChanged();
057
058    /**
059     * Initializes uiComments with currentDocument.
060     */
061    void initComments();
062
063    /**
064     * Initializes uiComments with given Document.
065     */
066    void initComments(DocumentModel commentedDoc);
067
068    /**
069     * Initializes uiComments with currentDocument if uiComments is null.
070     *
071     * @return list of ThreadEntry for currentDocument
072     */
073    List<ThreadEntry> getCommentsAsThread();
074
075    /**
076     * Initialize uiComments with given Document if uiComments is null.
077     *
078     * @return list of ThreadEntry for given Document.
079     */
080    List<ThreadEntry> getCommentsAsThread(DocumentModel commentedDoc);
081
082    /**
083     * @return list of ThreadEntry for given Document.
084     */
085    List<ThreadEntry> getCommentsAsThreadOnDoc(DocumentModel doc);
086
087    String beginComment();
088
089    String cancelComment();
090
091    /**
092     * creates a new comment from
093     *
094     * @return null to avoid navigation
095     */
096    String addComment();
097
098    /**
099     * Same as addComment() method but using the given document instead of currentDocument.
100     *
101     * @return null to avoid navigation
102     */
103    String createComment(DocumentModel docToComment);
104
105    /**
106     * Add the given comment DocumentModel to commentableDoc.
107     */
108    DocumentModel addComment(DocumentModel comment);
109
110    String deleteComment();
111
112    String deleteComment(String commentId);
113
114    void destroy();
115
116    String getNewContent();
117
118    void setNewContent(String newContent);
119
120    String getPrincipalName();
121
122    boolean getPrincipalIsAdmin();
123
124    boolean getCommentStarted();
125
126    String getSavedReplyCommentId();
127
128    void setSavedReplyCommentId(String savedReplyCommentId);
129
130    boolean getShowCreateForm();
131
132    void setShowCreateForm(boolean flag);
133
134    void toggleCreateForm(ActionEvent event);
135
136    // List<UIComment> getUiComments();
137
138    /***
139     * Retrieves a given number of comments from currentDocument.
140     *
141     * @param commentNumber the number of comment to fetch
142     */
143    List<UIComment> getLastCommentsByDate(String commentNumber);
144
145    /***
146     * Retrieves a given number of comments from the given Document.
147     *
148     * @param commentNumber the number of comment to fetch
149     * @param commentedDoc
150     */
151    List<UIComment> getLastCommentsByDate(String commentNumber, DocumentModel commentedDoc);
152}