1 25 26 package org.objectweb.jonas.webapp.jonasadmin.resource; 27 28 import javax.servlet.http.HttpServletRequest ; 29 30 import org.apache.struts.action.ActionMessage; 31 import org.apache.struts.action.ActionErrors; 32 import org.apache.struts.action.ActionForm; 33 import org.apache.struts.action.ActionMapping; 34 import org.objectweb.jonas.webapp.jonasadmin.Jlists; 35 36 39 public class DatasourcePropertiesForm extends ActionForm { 40 41 43 45 private String name = null; 46 private String datasourceName = null; 47 private String datasourceDescription = null; 48 private String datasourceUrl = null; 49 private String datasourceClassname = null; 50 private String datasourceUsername = null; 51 private String datasourcePassword = null; 52 private String datasourceMapper = null; 53 private String jdbcConnteststmt = null; 54 private String jdbcConnchecklevel = null; 55 private String jdbcConnmaxage = null; 56 private String jdbcMaxopentime = null; 57 private String jdbcMaxconpool = null; 58 private String jdbcMinconpool = null; 59 private String jdbcMaxwaittime = null; 60 private String jdbcMaxwaiters = null; 61 private String jdbcSamplingperiod = null; 62 63 private java.util.List booleanValues = Jlists.getBooleanValues(); 64 private java.util.List checkingLevels = Jlists.getJdbcConnectionCheckingLevels(); 65 private String action = "edit"; 66 67 69 public void reset(ActionMapping mapping, HttpServletRequest request) { 70 name = null; 72 datasourceName = null; 73 datasourceDescription = null; 74 datasourceUrl = null; 75 datasourceClassname = null; 76 datasourceUsername = null; 77 datasourcePassword = null; 78 datasourceMapper = null; 79 80 jdbcConnmaxage = "1440"; 81 jdbcMaxopentime = "1440"; 82 jdbcConnchecklevel = "1"; 83 jdbcConnteststmt = "SELECT 1"; 84 jdbcMinconpool = "0"; 85 jdbcMaxconpool = "-1"; 86 jdbcMaxwaittime = "10"; 87 jdbcMaxwaiters = "1000"; 88 } 89 90 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 91 ActionErrors oErrors = new ActionErrors(); 92 if ((name == null) || (name.length() == 0)) { 93 oErrors.add("name" 94 , new ActionMessage("error.resource.datasource.properties.name.required")); 95 } 96 if ((datasourceName == null) || (datasourceName.length() == 0)) { 97 oErrors.add("datasourceName" 98 , new ActionMessage("error.resource.datasource.properties.datasourceName.required")); 99 } 100 validateInteger(oErrors, jdbcConnmaxage, "jdbcConnmaxage" 101 , "error.resource.datasource.properties.jdbcConnmaxage.numberformat"); 102 validateInteger(oErrors, jdbcMaxopentime, "jdbcMaxopentime" 103 , "error.resource.datasource.properties.jdbcMaxopentime.numberformat"); 104 validateInteger(oErrors, jdbcMinconpool, "jdbcMinconpool" 105 , "error.resource.datasource.properties.jdbcMinconpool.numberformat"); 106 validateInteger(oErrors, jdbcMaxconpool, "jdbcMaxconpool" 107 , "error.resource.datasource.properties.jdbcMaxconpool.numberformat"); 108 validateInteger(oErrors, jdbcMaxwaittime, "jdbcMaxwaittime" 109 , "error.resource.datasource.properties.jdbcMaxwaitime.numberformat"); 110 validateInteger(oErrors, jdbcMaxwaiters, "jdbcMaxwaiters" 111 , "error.resource.datasource.properties.jdbcMaxwaiters.numberformat"); 112 return oErrors; 113 } 114 115 protected void validateInteger(ActionErrors p_Errors, String p_Value, String p_Tag 116 , String p_ResError) { 117 try { 118 Integer.parseInt(p_Value); 119 } 120 catch (NumberFormatException e) { 121 p_Errors.add(p_Tag, new ActionMessage(p_ResError)); 122 } 123 } 124 125 127 public String getName() { 128 return name; 129 } 130 131 public void setName(String name) { 132 this.name = name; 133 } 134 135 public String getDatasourceName() { 136 return datasourceName; 137 } 138 139 public void setDatasourceName(String datasourceName) { 140 this.datasourceName = datasourceName; 141 } 142 143 public String getDatasourceDescription() { 144 return datasourceDescription; 145 } 146 147 public void setDatasourceDescription(String datasourceDescription) { 148 this.datasourceDescription = datasourceDescription; 149 } 150 151 public String getDatasourceUrl() { 152 return datasourceUrl; 153 } 154 155 public void setDatasourceUrl(String datasourceUrl) { 156 this.datasourceUrl = datasourceUrl; 157 } 158 159 public String getDatasourceClassname() { 160 return datasourceClassname; 161 } 162 163 public void setDatasourceClassname(String datasourceClassname) { 164 this.datasourceClassname = datasourceClassname; 165 } 166 167 public String getDatasourceUsername() { 168 return datasourceUsername; 169 } 170 171 public void setDatasourceUsername(String datasourceUsername) { 172 this.datasourceUsername = datasourceUsername; 173 } 174 175 public String getDatasourcePassword() { 176 return datasourcePassword; 177 } 178 179 public void setDatasourcePassword(String datasourcePassword) { 180 this.datasourcePassword = datasourcePassword; 181 } 182 183 public String getDatasourceMapper() { 184 return datasourceMapper; 185 } 186 187 public void setDatasourceMapper(String datasourceMapper) { 188 this.datasourceMapper = datasourceMapper; 189 } 190 191 public String getJdbcConnmaxage() { 192 return jdbcConnmaxage; 193 } 194 195 public void setJdbcConnmaxage(String s) { 196 jdbcConnmaxage = s; 197 } 198 199 public String getJdbcMaxopentime() { 200 return jdbcMaxopentime; 201 } 202 203 public void setJdbcMaxopentime(String s) { 204 jdbcMaxopentime = s; 205 } 206 207 public String getJdbcConnchecklevel() { 208 return jdbcConnchecklevel; 209 } 210 211 public void setJdbcConnchecklevel(String jdbcConnchecklevel) { 212 this.jdbcConnchecklevel = jdbcConnchecklevel; 213 } 214 215 public String getJdbcConnteststmt() { 216 return jdbcConnteststmt; 217 } 218 219 public void setJdbcConnteststmt(String jdbcConnteststmt) { 220 this.jdbcConnteststmt = jdbcConnteststmt; 221 } 222 223 public String getJdbcMinconpool() { 224 return jdbcMinconpool; 225 } 226 227 public void setJdbcMinconpool(String jdbcMinconpool) { 228 this.jdbcMinconpool = jdbcMinconpool; 229 } 230 231 public String getJdbcMaxconpool() { 232 return jdbcMaxconpool; 233 } 234 235 public void setJdbcMaxconpool(String jdbcMaxconpool) { 236 this.jdbcMaxconpool = jdbcMaxconpool; 237 } 238 239 public String getJdbcMaxwaittime() { 240 return jdbcMaxwaittime; 241 } 242 243 public void setJdbcMaxwaittime(String jdbcMaxwaittime) { 244 this.jdbcMaxwaittime = jdbcMaxwaittime; 245 } 246 247 public String getJdbcMaxwaiters() { 248 return jdbcMaxwaiters; 249 } 250 251 public void setJdbcMaxwaiters(String jdbcMaxwaiters) { 252 this.jdbcMaxwaiters = jdbcMaxwaiters; 253 } 254 255 public String getJdbcSamplingperiod() { 256 return jdbcSamplingperiod; 257 } 258 259 public void setJdbcSamplingperiod(String s) { 260 this.jdbcSamplingperiod = s; 261 } 262 263 public java.util.List getBooleanValues() { 264 return booleanValues; 265 } 266 267 public java.util.List getCheckingLevels() { 268 return checkingLevels; 269 } 270 271 public String getAction() { 272 return action; 273 } 274 275 public void setAction(String action) { 276 this.action = action; 277 } 278 279 } 280 | Popular Tags |