View Javadoc

1   /**
2    * This file Copyright (c) 2003-2012 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.forum;
35  
36  import info.magnolia.cms.core.Content;
37  import info.magnolia.cms.security.AccessDeniedException;
38  import info.magnolia.objectfactory.Components;
39  
40  import java.util.Collection;
41  
42  import javax.jcr.RepositoryException;
43  
44  /**
45   * Basic forum contract defining all mandatory operations for each manager implementation.
46   * 
47   * @author gjoseph
48   * @version $Revision: $ ($Author: $)
49   */
50  public interface ForumManager {
51  
52      /**
53       * Use this to retrieve the configured impl of ForumManager.
54       */
55      public class Factory {
56          public static ForumManager getInstance() {
57              return Components.getSingleton(ForumManager.class);
58          }
59      }
60  
61      /**
62       * Creates a forum with the given name and returns its node.
63       */
64      Content createForum(String name, String title) throws RepositoryException;
65  
66      /**
67       * Creates a forum with the given name and returns its node.
68       */
69      Content createForum(String name, String title, boolean withMessageNesting) throws RepositoryException;
70  
71      /**
72       * Returns a Collection<Content> of available forums.
73       * This potentially filters out content unavailable to the current user.
74       * TODO : should return a List
75       */
76      Collection<Content> getForumList() throws RepositoryException;
77  
78      /**
79       * Resolves forum short name into uuid.
80       */
81      String getForumId(String shortName) throws RepositoryException;
82  
83      Content getForum(String forumId) throws RepositoryException;
84  
85      /**
86       * Returns a Collection<Content> of threads in the given forum.
87       * This potentially filters out content unavailable to the current user.
88       * TODO : should return a List
89       */
90      Collection<Content> getThreads(Content forum) throws RepositoryException;
91  
92      /**
93       * Creates a new thread in the given forum and returns this thread's node.
94       */
95      Content createThread(String forumID, String threadTitle, String messageText, String author, boolean isAnonymous) throws RepositoryException;
96  
97      /**
98       * Creates a new thread in the given forum and returns this thread's node.
99       */
100     Content createThread(String forumID, String threadTitle, String messageTitle, String messageText, String author, boolean isAnonymous) throws RepositoryException;
101 
102     /**
103      * Adds a message to a thread and returns this new message's node.
104      * @param isAnonymous TODO
105      */
106     Content replyToThread(String threadID, String inReplyToID, String messageTitle, String messageText, String author, boolean isAnonymous) throws RepositoryException;
107 
108     Content getThread(String threadID) throws RepositoryException;
109 
110     /**
111      * Returns the forum node associated to the given thread.
112      */
113     Content getForumFromThread(Content thread) throws RepositoryException;
114 
115     /**
116      * Returns the thread associated to the given message.
117      */
118     Content getThreadFromMessage(Content message) throws RepositoryException;
119 
120     /**
121      * Returns a given page of messages from the given thread. Will return the number of messages
122      * dictated by ForumConfiguration. Read permission is check when returning messages: messages
123      * which are not allowed to be read will not be returned, but will not be taken into account
124      * when calculating the range of messages to return either. Page count starts at 1.
125      */
126     PagedResult getMessages(Content thread, long page) throws RepositoryException;
127 
128     /**
129      * Gets all messages for given forum ordered by publication date.
130      */
131     Collection<Content> getForumMessages(String forumName) throws RepositoryException;
132 
133     void deleteForum(String forumID) throws RepositoryException;
134 
135     void deleteThread(String threadID) throws RepositoryException;
136 
137     void deleteMessage(String messageID) throws RepositoryException;
138 
139     /**
140      * A locked forum can not have threads created in it by users.
141      */
142     void lockForum(String forumID) throws RepositoryException;
143 
144     void unlockForum(String forumID) throws RepositoryException;
145 
146     void lockThread(String threadID) throws RepositoryException;
147 
148     void unlockThread(String threadID) throws RepositoryException;
149 
150     void validate(String messageID) throws RepositoryException;
151 
152     /**
153      * Marks a message as explicitly invalid.
154      */
155     void invalidate(String messageID) throws RepositoryException;
156 
157     // moderation "searches" ? getUncheckedMessages() ?
158 
159     /**
160      * Checks if current user is allowed to post on the given forum.
161      */
162     boolean isAllowedToPostOnForum(Content forum);
163 
164     /**
165      * Checks if current user is allowed to post on the given thread.
166      */
167     boolean isAllowedToPostOnThread(Content thread);
168 
169     /**
170      * Checks whether the current logged-in user is moderator.
171      * @throws AccessDeniedException
172      */
173     public void isModerator() throws AccessDeniedException;
174 
175 }