1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import org.apache.struts.action.*; 11 import org.apache.struts.util.*; 12 import java.util.*; 13 import java.sql.*; 14 import java.net.*; 15 import com.quikj.server.framework.*; 16 import com.quikj.application.communicator.applications.webtalk.model.*; 17 18 22 public class GroupWizardCannedMessageForm extends ActionForm 23 { 24 25 26 private int counter = 0; 27 28 29 private String messageType = "text"; 30 31 32 private String content; 33 34 35 private String description; 36 37 38 private String group; 39 40 41 private String submit; 42 43 44 private ArrayList userGroups = new ArrayList(); 45 46 47 private String domain; 48 49 50 public GroupWizardCannedMessageForm() 51 { 52 } 53 54 public ActionErrors validate(ActionMapping mapping, 55 HttpServletRequest request) 56 { 57 if ((submit.startsWith("Finished") == true) 58 || (submit.startsWith("Cancel") == true)) 59 { 60 return null; 61 } 62 63 ActionErrors errors = new ActionErrors(); 65 try 66 { 67 if ((group == null) || (group.length() == 0)) 68 { 69 errors.add("group", new ActionError( 70 "error.cannedmessage.no.group")); 71 } 72 73 if ((description == null) || (description.length() == 0)) 74 { 75 errors.add("description", new ActionError( 76 "error.cannedmessage.no.description")); 77 } 78 79 if ((content == null) || (content.length() == 0)) 80 { 81 errors.add("content", new ActionError( 82 "error.cannedmessage.no.content")); 83 } 84 85 try 86 { 87 URL url = new URL(content); 88 } 89 catch (MalformedURLException ex) 90 { 91 try 92 { 93 URL url = new URL("http://" + content); 95 } 96 catch (MalformedURLException ex1) 97 { 98 errors.add("content", new ActionError( 99 "error.cannedmessage.invalid.url")); 100 } 101 } 102 103 if (errors.isEmpty() == false) 104 { 105 GroupTable groups = new GroupTable(); 106 Connection c = (Connection) request.getSession().getAttribute( 107 "connection"); 108 109 groups.setConnection(c); 110 ArrayList group_list = groups.list(domain); 111 112 if (group_list != null) 113 { 114 ArrayList list = new ArrayList(); 115 Iterator iter = group_list.iterator(); 116 117 while (iter.hasNext() == true) 118 { 119 String group = (String ) iter.next(); 120 121 if (group.equals(domain) == false) 122 { 123 list.add(new LabelValueBean(group, URLEncoder 124 .encode(group, "UTF-8"))); 125 } 126 else 127 { 128 list.add(0, new LabelValueBean( 129 "All of this customer's groups", URLEncoder 130 .encode(group, "UTF-8"))); 131 } 132 } 133 134 setUserGroups(list); 135 } 136 } 137 } 138 catch (Exception e) 139 { 140 errors.add("content", new ActionError("error.internal.error")); 141 } 142 return errors; 143 } 144 145 151 public int getCounter() 152 { 153 return this.counter; 154 } 155 156 163 public void setCounter(int counter) 164 { 165 this.counter = counter; 166 } 167 168 174 public String getMessageType() 175 { 176 return this.messageType; 177 } 178 179 186 public void setMessageType(String messageType) 187 { 188 this.messageType = messageType.trim(); 189 } 190 191 197 public String getContent() 198 { 199 return this.content; 200 } 201 202 209 public void setContent(String content) 210 { 211 this.content = content.trim(); 212 } 213 214 public String getFormattedContent() 215 { 216 if (messageType.equals("text") == true) 217 { 218 return ("<text>" + AceXMLHelper.encodeXMLString(content) + "</text>"); 219 } 220 else if (messageType.equals("url") == true) 221 { 222 String loc = content; 223 try 224 { 225 URL url = new URL(content); 226 } 227 catch (MalformedURLException ex) 228 { 229 loc = "http://" + content; 231 } 232 233 return ("<href>" + loc + "</href>"); 234 } 235 236 return ""; 237 } 238 239 245 public String getDescription() 246 { 247 return this.description; 248 } 249 250 257 public void setDescription(String description) 258 { 259 this.description = description.trim(); 260 } 261 262 268 public String getGroup() 269 { 270 return this.group; 271 } 272 273 280 public void setGroup(String group) 281 { 282 this.group = group.trim(); 283 } 284 285 291 public String getSubmit() 292 { 293 return this.submit; 294 } 295 296 303 public void setSubmit(String submit) 304 { 305 this.submit = submit.trim(); 306 } 307 308 314 public ArrayList getUserGroups() 315 { 316 return this.userGroups; 317 } 318 319 326 public void setUserGroups(ArrayList userGroups) 327 { 328 this.userGroups = userGroups; 329 } 330 331 337 public String getDomain() 338 { 339 return this.domain; 340 } 341 342 349 public void setDomain(String domain) 350 { 351 this.domain = domain.trim(); 352 } 353 354 } | Popular Tags |