001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: DatasourcePropertiesForm.java 7273 2005-08-19 14:37:04Z kemlerp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.resource;
027:
028: import javax.servlet.http.HttpServletRequest;
029:
030: import org.apache.struts.action.ActionMessage;
031: import org.apache.struts.action.ActionErrors;
032: import org.apache.struts.action.ActionForm;
033: import org.apache.struts.action.ActionMapping;
034: import org.objectweb.jonas.webapp.jonasadmin.Jlists;
035:
036: /**
037: * @author Michel-Ange Anton
038: */
039: public class DatasourcePropertiesForm extends ActionForm {
040:
041: // --------------------------------------------------------- Constants
042:
043: // --------------------------------------------------------- Properties variables
044:
045: private String name = null;
046: private String datasourceName = null;
047: private String datasourceDescription = null;
048: private String datasourceUrl = null;
049: private String datasourceClassname = null;
050: private String datasourceUsername = null;
051: private String datasourcePassword = null;
052: private String datasourceMapper = null;
053: private String jdbcConnteststmt = null;
054: private String jdbcConnchecklevel = null;
055: private String jdbcConnmaxage = null;
056: private String jdbcMaxopentime = null;
057: private String jdbcMaxconpool = null;
058: private String jdbcMinconpool = null;
059: private String jdbcMaxwaittime = null;
060: private String jdbcMaxwaiters = null;
061: private String jdbcSamplingperiod = null;
062:
063: private java.util.List booleanValues = Jlists.getBooleanValues();
064: private java.util.List checkingLevels = Jlists
065: .getJdbcConnectionCheckingLevels();
066: private String action = "edit";
067:
068: // --------------------------------------------------------- Public Methods
069:
070: public void reset(ActionMapping mapping, HttpServletRequest request) {
071: // Reset datas
072: name = null;
073: datasourceName = null;
074: datasourceDescription = null;
075: datasourceUrl = null;
076: datasourceClassname = null;
077: datasourceUsername = null;
078: datasourcePassword = null;
079: datasourceMapper = null;
080:
081: jdbcConnmaxage = "1440";
082: jdbcMaxopentime = "1440";
083: jdbcConnchecklevel = "1";
084: jdbcConnteststmt = "SELECT 1";
085: jdbcMinconpool = "0";
086: jdbcMaxconpool = "-1";
087: jdbcMaxwaittime = "10";
088: jdbcMaxwaiters = "1000";
089: }
090:
091: public ActionErrors validate(ActionMapping mapping,
092: HttpServletRequest request) {
093: ActionErrors oErrors = new ActionErrors();
094: if ((name == null) || (name.length() == 0)) {
095: oErrors
096: .add(
097: "name",
098: new ActionMessage(
099: "error.resource.datasource.properties.name.required"));
100: }
101: if ((datasourceName == null) || (datasourceName.length() == 0)) {
102: oErrors
103: .add(
104: "datasourceName",
105: new ActionMessage(
106: "error.resource.datasource.properties.datasourceName.required"));
107: }
108: if ((datasourceClassname == null)
109: || (datasourceClassname.length() == 0)) {
110: oErrors
111: .add(
112: "datasourceClassname",
113: new ActionMessage(
114: "error.resource.datasource.properties.datasourceClassname.required"));
115: }
116: validateInteger(oErrors, jdbcConnmaxage, "jdbcConnmaxage",
117: "error.resource.datasource.properties.jdbcConnmaxage.numberformat");
118: validateInteger(oErrors, jdbcMaxopentime, "jdbcMaxopentime",
119: "error.resource.datasource.properties.jdbcMaxopentime.numberformat");
120: validateInteger(oErrors, jdbcMinconpool, "jdbcMinconpool",
121: "error.resource.datasource.properties.jdbcMinconpool.numberformat");
122: validateInteger(oErrors, jdbcMaxconpool, "jdbcMaxconpool",
123: "error.resource.datasource.properties.jdbcMaxconpool.numberformat");
124: validateInteger(oErrors, jdbcMaxwaittime, "jdbcMaxwaittime",
125: "error.resource.datasource.properties.jdbcMaxwaitime.numberformat");
126: validateInteger(oErrors, jdbcMaxwaiters, "jdbcMaxwaiters",
127: "error.resource.datasource.properties.jdbcMaxwaiters.numberformat");
128: return oErrors;
129: }
130:
131: protected void validateInteger(ActionErrors p_Errors,
132: String p_Value, String p_Tag, String p_ResError) {
133: try {
134: Integer.parseInt(p_Value);
135: } catch (NumberFormatException e) {
136: p_Errors.add(p_Tag, new ActionMessage(p_ResError));
137: }
138: }
139:
140: // --------------------------------------------------------- Properties Methods
141:
142: public String getName() {
143: return name;
144: }
145:
146: public void setName(String name) {
147: this .name = name;
148: }
149:
150: public String getDatasourceName() {
151: return datasourceName;
152: }
153:
154: public void setDatasourceName(String datasourceName) {
155: this .datasourceName = datasourceName;
156: }
157:
158: public String getDatasourceDescription() {
159: return datasourceDescription;
160: }
161:
162: public void setDatasourceDescription(String datasourceDescription) {
163: this .datasourceDescription = datasourceDescription;
164: }
165:
166: public String getDatasourceUrl() {
167: return datasourceUrl;
168: }
169:
170: public void setDatasourceUrl(String datasourceUrl) {
171: this .datasourceUrl = datasourceUrl;
172: }
173:
174: public String getDatasourceClassname() {
175: return datasourceClassname;
176: }
177:
178: public void setDatasourceClassname(String datasourceClassname) {
179: this .datasourceClassname = datasourceClassname;
180: }
181:
182: public String getDatasourceUsername() {
183: return datasourceUsername;
184: }
185:
186: public void setDatasourceUsername(String datasourceUsername) {
187: this .datasourceUsername = datasourceUsername;
188: }
189:
190: public String getDatasourcePassword() {
191: return datasourcePassword;
192: }
193:
194: public void setDatasourcePassword(String datasourcePassword) {
195: this .datasourcePassword = datasourcePassword;
196: }
197:
198: public String getDatasourceMapper() {
199: return datasourceMapper;
200: }
201:
202: public void setDatasourceMapper(String datasourceMapper) {
203: this .datasourceMapper = datasourceMapper;
204: }
205:
206: public String getJdbcConnmaxage() {
207: return jdbcConnmaxage;
208: }
209:
210: public void setJdbcConnmaxage(String s) {
211: jdbcConnmaxage = s;
212: }
213:
214: public String getJdbcMaxopentime() {
215: return jdbcMaxopentime;
216: }
217:
218: public void setJdbcMaxopentime(String s) {
219: jdbcMaxopentime = s;
220: }
221:
222: public String getJdbcConnchecklevel() {
223: return jdbcConnchecklevel;
224: }
225:
226: public void setJdbcConnchecklevel(String jdbcConnchecklevel) {
227: this .jdbcConnchecklevel = jdbcConnchecklevel;
228: }
229:
230: public String getJdbcConnteststmt() {
231: return jdbcConnteststmt;
232: }
233:
234: public void setJdbcConnteststmt(String jdbcConnteststmt) {
235: this .jdbcConnteststmt = jdbcConnteststmt;
236: }
237:
238: public String getJdbcMinconpool() {
239: return jdbcMinconpool;
240: }
241:
242: public void setJdbcMinconpool(String jdbcMinconpool) {
243: this .jdbcMinconpool = jdbcMinconpool;
244: }
245:
246: public String getJdbcMaxconpool() {
247: return jdbcMaxconpool;
248: }
249:
250: public void setJdbcMaxconpool(String jdbcMaxconpool) {
251: this .jdbcMaxconpool = jdbcMaxconpool;
252: }
253:
254: public String getJdbcMaxwaittime() {
255: return jdbcMaxwaittime;
256: }
257:
258: public void setJdbcMaxwaittime(String jdbcMaxwaittime) {
259: this .jdbcMaxwaittime = jdbcMaxwaittime;
260: }
261:
262: public String getJdbcMaxwaiters() {
263: return jdbcMaxwaiters;
264: }
265:
266: public void setJdbcMaxwaiters(String jdbcMaxwaiters) {
267: this .jdbcMaxwaiters = jdbcMaxwaiters;
268: }
269:
270: public String getJdbcSamplingperiod() {
271: return jdbcSamplingperiod;
272: }
273:
274: public void setJdbcSamplingperiod(String s) {
275: this .jdbcSamplingperiod = s;
276: }
277:
278: public java.util.List getBooleanValues() {
279: return booleanValues;
280: }
281:
282: public java.util.List getCheckingLevels() {
283: return checkingLevels;
284: }
285:
286: public String getAction() {
287: return action;
288: }
289:
290: public void setAction(String action) {
291: this.action = action;
292: }
293:
294: }
|