KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portlet > forums > commands > admin > OrderForumCommand


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.admin;
12
13 import java.util.Iterator JavaDoc;
14
15 import org.jboss.portal.common.command.result.Result;
16 import org.jboss.portal.core.modules.ModuleException;
17 import org.jboss.portlet.forums.ForumsModule;
18 import org.jboss.portlet.forums.commands.AbstractCommand;
19 import org.jboss.portlet.forums.model.Forum;
20 import org.jboss.portlet.JBossActionRequest;
21 import org.jboss.portlet.JBossActionResponse;
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.4 $
27  */

28 public class OrderForumCommand
29    extends AbstractCommand
30 {
31    /** DOCUMENT_ME */
32    public int move;
33
34    /** DOCUMENT_ME */
35    public Forum forum;
36
37    /** DOCUMENT_ME */
38    public ForumsModule module;
39
40    public OrderForumCommand(JBossActionRequest request, JBossActionResponse response)
41    {
42       super(request, response);
43    }
44
45    /**
46     * DOCUMENT_ME
47     *
48     * @return DOCUMENT_ME
49     */

50    public Result execute()
51    {
52       try
53       {
54          forum.setOrder(forum.getOrder() + move);
55          Iterator JavaDoc forums = module.findForumsByCategoryID(forum.getCategory().getID()).iterator();
56          for (int index = 10; forums.hasNext(); index += 10)
57          {
58             forum = (Forum) forums.next();
59             forum.setOrder(index);
60          }
61
62          return TYPE_FORUMS_ORDERED;
63       }
64       catch (ModuleException e)
65       {
66          log.error("", e);
67          return TYPE_CANNOT_ORDER_FORUMS;
68       }
69    }
70 }
Popular Tags