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: EjbForm.java 8163 2006-03-24 10:03:58Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.service.ejb;
025:
026: import java.util.ArrayList;
027: import java.util.HashMap;
028: import java.util.Hashtable;
029:
030: import javax.servlet.http.HttpServletRequest;
031:
032: import org.apache.struts.action.ActionErrors;
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionMapping;
035: import org.apache.struts.action.ActionMessage;
036:
037: /**
038: * @author Michel-Ange ANTON
039: */
040: public class EjbForm extends ActionForm {
041:
042: // --------------------------------------------------------- Properties variables
043:
044: /**
045: * Parameters properties
046: */
047: private String type = null;
048: private String fullType = null;
049: private String file = null;
050: private String name = null;
051: private String objectName = null;
052: private String action = null;
053:
054: /**
055: * Global MBean Ejb properties
056: */
057: private int cacheSize = 0;
058: private int maxCacheSize = 0;
059: private int minPoolSize = 0;
060: private int poolSize = 0;
061: private String displayName = null;
062: private String ejbClass = null;
063: private String ejbFileName = null;
064: private String ejbName = null;
065: private String homeClass = null;
066: private String jndiName = null;
067: private String localClass = null;
068: private String localHomeClass = null;
069: private String remoteClass = null;
070: private boolean dependency = false;
071: private boolean databaseServiceActivated = false;
072: private boolean resourceServiceActivated = false;
073: private boolean dataSource = false;
074: private HashMap dataSources = new HashMap();
075: private HashMap jdbcRas = new HashMap();
076: private boolean jmsServiceActivated = false;
077: private boolean joramResourceLoaded = false;
078: private boolean jmsConnection = false;
079: private ArrayList jmsConnections = new ArrayList();
080: private boolean jmsDestination = false;
081: private ArrayList jmsDestinations = new ArrayList();
082: private Hashtable jmsDestinationsTable = new Hashtable();
083: private boolean mailServiceActivated = false;
084: private boolean mailSession = false;
085: private HashMap mailSessions = new HashMap();
086: private boolean mailMime = false;
087: private HashMap mailMimes = new HashMap();
088:
089: // --------------------------------------------------------- Public Methods
090:
091: /**
092: * Reset all properties to their default values.
093: *
094: * @param mapping The mapping used to select this instance
095: * @param request The servlet request we are processing
096: */
097:
098: public void reset(ActionMapping mapping, HttpServletRequest request) {
099: // Parameters properties
100: type = null;
101: file = null;
102: name = null;
103: objectName = null;
104: fullType = null;
105: action = null;
106:
107: // Global MBean Ejb properties
108: cacheSize = 0;
109: maxCacheSize = 0;
110: minPoolSize = 0;
111: poolSize = 0;
112: displayName = null;
113: ejbClass = null;
114: ejbFileName = null;
115: ejbName = null;
116: homeClass = null;
117: jndiName = null;
118: localClass = null;
119: localHomeClass = null;
120: remoteClass = null;
121:
122: dependency = false;
123: databaseServiceActivated = false;
124: resourceServiceActivated = false;
125: dataSources = new HashMap();
126: dataSource = false;
127: jdbcRas = new HashMap();
128: jmsServiceActivated = false;
129: joramResourceLoaded = false;
130: jmsConnection = false;
131: jmsConnections = new ArrayList();
132: jmsDestination = false;
133: jmsDestinations = new ArrayList();
134: jmsDestinationsTable = new Hashtable();
135: mailServiceActivated = false;
136: mailSession = false;
137: mailSessions = new HashMap();
138: mailMime = false;
139: mailMimes = new HashMap();
140: }
141:
142: /**
143: * Validate the properties that have been set from this HTTP request,
144: * and return an <code>ActionErrors</code> object that encapsulates any
145: * validation errors that have been found. If no errors are found, return
146: * <code>null</code> or an <code>ActionErrors</code> object with no
147: * recorded error messages.
148: *
149: * @param mapping The mapping used to select this instance
150: * @param request The servlet request we are processing
151: * @return List of errors or null
152: */
153: public ActionErrors validate(ActionMapping mapping,
154: HttpServletRequest request) {
155: ActionErrors oErrors = new ActionErrors();
156: return oErrors;
157: }
158:
159: // --------------------------------------------------------- Properties Methods
160:
161: // Parameters properties
162:
163: public String getFile() {
164: return file;
165: }
166:
167: public String getFilename() {
168: String sFilename = null;
169: if (file != null) {
170: sFilename = file.replace('\\', '/');
171: int iPos = sFilename.lastIndexOf('/');
172: if (iPos > -1) {
173: sFilename = sFilename.substring(iPos + 1);
174: }
175: }
176: return sFilename;
177: }
178:
179: public String getName() {
180: return name;
181: }
182:
183: public String getObjectName() {
184: return objectName;
185: }
186:
187: public String getType() {
188: return type;
189: }
190:
191: public void setFile(String file) {
192: this .file = file;
193: }
194:
195: public void setName(String name) {
196: this .name = name;
197: }
198:
199: public void setObjectName(String objectName) {
200: this .objectName = objectName;
201: }
202:
203: public void setType(String type) {
204: this .type = type;
205: }
206:
207: // Global MBean Ejb properties
208: public String getDisplayName() {
209: return displayName;
210: }
211:
212: public String getEjbClass() {
213: return ejbClass;
214: }
215:
216: public String getEjbName() {
217: return ejbName;
218: }
219:
220: public String getHomeClass() {
221: return homeClass;
222: }
223:
224: public String getJndiName() {
225: return jndiName;
226: }
227:
228: public String getLocalClass() {
229: return localClass;
230: }
231:
232: public String getLocalHomeClass() {
233: return localHomeClass;
234: }
235:
236: public String getRemoteClass() {
237: return remoteClass;
238: }
239:
240: public void setDisplayName(String displayName) {
241: this .displayName = displayName;
242: }
243:
244: public void setEjbClass(String ejbClass) {
245: this .ejbClass = ejbClass;
246: }
247:
248: public void setEjbName(String ejbName) {
249: this .ejbName = ejbName;
250: }
251:
252: public void setHomeClass(String homeClass) {
253: this .homeClass = homeClass;
254: }
255:
256: public void setJndiName(String jndiName) {
257: this .jndiName = jndiName;
258: }
259:
260: public void setLocalClass(String localClass) {
261: this .localClass = localClass;
262: }
263:
264: public void setLocalHomeClass(String localHomeClass) {
265: this .localHomeClass = localHomeClass;
266: }
267:
268: public void setRemoteClass(String remoteClass) {
269: this .remoteClass = remoteClass;
270: }
271:
272: public String getEjbFileName() {
273: return ejbFileName;
274: }
275:
276: public void setEjbFileName(String ejbFileName) {
277: this .ejbFileName = ejbFileName;
278: }
279:
280: public String getFullType() {
281: return fullType;
282: }
283:
284: public void setFullType(String fullType) {
285: this .fullType = fullType;
286: }
287:
288: public HashMap getDataSources() {
289: return dataSources;
290: }
291:
292: public void setDataSources(HashMap dataSources) {
293: this .dataSources = dataSources;
294: }
295:
296: public boolean isDataSource() {
297: return dataSource;
298: }
299:
300: public void setDataSource(boolean dataSource) {
301: this .dataSource = dataSource;
302: }
303:
304: public boolean isDependency() {
305: return dependency;
306: }
307:
308: public void setDependency(boolean dependency) {
309: this .dependency = dependency;
310: }
311:
312: public boolean isJmsConnection() {
313: return jmsConnection;
314: }
315:
316: public void setJmsConnection(boolean jmsConnection) {
317: this .jmsConnection = jmsConnection;
318: }
319:
320: public ArrayList getJmsConnections() {
321: return jmsConnections;
322: }
323:
324: public void setJmsConnections(ArrayList jmsConnections) {
325: this .jmsConnections = jmsConnections;
326: }
327:
328: public boolean isJmsDestination() {
329: return jmsDestination;
330: }
331:
332: public void setJmsDestination(boolean jmsDestination) {
333: this .jmsDestination = jmsDestination;
334: }
335:
336: public ArrayList getJmsDestinations() {
337: return jmsDestinations;
338: }
339:
340: public void setJmsDestinations(ArrayList jmsDestinations) {
341: this .jmsDestinations = jmsDestinations;
342: }
343:
344: public HashMap getMailSessions() {
345: return mailSessions;
346: }
347:
348: public void setMailSessions(HashMap mailSessions) {
349: this .mailSessions = mailSessions;
350: }
351:
352: public HashMap getMailMimes() {
353: return mailMimes;
354: }
355:
356: public void setMailMimes(HashMap mailMimes) {
357: this .mailMimes = mailMimes;
358: }
359:
360: public boolean isMailSession() {
361: return mailSession;
362: }
363:
364: public void setMailSession(boolean mailSession) {
365: this .mailSession = mailSession;
366: }
367:
368: public boolean isMailMime() {
369: return mailMime;
370: }
371:
372: public void setMailMime(boolean mailMime) {
373: this .mailMime = mailMime;
374: }
375:
376: public boolean isDatabaseServiceActivated() {
377: return databaseServiceActivated;
378: }
379:
380: public void setDatabaseServiceActivated(
381: boolean databaseServiceActivated) {
382: this .databaseServiceActivated = databaseServiceActivated;
383: }
384:
385: public boolean isJmsServiceActivated() {
386: return jmsServiceActivated;
387: }
388:
389: public void setJmsServiceActivated(boolean jmsServiceActivated) {
390: this .jmsServiceActivated = jmsServiceActivated;
391: }
392:
393: public boolean isMailServiceActivated() {
394: return mailServiceActivated;
395: }
396:
397: public void setMailServiceActivated(boolean mailServiceActivated) {
398: this .mailServiceActivated = mailServiceActivated;
399: }
400:
401: /**
402: * @return Returns the joramResourceLoaded.
403: */
404: public boolean isJoramResourceLoaded() {
405: return joramResourceLoaded;
406: }
407:
408: /**
409: * @param joramResourceLoaded The joramResourceLoaded to set.
410: */
411: public void setJoramResourceLoaded(boolean joramResourceLoaded) {
412: this .joramResourceLoaded = joramResourceLoaded;
413: }
414:
415: /**
416: * @return Returns the action.
417: */
418: public String getAction() {
419: return action;
420: }
421:
422: /**
423: * @param action The action to set.
424: */
425: public void setAction(String action) {
426: this .action = action;
427: }
428:
429: /**
430: * Helper method to check that it is a required number and
431: * is a valid integer within the given range. (min, max).
432: *
433: * @param field The field name in the form for which this error occured.
434: * @param numText The string representation of the number.
435: * @param rangeCheck Boolean value set to true of reange check should be performed.
436: *
437: * @param min The lower limit of the range
438: * @param max The upper limit of the range
439: * error.webapp.setting.sessionTimeout.required
440: */
441: protected void numberCheck(ActionErrors p_Errors, String field,
442: String numText, boolean rangeCheck, int min, int max) {
443: // Check for 'is required'
444: if ((numText == null) || (numText.length() < 1)) {
445: p_Errors.add(field, new ActionMessage(
446: "error.ejb.type.session." + field + ".required"));
447: } else {
448:
449: // check for 'must be a number' in the 'valid range'
450: try {
451: int num = Integer.parseInt(numText);
452: // perform range check only if required
453: if (rangeCheck) {
454: if ((num < min) || (num > max)) {
455: p_Errors.add(field, new ActionMessage(
456: "error.ejb.type.session." + field
457: + ".range"));
458: }
459: }
460: } catch (NumberFormatException e) {
461: p_Errors.add(field, new ActionMessage(
462: "error.ejb.type.session." + field + ".format"));
463: }
464: }
465: }
466:
467: /**
468: * @return Returns the jmsDestinationsTable.
469: */
470: public Hashtable getJmsDestinationsTable() {
471: return jmsDestinationsTable;
472: }
473:
474: /**
475: * @param jmsDestinationsTable The jmsDestinationsTable to set.
476: */
477: public void setJmsDestinationsTable(Hashtable jmsDestinationsTable) {
478: this .jmsDestinationsTable = jmsDestinationsTable;
479: }
480:
481: /**
482: * @return Returns the cacheSize.
483: */
484: public int getCacheSize() {
485: return cacheSize;
486: }
487:
488: /**
489: * @param cacheSize The cacheSize to set.
490: */
491: public void setCacheSize(int cacheSize) {
492: this .cacheSize = cacheSize;
493: }
494:
495: /**
496: * @return Returns the maxCacheSize.
497: */
498: public int getMaxCacheSize() {
499: return maxCacheSize;
500: }
501:
502: /**
503: * @param maxCacheSize The maxCacheSize to set.
504: */
505: public void setMaxCacheSize(int maxCacheSize) {
506: this .maxCacheSize = maxCacheSize;
507: }
508:
509: /**
510: * @return Returns the minPoolSize.
511: */
512: public int getMinPoolSize() {
513: return minPoolSize;
514: }
515:
516: /**
517: * @param minPoolSize The minPoolSize to set.
518: */
519: public void setMinPoolSize(int minPoolSize) {
520: this .minPoolSize = minPoolSize;
521: }
522:
523: /**
524: * @return Returns the poolSize.
525: */
526: public int getPoolSize() {
527: return poolSize;
528: }
529:
530: /**
531: * @param poolSize The poolSize to set.
532: */
533: public void setPoolSize(int poolSize) {
534: this .poolSize = poolSize;
535: }
536:
537: public boolean isResourceServiceActivated() {
538: return resourceServiceActivated;
539: }
540:
541: public void setResourceServiceActivated(
542: boolean resourceServiceActivated) {
543: this .resourceServiceActivated = resourceServiceActivated;
544: }
545:
546: public HashMap getJdbcRas() {
547: return jdbcRas;
548: }
549:
550: public void setJdbcRas(HashMap jdbcRas) {
551: this.jdbcRas = jdbcRas;
552: }
553:
554: }
|