KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > Message


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25
26
27 package org.nemesis.forum;
28
29 import java.util.Date JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 import org.nemesis.forum.exception.UnauthorizedException;
33
34 /**
35  * A ForumMessage encapsulates message data. Each message belongs to a thread,
36  * and relates to other messages in a thread in a tree relationship. This system
37  * allows messages to represent threaded conversations. For example:
38  *
39  * <pre>
40  * [thread]
41  * |- [message]
42  * |- [message]
43  * |- [message]
44  * |- [message]
45  * |- [message]
46  * |- [message]
47  * </pre><p>
48  *
49  * Each message has a subject and body. Messages are authored by a user
50  * in the system or can be anonymous. An ID is given to each message so that
51  * it can be tracked uniquely. Because is possible that one might want to store
52  * considerable more information with each message besides a subject and body,
53  * each message can have an arbitrary number of properties. For example, a
54  * property "IP" could be stored with each message that records the IP address
55  * of the person posting the message for security reasons.<p>
56  *
57  * The creation date, and the date the message was last modified are maintained
58  * for each message.<p>
59  *
60  * For added functionality, any number of filters can be applied to a message.
61  * Filters dynamically format the subject and body of a message. Methods are
62  * also provided to bypass filters.
63  *
64  * @see ForumMessageFilter
65  */

