001: /* ====================================================================
002: * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
003: *
004: * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * 3. The end-user documentation included with the redistribution,
019: * if any, must include the following acknowledgment:
020: * "This product includes software developed by Jcorporate Ltd.
021: * (http://www.jcorporate.com/)."
022: * Alternately, this acknowledgment may appear in the software itself,
023: * if and wherever such third-party acknowledgments normally appear.
024: *
025: * 4. "Jcorporate" and product names such as "Expresso" must
026: * not be used to endorse or promote products derived from this
027: * software without prior written permission. For written permission,
028: * please contact info@jcorporate.com.
029: *
030: * 5. Products derived from this software may not be called "Expresso",
031: * or other Jcorporate product names; nor may "Expresso" or other
032: * Jcorporate product names appear in their name, without prior
033: * written permission of Jcorporate Ltd.
034: *
035: * 6. No product derived from this software may compete in the same
036: * market space, i.e. framework, without prior written permission
037: * of Jcorporate Ltd. For written permission, please contact
038: * partners@jcorporate.com.
039: *
040: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
041: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
042: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
043: * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
044: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
045: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
046: * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
047: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
048: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
049: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
050: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
051: * SUCH DAMAGE.
052: * ====================================================================
053: *
054: * This software consists of voluntary contributions made by many
055: * individuals on behalf of the Jcorporate Ltd. Contributions back
056: * to the project(s) are encouraged when you make modifications.
057: * Please send them to support@jcorporate.com. For more information
058: * on Jcorporate Ltd. and its products, please see
059: * <http://www.jcorporate.com/>.
060: *
061: * Portions of this software are based upon other open source
062: * products and are subject to their respective licenses.
063: */
064: package com.jcorporate.expresso.core;
065:
066: import com.jcorporate.expresso.core.db.DBException;
067: import com.jcorporate.expresso.core.dbobj.Schema;
068: import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
069: import com.jcorporate.expresso.core.misc.ConfigManager;
070: import com.jcorporate.expresso.core.security.User;
071: import com.jcorporate.expresso.kernel.InstallLog;
072: import com.jcorporate.expresso.kernel.util.ClassLocator;
073: import com.jcorporate.expresso.services.dbobj.JobQueue;
074:
075: /**
076: * Standard Schema
077: * object for the Expresso framework. It provides 'tie ins' for all the
078: * classes within the framework. You use your own Schema derived from
079: * <code>com.jcorporate.expresso.core.dbobj.Schema</code> when creating your
080: * own application
081: *
082: * @author Michael Nash
083: * @since Expresso 1.0
084: */
085: public final class ExpressoSchema extends Schema {
086: private static String currentVersionString = "5.6.0";
087: // private static String log4jRequiredVersion = "1.2.8";
088: // private static String xercesRequiredVersion = "XmlCommons 1.0";
089:
090: /**
091: * This variable prevents multiple complex instantiations since most of the
092: * schema data is kept in a static variable anyway.
093: */
094: private static boolean isInitialized = false;
095:
096: /**
097: * Constructor
098: *
099: * @throws DBException if there's an error building the object
100: */
101: public ExpressoSchema() throws DBException {
102: if (isInitialized) {
103: return;
104: }
105:
106: /* Check the Log4j version */
107: try {
108: ClassLocator.loadClass("org.apache.log4j.Logger");
109: } catch (Exception e) {
110: System.err
111: .println("You have an older version of log4j. "
112: + "Please install a version greater or equal to version 1.2.1");
113: }
114:
115: if (ConfigManager.isInitialized()) {
116: isInitialized = true;
117:
118: try {
119: constructDBObjects();
120: constructControllers();
121:
122: //Add all reports belonging to the Expresso Schema
123: addReportPage(com.jcorporate.expresso.ext.report.DownloadUsers.class);
124:
125: /* Now add the Jobs in this Schema */
126: addJob(com.jcorporate.expresso.ext.job.SendNotice.class);
127: addJob(com.jcorporate.expresso.services.job.TestJob.class);
128: addJob(com.jcorporate.expresso.services.job.ControllerJob.class);
129: addJob(com.jcorporate.expresso.services.job.ValidationJob.class);
130: addJob(com.jcorporate.expresso.services.job.ClearOldValidation.class);
131:
132: /* Now add the normal servlets */
133: addServlet(com.jcorporate.expresso.core.servlet.Test.class);
134:
135: constructSetupValues();
136: } catch (Exception e) {
137: e.printStackTrace();
138: isInitialized = false;
139: throw new DBException(e);
140: }
141: }
142: /* if */
143: }
144:
145: /* ExpressoSchema() */
146:
147: /**
148: * Returns the default component code for this schema. Useful for automated
149: * component testing/installation
150: *
151: * @return the component code string. In this case there is no component
152: * code so it returns an empty string.
153: */
154: public String getDefaultComponentCode() {
155: return "";
156: }
157:
158: /**
159: * Returns the default description for this schema. Useful for automated
160: * component testing/installation
161: *
162: * @return the name of the schema
163: */
164: public String getDefaultDescription() {
165: return "Expresso Framework Schema";
166: }
167:
168: /**
169: * Returns the path to the messages bundle property file
170: *
171: * @return the path to the messages bundle
172: */
173: public String getMessageBundlePath() {
174: return "com/jcorporate/expresso/core";
175: }
176:
177: /* getMessageBundlePath() */
178:
179: /**
180: * Gets the current version of this Framework
181: *
182: * @return the current version in string format
183: */
184: public String getVersion() {
185: return currentVersionString;
186: }
187:
188: /**
189: * Runs additional setup operations for the Expresso Schema
190: *
191: * @param installLog The 'logger' to send informational output to.
192: * @param dataContext the datacontext to work with.
193: * @throws com.jcorporate.expresso.core.db.DBException
194: * upon database access
195: * error
196: */
197: public synchronized void otherSetup(InstallLog installLog,
198: String dataContext)
199: throws com.jcorporate.expresso.core.db.DBException {
200: //Add a recurring 'Clear old validation entries job'
201: JobQueue jq = new JobQueue(SecuredDBObject.SYSTEM_ACCOUNT);
202: jq.setDataContext(dataContext);
203: jq
204: .setField(
205: JobQueue.FLD_JOBCODE,
206: com.jcorporate.expresso.services.job.ClearOldValidation.class
207: .getName());
208: if (!jq.find()) {
209:
210: //Execute every Saturday at midnight
211: jq.setField(JobQueue.FLD_JOBCRON_PARAMS, "0,0,-1,-1,7,-1");
212: jq.setField(JobQueue.FLD_SERVERID, 0);
213: jq.setField(JobQueue.FLD_STATUS_CODE,
214: JobQueue.JOB_STATUS_AVAILABLE);
215: jq
216: .setField(
217: JobQueue.FLD_JOBCODE,
218: com.jcorporate.expresso.services.job.ClearOldValidation.class
219: .getName());
220: jq.setField(JobQueue.FLD_UID, User.getAdminId(dataContext));
221: jq.add();
222: installLog
223: .info("Added "
224: + com.jcorporate.expresso.services.job.ClearOldValidation.class
225: .getName()
226: + " to execute once a week");
227: } else {
228: installLog
229: .info("Clear Old Validation Job already exists in jobqueue, skipping add.");
230: }
231:
232: super .otherSetup(installLog, dataContext);
233: }
234:
235: /**
236: * Adds the appropriate controllers to the schema
237: */
238: protected void constructControllers() {
239: /* Controllers */
240: addController(com.jcorporate.expresso.services.controller.ControllerSecurityMatrix.class);
241: addController(com.jcorporate.expresso.services.controller.QueueJob.class);
242: addController(com.jcorporate.expresso.services.controller.SimpleLoginController.class);
243: addController(com.jcorporate.expresso.services.controller.SimpleRegistration.class);
244: addController(com.jcorporate.expresso.services.controller.JobSecurityMatrix.class);
245: addController(com.jcorporate.expresso.services.controller.CacheControl.class);
246:
247: // addController(com.jcorporate.expresso.ext.controller.TestController.class);
248: addController(com.jcorporate.expresso.services.controller.DBMaint.class);
249: addController(com.jcorporate.expresso.services.controller.EditUserPreference.class);
250:
251: // addController(com.jcorporate.expresso.ext.controller.RunTests.class);
252: addController(com.jcorporate.expresso.ext.controller.HealthCheck.class);
253: addController(com.jcorporate.expresso.ext.controller.DataTransfer.class);
254: addController(com.jcorporate.expresso.services.controller.ValidationController.class);
255: addController(com.jcorporate.expresso.ext.controller.Download.class);
256: addController(com.jcorporate.expresso.ext.xml.controller.XMLController.class);
257: addController(com.jcorporate.expresso.ext.controller.RunSQL.class);
258: addController(com.jcorporate.expresso.services.controller.Log.class);
259: addController(com.jcorporate.expresso.services.controller.Status.class);
260: addController(com.jcorporate.expresso.services.controller.DBSecurityMatrix.class);
261:
262: addController(com.jcorporate.expresso.ext.controller.Upload.class);
263: addController(com.jcorporate.expresso.ext.controller.ServeTextFile.class);
264: addController(com.jcorporate.expresso.ext.controller.ComponentManager.class);
265: addController(com.jcorporate.expresso.ext.controller.ReportServer.class);
266: addController(com.jcorporate.expresso.services.controller.CronController.class);
267:
268: //
269: //Controllers for managing configuration system
270: //
271: addController(com.jcorporate.expresso.services.controller.configuration.CreateSettingsWizard.class);
272:
273: addController(com.jcorporate.expresso.services.controller.Configuration.class);
274:
275: addController(com.jcorporate.expresso.services.controller.configuration.UpgradeSettingsWizard.class);
276: }
277:
278: /**
279: * Adds all the Expresso DbObjects
280: */
281: protected void constructDBObjects() {
282: addDBObject(com.jcorporate.expresso.services.dbobj.Event.class);
283: addDBObject(com.jcorporate.expresso.services.dbobj.EventMail.class);
284: addDBObject(com.jcorporate.expresso.services.dbobj.MimeTypes.class);
285: addDBObject(com.jcorporate.expresso.services.dbobj.DBMessage.class);
286: addDBObject(com.jcorporate.expresso.services.dbobj.DBOtherMap.class);
287: addDBObject(com.jcorporate.expresso.services.dbobj.DBObjLimit.class);
288: addDBObject(com.jcorporate.expresso.ext.dbobj.DownloadFiles.class);
289: addDBObject(com.jcorporate.expresso.services.dbobj.Setup.class);
290: addDBObject(com.jcorporate.expresso.services.dbobj.UserPreferenceVal.class);
291: addDBObject(com.jcorporate.expresso.services.dbobj.UserPreferenceDef.class);
292: addDBObject(com.jcorporate.expresso.services.dbobj.ControllerDefault.class);
293: addDBObject(com.jcorporate.expresso.ext.dbobj.ISOCountryCodes.class);
294: addDBObject(com.jcorporate.expresso.ext.dbobj.ReverseLookupDomains.class);
295:
296: addDBObject(com.jcorporate.expresso.services.dbobj.ControllerSecurity.class);
297: addDBObject(com.jcorporate.expresso.services.dbobj.DefaultUserInfo.class);
298: addDBObject(com.jcorporate.expresso.services.dbobj.UserGroup.class);
299: addDBObject(com.jcorporate.expresso.ext.dbobj.RegisteredUser.class);
300: addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Person.class);
301: addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Phone.class);
302: addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Address.class);
303: addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Contact.class);
304: addDBObject(com.jcorporate.expresso.ext.dbobj.RestrictedCountries.class);
305: addDBObject(com.jcorporate.expresso.ext.dbobj.RestrictedOverrides.class);
306: addDBObject(com.jcorporate.expresso.services.dbobj.DBObjSecurity.class);
307: addDBObject(com.jcorporate.expresso.services.dbobj.JobSecurity.class);
308: addDBObject(com.jcorporate.expresso.services.dbobj.GroupMembers.class);
309: addDBObject(com.jcorporate.expresso.services.dbobj.GroupNest.class);
310: addDBObject(com.jcorporate.expresso.services.dbobj.RegistrationDomain.class);
311: addDBObject(com.jcorporate.expresso.services.dbobj.RegistrationObjectMap.class);
312: addDBObject(com.jcorporate.expresso.services.dbobj.RowPermissions.class);
313: addDBObject(com.jcorporate.expresso.services.dbobj.RowGroupPerms.class);
314:
315: addDBObject(com.jcorporate.expresso.ext.dbobj.DownloadLog.class);
316: addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTests.class);
317: addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestStat.class);
318: addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestSet.class);
319: addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestSetDet.class);
320: addDBObject(com.jcorporate.expresso.services.dbobj.JobQueue.class);
321: addDBObject(com.jcorporate.expresso.services.dbobj.JobQueueParam.class);
322: addDBObject(com.jcorporate.expresso.services.dbobj.LogEntry.class);
323: addDBObject(com.jcorporate.expresso.services.dbobj.SchemaList.class);
324: addDBObject(com.jcorporate.expresso.services.dbobj.JobHandlerRegistry.class);
325: addDBObject(com.jcorporate.expresso.services.dbobj.JobHandlerControl.class);
326: addDBObject(com.jcorporate.expresso.ext.dbobj.AppIntegration.class);
327: addDBObject(com.jcorporate.expresso.services.dbobj.ValidationQueue.class);
328: addDBObject(com.jcorporate.expresso.services.dbobj.ValidationQueueParam.class);
329: addDBObject(com.jcorporate.expresso.services.dbobj.UserPreference.class);
330: addDBObject(com.jcorporate.expresso.ext.xml.dbobj.UserAgent.class);
331: addDBObject(com.jcorporate.expresso.ext.xml.dbobj.ControllerXSLMap.class);
332:
333: /** @todo this is required for AuditedSecuredDBObject to work *RD* Mon Jul 27 2004 */
334: addDBObject(com.jcorporate.expresso.ext.dbobj.AuditLog.class);
335: addDBObject(com.jcorporate.expresso.ext.dbobj.AuditLogL.class);
336:
337: /** @todo this is required for change log to work *RD* Mon Jul 27 2004 */
338: addDBObject(com.jcorporate.expresso.services.dbobj.ChangeLog.class);
339:
340: }
341:
342: /**
343: * Adds the setup values for this schema to the schema's definition
344: *
345: * @throws DBException upon database access error
346: */
347: protected void constructSetupValues() throws DBException {
348: addSetup("DefaultXSL", "Default XSL Stylesheet",
349: "%web-app%/expresso/xsl/default.xsl");
350: addSetup("BaseDir", getString("Web_Document_Root_Director"),
351: getSetupDefault("BaseDir", "%web-app%"));
352: addSetup("HTTPServ", getString("Web_Server_Host_Name"),
353: getSetupDefault("HTTPServ", "javacorp"));
354: addSetup("MAILFrom", getString("Value_for_From_field_in_Ev"),
355: getSetupDefault("MAILFrom", "none"));
356: addSetup("MAILPassword",
357: getString("Password_for_sending_e-mai"),
358: getSetupDefault("MAILPassword", ""));
359: addSetup("MAILServer", getString("SMTP_Server_Name_for_sendi"),
360: getSetupDefault("MAILServer", "example.org"));
361: addSetup("MAILUserName",
362: getString("User_Name_for_sending_e-ma"),
363: getSetupDefault("MAILUserName", ""));
364: addSetup("MaxJobs", getString("Max_Number_of_Server_Jobs_"),
365: getSetupDefault("MaxJobs", "1"));
366: addSetup("ServletPath", getString("Default_path_for_Servlets"),
367: getSetupDefault("ServletPath", "/servlet"));
368: addSetup("ServletPort",
369: getString("Port_Number_for_Servlet_Se"),
370: getSetupDefault("ServletPort", "80"));
371: addSetup("TempDir", getString("Temporary_Directory"),
372: getSetupDefault("TempDir", "%web-app%temp/"));
373: addSetup("TimerInterval",
374: getString("Scan_Job_Queue_and_directo"),
375: getSetupDefault("TimerInterval", "30"));
376: addSetup("ConnTimeOut",
377: getString("Database_Connection_Timout"),
378: getSetupDefault("ConnTimeOut", "60"));
379: addSetup("DefaultGroup",
380: getString("Default_User_Group_for_Sel"),
381: getSetupDefault("DefaultGroup", "Demo"));
382: addSetup("MaxConnections",
383: getString("Maximum_connections_to_att"),
384: getSetupDefault("MaxConnections", "4"));
385: addSetup("MinConnections",
386: getString("Minimum_connections_to_att"),
387: getSetupDefault("MinConnections", "2"));
388: addSetup("MailList", getString("Mailing_List_Address"),
389: getSetupDefault("MailList", "opensource@servlets.net"));
390: addSetup("RestartServer", getString("RestartServer"),
391: getSetupDefault("RestartServer", ""));
392:
393: // Added to better customize standard messages, such as email validations
394: addSetup("RequireEmailValidate",
395: getString("RequireEmailValidate"), getSetupDefault(
396: "RequireEmailValidate", "N"));
397: addSetup(
398: "EmailValidateURL",
399: getString("EmailValidateURL"),
400: getSetupDefault("EmailValidateURL",
401: "http://www.yourdomain.com/servlet/EmailValidation"));
402: addSetup("AdminName", getString("AdminName"), getSetupDefault(
403: "AdminName", "webmaster"));
404: addSetup("AdminEmail", getString("AdminEmail"),
405: getSetupDefault("AdminEmail", ""));
406: addSetup("CompanyName", getString("CompanyName"),
407: getSetupDefault("CompanyName", ""));
408: addSetup("HomePageURL", getString("HomePageURL"),
409: getSetupDefault("HomePageURL", ""));
410: addSetup("ServletEvent", getString("ServletEvent"),
411: getSetupDefault("ServletEvent", "Y"));
412: addSetup("ContextPath", "Context Path for Expresso",
413: getSetupDefault("ContextPath", "%context%"));
414: addSetup("Header", "Header URL for Framesets", getSetupDefault(
415: "Header", "%context%/%expresso-dir%/header.jsp"));
416: addSetup("HeaderHeight", "Size of Header for Framesets",
417: getSetupDefault("HeaderHeight", "73"));
418:
419: addSetup("SecurityDB",
420: "Database to use for User/Group Security Info",
421: getSetupDefault("SecurityDB", ""));
422:
423: addSetup("SecurityDBObjs",
424: "Database Objects that use the SecurityDB db/context",
425: getSetupDefault("SecurityDB", ""));
426:
427: //
428: //This 'default' is not the same as 'default context'
429: //
430: addSetup("defaultRegDomain", "Default Registration Domain",
431: getSetupDefault("defaultRegDomain", "default"));
432:
433: addSetup("defaultCSS", "Default CSS Extension",
434: getSetupDefault("defaultCSS", ""));
435:
436: addSetup("privacyPolicy", "URL To Website Privacy Policy",
437: getSetupDefault("privacyPolicy", ""));
438:
439: addSetup(
440: "isNotifyOnJobSuccess",
441: "Boolean flag for whether to send an e-mail notification when a job completes successfully",
442: "N");
443:
444: // addSetup("nativeBlob","Native Blob Types (Y/N)", "N");
445:
446: addSetup("insecureDBMaint",
447: "Allow DBMaint to Edit Unsecured DBObjects", "N");
448:
449: addSetup(
450: "enableGlobalExceptions",
451: "Allow all Expresso Controllers to pass unhandled exception to GlobalExceptions as of Struts 1.1",
452: "N");
453:
454: //Asynchronous process setup values
455: addSetup("AsyncClaimTimeout",
456: "Claim Timeout for Asynchronous processes", "30000");
457:
458: addSetup("AsyncNumThreads", "Number of aysnc handling threads",
459: "10");
460: addSetup("AsyncQueueSize",
461: "Size of queue for waiting async processes.", "20");
462:
463: }
464: }
465:
466: /* ExpressoSchema */
|