1 11 package org.jboss.portlet.forums.commands.post; 12 13 import org.jboss.portal.common.command.result.Result; 14 import org.jboss.portal.core.modules.ModuleException; 15 import org.jboss.portlet.JBossActionRequest; 16 import org.jboss.portlet.JBossActionResponse; 17 import org.jboss.portlet.forums.ForumsConstants; 18 import org.jboss.portlet.forums.commands.ValidationException; 19 import org.jboss.portlet.forums.model.Post; 20 21 import java.util.Date ; 22 23 28 public final class NewTopicCommand 29 extends ForumCommand 30 { 31 34 public Date current_time; 35 36 39 public int topic_type; 40 41 44 public boolean notify; 45 46 49 public Post post; 50 51 public NewTopicCommand(JBossActionRequest request, JBossActionResponse response) 52 { 53 super(request, response); 54 } 55 56 61 public int authType() 62 { 63 return ForumsConstants.TOPIC_TYPE_TO_AUTH_TYPE[topic_type]; 64 } 65 66 71 protected void prepare() 72 throws ValidationException 73 { 74 super.prepare(); 75 PostTools.validate(message); 76 77 } 79 80 85 protected Result __execute() 86 { 87 try 88 { 89 post = forumsModule.createTopic(forum, 90 message, 91 new Date (), 92 poster, 93 topic_type); 94 forumsModule.createWatch(poster, post.getTopic()); 95 poster.incrementPostCount(); 96 } 97 catch(ModuleException e) 98 { 99 e.printStackTrace(); 101 } 102 103 153 return TYPE_NEW_TOPIC_POSTED; 154 } 155 } | Popular Tags |