KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portlet > forums > commands > post > ReplyCommand


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.commands.post;
12
13 import java.util.Date JavaDoc;
14
15 import org.jboss.portal.common.command.result.Result;
16 import org.jboss.portlet.forums.commands.ValidationException;
17 import org.jboss.portlet.forums.model.Post;
18 import org.jboss.portlet.forums.model.AuthType;
19 import org.jboss.portlet.JBossActionRequest;
20 import org.jboss.portlet.JBossActionResponse;
21
22 /**
23  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
24  * @version $Revision: 1.5 $
25  */

26 public final class ReplyCommand
27    extends PostCommand
28 {
29    /** DOCUMENT_ME */
30    public Post newPost;
31
32    /** DOCUMENT_ME */
33    public Date JavaDoc current_time;
34
35    /** DOCUMENT_ME */
36    public boolean notify;
37
38    public ReplyCommand(JBossActionRequest request, JBossActionResponse response)
39    {
40       super(request, response);
41    }
42
43    /**
44     * DOCUMENT_ME
45     *
46     * @return DOCUMENT_ME
47     */

48    public int authType()
49    {
50       return AuthType.REPLY;
51    }
52
53    /**
54     * DOCUMENT_ME
55     *
56     * @throws ValidationException DOCUMENT_ME
57     */

58    protected void prepare()
59    throws ValidationException
60    {
61       super.prepare();
62       PostTools.validate(message);
63    }
64
65    /**
66     * DOCUMENT_ME
67     *
68     * @return DOCUMENT_ME
69     */

70    public Result __execute()
71    {
72       try
73       {
74          newPost = forumsModule.createPost(topic,
75                                                 forum,
76                                                 message,
77                                                 current_time,
78                                                 getPoster());
79          poster.incrementPostCount();
80
81          /*
82             TopicWatchEJBLocal watch = null;
83             try
84             {
85                watch = homes.topicWatch.findByPrimaryKey(new TopicWatchEJBPK(getPoster().getUser().getId(), topic.getId()));
86             }
87             catch(ObjectNotFoundException e)
88             {
89                // we consider it is ObjectNotFoundException
90             }
91             if (watch == null && notify)
92             {
93                homes.topicWatch.create(getPoster().getUser(), topic);
94             }
95             else if (watch != null && !notify)
96             {
97                watch.remove();
98             }
99             if (attachments != null) {
100                for (int i = 0;i < attachments.length;i++)
101                {
102                   Attachment attachment = attachments[i];
103                   homes.attachment.create(post,
104                         attachment.getFile().getName(),
105                         attachment.getFile().getContent(),
106                         attachment.getComment(),
107                         attachment.getFile().getContentType(),
108                         attachment.getFile().getSize(),
109                         current_time);
110                }
111             }
112           */

113       }
114       catch (Exception JavaDoc e)
115       {
116          log.error("Cannot create post reply", e);
117          return TYPE_ERROR_IN_POSTING;
118       }
119
120       return TYPE_REPLY_POSTED;
121    }
122 }
Popular Tags