KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > connector > ConnectorForm


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.connector;
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.net.InetAddress JavaDoc;
26 import java.util.List JavaDoc;
27
28 /**
29  * Form bean for the connector page.
30  *
31  * @author Manveen Kaur
32  * @version $Revision: 1.11 $ $Date: 2004/06/28 02:14:50 $
33  */

34
35 public final class ConnectorForm extends ActionForm {
36     
37     // ----------------------------------------------------- Instance Variables
38

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

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

47     private String JavaDoc objectName = null;
48     
49     /**
50      * The object name of the service this connector belongs to.
51      */

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

57     private String JavaDoc scheme = null;
58
59     /**
60      * The text for the connector type.
61      * Specifies if it is a CoyoteConnector or AJP13Connector etc.
62      */

63     private String JavaDoc connectorType = null;
64     
65      /**
66      * The text for the node label.
67      */

68     private String JavaDoc nodeLabel = null;
69     
70     /**
71      * The text for the accept Count.
72      */

73     private String JavaDoc acceptCountText = null;
74     
75     /**
76      * The text for the algorithm.
77      */

78     private String JavaDoc algorithm = null;
79     
80     /**
81      * The text for the ciphers.
82      */

83     private String JavaDoc ciphers = null;
84     
85     /**
86      * The text for the Connection Linger.
87      */

88     private String JavaDoc connLingerText = null;
89     
90     /**
91      * The text for the Connection Time Out.
92      */

93     private String JavaDoc connTimeOutText = null;
94     
95     /**
96      * The text for the Connection Upload Time Out.
97      */

98     private String JavaDoc connUploadTimeOutText = null;
99     
100     /**
101      * The text for the buffer size.
102      */

103     private String JavaDoc bufferSizeText = null;
104     
105     /**
106      * The value of disable upload timeout.
107      */

108     private String JavaDoc disableUploadTimeout = "false";
109     
110     /**
111      * The value of enable Lookups.
112      */

113     private String JavaDoc enableLookups = "false";
114     
115     /**
116      * The value of compression.
117      */

118     private String JavaDoc compression = "off";
119     
120     /**
121      * The text for the address.
122      */

123     private String JavaDoc address = null;
124     
125     /**
126      * The text for the minProcessors.
127      */

128     private String JavaDoc minProcessorsText = null;
129     
130     /**
131      * The text for the max Processors.
132      */

133     private String JavaDoc maxProcessorsText = null;
134     
135     /**
136      * The text for the maxKeepAlive.
137      */

138     private String JavaDoc maxKeepAliveText = null;
139     
140     /**
141      * The text for the maxSpare.
142      */

143     private String JavaDoc maxSpare = null;
144     
145     /**
146      * The text for the maxThreads.
147      */

148     private String JavaDoc maxThreads = null;
149     
150     /**
151      * The text for the minSpare.
152      */

153     private String JavaDoc minSpare = null;
154
155     /**
156      * The text for the threadPriority.
157      */

158     private String JavaDoc threadPriority = null;
159     
160     /**
161      * The text for the URIEncoding.
162      */

163     private String JavaDoc uriEncodingText = null;
164     
165     /**
166      * The value of useBodyEncodingForURI.
167      */

168     private String JavaDoc useBodyEncodingForURI = "false";
169
170     /**
171      * The value of allowTrace.
172      */

173     private String JavaDoc allowTrace = "false";
174
175     /**
176      * The text for the port.
177      */

178     private String JavaDoc portText = null;
179     
180     /**
181      * The text for the redirect port.
182      */

183     private String JavaDoc redirectPortText = null;
184     
185     /**
186      * The text for the proxyName.
187      */

188     private String JavaDoc proxyName = null;
189     
190     /**
191      * The text for the proxy Port Number.
192      */

193     private String JavaDoc proxyPortText = null;
194     
195     
196     /**
197      * The text for the connectorName.
198      */

199     private String JavaDoc connectorName = null;
200         
201     /**
202      * Whether client authentication is supported.
203      */

204     private String JavaDoc clientAuthentication = "false";
205         
206     /**
207      * The keyStore Filename.
208      */

209     private String JavaDoc keyStoreFileName = null;
210         
211     /**
212      * The keyStore Password.
213      */

214     private String JavaDoc keyStorePassword = null;
215     
216     /**
217      * The keyStore Type.
218      */

219     private String JavaDoc keyStoreType = null;
220
221     /**
222      * The text for the Ssl Protocol.
223      */

224     private String JavaDoc sslProtocol= null;
225     
226     /*
227      * Represent boolean (true, false) values for enableLookups etc.
228      */

229     private List JavaDoc booleanVals = null;
230
231     /*
232      * Represent supported connector types.
233      */

234     private List JavaDoc connectorTypeVals = null;
235
236     /**
237      * Represent supported clientAuth values.
238      */

239     private List JavaDoc clientAuthVals = null;
240
241     /**
242      * The value of secure.
243      */

244     private String JavaDoc secure = "false";
245     /**
246      * The value of tcpNoDelay.
247      */

248     private String JavaDoc tcpNoDelay = "true";
249     
250     /**
251      * The value of xpoweredBy.
252      */

253     private String JavaDoc xpoweredBy = "false";
254     
255     // ------------------------------------------------------------- Properties
256

257    /**
258      * Return the administrative action represented by this form.
259      */

260     public String JavaDoc getAdminAction() {
261
262         return this.adminAction;
263
264     }
265
266
267     /**
268      * Set the administrative action represented by this form.
269      */

270     public void setAdminAction(String JavaDoc adminAction) {
271
272         this.adminAction = adminAction;
273
274     }
275
276     /**
277      * Return the object name of the Connector this bean refers to.
278      */

279     public String JavaDoc getObjectName() {
280
281         return this.objectName;
282
283     }
284
285
286     /**
287      * Set the object name of the Connector this bean refers to.
288      */

289     public void setObjectName(String JavaDoc objectName) {
290
291         this.objectName = objectName;
292
293     }
294     
295       /**
296      * Return the object name of the service this connector belongs to.
297      */

298     public String JavaDoc getServiceName() {
299
300         return this.serviceName;
301
302     }
303
304
305     /**
306      * Set the object name of the Service this connector belongs to.
307      */

308     public void setServiceName(String JavaDoc serviceName) {
309
310         this.serviceName = serviceName;
311
312     }
313     
314     /**
315      * Return the Scheme.
316      */

317     public String JavaDoc getScheme() {
318         
319         return this.scheme;
320         
321     }
322     
323     /**
324      * Set the Scheme.
325      */

326     public void setScheme(String JavaDoc scheme) {
327         
328         this.scheme = scheme;
329         
330     }
331     
332     /**
333      * Return the Connector type.
334      */

335     public String JavaDoc getConnectorType() {
336         
337         return this.connectorType;
338         
339     }
340     
341     /**
342      * Set the Connector type.
343      */

344     public void setConnectorType(String JavaDoc connectorType) {
345         
346         this.connectorType = connectorType;
347         
348     }
349     
350     /**
351      * Return the label of the node that was clicked.
352      */

353     public String JavaDoc getNodeLabel() {
354         
355         return this.nodeLabel;
356         
357     }
358     
359     /**
360      * Set the node label.
361      */

362     public void setNodeLabel(String JavaDoc nodeLabel) {
363         
364         this.nodeLabel = nodeLabel;
365         
366     }
367     
368     /**
369      * Return the acceptCountText.
370      */

371     public String JavaDoc getAcceptCountText() {
372         
373         return this.acceptCountText;
374         
375     }
376     
377     
378     /**
379      * Set the acceptCountText.
380      */

381     
382     public void setAcceptCountText(String JavaDoc acceptCountText) {
383         
384         this.acceptCountText = acceptCountText;
385         
386     }
387     
388     /**
389      * Return the algorithm.
390      */

391     public String JavaDoc getAlgorithm() {
392         
393         return this.algorithm;
394         
395     }
396     
397     
398     /**
399      * Set the algorithm.
400      */

401     
402     public void setAlgorithm(String JavaDoc algorithm) {
403         
404         this.algorithm = algorithm;
405         
406     }
407     
408     /**
409      * Return the ciphers.
410      */

411     public String JavaDoc getCiphers() {
412         
413         return this.ciphers;
414         
415     }
416     
417     /**
418      * Set the ciphers.
419      */

420     
421     public void setCiphers(String JavaDoc ciphers) {
422         
423         this.ciphers = ciphers;
424         
425     }
426     
427     /**
428      * Return the connLingerText.
429      */

430     public String JavaDoc getConnLingerText() {
431         
432         return this.connLingerText;
433         
434     }
435     
436     /**
437      * Set the connLingerText.
438      */

439     
440     public void setConnLingerText(String JavaDoc connLingerText) {
441         
442         this.connLingerText = connLingerText;
443         
444     }
445     
446     /**
447      * Return the connTimeOutText.
448      */

449     public String JavaDoc getConnTimeOutText() {
450         
451         return this.connTimeOutText;
452         
453     }
454     
455     /**
456      * Set the connTimeOutText.
457      */

458     
459     public void setConnTimeOutText(String JavaDoc connTimeOutText) {
460         
461         this.connTimeOutText = connTimeOutText;
462         
463     }
464        
465     /**
466      * Return the connUploadTimeOutText.
467      */

468     public String JavaDoc getConnUploadTimeOutText() {
469         
470         return this.connUploadTimeOutText;
471         
472     }
473     
474     /**
475      * Set the connUploadTimeOutText.
476      */

477     
478     public void setConnUploadTimeOutText(String JavaDoc connUploadTimeOutText) {
479         
480         this.connUploadTimeOutText = connUploadTimeOutText;
481         
482     }
483     /**
484      * Return the bufferSizeText.
485      */

486     public String JavaDoc getBufferSizeText() {
487         
488         return this.bufferSizeText;
489         
490     }
491     
492     /**
493      * Set the bufferSizeText.
494      */

495     
496     public void setBufferSizeText(String JavaDoc bufferSizeText) {
497         
498         this.bufferSizeText = bufferSizeText;
499         
500     }
501     
502     /**
503      * Return the address.
504      */

505     public String JavaDoc getAddress() {
506         
507         return this.address;
508         
509     }
510     
511     /**
512      * Set the address.
513      */

514     
515     public void setAddress(String JavaDoc address) {
516         
517         this.address = address;
518         
519     }
520     
521     
522     /**
523      * Return the proxy Name.
524      */

525     public String JavaDoc getProxyName() {
526         
527         return this.proxyName;
528         
529     }
530     
531     /**
532      * Set the proxy Name.
533      */

534     
535     public void setProxyName(String JavaDoc proxyName) {
536         
537         this.proxyName = proxyName;
538         
539     }
540     
541     /**
542      * Return the proxy Port NumberText.
543      */

544     public String JavaDoc getProxyPortText() {
545         
546         return this.proxyPortText;
547         
548     }
549     
550     /**
551      * Set the proxy Port NumberText.
552      */

553     
554     public void setProxyPortText(String JavaDoc proxyPortText) {
555         
556         this.proxyPortText = proxyPortText;
557         
558     }
559
560    /**
561      * Return the true/false value of client authentication.
562      */

563     public String JavaDoc getClientAuthentication() {
564
565         return this.clientAuthentication;
566
567     }
568
569
570     /**
571      * Set whether client authentication is supported or not.
572      */

573     public void setClientAuthentication(String JavaDoc clientAuthentication) {
574
575         this.clientAuthentication = clientAuthentication;
576
577     }
578
579     /**
580      * Return the object name of the service this connector belongs to.
581      */

582     public String JavaDoc getKeyStoreFileName() {
583
584         return this.keyStoreFileName;
585
586     }
587
588
589     /**
590      * Set the object name of the Service this connector belongs to.
591      */

592     public void setKeyStoreFileName(String JavaDoc keyStoreFileName) {
593
594         this.keyStoreFileName = keyStoreFileName;
595
596     }
597
598     /**
599      * Return the object name of the service this connector belongs to.
600      */

601     public String JavaDoc getKeyStorePassword() {
602
603         return this.keyStorePassword;
604
605     }
606
607
608     /**
609      * Set the object name of the Service this connector belongs to.
610      */

611     public void setKeyStorePassword(String JavaDoc keyStorePassword) {
612
613         this.keyStorePassword = keyStorePassword;
614
615     }
616
617     /**
618      * Return the keystore type.
619      */

620     public String JavaDoc getKeyStoreType() {
621
622         return this.keyStoreType;
623
624     }
625
626
627     /**
628      * Set the keystore type.
629      */

630     public void setKeyStoreType(String JavaDoc keyStoreType) {
631
632         this.keyStoreType = keyStoreType;
633
634     }
635     /**
636      * Return the sslProtocol
637      */

638     public String JavaDoc getSslProtocol() {
639
640         return this.sslProtocol;
641
642     }
643
644
645     /**
646      * Set the sslProtocol.
647      */

648     public void setSslProtocol(String JavaDoc sslProtocol) {
649
650         this.sslProtocol = sslProtocol;
651
652     }
653     
654     /**
655      * Return the Enable lookup Text.
656      */

657     
658     public String JavaDoc getEnableLookups() {
659         
660         return this.enableLookups;
661         
662     }
663     
664     /**
665      * Set the Enable Lookup Text.
666      */

667     public void setEnableLookups(String JavaDoc enableLookups) {
668         
669         this.enableLookups = enableLookups;
670         
671     }
672     
673     /**
674      * Return the disableUploadTimeout.
675      */

676     
677     public String JavaDoc getDisableUploadTimeout() {
678         
679         return this.disableUploadTimeout;
680         
681     }
682     
683     /**
684      * Set the disableUploadTimeout.
685      */

686     public void setDisableUploadTimeout(String JavaDoc disableUploadTimeout) {
687         
688         this.disableUploadTimeout = disableUploadTimeout;
689         
690     }
691     
692     /**
693      * Return the compression Text.
694      */

695     
696     public String JavaDoc getCompression() {
697         
698         return this.compression;
699         
700     }
701     
702     /**
703      * Set the Compression Text.
704      */

705     public void setCompression(String JavaDoc compression) {
706         
707         this.compression = compression;
708         
709     }
710     
711     /**
712      * Return the booleanVals.
713      */

714     public List JavaDoc getBooleanVals() {
715         
716         return this.booleanVals;
717         
718     }
719     
720     /**
721      * Set the debugVals.
722      */

723     public void setBooleanVals(List JavaDoc booleanVals) {
724         
725         this.booleanVals = booleanVals;
726         
727     }
728
729     /**
730      * Return the clientAuth values.
731      */

732     public List JavaDoc getClientAuthVals() {
733         return clientAuthVals;
734     }
735     /**
736      * Set the clientAuth vaues.
737      */

738     public void setClientAuthVals(List JavaDoc clientAuthVals) {
739         this.clientAuthVals = clientAuthVals;
740     }
741     
742     /**
743      * Return the min Processors Text.
744      */

745     public String JavaDoc getMinProcessorsText() {
746         
747         return this.minProcessorsText;
748         
749     }
750     
751     /**
752      * Set the minProcessors Text.
753      */

754     public void setMinProcessorsText(String JavaDoc minProcessorsText) {
755         
756         this.minProcessorsText = minProcessorsText;
757         
758     }
759     
760     /**
761      * Return the max processors Text.
762      */

763     public String JavaDoc getMaxProcessorsText() {
764         
765         return this.maxProcessorsText;
766         
767     }
768     
769     /**
770      * Set the Max Processors Text.
771      */

772     public void setMaxProcessorsText(String JavaDoc maxProcessorsText) {
773         
774         this.maxProcessorsText = maxProcessorsText;
775         
776     }
777     
778     /**
779      * Return the maxKeepAliveText.
780      */

781     public String JavaDoc getMaxKeepAliveText() {
782         
783         return this.maxKeepAliveText;
784         
785     }
786     
787     /**
788      * Set the maxKeepAliveText.
789      */

790     
791     public void setMaxKeepAliveText(String JavaDoc maxKeepAliveText) {
792         
793         this.maxKeepAliveText = maxKeepAliveText;
794         
795     }
796     
797     /**
798      * Return the maxSpare.
799      */

800     public String JavaDoc getMaxSpare() {
801         
802         return this.maxSpare;
803         
804     }
805     
806     /**
807      * Set the maxSpare.
808      */

809     
810     public void setMaxSpare(String JavaDoc maxSpare) {
811         
812         this.maxSpare = maxSpare;
813         
814     }
815     
816     /**
817      * Return the maxThreads.
818      */

819     public String JavaDoc getMaxThreads() {
820         
821         return this.maxThreads;
822         
823     }
824     
825     /**
826      * Set the maxThreads.
827      */

828     
829     public void setMaxThreads(String JavaDoc maxThreads) {
830         
831         this.maxThreads = maxThreads;
832         
833     }
834     
835     /**
836      * Return the minSpare.
837      */

838     public String JavaDoc getMinSpare() {
839         
840         return this.minSpare;
841         
842     }
843     
844     /**
845      * Set the minSpare.
846      */

847     
848     public void setMinSpare(String JavaDoc minSpare) {
849         
850         this.minSpare = minSpare;
851         
852     }
853
854     /**
855      * Return the threadPriority.
856      */

857     public String JavaDoc getThreadPriority() {
858
859       return this.threadPriority;
860
861     }
862
863     /**
864      * Set the threadPriority.
865      */

866     
867     public void setThreadPriority(String JavaDoc threadPriority) {
868       
869       this.threadPriority = threadPriority;
870     
871     }
872     
873     /**
874      * Return the URIEncoding text.
875      */

876     public String JavaDoc getURIEncodingText() {
877         
878         return this.uriEncodingText;
879         
880     }
881     
882     /**
883      * Set the URIEncoding Text.
884      */

885     public void setURIEncodingText(String JavaDoc uriEncodingText) {
886         
887         this.uriEncodingText = uriEncodingText;
888         
889     }
890     
891     /**
892      * Return the useBodyEncodingForURI Text.
893      */

894     public String JavaDoc getUseBodyEncodingForURIText() {
895         
896         return this.useBodyEncodingForURI;
897         
898     }
899     
900     /**
901      * Set the useBodyEncodingForURI Text.
902      */

903     public void setUseBodyEncodingForURIText(String JavaDoc useBodyEncodingForURI) {
904         
905         this.useBodyEncodingForURI = useBodyEncodingForURI;
906         
907     }
908     
909     /**
910      * Return the allowTrace Text.
911      */

912     public String JavaDoc getAllowTraceText() {
913         
914         return this.allowTrace;
915         
916     }
917     
918     /**
919      * Set the allowTrace Text.
920      */

921     public void setAllowTraceText(String JavaDoc allowTrace) {
922         
923         this.allowTrace = allowTrace;
924         
925     }
926     
927     /**
928      * Return the port text.
929      */

930     public String JavaDoc getPortText() {
931         
932         return this.portText;
933         
934     }
935     
936     /**
937      * Set the port Text.
938      */

939     public void setPortText(String JavaDoc portText) {
940         
941         this.portText = portText;
942         
943     }
944     
945     
946     /**
947      * Return the port.
948      */

949     public String JavaDoc getRedirectPortText() {
950         
951         return this.redirectPortText;
952         
953     }
954     
955     /**
956      * Set the Redirect Port Text.
957      */

958     public void setRedirectPortText(String JavaDoc redirectPortText) {
959         
960         this.redirectPortText = redirectPortText;
961         
962     }
963     
964     /**
965      * Return the Service Name.
966      */

967     public String JavaDoc getConnectorName() {
968         
969         return this.connectorName;
970         
971     }
972     
973     /**
974      * Set the Service Name.
975      */

976     public void setConnectorName(String JavaDoc connectorName) {
977         
978         this.connectorName = connectorName;
979         
980     }
981     
982     /**
983      * Return the connectorTypeVals.
984      */

985     public List JavaDoc getConnectorTypeVals() {
986         
987         return this.connectorTypeVals;
988         
989     }
990     
991     /**
992      * Set the connectorTypeVals.
993      */

994     public void setConnectorTypeVals(List JavaDoc connectorTypeVals) {
995         
996         this.connectorTypeVals = connectorTypeVals;
997         
998     }
999     
1000     /**
1001     * Return the secure Text.
1002     */

1003    public String JavaDoc getSecure() {
1004        
1005        return this.secure;
1006        
1007    }
1008    
1009    /**
1010     * Set the secure Text.
1011     */

1012    public void setSecure(String JavaDoc secure) {
1013        
1014        this.secure = secure;
1015        
1016    }
1017    
1018    /**
1019     * Return the tcpNoDelay Text.
1020     */

1021    public String JavaDoc getTcpNoDelay() {
1022        
1023        return this.tcpNoDelay;
1024        
1025    }
1026    
1027    /**
1028     * Set the tcpNoDelay Text.
1029     */

1030    public void setTcpNoDelay(String JavaDoc tcpNoDelay) {
1031        
1032        this.tcpNoDelay = tcpNoDelay;
1033        
1034    }
1035    
1036    /**
1037     * Return the xpoweredBy Text.
1038     */

1039    public String JavaDoc getXpoweredBy() {
1040        
1041        return this.xpoweredBy;
1042        
1043    }
1044    
1045    /**
1046     * Set the xpoweredBy Text.
1047     */

1048    public void setXpoweredBy(String JavaDoc xpoweredBy) {
1049        
1050        this.xpoweredBy = xpoweredBy;
1051        
1052    }
1053    
1054    // --------------------------------------------------------- Public Methods
1055

1056    /**
1057     * Reset all properties to their default values.
1058     *
1059     * @param mapping The mapping used to select this instance
1060     * @param request The servlet request we are processing
1061     */

1062    public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
1063    
1064        this.objectName = null;
1065        this.connectorType = null;
1066        this.portText = null;
1067        this.acceptCountText = null;
1068        this.connLingerText = null;
1069        this.connTimeOutText = null;
1070        this.connUploadTimeOutText = null;
1071        this.bufferSizeText = null;
1072        this.address = null;
1073        this.enableLookups = "false";
1074        this.compression = "off";
1075        this.minProcessorsText = null;
1076        this.maxProcessorsText = null;
1077        this.maxKeepAliveText = null;
1078        this.maxSpare = null;
1079        this.maxThreads = null;
1080        this.minSpare = null;
1081        this.threadPriority = null;
1082        this.uriEncodingText = null;
1083        this.useBodyEncodingForURI = "false";
1084        this.allowTrace = "false";
1085        this.portText = null;
1086        this.redirectPortText = null;
1087        this.proxyName = null;
1088        this.proxyPortText = null;
1089        this.keyStoreFileName = null;
1090        this.keyStorePassword = null;
1091        this.clientAuthentication = "false";
1092        this.secure = "false";
1093        this.tcpNoDelay = "false";
1094        this.xpoweredBy = "false";
1095        
1096    }
1097    
1098    /**
1099     * Validate the properties that have been set from this HTTP request,
1100     * and return an <code>ActionErrors</code> object that encapsulates any
1101     * validation errors that have been found. If no errors are found, return
1102     * <code>null</code> or an <code>ActionErrors</code> object with no
1103     * recorded error messages.
1104     *
1105     * @param mapping The mapping used to select this instance
1106     * @param request The servlet request we are processing
1107     */

