KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.jboss.portal.common.command.result.Result;
14 import org.jboss.portal.core.modules.ModuleException;
15 import org.jboss.portlet.forums.ForumsModule;
16 import org.jboss.portlet.forums.commands.AbstractCommand;
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  * @author <a HREF="mailto:theute@jboss.org">Thomas Heute</a>
23  * @version $Revision: 1.2 $
24  */

25 public class CreateCategoryCommand
26    extends AbstractCommand
27 {
28    /** DOCUMENT_ME */
29    public String JavaDoc name;
30
31    /** DOCUMENT_ME */
32    public ForumsModule module;
33
34    public CreateCategoryCommand(JBossActionRequest request, JBossActionResponse response)
35    {
36       super(request, response);
37    }
38
39    /**
40     * DOCUMENT_ME
41     *
42     * @return DOCUMENT_ME
43     */

44    public Result execute()
45    {
46       if (name == null)
47       {
48          return TYPE_CANNOT_CREATE_CATEGORY_INVALID_NAME;
49       }
50
51       try
52       {
53          module.createCategory(name);
54          return TYPE_CATEGORY_CREATED;
55       }
56       catch (ModuleException e)
57       {
58          log.error("", e);
59          return TYPE_CANNOT_CREATE_CATEGORY_INSERTION_FAILED;
60       }
61    }
62 }
Popular Tags