KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > host > HostForm


1 /*
2  * Copyright 2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.webapp.admin.host;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import org.apache.struts.action.ActionError;
22 import org.apache.struts.action.ActionErrors;
23 import org.apache.struts.action.ActionForm;
24 import org.apache.struts.action.ActionMapping;
25 import java.util.List JavaDoc;
26
27 /**
28  * Form bean for the host page.
29  *
30  * @author Manveen Kaur
31  * @version $Revision: 1.10 $ $Date: 2004/06/28 02:14:51 $
32  */

33
34 public final class HostForm extends ActionForm {
35
36     // ----------------------------------------------------- Instance Variables
37

38     /**
39      * The administrative action represented by this form.
40      */

41     private String JavaDoc adminAction = "Edit";
42
43     /**
44      * The object name of this Host bean refers to.
45      */

46     private String JavaDoc objectName = null;
47
48     /**
49      * The text for the node label. This is of the form 'Host(name)'
50      * and is picked up from the node of the tree that is clicked on.
51      */

52     private String JavaDoc nodeLabel = null;
53
54     /**
55      * The text for the hostName.
56      */

57     private String JavaDoc hostName = null;
58
59     /**
60      * The object name of the service this host belongs to.
61      */

62     private String JavaDoc serviceName = null;
63
64     /**
65      * The directory for the appBase.
66      */

67     private String JavaDoc appBase = null;
68
69     /**
70      * Boolean for autoDeploy.
71      */

72     private String JavaDoc autoDeploy = "true";
73
74     /**
75      * Boolean for deployXML.
76      */

77     private String JavaDoc deployXML = "true";
78
79     /**
80      * Boolean for deployOnStartup.
81      */

82     private String JavaDoc deployOnStartup = "true";
83     
84     /**
85      * Boolean for unpack WARs.
86      */

87     private String JavaDoc unpackWARs = "false";
88
89     /**
90      * The text for the port. -- TBD
91      */

92     private String JavaDoc findAliases = null;
93
94     /*
95      * Represent boolean (true, false) values for unpackWARs etc.
96      */

97     private List JavaDoc booleanVals = null;
98
99     /*
100      * Represent aliases as a List.
101      */

102     private List JavaDoc aliasVals = null;
103
104     /**
105      * Boolean for xmlNamespaceAware.
106      */

107     private String JavaDoc xmlNamespaceAware = "false";
108
109     /**
110      * Boolean for xmlValidation.
111      */

112     private String JavaDoc xmlValidation = "false";
113
114     // ------------------------------------------------------------- Properties
115

116     /**
117      * Return the administrative action represented by this form.
118      */

119     public String JavaDoc getAdminAction() {
120
121         return this.adminAction;
122
123     }
124
125
126     /**
127      * Set the administrative action represented by this form.
128      */

129     public void setAdminAction(String JavaDoc adminAction) {
130
131         this.adminAction = adminAction;
132
133     }
134
135     /**
136      * Return the object name of the Host this bean refers to.
137      */

138     public String JavaDoc getObjectName() {
139
140         return this.objectName;
141
142     }
143
144
145     /**
146      * Set the object name of the Host this bean refers to.
147      */

148     public void setObjectName(String JavaDoc objectName) {
149
150         this.objectName = objectName;
151
152     }
153     
154
155     /**
156      * Return the object name of the service this host belongs to.
157      */

158     public String JavaDoc getServiceName() {
159
160         return this.serviceName;
161
162     }
163
164
165     /**
166      * Set the object name of the Service this host belongs to.
167      */

168     public void setServiceName(String JavaDoc serviceName) {
169
170         this.serviceName = serviceName;
171
172     }
173
174     /**
175      * Return the label of the node that was clicked.
176      */

177     public String JavaDoc getNodeLabel() {
178
179         return this.nodeLabel;
180
181     }
182
183     /**
184      * Set the node label.
185      */

186     public void setNodeLabel(String JavaDoc nodeLabel) {
187
188         this.nodeLabel = nodeLabel;
189
190     }
191
192     /**
193      * Return the host name.
194      */

195     public String JavaDoc getHostName() {
196
197         return this.hostName;
198
199     }
200
201     /**
202      * Set the host name.
203      */

204     public void setHostName(String JavaDoc hostName) {
205
206         this.hostName = hostName;
207
208     }
209
210     /**
211      * Return the appBase.
212      */

213     public String JavaDoc getAppBase() {
214
215         return this.appBase;
216
217     }
218     
219     /**
220      * Return the autoDeploy.
221      */

222     public String JavaDoc getAutoDeploy() {
223         
224         return this.autoDeploy;
225         
226     }
227     
228     /**
229      * Set the autoDeploy.
230      */

231     
232     public void setAutoDeploy(String JavaDoc autoDeploy) {
233         
234         this.autoDeploy = autoDeploy;
235         
236     }
237
238     /**
239      * Return the deployXML.
240      */

241     public String JavaDoc getDeployXML() {
242         
243         return this.deployXML;
244         
245     }
246     
247     /**
248      * Set the deployXML.
249      */

250     
251     public void setDeployXML(String JavaDoc deployXML) {
252         
253         this.deployXML = deployXML;
254         
255     }
256
257     /**
258      * Return the deployOnStartup.
259      */

260     public String JavaDoc getDeployOnStartup() {
261         
262         return this.deployOnStartup;
263         
264     }
265     
266     /**
267      * Set the deployOnStartup.
268      */

269     
270     public void setDeployOnStartup(String JavaDoc deployOnStartup) {
271         
272         this.deployOnStartup = deployOnStartup;
273         
274     }
275
276     /**
277      * Set the appBase.
278      */

279
280     public void setAppBase(String JavaDoc appBase) {
281
282         this.appBase = appBase;
283
284     }
285
286     /**
287      * Return the unpackWARs.
288      */

289     public String JavaDoc getUnpackWARs() {
290
291         return this.unpackWARs;
292
293     }
294
295     /**
296      * Set the unpackWARs.
297      */

298
299     public void setUnpackWARs(String JavaDoc unpackWARs) {
300
301         this.unpackWARs = unpackWARs;
302
303     }
304
305     /**
306      * Return the booleanVals.
307      */

308     public List JavaDoc getBooleanVals() {
309
310         return this.booleanVals;
311
312     }
313
314     /**
315      * Set the booleanVals.
316      */

317     public void setBooleanVals(List JavaDoc booleanVals) {
318
319         this.booleanVals = booleanVals;
320
321     }
322
323     /**
324      * Return the List of alias Vals.
325      */

326     public List JavaDoc getAliasVals() {
327
328         return this.aliasVals;
329
330     }
331
332     /**
333      * Set the alias Vals.
334      */

335     public void setAliasVals(List JavaDoc aliasVals) {
336
337         this.aliasVals = aliasVals;
338
339     }
340
341     /**
342      * Return the xmlNamespaceAware.
343      */

344     public String JavaDoc getXmlNamespaceAware() {
345
346         return this.xmlNamespaceAware;
347
348     }
349
350     /**
351      * Set the xmlNamespaceAware.
352      */

353
354     public void setXmlNamespaceAware(String JavaDoc xmlNamespaceAware) {
355
356         this.xmlNamespaceAware = xmlNamespaceAware;
357
358     }
359
360     /**
361      * Return the xmlValidation.
362      */

363     public String JavaDoc getXmlValidation() {
364
365         return this.xmlValidation;
366
367     }
368
369     /**
370      * Set the xmlValidation.
371      */

372
373     public void setXmlValidation(String JavaDoc xmlValidation) {
374
375         this.xmlValidation = xmlValidation;
376
377     }
378
379     // --------------------------------------------------------- Public Methods
380

381     /**
382      * Reset all properties to their default values.
383      *
384      * @param mapping The mapping used to select this instance
385      * @param request The servlet request we are processing
386      */

387     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
388
389         this.objectName = null;
390         this.serviceName = null;
391         this.hostName = null;
392         this.appBase = null;
393         this.autoDeploy = "true";
394         this.deployXML = "true";
395         this.deployOnStartup = "true";
396         this.unpackWARs = "true";
397
398     }
399
400      /**
401      * Render this object as a String.
402      */

