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 * ${user} 016 * 017 * $Id 018 */ 019package org.nuxeo.ecm.platform.forum.web.api; 020 021import java.io.Serializable; 022import java.util.List; 023 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.platform.comment.web.ThreadEntry; 026 027/** 028 * This Action Listener represents a Thread inside a forum. 029 * 030 * @author <a href="bchaffangeon@nuxeo.com">Brice Chaffangeon</a> 031 */ 032public interface ThreadAction extends Serializable { 033 034 /** 035 * Gets the title of the Thread to be created. 036 */ 037 String getTitle(); 038 039 /** 040 * Sets the title of the Thread. 041 */ 042 void setTitle(String title); 043 044 /** 045 * Gets the description of the Thread. 046 */ 047 String getDescription(); 048 049 /** 050 * Sets the description of the Thread. 051 */ 052 void setDescription(String description); 053 054 /** 055 * Adds the thread inside the forum. 056 */ 057 String addThread(); 058 059 /** 060 * Returns true if the thread is moderated, false otherwise. Just used at creation time. 061 */ 062 boolean isModerated(); 063 064 /** 065 * Return the label of the moderation state of the thread 066 * 067 * @param thread is the thread we want 068 */ 069 String getModerationAsString(DocumentModel thread); 070 071 /** 072 * Sets the moderation on a thread. 073 */ 074 void setModerated(boolean moderated); 075 076 /** 077 * Get all moderators on the thread. 078 */ 079 List<String> getModerators(); 080 081 /** 082 * Returns true if the principal (logged user) is a moderator, else otherwise. 083 */ 084 boolean isPrincipalModerator(); 085 086 /** 087 * Returns true if the principal(s group is a moderator group 088 */ 089 boolean isPrincipalGroupModerator(); 090 091 /** 092 * Returns true if the thread is moderated, false otherwise. Intends to be used by a Post. 093 */ 094 boolean isCurrentThreadModerated(); 095 096 /** 097 * Returns true if the given thread is moderated, false otherwise. 098 * 099 * @param thread is the thread to test 100 */ 101 boolean isThreadModerated(DocumentModel thread); 102 103 /** 104 * Gets the latest post published in given thread. 105 */ 106 DocumentModel getLastPostPublished(DocumentModel thread); 107 108 /** 109 * Gets all available posts in the thread according the Post state and principal rights. I.e., Post that are not 110 * published won't be visible for non-moderators. 111 * 112 * @return a list of ThreadEntry, directly usable for display with indentation 113 */ 114 List<ThreadEntry> getPostsAsThread(); 115 116 /** 117 * Gets all Posts in the Thread with the specified state. Return all posts if state is null. 118 */ 119 List<DocumentModel> getAllPosts(DocumentModel thread, String state); 120 121 /** 122 * Gets published posts in a thread. 123 */ 124 List<DocumentModel> getPostsPublished(DocumentModel thread); 125 126 /** 127 * Gets pending posts in a thread. 128 */ 129 List<DocumentModel> getPostsPending(DocumentModel thread); 130 131 /** 132 * Return the parent post of the specified index of the post in the getPostsAsThread() list. 133 */ 134 DocumentModel getParentPost(int post); 135 136 /** 137 * Return true if the parent post identified by it's number in the getPostsAsThread list is published. 138 */ 139 boolean isParentPostPublished(int post); 140 141 ThreadAdapter getAdapter(DocumentModel thread); 142 143}