KickJava   Java API By Example, From Geeks To Geeks.

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


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
14 import org.jboss.portal.common.command.result.Result;
15 import org.jboss.portlet.forums.model.Post;
16 import org.jboss.portlet.forums.model.AuthType;
17 import org.jboss.portlet.JBossActionRequest;
18 import org.jboss.portlet.JBossActionResponse;
19
20 /**
21  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
22  * @version $Revision: 1.3 $
23  */

24 public class VoteTopicCommand
25    extends TopicCommand
26 {
27    /** DOCUMENT_ME */
28    public Post post;
29
30    /** DOCUMENT_ME */
31    public int voteOptionId;
32
33    public VoteTopicCommand(JBossActionRequest request, JBossActionResponse response)
34    {
35       super(request, response);
36    }
37
38    /**
39     * DOCUMENT_ME
40     *
41     * @return DOCUMENT_ME
42     */

43    public int authType()
44    {
45       return AuthType.READ;
46    }
47
48    /**
49     * DOCUMENT_ME
50     *
51     * @return DOCUMENT_ME
52     */

53    protected Result __execute()
54    {
55       /* if (voteOptionId != -1)
56          {
57             try
58             {
59                OptionEJBLocal optionEJB = homes.option.findByPrimaryKey(new Integer(voteOptionId));
60                PollEJBLocal pollEJB = optionEJB.getPoll();
61                try
62                {
63                   if (getPoster() == null)
64                   {
65                      return TYPE_CANNOT_OBTAIN_USER_DATA;
66                   }
67                   homes.vote.findByPollAndUser(pollEJB, getPoster().getUser());
68                   return TYPE_ALREADY_VOTED;
69                }
70                catch(ObjectNotFoundException e)
71                {
72                   try
73                   {
74                      homes.vote.create(pollEJB, getPoster().getUser(), getPoster().getIp());
75                      optionEJB.setResult(optionEJB.getResult() + 1);
76                   }
77                   catch (CreateException ce)
78                   {
79                      log.error("Cannot insert vote", e);
80                      return TYPE_CANNOT_INSERT_VOTE;
81                   }
82                   return TYPE_VOTE_CAST;
83                }
84                catch (FinderException e)
85                {
86                   return TYPE_CANNOT_OBTAIN_USER_DATA;
87                }
88             }
89             catch(ObjectNotFoundException e)
90             {
91                return TYPE_NO_VOTE_OPTION;
92             }
93             catch(FinderException e)
94             {
95                return TYPE_COULD_NOT_OBTAIN_VOTE_DATA;
96             }
97          }
98          else
99          {
100             return TYPE_NO_VOTE_OPTION;
101          }
102        */

103       return null;
104    }
105 }
Popular Tags