1 6 7 package com.quikj.application.communicator.applications.webtalk.controller; 8 9 import com.quikj.server.framework.*; 10 11 import javax.servlet.http.HttpServletRequest ; 12 import org.apache.struts.action.*; 13 import java.util.*; 14 15 19 public class FeatureOperatorManagementForm extends ActionForm 20 { 21 22 23 private String name; 24 25 26 private String submit = "Find"; 27 28 29 private boolean active = false; 30 31 32 private int maxOperators; 33 34 35 private int maxSessions; 36 37 38 private int maxQueueSize; 39 40 41 private boolean proactive = false; 42 43 44 public FeatureOperatorManagementForm() 45 { 46 } 47 48 52 public String getName() 53 { 54 return this.name; 55 } 56 57 61 public void setName(String name) 62 { 63 this.name = name.trim(); 64 } 65 66 70 public String getSubmit() 71 { 72 return this.submit; 73 } 74 75 79 public void setSubmit(String submit) 80 { 81 this.submit = submit; 82 } 83 84 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 85 { 86 ActionErrors errors = new ActionErrors(); 88 89 if ((name == null) || (name.length() == 0)) 90 { 91 errors.add("name", new ActionError("error.feature.no.name")); 92 } 93 94 if (DataCheckUtility.followsTableIdRules(name) == false) 95 { 96 errors.add("name", new ActionError("error.feature.invalid.id")); 97 } 98 if ((submit.equals("Create") == true) || (submit.equals("Modify") == true)) 100 { 101 if (maxOperators <= 0) 102 { 103 errors.add("maxOperators", new ActionError("error.feature.operator.maxoperators")); 104 } 105 106 if (maxSessions <= 0) 107 { 108 errors.add("maxSessions", new ActionError("error.feature.operator.maxsessions")); 109 } 110 111 if (maxQueueSize <= 0) 112 { 113 errors.add("maxQueueSize", new ActionError("error.feature.operator.maxqueuesize")); 114 } 115 } 116 117 return errors; 118 } 119 120 public void reset() 121 { 122 name = null; 123 submit = "Find"; 124 active = false; 125 126 maxOperators = 0; 127 maxSessions = 0; 128 maxQueueSize = 0; 129 proactive = false; 130 } 131 132 136 public boolean isActive() 137 { 138 return this.active; 139 } 140 141 145 public void setActive(boolean active) 146 { 147 this.active = active; 148 } 149 150 154 public int getMaxOperators() 155 { 156 return this.maxOperators; 157 } 158 159 163 public void setMaxOperators(int maxOperators) 164 { 165 this.maxOperators = maxOperators; 166 } 167 168 172 public int getMaxSessions() 173 { 174 return this.maxSessions; 175 } 176 177 181 public void setMaxSessions(int maxSessions) 182 { 183 this.maxSessions = maxSessions; 184 } 185 186 190 public int getMaxQueueSize() 191 { 192 return this.maxQueueSize; 193 } 194 195 199 public void setMaxQueueSize(int maxQueueSize) 200 { 201 this.maxQueueSize = maxQueueSize; 202 } 203 204 208 public boolean isProactive() 209 { 210 return this.proactive; 211 } 212 213 217 public void setProactive(boolean proactive) 218 { 219 this.proactive = proactive; 220 } 221 222 223 public HashMap getParamsList() 224 { 225 HashMap map = new HashMap(4); 226 227 map.put("max-sessions", String.valueOf(getMaxSessions())); 228 map.put("max-queue-size", String.valueOf(getMaxQueueSize())); 229 map.put("max-operators", String.valueOf(getMaxOperators())); 230 231 if (isProactive() == true) 232 { 233 map.put("proactive-monitoring", "yes"); 234 } 235 else 236 { 237 map.put("proactive-monitoring", "no"); 238 } 239 240 241 return map; 242 } 243 244 public void setParamsList(HashMap map) 245 { 246 String value; 247 248 value = (String )map.get("max-sessions"); 249 if (value != null) 250 { 251 try 252 { 253 setMaxSessions(Integer.parseInt(value)); 254 } 255 catch (NumberFormatException ex) 256 { 257 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 258 "FeatureOperatorManagementForm.setParamsList() -- Non-numeric parm encountered : max-sessions"); 259 } 260 } 261 262 value = (String )map.get("max-queue-size"); 263 if (value != null) 264 { 265 try 266 { 267 setMaxQueueSize(Integer.parseInt(value)); 268 } 269 catch (NumberFormatException ex) 270 { 271 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 272 "FeatureOperatorManagementForm.setParamsList() -- Non-numeric parm encountered : max-queue-size"); 273 } 274 } 275 276 value = (String )map.get("max-operators"); 277 if (value != null) 278 { 279 try 280 { 281 setMaxOperators(Integer.parseInt(value)); 282 } 283 catch (NumberFormatException ex) 284 { 285 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 286 "FeatureOperatorManagementForm.setParamsList() -- Non-numeric parm encountered : max-operators"); 287 } 288 } 289 290 value = (String )map.get("proactive-monitoring"); 291 if (value != null) 292 { 293 if (value.equals("yes") == true) 294 { 295 setProactive(true); 296 } 297 else if (value.equals("no") == true) 298 { 299 setProactive(false); 300 } 301 else 302 { 303 AceLogger.Instance().log(AceLogger.ERROR, AceLogger.SYSTEM_LOG, 304 "FeatureOperatorManagementForm.setParamsList() -- Invalid proactive-monitoring value : " + value); 305 } 306 } 307 308 } 309 310 } 311 | Popular Tags |