KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > communicator > applications > webtalk > controller > FeatureOperatorManagementForm


1 /*
2  * FeatureManagementForm.java
3  *
4  * Form Bean for Operator feature
5  */

6
7 package com.quikj.application.communicator.applications.webtalk.controller;
8
9 import com.quikj.server.framework.*;
10
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12 import org.apache.struts.action.*;
13 import java.util.*;
14
15 /**
16  *
17  * @author bhm
18  */

19 public class FeatureOperatorManagementForm extends ActionForm
20 {
21     
22     /** Holds value of property name. */
23     private String JavaDoc name;
24     
25     /** Holds value of property submit. */
26     private String JavaDoc submit = "Find";
27     
28     /** Holds value of property active. */
29     private boolean active = false;
30     
31     /** Holds value of property maxOperators. */
32     private int maxOperators;
33     
34     /** Holds value of property maxSessions. */
35     private int maxSessions;
36     
37     /** Holds value of property maxQueueSize. */
38     private int maxQueueSize;
39     
40     /** Holds value of property proactive. */
41     private boolean proactive = false;
42     
43     /** Creates a new instance of GroupManagementForm */
44     public FeatureOperatorManagementForm()
45     {
46     }
47     
48     /** Getter for property name.
49      * @return Value of property name.
50      *
51      */

52     public String JavaDoc getName()
53     {
54         return this.name;
55     }
56     
57     /** Setter for property name.
58      * @param name New value of property name.
59      *
60      */

61     public void setName(String JavaDoc name)
62     {
63         this.name = name.trim();
64     }
65     
66     /** Getter for property submit.
67      * @return Value of property submit.
68      *
69      */

70     public String JavaDoc getSubmit()
71     {
72         return this.submit;
73     }
74     
75     /** Setter for property submit.
76      * @param submit New value of property submit.
77      *
78      */

79     public void setSubmit(String JavaDoc submit)
80     {
81         this.submit = submit;
82     }
83     
84     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request)
85     {
86         // Check for mandatory data
87
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         // general checks for create/modify
99
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     /** Getter for property active.
133      * @return Value of property active.
134      *
135      */

136     public boolean isActive()
137     {
138         return this.active;
139     }
140     
141     /** Setter for property active.
142      * @param active New value of property active.
143      *
144      */

145     public void setActive(boolean active)
146     {
147         this.active = active;
148     }
149     
150     /** Getter for property maxOperators.
151      * @return Value of property maxOperators.
152      *
153      */

154     public int getMaxOperators()
155     {
156         return this.maxOperators;
157     }
158     
159     /** Setter for property maxOperators.
160      * @param maxOperators New value of property maxOperators.
161      *
162      */

163     public void setMaxOperators(int maxOperators)
164     {
165         this.maxOperators = maxOperators;
166     }
167     
168     /** Getter for property maxSessions.
169      * @return Value of property maxSessions.
170      *
171      */

172     public int getMaxSessions()
173     {
174         return this.maxSessions;
175     }
176     
177     /** Setter for property maxSessions.
178      * @param maxSessions New value of property maxSessions.
179      *
180      */

181     public void setMaxSessions(int maxSessions)
182     {
183         this.maxSessions = maxSessions;
184     }
185     
186     /** Getter for property maxQueueSize.
187      * @return Value of property maxQueueSize.
188      *
189      */

190     public int getMaxQueueSize()
191     {
192         return this.maxQueueSize;
193     }
194     
195     /** Setter for property maxQueueSize.
196      * @param maxQueueSize New value of property maxQueueSize.
197      *
198      */

199     public void setMaxQueueSize(int maxQueueSize)
200     {
201         this.maxQueueSize = maxQueueSize;
202     }
203     
204     /** Getter for property proactive.
205      * @return Value of property proactive.
206      *
207      */

208     public boolean isProactive()
209     {
210         return this.proactive;
211     }
212     
213     /** Setter for property proactive.
214      * @param proactive New value of property proactive.
215      *
216      */

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 JavaDoc value;
247         
248         value = (String JavaDoc)map.get("max-sessions");
249         if (value != null)
250         {
251             try
252             {
253                 setMaxSessions(Integer.parseInt(value));
254             }
255             catch (NumberFormatException JavaDoc 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 JavaDoc)map.get("max-queue-size");
263         if (value != null)
264         {
265             try
266             {
267                 setMaxQueueSize(Integer.parseInt(value));
268             }
269             catch (NumberFormatException JavaDoc 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 JavaDoc)map.get("max-operators");
277         if (value != null)
278         {
279             try
280             {
281                 setMaxOperators(Integer.parseInt(value));
282             }
283             catch (NumberFormatException JavaDoc 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 JavaDoc)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