403     public String JavaDoc toString() {
404
405         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("HostForm[adminAction=");
406         sb.append(adminAction);
407         sb.append(",appBase=");
408         sb.append(appBase);
409         sb.append(",autoDeploy=");
410         sb.append(autoDeploy);
411         sb.append(",deployXML=");
412         sb.append(deployXML);
413         sb.append(",deployOnStartup=");
414         sb.append(deployOnStartup);
415         sb.append(",unpackWARs=");
416         sb.append(unpackWARs);
417         sb.append("',objectName='");
418         sb.append(objectName);
419         sb.append("',hostName=");
420         sb.append(hostName);
421         sb.append("',serviceName=");
422         sb.append(serviceName);
423         sb.append("]");
424         return (sb.toString());
425
426     }
427
428     /**
429      * Validate the properties that have been set from this HTTP request,
430      * and return an <code>ActionErrors</code> object that encapsulates any
431      * validation errors that have been found. If no errors are found, return
432      * <code>null</code> or an <code>ActionErrors</code> object with no
433      * recorded error messages.
434      *
435      * @param mapping The mapping used to select this instance
436      * @param request The servlet request we are processing
437      */

438
439     public ActionErrors validate(ActionMapping mapping,
440     HttpServletRequest JavaDoc request) {
441
442         ActionErrors errors = new ActionErrors();
443
444         String JavaDoc submit = request.getParameter("submit");
445
446         // front end validation when save is clicked.
447
//if (submit != null) {
448

449             // hostName cannot be null
450
if ((hostName== null) || (hostName.length() < 1)) {
451                 errors.add("hostName", new ActionError("error.hostName.required"));
452             }
453
454             // appBase cannot be null
455
if ((appBase == null) || (appBase.length() < 1)) {
456                 errors.add("appBase", new ActionError("error.appBase.required"));
457             }
458
459         //}
460
return errors;
461
462     }
463
464 }
465
Popular Tags