KickJava   Java API By Example, From Geeks To Geeks.

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


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.Category;
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  * @version $Revision: 1.3 $
26  */

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

49    public Result execute()
50    {
51       try
52       {
53          category.setOrder(category.getOrder() + move);
54          Iterator JavaDoc categories = module.findCategories().iterator();
55          for (int index = 10; categories.hasNext(); index += 10)
56          {
57             category = (Category) categories.next();
58             category.setOrder(index);
59          }
60
61          return TYPE_CATEGORIES_ORDERED;
62       }
63       catch (ModuleException e)
64       {
65          log.error("", e);
66          return TYPE_CANNOT_ORDER_CATEGORIES;
67       }
68    }
69 }
Popular Tags