1 11 package org.jboss.portlet.forums.action; 12 13 import java.util.Collections ; 14 import java.util.List ; 15 16 import org.jboss.portal.core.modules.ModuleException; 17 import org.jboss.portlet.forums.model.Forum; 18 import org.jboss.portlet.forums.model.Message; 19 import org.jboss.portlet.forums.model.Post; 20 import org.jboss.portlet.forums.model.Poster; 21 import org.jboss.portlet.forums.model.Topic; 22 23 28 public class ReplyAction 29 extends PostAction 30 { 31 private boolean quote; 32 private int postId; 33 private Message message; 34 private Poster poster; 35 private List attachments; 36 private Post post; 37 private Topic topic; 38 private boolean firstPost = false; 39 40 48 public ReplyAction(int postId, 49 Message message, 50 Poster poster, 51 List attachments) 52 { 53 super(REFRESH); 54 this.postId = postId; 55 this.message = message; 56 this.poster = poster; 57 this.attachments = attachments; 58 } 59 60 68 public ReplyAction(boolean quote, 69 int postId, 70 Message message, 71 Poster poster) 72 { 73 super(INIT); 74 this.quote = quote; 75 this.postId = postId; 76 this.message = message; 77 this.poster = poster; 78 this.attachments = Collections.EMPTY_LIST; 79 } 80 81 86 public Post getPost() 87 { 88 return post; 89 } 90 91 96 public Topic getTopic() 97 { 98 return getPost().getTopic(); 99 } 100 101 106 public Forum getForum() 107 { 108 return getTopic().getForum(); 109 } 110 111 116 public Poster getPoster() 117 { 118 return poster; 119 } 120 121 126 public Message getMessage() 127 { 128 return message; 129 } 130 131 136 public List getAttachments() 137 { 138 return attachments; 139 } 140 141 144 public void init() 145 { 146 try 147 { 148 post = module.findPostByID(new Integer (postId)); 149 topic = post.getTopic(); 150 if (topic.getFirstPost().getID().equals(post.getID())) 151 { 152 firstPost = true; 153 } 154 155 if (getMode() == ForumAction.INIT) 157 { 158 Topic topic = post.getTopic(); 166 message.setSubject(topic.getSubject()); 167 168 if (!message.getSubject().startsWith("Re:")) 170 { 171 message.setSubject("Re: " + message.getSubject()); 172 } 173 174 String signature = getPoster().getUser().getSignature(); 175 if ((signature != null) && (signature.trim().length() != 0)) 176 { 177 message.setSignatureEnabled(true); 178 } 179 } 180 } 181 catch (ModuleException e) 182 { 183 e.printStackTrace(); 184 } 185 } 186 187 192 public boolean isFirstPost() 193 { 194 return firstPost; 195 } 196 } | Popular Tags |