ConnectorForm.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.catalina;
00027 
00028 import java.net.InetAddress;
00029 import java.util.List;
00030 
00031 import javax.servlet.http.HttpServletRequest;
00032 
00033 import org.apache.struts.action.ActionError;
00034 import org.apache.struts.action.ActionErrors;
00035 import org.apache.struts.action.ActionForm;
00036 import org.apache.struts.action.ActionMapping;
00037 
00045 public final class ConnectorForm extends ActionForm {
00046 
00047     // ----------------------------------------------------- Instance Variables
00048 
00052     private String action = "edit";
00053 
00057     private boolean save = false;
00058 
00062     private String objectName = null;
00063 
00067     private String serviceName = null;
00068 
00072     private String scheme = null;
00073 
00078     private String connectorType = null;
00079 
00087     private String acceptCountText = "10";
00088 
00092     private String connTimeOutText = "60000";
00093 
00097     private String debugLvl = "0";
00098 
00102     private String bufferSizeText = "2048";
00103 
00107     private boolean enableLookups = true;
00108 
00112     private String address = null;
00113 
00117     private String minSpareThreadsText = null;
00118 
00122     private String maxSpareThreadsText = null;
00123 
00127     private String maxThreadsText = null;
00128 
00132     private String portText = null;
00133 
00137     private String redirectPortText = "-1";
00138 
00142     private String proxyName = null;
00143 
00147     private String proxyPortText = "0";
00148 
00152     private String connectorName = null;
00153 
00157     private boolean clientAuthentication = false;
00158 
00162     private String keyStoreFileName = null;
00163 
00167     private String keyStorePassword = null;
00168 
00172     private List debugLvlVals = null;
00173 
00177     private List booleanVals = null;
00178 
00182     private List connectorTypeVals = null;
00183 
00187     private String minProcessorsText = "5";
00188 
00192     private String maxProcessorsText = "20";
00193 
00194     // --------------------------------------------------------- Public Methods
00206     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
00207 
00208         ActionErrors oErrors = new ActionErrors();
00209 
00210         // general
00211         numberCheck(oErrors, "acceptCountText", acceptCountText, true, 0, 128);
00212         numberCheck(oErrors, "connTimeOutText", connTimeOutText, true, -1, 60000);
00213         numberCheck(oErrors, "bufferSizeText", bufferSizeText, true, 1, 8192);
00214 
00215         // The IP address can also be null --
00216         // which means open the server socket on *all* IP addresses for this host
00217         if (address.length() > 0) {
00218             try {
00219                 InetAddress.getByName(address);
00220             } catch (Exception e) {
00221                 oErrors.add("address", new ActionError("error.catalina.connector.address.invalid"));
00222             }
00223         } else {
00224             address = null;
00225         }
00226 
00227         // ports
00228         numberCheck(oErrors, "portNumber", portText, true, 1, 65535);
00229         numberCheck(oErrors, "redirectPortText", redirectPortText, true, -1, 65535);
00230 
00231         // SpareThreads Check removed as no more WRITE in the JSP
00232         /*
00233         numberCheck(oErrors, "maxThreadsText", maxThreadsText, true, 1, 65535);
00234         numberCheck(oErrors, "minSpareThreadsText", minSpareThreadsText, true, 1, 65535);
00235         try {
00236             // if min is a valid integer, then check that max >= min
00237             int min = Integer.parseInt(minSpareThreadsText);
00238             numberCheck(oErrors, "maxSpareThreadsText", maxSpareThreadsText, true, min, 65535);
00239         }
00240         catch (Exception e) {
00241             // check for the complete range
00242             numberCheck(oErrors, "maxSpareThreadsText", maxSpareThreadsText, true, 1, 65535);
00243         }*/
00244 
00245         // proxy
00246         if ((proxyName != null) && (proxyName.length() > 0)) {
00247             try {
00248                 InetAddress.getByName(proxyName);
00249             } catch (Exception e) {
00250                 oErrors.add("proxyName"
00251                     , new ActionError("error.catalina.connector.proxyName.invalid"));
00252             }
00253         }
00254 
00255         // supported only by Coyote HTTP and HTTPS connectors
00256         if (!("AJP".equalsIgnoreCase(connectorType))) {
00257             numberCheck(oErrors, "proxyPortText", proxyPortText, true, 0, 65535);
00258         }
00259 
00260         return oErrors;
00261     }
00262 
00275     public void numberCheck(ActionErrors pErrors, String field, String numText, boolean rangeCheck
00276         , int min, int max) {
00277         // Check for 'is required'
00278         if ((numText == null) || (numText.length() < 1)) {
00279             pErrors.add(field, new ActionError("error.catalina.connector." + field + ".required"));
00280         } else {
00281 
00282             // check for 'must be a number' in the 'valid range'
00283             try {
00284                 int num = Integer.parseInt(numText);
00285                 // perform range check only if required
00286                 if (rangeCheck) {
00287                     if ((num < min) || (num > max)) {
00288                         pErrors.add(field
00289                             , new ActionError("error.catalina.connector." + field + ".range"));
00290                     }
00291                 }
00292             } catch (NumberFormatException e) {
00293                 pErrors.add(field, new ActionError("error.catalina.connector." + field + ".format"));
00294             }
00295         }
00296     }
00297 
00298 // ------------------------------------------------------------- Properties methods
00299 
00304     public String getAction() {
00305         return this.action;
00306     }
00307 
00312     public void setAction(String action) {
00313         this.action = action;
00314     }
00315 
00320     public String getObjectName() {
00321         return this.objectName;
00322     }
00323 
00328     public void setObjectName(String objectName) {
00329         this.objectName = objectName;
00330     }
00331 
00336     public String getServiceName() {
00337         return this.serviceName;
00338     }
00339 
00344     public void setServiceName(String serviceName) {
00345         this.serviceName = serviceName;
00346     }
00347 
00352     public String getScheme() {
00353         return this.scheme;
00354     }
00355 
00360     public void setScheme(String scheme) {
00361         this.scheme = scheme;
00362     }
00363 
00368     public String getConnectorType() {
00369         return this.connectorType;
00370     }
00371 
00376     public void setConnectorType(String connectorType) {
00377         this.connectorType = connectorType;
00378     }
00379 
00384     public String getAcceptCountText() {
00385         return this.acceptCountText;
00386     }
00387 
00392     public void setAcceptCountText(String acceptCountText) {
00393         this.acceptCountText = acceptCountText;
00394     }
00395 
00400     public String getConnTimeOutText() {
00401         return this.connTimeOutText;
00402     }
00403 
00408     public void setConnTimeOutText(String connTimeOutText) {
00409         this.connTimeOutText = connTimeOutText;
00410     }
00411 
00416     public String getBufferSizeText() {
00417         return this.bufferSizeText;
00418     }
00419 
00424     public void setBufferSizeText(String bufferSizeText) {
00425         this.bufferSizeText = bufferSizeText;
00426     }
00427 
00432     public String getAddress() {
00433         return this.address;
00434     }
00435 
00440     public void setAddress(String address) {
00441         this.address = address;
00442     }
00443 
00448     public String getProxyName() {
00449         return this.proxyName;
00450     }
00451 
00456     public void setProxyName(String proxyName) {
00457         this.proxyName = proxyName;
00458     }
00459 
00464     public String getProxyPortText() {
00465         return this.proxyPortText;
00466     }
00467 
00472     public void setProxyPortText(String proxyPortText) {
00473         this.proxyPortText = proxyPortText;
00474     }
00475 
00480     public boolean isClientAuthentication() {
00481         return this.clientAuthentication;
00482     }
00483 
00488     public void setClientAuthentication(boolean clientAuthentication) {
00489         this.clientAuthentication = clientAuthentication;
00490     }
00491 
00495     public String getKeyStoreFileName() {
00496         return this.keyStoreFileName;
00497     }
00498 
00502     public void setKeyStoreFileName(String keyStoreFileName) {
00503         this.keyStoreFileName = keyStoreFileName;
00504     }
00505 
00509     public String getKeyStorePassword() {
00510         return this.keyStorePassword;
00511     }
00512 
00516     public void setKeyStorePassword(String keyStorePassword) {
00517         this.keyStorePassword = keyStorePassword;
00518     }
00519 
00524     public List getDebugLvlVals() {
00525         return this.debugLvlVals;
00526     }
00527 
00532     public void setDebugLvlVals(List debugLvlVals) {
00533         this.debugLvlVals = debugLvlVals;
00534     }
00535 
00540     public String getDebugLvl() {
00541         return this.debugLvl;
00542     }
00543 
00548     public void setDebugLvl(String debugLvl) {
00549         this.debugLvl = debugLvl;
00550     }
00551 
00556     public boolean isEnableLookups() {
00557         return this.enableLookups;
00558     }
00559 
00564     public void setEnableLookups(boolean enableLookups) {
00565         this.enableLookups = enableLookups;
00566     }
00567 
00571     public List getBooleanVals() {
00572         return this.booleanVals;
00573     }
00574 
00578     public void setBooleanVals(List booleanVals) {
00579         this.booleanVals = booleanVals;
00580     }
00581 
00586     public String getMinSpareThreadsText() {
00587         return this.minSpareThreadsText;
00588     }
00589 
00594     public void setMinSpareThreadsText(String minSpareThreadsText) {
00595         this.minSpareThreadsText = minSpareThreadsText;
00596     }
00597 
00602     public String getMaxSpareThreadsText() {
00603         return this.maxSpareThreadsText;
00604     }
00605 
00610     public void setMaxSpareThreadsText(String maxSpareThreadsText) {
00611         this.maxSpareThreadsText = maxSpareThreadsText;
00612     }
00613 
00618     public String getMaxThreadsText() {
00619         return this.maxThreadsText;
00620     }
00621 
00626     public void setMaxThreadsText(String maxThreadsText) {
00627         this.maxThreadsText = maxThreadsText;
00628     }
00629 
00634     public String getPortText() {
00635         return this.portText;
00636     }
00637 
00642     public void setPortText(String portText) {
00643         this.portText = portText;
00644     }
00645 
00650     public String getRedirectPortText() {
00651         return this.redirectPortText;
00652     }
00653 
00658     public void setRedirectPortText(String redirectPortText) {
00659         this.redirectPortText = redirectPortText;
00660     }
00661 
00665     public String getConnectorName() {
00666         return this.connectorName;
00667     }
00668 
00672     public void setConnectorName(String connectorName) {
00673         this.connectorName = connectorName;
00674     }
00675 
00680     public List getConnectorTypeVals() {
00681         return this.connectorTypeVals;
00682     }
00683 
00688     public void setConnectorTypeVals(List connectorTypeVals) {
00689         this.connectorTypeVals = connectorTypeVals;
00690     }
00694     public String getLabel() {
00695         StringBuffer sb = new StringBuffer(getPortText());
00696         if (getAddress() != null) {
00697             sb.append(" (");
00698             sb.append(getAddress());
00699             sb.append(")");
00700         }
00701         return sb.toString();
00702     }
00703 
00708     public boolean isSave() {
00709         return save;
00710     }
00711 
00716     public void setSave(boolean save) {
00717         this.save = save;
00718     }
00722     public String getMinProcessorsText() {
00723         return minProcessorsText;
00724     }
00728     public void setMinProcessorsText(String minProcessorsText) {
00729         this.minProcessorsText = minProcessorsText;
00730     }
00734     public String getMaxProcessorsText() {
00735         return maxProcessorsText;
00736     }
00740     public void setMaxProcessorsText(String maxProcessorsText) {
00741         this.maxProcessorsText = maxProcessorsText;
00742     }
00743 }

Generated on Tue Feb 15 15:05:26 2005 for JOnAS by  doxygen 1.3.9.1