KickJava   Java API By Example, From Geeks To Geeks.

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


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.forums.model.Category;
18 import org.jboss.portlet.JBossActionRequest;
19 import org.jboss.portlet.JBossActionResponse;
20
21 /**
22  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
23  * @author <a HREF="mailto:theute@jboss.org">Thomas Heute</a>
24  * @version $Revision: 1.2 $
25  */

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

51    public Result execute()
52    {
53       if ("".equals(name))
54       {
55          return TYPE_CANNOT_CREATE_FORUM_INVALID_NAME;
56       }
57
58       if (category == null)
59       {
60          return TYPE_CANNOT_CREATE_FORUM_INVALID_CATEGORY;
61       }
62
63       try
64       {
65          module.createForum(category, name, description);
66          return TYPE_FORUM_CREATED;
67       }
68       catch (ModuleException e)
69       {
70          log.error("", e);
71          return TYPE_CANNOT_CREATE_FORUM_INSERTION_FAILED;
72       }
73    }
74 }
Popular Tags