66 public interface Message {
67
68
69 //-------********************** isapproved???????, setapproved.....
70

71
72
73     /**
74      * Returns the id of the message.
75      *
76      * @return the unique id of the message.
77      */

78     public int getID();
79
80     /**
81      * Returns the date the message was created.
82      *
83      * @return the date the message was created.
84      */

85     public Date JavaDoc getCreationDate();
86
87     /**
88      * Sets the creation date of the message. In most cases, the creation date
89      * will default to when the message was entered into the system. However,
90      * the creation date needs to be set manually when importing messages.
91      * In other words, skin authors should ignore this method since it only
92      * intended for system maintenance.
93      *
94      * @param creationDate the date the message was created.
95      *
96      * @throws UnauthorizedException if does not have ADMIN permissions.
97      */

98     public void setCreationDate(Date JavaDoc creationDate) throws UnauthorizedException;
99
100     /**
101      * Returns the date the message was last modified. When a message is first
102      * created, the date returned by this method is identical to the creation
103      * date. The modified date is updated every time a message property is
104      * updated, such as the message body.
105      *
106      * @return the date the message was last modified.
107      */

108     public Date JavaDoc getModifiedDate();
109
110     /**
111      * Sets the date the message was last modified. In most cases, last modifed
112      * will default to when the message data was last changed. However,
113      * the last modified date needs to be set manually when importing messages.
114      * In other words, skin authors should ignore this method since it only
115      * intended for system maintenance.
116      *
117      * @param modifiedDate the date the message was modified.
118      * @throws UnauthorizedException if does not have ADMIN permissions.
119      */

120     public void setModifiedDate(Date JavaDoc modifiedDate) throws UnauthorizedException;
121
122     /**
123      * Returns the message subject. If message filters are active, the
124      * subject returned will be a filtered one. Because filters often provide
125      * security functionality, this method is the preferred way to get the
126      * subject of a message.
127      *
128      * @return the subject of the message.
129      */

130     public String JavaDoc getSubject();
131
132     /**
133      * Returns the message subject, bypassing any active filters. Because
134      * filters often provide security, this method should be used with caution.
135      * In particular, you should avoid showing unfiltered data in an environment
136      * where embedded HTML might be interpreted.<p>
137      *
138      * Unfiltered content is necessary for a few reasons. One is when saving
139      * content to another persistence mechanism such as an XML format.
140      * Another is when you need to skip filter formatting, such as when a user
141      * is responding to another user's message.
142      *
143      * @return the subject of the message.
144      */

145     public String JavaDoc getUnfilteredSubject();
146
147     /**
148      * Sets the subject of the message.
149      *
150      * @param subject the subject of the message.
151      * @throws UnauthorizedException if does not have ADMIN permissions.
152      */

153     public void setSubject(String JavaDoc subject) throws UnauthorizedException;
154
155     /**
156      * Returns the message body. If message filters are active, the body
157      * returned will be a filtered one. Because filters often provide security
158      * functionality, this method is the preferred way to get the body of a
159      * message.
160      *
161      * @return the body of the message.
162      */

163     public String JavaDoc getBody();
164
165     /**
166      * Returns the message body, bypassing any active filters. Because filters
167      * often provide security, this method should be used with caution. In
168      * particular, you should avoid showing unfiltered data in an environment
169      * where embedded HTML might be interpreted.<p>
170      *
171      * Unfiltered content is necessary for a few reasons. One is when saving
172      * content to another persistence mechanism such as an XML format.
173      * Another is when you need to skip filter formatting, such as when a user
174      * is responding to another user's message.
175      *
176      * @return the body of the message.
177      */

178     public String JavaDoc getUnfilteredBody();
179
180     /**
181      * Sets the body of the message.
182      *
183      * @param body the body of the message.
184      * @throws UnauthorizedException if does not have ADMIN permissions.
185      */

186     public void setBody(String JavaDoc body) throws UnauthorizedException;
187
188     /**
189      * Returns the User that authored the message. If the message was created
190      * anonymously, the Anonymous User object will be returned.
191      *
192      * @return the author of the message.
193      */

194     public User getUser();
195
196     /**
197      * Returns an extended property of the message. Each message can have an
198      * arbitrary number of extended properties. This lets particular skins
199      * or filters provide enhanced functionality that is not part of the base
200      * interface.<p>
201      *
202      * For security reasons, all property values are run through an HTML filter
203      * before being returned.
204      *
205      * @param name the name of the property to get.
206      * @return the value of the property.
207      */

208     public String JavaDoc getProperty(String JavaDoc name);
209
210     /**
211      * Returns an extended property of the message, bypassing the HTML filter.
212      * Each message can have an arbitrary number of extended properties. This
213      * lets particular skins or filters provide enhanced functionality that is
214      * not part of the base interface.<p>
215      *
216      * Because properties are not filtered before being returned, this method
217      * should be used with caution. In particular, you should avoid showing
218      * unfiltered data in an environment where embedded HTML might be
219      * interpreted.
220      *
221      * @param name the name of the property to get.
222      * @return the value of the property.
223      */

224     public String JavaDoc getUnfilteredProperty(String JavaDoc name);
225
226     /**
227      * Sets an extended property of the message. Each message can have an
228      * arbitrary number of extended properties. This lets particular skins
229      * or filters provide enhanced functionality that is not part of the base
230      * interface.
231      *
232      * @param name the name of the property to set.
233      * @param value the new value for the property.
234      */

235     public void setProperty(String JavaDoc name, String JavaDoc value);
236
237     /**
238      * Returns an Iterator for all the names of the message properties.
239      *
240      * @return an Iterator for the names of all message properties.
241      */

242     public Iterator JavaDoc propertyNames();
243
244     /**
245      * Returns whether the message was posted anonymously. This is a convenience
246      * method and is equivalent to getUser().isAnonymous();
247      *
248      * @return true if the message was posted anonymously.
249      */

250     public boolean isAnonymous();
251
252     /**
253      * Returns the thread the message belongs to.
254      *
255      * @return the thread the message belongs to.
256      */

257     public ForumThread getForumThread();
258
259     /**
260      * Returns true if the handle on the object has the permission specified.
261      * A list of possible permissions can be found in the ForumPermissions
262      * class. Certain methods of this class are restricted to certain
263      * permissions as specified in the method comments.
264      *
265      * @param type a permission type.
266      * @return true if the specified permission is valid.
267      * @see ForumPermissions
268      */

269     public boolean hasPermission(int type);
270     
271 // AJOUT
272
/**
273      * return true if the message is approved
274      */

275     public boolean isApproved();
276     
277     public void setApproved(boolean approved) throws UnauthorizedException;
278 }
279
280
Popular Tags