001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     ${user}
018 *
019 * $Id
020 */
021package org.nuxeo.ecm.platform.forum.web.api;
022
023import java.io.Serializable;
024import java.util.List;
025
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.platform.comment.web.ThreadEntry;
028
029/**
030 * This Action Listener represents a Thread inside a forum.
031 *
032 * @author <a href="bchaffangeon@nuxeo.com">Brice Chaffangeon</a>
033 */
034public interface ThreadAction extends Serializable {
035
036    /**
037     * Gets the title of the Thread to be created.
038     */
039    String getTitle();
040
041    /**
042     * Sets the title of the Thread.
043     */
044    void setTitle(String title);
045
046    /**
047     * Gets the description of the Thread.
048     */
049    String getDescription();
050
051    /**
052     * Sets the description of the Thread.
053     */
054    void setDescription(String description);
055
056    /**
057     * Adds the thread inside the forum.
058     */
059    String addThread();
060
061    /**
062     * Returns true if the thread is moderated, false otherwise. Just used at creation time.
063     */
064    boolean isModerated();
065
066    /**
067     * Return the label of the moderation state of the thread
068     *
069     * @param thread is the thread we want
070     */
071    String getModerationAsString(DocumentModel thread);
072
073    /**
074     * Sets the moderation on a thread.
075     */
076    void setModerated(boolean moderated);
077
078    /**
079     * Get all moderators on the thread.
080     */
081    List<String> getModerators();
082
083    /**
084     * Returns true if the principal (logged user) is a moderator, else otherwise.
085     */
086    boolean isPrincipalModerator();
087
088    /**
089     * Returns true if the principal(s group is a moderator group
090     */
091    boolean isPrincipalGroupModerator();
092
093    /**
094     * Returns true if the thread is moderated, false otherwise. Intends to be used by a Post.
095     */
096    boolean isCurrentThreadModerated();
097
098    /**
099     * Returns true if the given thread is moderated, false otherwise.
100     *
101     * @param thread is the thread to test
102     */
103    boolean isThreadModerated(DocumentModel thread);
104
105    /**
106     * Gets the latest post published in given thread.
107     */
108    DocumentModel getLastPostPublished(DocumentModel thread);
109
110    /**
111     * Gets all available posts in the thread according the Post state and principal rights. I.e., Post that are not
112     * published won't be visible for non-moderators.
113     *
114     * @return a list of ThreadEntry, directly usable for display with indentation
115     */
116    List<ThreadEntry> getPostsAsThread();
117
118    /**
119     * Gets all Posts in the Thread with the specified state. Return all posts if state is null.
120     */
121    List<DocumentModel> getAllPosts(DocumentModel thread, String state);
122
123    /**
124     * Gets published posts in a thread.
125     */
126    List<DocumentModel> getPostsPublished(DocumentModel thread);
127
128    /**
129     * Gets pending posts in a thread.
130     */
131    List<DocumentModel> getPostsPending(DocumentModel thread);
132
133    /**
134     * Return the parent post of the specified index of the post in the getPostsAsThread() list.
135     */
136    DocumentModel getParentPost(int post);
137
138    /**
139     * Return true if the parent post identified by it's number in the getPostsAsThread list is published.
140     */
141    boolean isParentPostPublished(int post);
142
143    ThreadAdapter getAdapter(DocumentModel thread);
144
145}