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.model.User; 15 import org.jboss.portal.core.modules.ModuleException; 16 import org.jboss.portlet.forums.ForumsModule; 17 import org.jboss.portlet.forums.commands.AbstractCommand; 18 import org.jboss.portlet.forums.commands.ValidationException; 19 import org.jboss.portlet.forums.model.Category; 20 import org.jboss.portlet.forums.model.Forum; 21 import org.jboss.portlet.forums.model.Message; 22 import org.jboss.portlet.forums.model.Poll; 23 import org.jboss.portlet.forums.model.Poster; 24 import org.jboss.portlet.command.ActionCommand; 25 import org.jboss.portlet.JBossActionRequest; 26 import org.jboss.portlet.JBossActionResponse; 27 28 33 public abstract class ForumCommand 34 extends AbstractCommand 35 { 36 37 protected ForumCommand(JBossActionRequest request, JBossActionResponse response) 38 { 39 super(request, response); 40 } 41 42 54 55 56 public int forumId; 57 58 59 public User currentUser; 60 61 62 public Forum forum; 63 64 65 public Category category; 66 67 68 public Poster poster; 69 70 71 public Message message; 72 73 74 public Poll poll; 75 76 78 79 public ForumsModule forumsModule; 80 private String category_title; 81 private String forum_name; 82 private int forum_status; 83 84 87 protected void find() 88 { 89 try 90 { 91 forum = forumsModule.findForumByID(new Integer (forumId)); 92 } 93 catch (ModuleException e) 94 { 95 e.printStackTrace(); 96 } 97 98 category = forum.getCategory(); 99 } 100 101 106 protected void prepare() 107 throws ValidationException 108 { 109 find(); 110 category_title = category.getTitle(); 111 forum_status = forum.getStatus(); 112 forum_name = forum.getName(); 113 114 117 151 } 152 153 158 public Result execute() 159 { 160 try 161 { 162 prepare(); 163 return __execute(); 164 } 165 catch (ValidationException e) 166 { 167 return e.getResult(); 168 } 169 } 170 171 176 public abstract int authType(); 177 178 183 protected abstract Result __execute(); 184 185 190 public User currentUser() 191 { 192 return currentUser; 193 } 194 195 200 public void setCurrentUser(User currentUser) 201 { 202 this.currentUser = currentUser; 203 } 204 205 210 public Poster getPoster() 211 { 212 return poster; 213 } 214 215 220 public void setPoster(Poster poster) 221 { 222 this.poster = poster; 223 } 224 225 230 public ForumsModule getModule() 231 { 232 return forumsModule; 233 } 234 235 240 public void setModule(ForumsModule module) 241 { 242 this.forumsModule = module; 243 } 244 } | Popular Tags |