1108    
1109    private ActionErrors errors;
1110    
1111    public ActionErrors validate(ActionMapping mapping,
1112    HttpServletRequest JavaDoc request) {
1113    
1114        errors = new ActionErrors();
1115        
1116        String JavaDoc submit = request.getParameter("submit");
1117        // front end validation when save is clicked.
1118
//if (submit != null) {
1119

1120            /* The IP address can also be null -- which means open the
1121             server socket on *all* IP addresses for this host */

1122            if ((address.length() > 0) && !address.equalsIgnoreCase(" ")) {
1123                try {
1124                    InetAddress.getByName(address);
1125                } catch (Exception JavaDoc e) {
1126                    errors.add("address", new ActionError("error.address.invalid"));
1127                }
1128            } else {
1129                address = " ";
1130            }
1131            
1132            /* ports */
1133            numberCheck("portNumber", portText, true, 1, 65535);
1134            numberCheck("redirectPortText", redirectPortText, true, -1, 65535);
1135            
1136            /* processors*/
1137            //numberCheck("minProcessorsText", minProcessorsText, true, 1, 512);
1138
//try {
1139
// if min is a valid integer, then check that max >= min
1140
//int min = Integer.parseInt(minProcessorsText);
1141
//numberCheck("maxProcessorsText", maxProcessorsText, true, min, 512);
1142
//} catch (Exception e) {
1143
// check for the complete range
1144
//numberCheck("maxProcessorsText", maxProcessorsText, true, 1, 512);
1145
//}
1146

1147            // proxy
1148
if ((proxyName!= null) && (proxyName.length() > 0)) {
1149                try {
1150                    InetAddress.getByName(proxyName);
1151                } catch (Exception JavaDoc e) {
1152                    errors.add("proxyName", new ActionError("error.proxyName.invalid"));
1153                }
1154            }
1155            
1156            // supported only by Coyote HTTP and HTTPS connectors
1157
if (!("AJP".equalsIgnoreCase(connectorType))) {
1158                numberCheck("acceptCountText", acceptCountText, true, 0, 128);
1159                //numberCheck("connTimeOutText", connTimeOutText, true, -1, 60000);
1160
numberCheck("bufferSizeText", bufferSizeText, true, 1, 8192);
1161                numberCheck("proxyPortText", proxyPortText, true, 0, 65535);
1162            }
1163        //}
1164

1165        return errors;
1166    }
1167    
1168    /*
1169     * Helper method to check that it is a required number and
1170     * is a valid integer within the given range. (min, max).
1171     *
1172     * @param field The field name in the form for which this error occured.
1173     * @param numText The string representation of the number.
1174     * @param rangeCheck Boolean value set to true of reange check should be performed.
1175     *
1176     * @param min The lower limit of the range
1177     * @param max The upper limit of the range
1178     *
1179     */

1180    
1181    public void numberCheck(String JavaDoc field, String JavaDoc numText, boolean rangeCheck,
1182    int min, int max) {
1183        
1184        /* Check for 'is required' */
1185        if ((numText == null) || (numText.length() < 1)) {
1186            errors.add(field, new ActionError("error."+field+".required"));
1187        } else {
1188            
1189        /*check for 'must be a number' in the 'valid range'*/
1190            try {
1191                int num = Integer.parseInt(numText);
1192                // perform range check only if required
1193
if (rangeCheck) {
1194                    if ((num < min) || (num > max ))
1195                        errors.add( field,
1196                        new ActionError("error."+ field +".range"));
1197                }
1198            } catch (NumberFormatException JavaDoc e) {
1199                errors.add(field,
1200                new ActionError("error."+ field + ".format"));
1201            }
1202        }
1203    }
1204    
1205}
1206
Popular Tags