1 package com.dotmarketing.portlets.communications.struts; 2 3 import java.text.ParseException ; 4 import java.text.SimpleDateFormat ; 5 6 import javax.servlet.http.HttpServletRequest ; 7 8 import org.apache.struts.action.ActionErrors; 9 import org.apache.struts.action.ActionMapping; 10 import org.apache.struts.action.ActionMessage; 11 import org.apache.struts.action.ActionMessages; 12 import org.apache.struts.validator.ValidatorForm; 13 14 import com.dotmarketing.portlets.categories.factories.CategoryFactory; 15 import com.dotmarketing.portlets.categories.model.Category; 16 import com.dotmarketing.util.Logger; 17 import com.dotmarketing.util.UtilMethods; 18 import com.liferay.portal.jaas.ext.pramati.PortalUserManager; 19 import com.liferay.portal.util.Constants; 20 import com.liferay.portal.util.PortalUtil; 21 import com.liferay.util.servlet.SessionMessages; 22 23 28 public class CommunicationsForm extends ValidatorForm { 29 30 private static final long serialVersionUID = 1L; 31 private String title; 32 private long trackBackLinkInode; 33 private String communicationType; 34 private String fromEmail; 35 private String fromName; 36 private String emailSubject; 37 private long htmlPage; 38 private String selectedhtmlPage; 39 private String textMessage; 40 private java.util.Date modDate; 41 private String modifiedBy; 42 private String webModDate; 43 private long inode; 44 private long identifier; 45 private String type; 46 private String externalCommunicationIdentifier; 47 48 52 public long getIdentifier() { 53 return identifier; 54 } 55 56 60 public void setIdentifier(long identifier) { 61 this.identifier = identifier; 62 } 63 64 68 public long getInode() { 69 return inode; 70 } 71 72 76 public void setInode(long inode) { 77 this.inode = inode; 78 } 79 80 84 public java.util.Date getModDate() { 85 return modDate; 86 } 87 88 92 public void setModDate(java.util.Date modDate) { 93 this.modDate = modDate; 94 } 95 96 100 public String getModifiedBy() { 101 return modifiedBy; 102 } 103 104 108 public void setModifiedBy(String modifiedBy) { 109 this.modifiedBy = modifiedBy; 110 } 111 112 116 public String getEmailSubject() { 117 return emailSubject; 118 } 119 120 124 public void setEmailSubject(String emailSubject) { 125 this.emailSubject = emailSubject; 126 } 127 128 132 public String getFromEmail() { 133 return fromEmail; 134 } 135 136 140 public void setFromEmail(String fromEmail) { 141 this.fromEmail = fromEmail; 142 } 143 144 148 public String getFromName() { 149 return fromName; 150 } 151 152 156 public void setFromName(String fromName) { 157 this.fromName = fromName; 158 } 159 160 164 public long getHtmlPage() { 165 return htmlPage; 166 } 167 168 172 public void setHtmlPage(long htmlPageInode) { 173 this.htmlPage = htmlPageInode; 174 } 175 176 180 public String getTextMessage() { 181 return textMessage; 182 } 183 184 188 public void setTextMessage(String textMessage) { 189 this.textMessage = textMessage; 190 } 191 192 196 public String getTitle() { 197 return title; 198 } 199 200 204 public void setTitle(String title) { 205 this.title = title; 206 } 207 208 212 public long getTrackBackLinkInode() { 213 return trackBackLinkInode; 214 } 215 216 220 public void setTrackBackLinkInode(long trackBackLinkInode) { 221 this.trackBackLinkInode = trackBackLinkInode; 222 } 223 224 228 public String getCommunicationType() { 229 return communicationType; 230 } 231 232 235 public void setCommunicationType(String communicationType) { 236 this.communicationType = communicationType; 237 this.type = communicationType; 238 } 239 240 244 public String getWebModDate() { 245 return UtilMethods.dateToHTMLDate(modDate) + " " + UtilMethods.dateToHTMLTime(modDate); 246 } 247 248 252 public void setWebModDate(String webModDate) { 253 254 this.webModDate = webModDate; 255 try { 256 Logger.debug(this, "Setting Web Create Date " + webModDate); 257 this.modDate = new SimpleDateFormat ("MM/dd/yyyy HH:mm").parse(webModDate); 258 Logger.debug(this, "Setting Create Date " + this.webModDate); 259 } catch(ParseException ex) { 260 } 261 } 262 263 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 264 if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.ADD)) { 265 ActionErrors ae = super.validate(mapping, request); 267 268 Logger.debug(this, "action errors: " + ae); 269 if(communicationType.equals("email")){ 270 if(!UtilMethods.isSet(title)){ 271 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTitle")); 272 273 } 274 if(!UtilMethods.isSet(fromName)){ 275 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsFromName")); 276 277 } 278 if(!UtilMethods.isSet(fromEmail)){ 279 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsFromEmail")); 280 281 } 282 if(!UtilMethods.isSet(emailSubject)){ 283 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsSubject")); 284 285 } 286 if(!UtilMethods.isSet(selectedhtmlPage) && !UtilMethods.isSet(textMessage)){ 287 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTextMessage")); 288 289 } 290 291 return ae; 292 293 }else { 294 if(!UtilMethods.isSet(title)){ 295 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTitle")); 296 297 } 298 if(trackBackLinkInode == 0){ 299 ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTrackBackLinkInode")); 300 301 } 302 303 return ae; 304 } 305 306 } 307 308 return null; 309 } 310 311 315 public String getSelectedhtmlPage() { 316 return selectedhtmlPage; 317 } 318 319 323 public void setSelectedhtmlPage(String selectedHtmlPage) { 324 this.selectedhtmlPage = selectedHtmlPage; 325 } 326 327 331 public String getType() { 332 return type; 333 } 334 335 338 public void setType(String type) { 339 this.type = type; 340 } 341 342 346 public String getExternalCommunicationIdentifier() { 347 return externalCommunicationIdentifier; 348 } 349 350 354 public void setExternalCommunicationIdentifier( 355 String externalCommunicationIdentifier) { 356 this.externalCommunicationIdentifier = externalCommunicationIdentifier; 357 } 358 359 } 360 | Popular Tags |