Source Code Cross Referenced for HibernateSetupForm.java in  » Groupware » ivatagroupware » com » ivata » groupware » admin » struts » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » ivatagroupware » com.ivata.groupware.admin.struts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * ---------------------------------------------------------
005:         * ivata groupware may be redistributed under the GNU General Public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General Public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General Public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * ---------------------------------------------------------
030:         * $Log: HibernateSetupForm.java,v $
031:         * Revision 1.5  2005/10/12 18:36:18  colinmacleod
032:         * Standardized format of Logger declaration - to make it easier to find instances
033:         * which are not both static and final.
034:         *
035:         * Revision 1.4  2005/10/11 18:57:17  colinmacleod
036:         * Fixed some checkstyle and javadoc issues.
037:         *
038:         * Revision 1.3  2005/10/03 10:21:15  colinmacleod
039:         * Fixed some style and javadoc issues.
040:         *
041:         * Revision 1.2  2005/10/02 14:08:59  colinmacleod
042:         * Added/improved log4j logging.
043:         *
044:         * Revision 1.1  2005/09/29 13:06:06  colinmacleod
045:         * First version of setting subproject.
046:         * Existing classes restructured, new setting user interface created.
047:         * Flexible XML UI configuration makes it easy to reuse the same web pages in
048:         * other projects.
049:         * Web files work as stand-alone webapp for testing.
050:         *
051:         * Revision 1.2  2005/09/14 16:00:16  colinmacleod
052:         * Made database paths more flexible, to suit ivata cms.
053:         * Removed unused local and class variables.
054:         * Added serialVersionUID.
055:         *
056:         * Revision 1.1  2005/04/11 10:03:43  colinmacleod
057:         * Added setup feature.
058:         *
059:         * ---------------------------------------------------------
060:         */
061:        package com.ivata.groupware.admin.struts;
062:
063:        import java.util.Arrays;
064:        import java.util.List;
065:
066:        import javax.servlet.http.HttpServletRequest;
067:        import javax.servlet.http.HttpSession;
068:
069:        import org.apache.log4j.Logger;
070:        import org.apache.struts.action.ActionMapping;
071:
072:        import com.ivata.groupware.admin.security.server.SecuritySession;
073:        import com.ivata.groupware.admin.setting.Settings;
074:        import com.ivata.groupware.container.persistence.hibernate.HibernateSetupConstants;
075:        import com.ivata.mask.util.StringHandling;
076:        import com.ivata.mask.util.SystemException;
077:        import com.ivata.mask.validation.ValidationError;
078:        import com.ivata.mask.validation.ValidationErrors;
079:        import com.ivata.mask.web.struts.DialogForm;
080:
081:        /**
082:         * Contains all of the values you need to setup a basic <strong>ivata
083:         * groupware</strong> installation.
084:         *
085:         * @since ivata groupware 0.11 (2005-03-27)
086:         * @author Colin MacLeod
087:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
088:         * @version $Revision: 1.5 $
089:         */
090:        public class HibernateSetupForm extends DialogForm {
091:            /**
092:             * Serialization version (for <code>Serializable</code> interface).
093:             */
094:            private static final long serialVersionUID = 1L;
095:            /**
096:             * Logger for this class.
097:             */
098:            private static final Logger logger = Logger
099:                    .getLogger(HibernateSetupForm.class);
100:            /**
101:             * <copyDoc>Refer to {@link #isCreateDatabaseAutomatically}.</copyDoc>
102:             */
103:            private boolean createDatabaseAutomatically;
104:            /**
105:             * <copyDoc>Refer to {@link #getDatabaseDialect}.</copyDoc>
106:             */
107:            private String databaseDialect;
108:            /**
109:             * <copyDoc>Refer to {@link #getDatabaseDialects}.</copyDoc>
110:             */
111:            private List databaseDialects;
112:            /**
113:             * <copyDoc>Refer to {@link #getDatabaseDriver}.</copyDoc>
114:             */
115:            private String databaseDriver;
116:            /**
117:             * <copyDoc>Refer to {@link #getDatabaseDrivers}.</copyDoc>
118:             */
119:            private List databaseDrivers;
120:            /**
121:             * <copyDoc>Refer to {@link #getDatabasePassword}.</copyDoc>
122:             */
123:            private String databasePassword;
124:            /**
125:             * <copyDoc>Refer to {@link #getDatabaseTypes}.</copyDoc>
126:             */
127:            private List databaseTypes;
128:            /**
129:             * <copyDoc>Refer to {@link #getDatabaseURL}.</copyDoc>
130:             */
131:            private String databaseURL;
132:            /**
133:             * <copyDoc>Refer to {@link #getDatabaseURLs}.</copyDoc>
134:             */
135:            private List databaseURLs;
136:            /**
137:             * <copyDoc>Refer to {@link #getDatabaseUserName}.</copyDoc>
138:             */
139:            private String databaseUserName;
140:            /**
141:             * <copyDoc>
142:             * Refer to {@link HibernateSetupForm#HibernateSetupForm(Settings)}.
143:             * </copyDoc>
144:             */
145:            private Settings settings;
146:
147:            /**
148:             * Constructor. Normally called by <code>PicoContainer</code>.
149:             *
150:             * @param settingsParam Used to retrieve system setting
151:             * &quot;siteDefaultDB&quot;.
152:             */
153:            public HibernateSetupForm(final Settings settingsParam) {
154:                this .settings = settingsParam;
155:            }
156:
157:            /**
158:             * Prepare the form.
159:             *
160:             * @see com.ivata.mask.web.struts.DialogForm#clear()
161:             */
162:            protected void clear() {
163:                if (logger.isDebugEnabled()) {
164:                    logger.debug("clear() - start");
165:                }
166:
167:                if (logger.isDebugEnabled()) {
168:                    logger.debug("clear() - end");
169:                }
170:            }
171:
172:            /**
173:             * The <strong>Hibernate</strong> dialect of the database we will use.
174:             *
175:             * @return Returns the database dialect.
176:             */
177:            public String getDatabaseDialect() {
178:                if (logger.isDebugEnabled()) {
179:                    logger.debug("getDatabaseDialect() - start");
180:                }
181:
182:                if (logger.isDebugEnabled()) {
183:                    logger.debug("getDatabaseDialect() - end - return value = "
184:                            + databaseDialect);
185:                }
186:                return databaseDialect;
187:            }
188:
189:            /**
190:             * A list of all the string names of the <strong>Hibernate</strong>
191:             * dialects available.
192:             * @return Returns the database dialects.
193:             */
194:            public List getDatabaseDialects() {
195:                if (logger.isDebugEnabled()) {
196:                    logger.debug("getDatabaseDialects() - start");
197:                }
198:
199:                if (logger.isDebugEnabled()) {
200:                    logger
201:                            .debug("getDatabaseDialects() - end - return value = "
202:                                    + databaseDialects);
203:                }
204:                return databaseDialects;
205:            }
206:
207:            /**
208:             * The name of the <strong>JDBC</strong> database driver class we will use.
209:             * @return Returns the database driver.
210:             */
211:            public String getDatabaseDriver() {
212:                if (logger.isDebugEnabled()) {
213:                    logger.debug("getDatabaseDriver() - start");
214:                }
215:
216:                if (logger.isDebugEnabled()) {
217:                    logger.debug("getDatabaseDriver() - end - return value = "
218:                            + databaseDriver);
219:                }
220:                return databaseDriver;
221:            }
222:
223:            /**
224:             * A list of all available <strong>JDBC</strong> database driver classes.
225:             *
226:             * @return Returns the database drivers.
227:             */
228:            public List getDatabaseDrivers() {
229:                if (logger.isDebugEnabled()) {
230:                    logger.debug("getDatabaseDrivers() - start");
231:                }
232:
233:                if (logger.isDebugEnabled()) {
234:                    logger.debug("getDatabaseDrivers() - end - return value = "
235:                            + databaseDrivers);
236:                }
237:                return databaseDrivers;
238:            }
239:
240:            /**
241:             * Password used within the database system.
242:             * @return Returns the database password.
243:             */
244:            public String getDatabasePassword() {
245:                if (logger.isDebugEnabled()) {
246:                    logger.debug("getDatabasePassword() - start");
247:                }
248:
249:                if (logger.isDebugEnabled()) {
250:                    logger
251:                            .debug("getDatabasePassword() - end - return value = "
252:                                    + databasePassword);
253:                }
254:                return databasePassword;
255:            }
256:
257:            /**
258:             * This list should correspond to {@link #getDatabaseDialects} and is a
259:             * list of the database names for each dialect.
260:             * @return Returns the database types.
261:             */
262:            public List getDatabaseTypes() {
263:                if (logger.isDebugEnabled()) {
264:                    logger.debug("getDatabaseTypes() - start");
265:                }
266:
267:                if (logger.isDebugEnabled()) {
268:                    logger.debug("getDatabaseTypes() - end - return value = "
269:                            + databaseTypes);
270:                }
271:                return databaseTypes;
272:            }
273:
274:            /**
275:             * The <strong>JDBC</strong> URL of the database we will use.
276:             *
277:             * @return Returns the database URL.
278:             */
279:            public String getDatabaseURL() {
280:                if (logger.isDebugEnabled()) {
281:                    logger.debug("getDatabaseURL() - start");
282:                }
283:
284:                if (logger.isDebugEnabled()) {
285:                    logger.debug("getDatabaseURL() - end - return value = "
286:                            + databaseURL);
287:                }
288:                return databaseURL;
289:            }
290:
291:            /**
292:             * This list should correspond to {@link #getDatabaseDialects} and is a
293:             * list of the default URLs for each dialect.
294:             *
295:             * @return Returns the default database URLs.
296:             */
297:            public List getDatabaseURLs() {
298:                if (logger.isDebugEnabled()) {
299:                    logger.debug("getDatabaseURLs() - start");
300:                }
301:
302:                if (logger.isDebugEnabled()) {
303:                    logger.debug("getDatabaseURLs() - end - return value = "
304:                            + databaseURLs);
305:                }
306:                return databaseURLs;
307:            }
308:
309:            /**
310:             * The user name used to login to the database system.
311:             * @return Returns the database user name.
312:             */
313:            public String getDatabaseUserName() {
314:                if (logger.isDebugEnabled()) {
315:                    logger.debug("getDatabaseUserName() - start");
316:                }
317:
318:                if (logger.isDebugEnabled()) {
319:                    logger
320:                            .debug("getDatabaseUserName() - end - return value = "
321:                                    + databaseUserName);
322:                }
323:                return databaseUserName;
324:            }
325:
326:            /**
327:             * Determines whether or not setup should create a simple
328:             * <strong>HSQLDB</strong> database automaticlaly.
329:             *
330:             * @return <code>true</code> if the database should be created
331:             * automatically.
332:             */
333:            public boolean isCreateDatabaseAutomatically() {
334:                if (logger.isDebugEnabled()) {
335:                    logger.debug("isCreateDatabaseAutomatically() - start");
336:                }
337:
338:                if (logger.isDebugEnabled()) {
339:                    logger
340:                            .debug("isCreateDatabaseAutomatically - end - return value = "
341:                                    + createDatabaseAutomatically);
342:                }
343:                return createDatabaseAutomatically;
344:            }
345:
346:            /**
347:             * {@inheritDoc}
348:             *
349:             * @param mappingParam {@inheritDoc}
350:             * @param requestParam {@inheritDoc}
351:             */
352:            public void reset(final ActionMapping mappingParam,
353:                    final HttpServletRequest requestParam) {
354:                if (logger.isDebugEnabled()) {
355:                    logger.debug("reset(ActionMapping mappingParam = "
356:                            + mappingParam
357:                            + ", HttpServletRequest requestParam = "
358:                            + requestParam + ") - start");
359:                }
360:
361:                // the following are the settings we'll use to make an automatic
362:                // database (constructed using hsql)
363:                createDatabaseAutomatically = false;
364:
365:                databaseDialect = "";
366:                databaseDialects = Arrays
367:                        .asList(HibernateSetupConstants.DATABASE_DIALECTS);
368:                databaseDriver = "";
369:                databaseDrivers = Arrays
370:                        .asList(HibernateSetupConstants.DATABASE_DRIVERS);
371:                databaseTypes = Arrays
372:                        .asList(HibernateSetupConstants.DATABASE_TYPES);
373:                databaseURL = "";
374:                databaseURLs = Arrays
375:                        .asList(HibernateSetupConstants.DATABASE_URLS);
376:
377:                if (logger.isDebugEnabled()) {
378:                    logger
379:                            .debug("reset(ActionMapping, HttpServletRequest) - end");
380:                }
381:            }
382:
383:            /**
384:             * <copyDoc>Refer to {@link #isCreateDatabaseAutomatically}.</copyDoc>
385:             * @param createDatabaseAutomaticallyParam Refer to
386:             * {@link #isCreateDatabaseAutomatically}.
387:             */
388:            public void setCreateDatabaseAutomatically(
389:                    final boolean createDatabaseAutomaticallyParam) {
390:                if (logger.isDebugEnabled()) {
391:                    logger
392:                            .debug("Setting createDatabaseAutomatically. Before '"
393:                                    + createDatabaseAutomatically
394:                                    + "', after '"
395:                                    + createDatabaseAutomaticallyParam + "'");
396:                }
397:                createDatabaseAutomatically = createDatabaseAutomaticallyParam;
398:
399:                if (logger.isDebugEnabled()) {
400:                    logger
401:                            .debug("setCreateDatabaseAutomatically(boolean) - end");
402:                }
403:            }
404:
405:            /**
406:             * <copyDoc>Refer to {@link #getDatabaseDialect}.</copyDoc>
407:             * @param databaseDialectParam
408:             *  <copyDoc>Refer to {@link #getDatabaseDialect}.</copyDoc>
409:             */
410:            public void setDatabaseDialect(final String databaseDialectParam) {
411:                if (logger.isDebugEnabled()) {
412:                    logger.debug("Setting databaseDialect. Before '"
413:                            + databaseDialect + "', after '"
414:                            + databaseDialectParam + "'");
415:                }
416:                databaseDialect = databaseDialectParam;
417:
418:                if (logger.isDebugEnabled()) {
419:                    logger.debug("setDatabaseDialect(String) - end");
420:                }
421:            }
422:
423:            /**
424:             * <copyDoc>Refer to {@link #getDatabaseDialects}.</copyDoc>
425:             * @param databaseDialectsParam
426:             * <copyDoc>Refer to {@link #getDatabaseDialects}.</copyDoc>
427:             */
428:            public void setDatabaseDialects(final List databaseDialectsParam) {
429:                if (logger.isDebugEnabled()) {
430:                    logger.debug("Setting databaseDialects. Before '"
431:                            + databaseDialects + "', after '"
432:                            + databaseDialectsParam + "'");
433:                }
434:                databaseDialects = databaseDialectsParam;
435:
436:                if (logger.isDebugEnabled()) {
437:                    logger.debug("setDatabaseDialects(List) - end");
438:                }
439:            }
440:
441:            /**
442:             * <copyDoc>Refer to {@link #getDatabaseDriver}.</copyDoc>
443:             * @param databaseDriverParam
444:             * <copyDoc>Refer to {@link #getDatabaseDriver}.</copyDoc>
445:             */
446:            public void setDatabaseDriver(final String databaseDriverParam) {
447:                if (logger.isDebugEnabled()) {
448:                    logger.debug("Setting databaseDriver. Before '"
449:                            + databaseDriver + "', after '"
450:                            + databaseDriverParam + "'");
451:                }
452:                databaseDriver = databaseDriverParam;
453:
454:                if (logger.isDebugEnabled()) {
455:                    logger.debug("setDatabaseDriver(String) - end");
456:                }
457:            }
458:
459:            /**
460:             * <copyDoc>Refer to {@link #getDatabaseDrivers}.</copyDoc>
461:             * @param databaseDriversParam
462:             * <copyDoc>Refer to {@link #getDatabaseDrivers}.</copyDoc>
463:             */
464:            public void setDatabaseDrivers(final List databaseDriversParam) {
465:                if (logger.isDebugEnabled()) {
466:                    logger.debug("Setting databaseDrivers. Before '"
467:                            + databaseDrivers + "', after '"
468:                            + databaseDriversParam + "'");
469:                }
470:                databaseDrivers = databaseDriversParam;
471:
472:                if (logger.isDebugEnabled()) {
473:                    logger.debug("setDatabaseDrivers(List) - end");
474:                }
475:            }
476:
477:            /**
478:             * <copyDoc>Refer to {@link #getDatabasePassword}.</copyDoc>
479:             * @param databasePasswordParam
480:             * <copyDoc>Refer to {@link #getDatabasePassword}.</copyDoc>
481:             */
482:            public void setDatabasePassword(final String databasePasswordParam) {
483:                if (logger.isDebugEnabled()) {
484:                    logger.debug("Setting databasePassword. Before '"
485:                            + databasePassword + "', after '"
486:                            + databasePasswordParam + "'");
487:                }
488:                databasePassword = databasePasswordParam;
489:
490:                if (logger.isDebugEnabled()) {
491:                    logger.debug("setDatabasePassword(String) - end");
492:                }
493:            }
494:
495:            /**
496:             * <copyDoc>Refer to {@link #getDatabaseTypes}.</copyDoc>
497:             * @param databaseTypesParam
498:             * <copyDoc>Refer to {@link #getDatabaseTypes}.</copyDoc>
499:             */
500:            public void setDatabaseTypes(final List databaseTypesParam) {
501:                if (logger.isDebugEnabled()) {
502:                    logger.debug("Setting databaseTypes. Before '"
503:                            + databaseTypes + "', after '" + databaseTypesParam
504:                            + "'");
505:                }
506:                databaseTypes = databaseTypesParam;
507:
508:                if (logger.isDebugEnabled()) {
509:                    logger.debug("setDatabaseTypes(List) - end");
510:                }
511:            }
512:
513:            /**
514:             * <copyDoc>Refer to {@link #getDatabaseURL}.</copyDoc>
515:             * @param databaseURLParam
516:             * <copyDoc>Refer to {@link #getDatabaseURL}.</copyDoc>
517:             */
518:            public void setDatabaseURL(final String databaseURLParam) {
519:                if (logger.isDebugEnabled()) {
520:                    logger.debug("Setting databaseURL. Before '" + databaseURL
521:                            + "', after '" + databaseURLParam + "'");
522:                }
523:                databaseURL = databaseURLParam;
524:
525:                if (logger.isDebugEnabled()) {
526:                    logger.debug("setDatabaseURL(String) - end");
527:                }
528:            }
529:
530:            /**
531:             * <copyDoc>Refer to {@link #getDatabaseURLs}.</copyDoc>
532:             * @param databaseURLsParam
533:             * <copyDoc>Refer to {@link #getDatabaseURLs}.</copyDoc>
534:             */
535:            public void setDatabaseURLs(final List databaseURLsParam) {
536:                if (logger.isDebugEnabled()) {
537:                    logger.debug("Setting databaseURLs. Before '"
538:                            + databaseURLs + "', after '" + databaseURLsParam
539:                            + "'");
540:                }
541:                databaseURLs = databaseURLsParam;
542:
543:                if (logger.isDebugEnabled()) {
544:                    logger.debug("setDatabaseURLs(List) - end");
545:                }
546:            }
547:
548:            /**
549:             * <copyDoc>Refer to {@link #getDatabaseUserName}.</copyDoc>
550:             * @param databaseUserNameParam
551:             * <copyDoc>Refer to {@link #getDatabaseUserName}.</copyDoc>
552:             */
553:            public void setDatabaseUserName(final String databaseUserNameParam) {
554:                if (logger.isDebugEnabled()) {
555:                    logger.debug("Setting databaseUserName. Before '"
556:                            + databaseUserName + "', after '"
557:                            + databaseUserNameParam + "'");
558:                }
559:                databaseUserName = databaseUserNameParam;
560:
561:                if (logger.isDebugEnabled()) {
562:                    logger.debug("setDatabaseUserName(String) - end");
563:                }
564:            }
565:
566:            /**
567:             * Check all of the input is valid.
568:             * @param requestParam
569:             * <copyDoc>Refer to {@link com.ivata.mask.web.struts.DialogForm#validate}.
570:             * </copyDoc>
571:             * @param sessionParam
572:             * <copyDoc>Refer to {@link com.ivata.mask.web.struts.DialogForm#validate}.
573:             * </copyDoc>
574:             * @return
575:             * <copyDoc>Refer to {@link com.ivata.mask.web.struts.DialogForm#validate}.
576:             * </copyDoc>
577:             */
578:            public ValidationErrors validate(
579:                    final HttpServletRequest requestParam,
580:                    final HttpSession sessionParam) {
581:                if (logger.isDebugEnabled()) {
582:                    logger.debug("validate(HttpServletRequest requestParam = "
583:                            + requestParam + ", HttpSession sessionParam = "
584:                            + sessionParam + ") - start");
585:                }
586:
587:                ValidationErrors errors = super .validate(requestParam,
588:                        sessionParam);
589:                // if we should create the database automatically, default the values
590:                // (as the disabled fields will not be submitted)
591:                if (createDatabaseAutomatically) {
592:                    databaseDriver = HibernateSetupConstants.AUTOMATIC_DATABASE_DRIVER;
593:                    databaseDialect = HibernateSetupConstants.AUTOMATIC_DATABASE_DIALECT;
594:                    databasePassword = HibernateSetupConstants.AUTOMATIC_DATABASE_PASSWORD;
595:                    databaseUserName = HibernateSetupConstants.AUTOMATIC_DATABASE_USER_NAME;
596:                    // check the URL starts with the hypersonic file URL
597:                    if (!databaseURL
598:                            .startsWith(HibernateSetupConstants.AUTOMATIC_DATABASE_URL_START)) {
599:                        errors
600:                                .add(new ValidationError(
601:                                        "errors.setup.automaticDatabaseURL",
602:                                        Arrays
603:                                                .asList(new String[] {
604:                                                        HibernateSetupConstants.AUTOMATIC_DATABASE_URL_START,
605:                                                        databaseURL })));
606:                    }
607:                } else {
608:                    // if you don't specify any of the database fields, default back
609:                    // to the memory database
610:                    if (StringHandling.isNullOrEmpty(databaseDriver)
611:                            && StringHandling.isNullOrEmpty(databasePassword)
612:                            && StringHandling.isNullOrEmpty(databaseUserName)
613:                            && StringHandling.isNullOrEmpty(databaseURL)) {
614:                        databaseDriver = HibernateSetupConstants.AUTOMATIC_DATABASE_DRIVER;
615:                        databaseDialect = HibernateSetupConstants.AUTOMATIC_DATABASE_DIALECT;
616:                        databasePassword = HibernateSetupConstants.AUTOMATIC_DATABASE_PASSWORD;
617:                        databaseUserName = HibernateSetupConstants.AUTOMATIC_DATABASE_USER_NAME;
618:
619:                        SecuritySession securitySession = (SecuritySession) sessionParam
620:                                .getAttribute("securitySession");
621:                        assert (securitySession != null);
622:
623:                        try {
624:                            databaseURL = HibernateSetupConstants.AUTOMATIC_DATABASE_MEMORY_URL
625:                                    + settings.getStringSetting(
626:                                            securitySession, "siteDefaultDB",
627:                                            null);
628:                        } catch (SystemException e) {
629:                            logger
630:                                    .error(
631:                                            "validate(HttpServletRequest, HttpSession)",
632:                                            e);
633:
634:                            throw new RuntimeException(e);
635:                        }
636:
637:                        // otherwise, if you specify any of the DB fields, you need at least
638:                        // dialect driver and URL.
639:                    } else if (StringHandling.isNullOrEmpty(databaseDialect)
640:                            || StringHandling.isNullOrEmpty(databaseDriver)
641:                            || StringHandling.isNullOrEmpty(databaseURL)) {
642:                        errors.add(new ValidationError("errors.setup.database",
643:                                Arrays.asList(new String[] {})));
644:                    }
645:                }
646:
647:                if (logger.isDebugEnabled()) {
648:                    logger.debug("validate - end - return value = " + errors);
649:                }
650:                return errors;
651:            }
652:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.