1 11 package org.jboss.portlet.forums.action; 12 13 import org.jboss.portal.core.modules.ModuleException; 14 import org.jboss.portlet.forums.impl.PollImpl; 15 import org.jboss.portlet.forums.model.*; 16 17 import java.util.Collections ; 18 import java.util.List ; 19 20 24 public class EditPostAction 25 extends PostAction 26 { 27 private Message message; 28 private Poster poster; 29 private int postID; 30 private List attachments; 31 private Post post; 32 private Topic topic; 33 private Poll poll; 34 private boolean firstPost; 35 36 public EditPostAction(Message message, 39 Poster poster, 40 int postID, 41 List attachments, 42 Poll poll) 43 { 44 super(ForumAction.REFRESH); 45 this.message = message; 46 this.poster = poster; 47 this.postID = postID; 48 this.attachments = attachments; 49 this.poll = poll; 50 } 51 52 57 public EditPostAction(int postID) 58 { 59 super(ForumAction.INIT); 60 this.message = null; 61 this.poster = null; 62 this.postID = postID; 63 this.poll = new PollImpl(); 64 this.attachments = Collections.EMPTY_LIST; 65 } 66 67 72 public Post getPost() 73 { 74 return post; 75 } 76 77 82 public Topic getTopic() 83 { 84 return topic; 85 } 86 87 92 public Forum getForum() 93 { 94 return getTopic().getForum(); 95 } 96 97 102 public Poster getPoster() 103 { 104 return null; 106 } 107 108 113 public Message getMessage() 114 { 115 return (getMode() == ForumAction.INIT) ? getPost().getMessage() : message; 116 } 117 118 123 public List getAttachments() 124 { 125 return attachments; 126 } 127 128 131 public void init() 132 { 133 System.out.println("EditPostAction.init()"); 134 try 135 { 136 post = module.findPostByID(new Integer (postID)); 137 topic = post.getTopic(); 138 if(topic.getFirstPost().getID().equals(post.getID())) 139 { 140 firstPost = true; 141 } 142 143 Topic topic = post.getTopic(); 144 message.setSubject(topic.getSubject()); 145 } 146 catch(ModuleException e) 147 { 148 e.printStackTrace(); 149 } 150 194 } 195 196 201 public Poll getPoll() 202 { 203 return poll; 204 } 205 206 211 public boolean isFirstPost() 212 { 213 return firstPost; 214 } 215 } | Popular Tags |