DatasourcePropertiesForm.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: DatasourcePropertiesForm.java,v 1.9 2004/09/01 16:48:28 durieuxp Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.resource;
00027 
00028 import javax.servlet.http.HttpServletRequest;
00029 
00030 import org.apache.struts.action.ActionError;
00031 import org.apache.struts.action.ActionErrors;
00032 import org.apache.struts.action.ActionForm;
00033 import org.apache.struts.action.ActionMapping;
00034 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
00035 
00039 public class DatasourcePropertiesForm extends ActionForm {
00040 
00041 // --------------------------------------------------------- Constants
00042 
00043 // --------------------------------------------------------- Properties variables
00044 
00045     private String name = null;
00046     private String datasourceName = null;
00047     private String datasourceDescription = null;
00048     private String datasourceUrl = null;
00049     private String datasourceClassname = null;
00050     private String datasourceUsername = null;
00051     private String datasourcePassword = null;
00052     private String datasourceMapper = null;
00053     private String jdbcConnteststmt = null;
00054     private String jdbcConnchecklevel = null;
00055     private String jdbcConnmaxage = null;
00056     private String jdbcMaxopentime = null;
00057     private String jdbcMaxconpool = null;
00058     private String jdbcMinconpool = null;
00059     private String jdbcMaxwaittime = null;
00060     private String jdbcMaxwaiters = null;
00061     private String jdbcSamplingperiod = null;
00062 
00063     private java.util.List booleanValues = Jlists.getBooleanValues();
00064     private java.util.List checkingLevels = Jlists.getJdbcConnectionCheckingLevels();
00065     private String action = "edit";
00066 
00067 // --------------------------------------------------------- Public Methods
00068 
00069     public void reset(ActionMapping mapping, HttpServletRequest request) {
00070         // Reset datas
00071         name = null;
00072         datasourceName = null;
00073         datasourceDescription = null;
00074         datasourceUrl = null;
00075         datasourceClassname = null;
00076         datasourceUsername = null;
00077         datasourcePassword = null;
00078         datasourceMapper = null;
00079 
00080         jdbcConnmaxage = "1440";
00081         jdbcMaxopentime = "1440";
00082         jdbcConnchecklevel = "1";
00083         jdbcConnteststmt = "SELECT 1";
00084         jdbcMinconpool = "0";
00085         jdbcMaxconpool = "-1";
00086         jdbcMaxwaittime = "10";
00087         jdbcMaxwaiters = "1000";
00088     }
00089 
00090     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
00091         ActionErrors oErrors = new ActionErrors();
00092         if ((name == null) || (name.length() == 0)) {
00093             oErrors.add("name"
00094                 , new ActionError("error.resource.datasource.properties.name.required"));
00095         }
00096         if ((datasourceName == null) || (datasourceName.length() == 0)) {
00097             oErrors.add("datasourceName"
00098                 , new ActionError("error.resource.datasource.properties.datasourceName.required"));
00099         }
00100         validateInteger(oErrors, jdbcConnmaxage, "jdbcConnmaxage"
00101             , "error.resource.datasource.properties.jdbcConnmaxage.numberformat");
00102         validateInteger(oErrors, jdbcMaxopentime, "jdbcMaxopentime"
00103             , "error.resource.datasource.properties.jdbcMaxopentime.numberformat");
00104         validateInteger(oErrors, jdbcMinconpool, "jdbcMinconpool"
00105             , "error.resource.datasource.properties.jdbcMinconpool.numberformat");
00106         validateInteger(oErrors, jdbcMaxconpool, "jdbcMaxconpool"
00107             , "error.resource.datasource.properties.jdbcMaxconpool.numberformat");
00108         validateInteger(oErrors, jdbcMaxwaittime, "jdbcMaxwaittime"
00109             , "error.resource.datasource.properties.jdbcMaxwaitime.numberformat");
00110         validateInteger(oErrors, jdbcMaxwaiters, "jdbcMaxwaiters"
00111             , "error.resource.datasource.properties.jdbcMaxwaiters.numberformat");
00112         return oErrors;
00113     }
00114 
00115     protected void validateInteger(ActionErrors p_Errors, String p_Value, String p_Tag
00116         , String p_ResError) {
00117         try {
00118             Integer.parseInt(p_Value);
00119         }
00120         catch (NumberFormatException e) {
00121             p_Errors.add(p_Tag, new ActionError(p_ResError));
00122         }
00123     }
00124 
00125 // --------------------------------------------------------- Properties Methods
00126 
00127     public String getName() {
00128         return name;
00129     }
00130 
00131     public void setName(String name) {
00132         this.name = name;
00133     }
00134 
00135     public String getDatasourceName() {
00136         return datasourceName;
00137     }
00138 
00139     public void setDatasourceName(String datasourceName) {
00140         this.datasourceName = datasourceName;
00141     }
00142 
00143     public String getDatasourceDescription() {
00144         return datasourceDescription;
00145     }
00146 
00147     public void setDatasourceDescription(String datasourceDescription) {
00148         this.datasourceDescription = datasourceDescription;
00149     }
00150 
00151     public String getDatasourceUrl() {
00152         return datasourceUrl;
00153     }
00154 
00155     public void setDatasourceUrl(String datasourceUrl) {
00156         this.datasourceUrl = datasourceUrl;
00157     }
00158 
00159     public String getDatasourceClassname() {
00160         return datasourceClassname;
00161     }
00162 
00163     public void setDatasourceClassname(String datasourceClassname) {
00164         this.datasourceClassname = datasourceClassname;
00165     }
00166 
00167     public String getDatasourceUsername() {
00168         return datasourceUsername;
00169     }
00170 
00171     public void setDatasourceUsername(String datasourceUsername) {
00172         this.datasourceUsername = datasourceUsername;
00173     }
00174 
00175     public String getDatasourcePassword() {
00176         return datasourcePassword;
00177     }
00178 
00179     public void setDatasourcePassword(String datasourcePassword) {
00180         this.datasourcePassword = datasourcePassword;
00181     }
00182 
00183     public String getDatasourceMapper() {
00184         return datasourceMapper;
00185     }
00186 
00187     public void setDatasourceMapper(String datasourceMapper) {
00188         this.datasourceMapper = datasourceMapper;
00189     }
00190 
00191     public String getJdbcConnmaxage() {
00192         return jdbcConnmaxage;
00193     }
00194 
00195     public void setJdbcConnmaxage(String s) {
00196         jdbcConnmaxage = s;
00197     }
00198 
00199     public String getJdbcMaxopentime() {
00200         return jdbcMaxopentime;
00201     }
00202 
00203     public void setJdbcMaxopentime(String s) {
00204         jdbcMaxopentime = s;
00205     }
00206 
00207     public String getJdbcConnchecklevel() {
00208         return jdbcConnchecklevel;
00209     }
00210 
00211     public void setJdbcConnchecklevel(String jdbcConnchecklevel) {
00212         this.jdbcConnchecklevel = jdbcConnchecklevel;
00213     }
00214 
00215     public String getJdbcConnteststmt() {
00216         return jdbcConnteststmt;
00217     }
00218 
00219     public void setJdbcConnteststmt(String jdbcConnteststmt) {
00220         this.jdbcConnteststmt = jdbcConnteststmt;
00221     }
00222 
00223     public String getJdbcMinconpool() {
00224         return jdbcMinconpool;
00225     }
00226 
00227     public void setJdbcMinconpool(String jdbcMinconpool) {
00228         this.jdbcMinconpool = jdbcMinconpool;
00229     }
00230 
00231     public String getJdbcMaxconpool() {
00232         return jdbcMaxconpool;
00233     }
00234 
00235     public void setJdbcMaxconpool(String jdbcMaxconpool) {
00236         this.jdbcMaxconpool = jdbcMaxconpool;
00237     }
00238 
00239     public String getJdbcMaxwaittime() {
00240         return jdbcMaxwaittime;
00241     }
00242 
00243     public void setJdbcMaxwaittime(String jdbcMaxwaittime) {
00244         this.jdbcMaxwaittime = jdbcMaxwaittime;
00245     }
00246     
00247     public String getJdbcMaxwaiters() {
00248         return jdbcMaxwaiters;
00249     }
00250 
00251     public void setJdbcMaxwaiters(String jdbcMaxwaiters) {
00252         this.jdbcMaxwaiters = jdbcMaxwaiters;
00253     }
00254     
00255     public String getJdbcSamplingperiod() {
00256         return jdbcSamplingperiod;
00257     }
00258 
00259     public void setJdbcSamplingperiod(String s) {
00260         this.jdbcSamplingperiod = s;
00261     }
00262     
00263     public java.util.List getBooleanValues() {
00264         return booleanValues;
00265     }
00266 
00267     public java.util.List getCheckingLevels() {
00268         return checkingLevels;
00269     }
00270 
00271     public String getAction() {
00272         return action;
00273     }
00274 
00275     public void setAction(String action) {
00276         this.action = action;
00277     }
00278 
00279 }

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