1 53 54 106 107 package com.Yasna.forum.tags; 108 109 import java.io.*; 110 import javax.servlet.*; 111 import javax.servlet.jsp.*; 112 import javax.servlet.jsp.tagext.*; 113 import javax.servlet.http.*; 114 import com.Yasna.forum.*; 115 import com.Yasna.forum.Exceptions.RapidPostingException; 116 import com.Yasna.forum.Exceptions.UserBlackListedException; 117 import com.Yasna.forum.util.ClientIP; 118 import com.Yasna.forum.tags.*; 119 120 141 142 public class PreviewMessageTag extends TagSupport implements GetNestedMessage 143 { 144 private YazdState js = null; 145 private YazdRequest jr = null; 146 private String subject; 147 private String body; 148 private ForumMessage message; 149 150 156 public final int doStartTag() throws JspException 157 { 158 String IP =""; 159 String localIP=""; 160 js = (YazdState)pageContext.getAttribute("yazdUserState", 162 PageContext.SESSION_SCOPE); 163 if( js == null ) 164 throw new JspException("Yazd preview_message tag, could not find yazdUserState"); 165 166 jr = (YazdRequest)pageContext.getAttribute("yazdUserRequest", 168 PageContext.REQUEST_SCOPE); 169 if( jr == null ) 170 throw new JspException("Could not find request"); 171 172 ServletRequest req = pageContext.getRequest(); 174 IP=req.getRemoteAddr(); 175 localIP = req.getParameter("localip"); 176 subject = req.getParameter("subject"); 177 if( subject == null || subject.length() == 0) 178 subject = " "; 179 body = req.getParameter("body"); 180 if( body == null || body.length() == 0 ) 181 body = " "; 182 183 Forum cf = jr.getForum(); 184 User user = null; 185 186 try { 187 user = jr.getProfileManager().getUser( js.getAuthorization().getUserID() ); 188 } catch( UserNotFoundException e ) { 189 return SKIP_BODY; 190 } 191 try { 192 ClientIP clientip = new ClientIP(localIP,IP); 193 ForumMessage nm = cf.createMessage( user,clientip ); 194 nm.setSubject( subject ); 195 nm.setBody( body.toString() ); 196 message = cf.applyFilters(nm); 197 } catch( UnauthorizedException ue ) { 198 return SKIP_BODY; 199 } catch( RapidPostingException e){ 200 return SKIP_BODY; 201 } catch( UserBlackListedException e){ 202 return SKIP_BODY; 203 } 204 205 return EVAL_BODY_INCLUDE; 206 } 207 208 213 public final ForumMessage getMessage() 214 { 215 return message; 216 } 217 218 224 public final int getTotal() 225 { 226 return 0; 227 } 228 229 } 230 | Popular Tags |