KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portlet > forums > action > ReplyAction


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Forums JBoss Portlet *
6  * *
7  * Distributable under GPL license. *
8  * See terms of license at gnu.org. *
9  * *
10  *****************************************/

11 package org.jboss.portlet.forums.action;
12
13 import java.util.Collections JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.jboss.portal.core.modules.ModuleException;
17 import org.jboss.portlet.forums.model.Forum;
18 import org.jboss.portlet.forums.model.Message;
19 import org.jboss.portlet.forums.model.Post;
20 import org.jboss.portlet.forums.model.Poster;
21 import org.jboss.portlet.forums.model.Topic;
22
23 /**
24  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
25  * @author <a HREF="mailto:theute@jboss.org">Thomas Heute</a>
26  * @version $Revision: 1.2 $
27  */

28 public class ReplyAction
29    extends PostAction
30 {
31    private boolean quote;
32    private int postId;
33    private Message message;
34    private Poster poster;
35    private List JavaDoc attachments;
36    private Post post;
37    private Topic topic;
38    private boolean firstPost = false;
39
40    /**
41     * Creates a new {@link ReplyAction} object.
42     *
43     * @param postId DOCUMENT_ME
44     * @param message DOCUMENT_ME
45     * @param poster DOCUMENT_ME
46     * @param attachments DOCUMENT_ME
47     */

48    public ReplyAction(int postId,
49                       Message message,
50                       Poster poster,
51                       List JavaDoc attachments)
52    {
53       super(REFRESH);
54       this.postId = postId;
55       this.message = message;
56       this.poster = poster;
57       this.attachments = attachments;
58    }
59
60    /**
61     * Creates a new {@link ReplyAction} object.
62     *
63     * @param quote DOCUMENT_ME
64     * @param postId DOCUMENT_ME
65     * @param message DOCUMENT_ME
66     * @param poster DOCUMENT_ME
67     */

68    public ReplyAction(boolean quote,
69                       int postId,
70                       Message message,
71                       Poster poster)
72    {
73       super(INIT);
74       this.quote = quote;
75       this.postId = postId;
76       this.message = message;
77       this.poster = poster;
78       this.attachments = Collections.EMPTY_LIST;
79    }
80
81    /**
82     * DOCUMENT_ME
83     *
84     * @return DOCUMENT_ME
85     */

86    public Post getPost()
87    {
88       return post;
89    }
90
91    /**
92     * DOCUMENT_ME
93     *
94     * @return DOCUMENT_ME
95     */

96    public Topic getTopic()
97    {
98       return getPost().getTopic();
99    }
100
101    /**
102     * DOCUMENT_ME
103     *
104     * @return DOCUMENT_ME
105     */

106    public Forum getForum()
107    {
108       return getTopic().getForum();
109    }
110
111    /**
112     * DOCUMENT_ME
113     *
114     * @return DOCUMENT_ME
115     */

116    public Poster getPoster()
117    {
118       return poster;
119    }
120
121    /**
122     * DOCUMENT_ME
123     *
124     * @return DOCUMENT_ME
125     */

126    public Message getMessage()
127    {
128       return message;
129    }
130
131    /**
132     * DOCUMENT_ME
133     *
134     * @return DOCUMENT_ME
135     */

136    public List JavaDoc getAttachments()
137    {
138       return attachments;
139    }
140
141    /**
142     * DOCUMENT_ME
143     */

144    public void init()
145    {
146       try
147       {
148          post = module.findPostByID(new Integer JavaDoc(postId));
149          topic = post.getTopic();
150          if (topic.getFirstPost().getID().equals(post.getID()))
151          {
152             firstPost = true;
153          }
154
155          // firstPost = EJB.areIdentical(post, topic.getFirstPost());
156
if (getMode() == ForumAction.INIT)
157          {
158             // if (quote)
159
// {
160
// message = (Message)post.getMessage().clone();
161
// message.setText("[quote=\"" + post.getPoster().getUserName() + "\"]" + message.getText() + "[/quote]");
162
// }
163
// else
164
// {
165
Topic topic = post.getTopic();
166             message.setSubject(topic.getSubject());
167
168             // }
169
if (!message.getSubject().startsWith("Re:"))
170             {
171                message.setSubject("Re: " + message.getSubject());
172             }
173
174             String JavaDoc signature = getPoster().getUser().getSignature();
175             if ((signature != null) && (signature.trim().length() != 0))
176             {
177                message.setSignatureEnabled(true);
178             }
179          }
180       }
181       catch (ModuleException e)
182       {
183          e.printStackTrace();
184       }
185    }
186
187    /**
188     * DOCUMENT_ME
189     *
190     * @return DOCUMENT_ME
191     */

192    public boolean isFirstPost()
193    {
194       return firstPost;
195    }
196 }
Popular Tags