/* ====================================================================
* The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
*
* Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by Jcorporate Ltd.
* (http://www.jcorporate.com/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. "Jcorporate" and product names such as "Expresso" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written permission,
* please contact info@jcorporate.com.
*
* 5. Products derived from this software may not be called "Expresso",
* or other Jcorporate product names; nor may "Expresso" or other
* Jcorporate product names appear in their name, without prior
* written permission of Jcorporate Ltd.
*
* 6. No product derived from this software may compete in the same
* market space, i.e. framework, without prior written permission
* of Jcorporate Ltd. For written permission, please contact
* partners@jcorporate.com.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Jcorporate Ltd. Contributions back
* to the project(s) are encouraged when you make modifications.
* Please send them to support@jcorporate.com. For more information
* on Jcorporate Ltd. and its products, please see
* <http://www.jcorporate.com/>.
*
* Portions of this software are based upon other open source
* products and are subject to their respective licenses.
*/
package com.jcorporate.expresso.core;
import com.jcorporate.expresso.core.db.DBException;
import com.jcorporate.expresso.core.dbobj.Schema;
import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
import com.jcorporate.expresso.core.misc.ConfigManager;
import com.jcorporate.expresso.core.security.User;
import com.jcorporate.expresso.kernel.InstallLog;
import com.jcorporate.expresso.kernel.util.ClassLocator;
import com.jcorporate.expresso.services.dbobj.JobQueue;
/**
* Standard Schema
* object for the Expresso framework. It provides 'tie ins' for all the
* classes within the framework. You use your own Schema derived from
* <code>com.jcorporate.expresso.core.dbobj.Schema</code> when creating your
* own application
*
* @author Michael Nash
* @since Expresso 1.0
*/
public final class ExpressoSchema extends Schema {
private static String currentVersionString = "5.6.0";
// private static String log4jRequiredVersion = "1.2.8";
// private static String xercesRequiredVersion = "XmlCommons 1.0";
/**
* This variable prevents multiple complex instantiations since most of the
* schema data is kept in a static variable anyway.
*/
private static boolean isInitialized = false;
/**
* Constructor
*
* @throws DBException if there's an error building the object
*/
public ExpressoSchema() throws DBException {
if (isInitialized) {
return;
}
/* Check the Log4j version */
try {
ClassLocator.loadClass("org.apache.log4j.Logger");
} catch (Exception e) {
System.err.println("You have an older version of log4j. " +
"Please install a version greater or equal to version 1.2.1");
}
if (ConfigManager.isInitialized()) {
isInitialized = true;
try {
constructDBObjects();
constructControllers();
//Add all reports belonging to the Expresso Schema
addReportPage(com.jcorporate.expresso.ext.report.DownloadUsers.class);
/* Now add the Jobs in this Schema */
addJob(com.jcorporate.expresso.ext.job.SendNotice.class);
addJob(com.jcorporate.expresso.services.job.TestJob.class);
addJob(com.jcorporate.expresso.services.job.ControllerJob.class);
addJob(com.jcorporate.expresso.services.job.ValidationJob.class);
addJob(com.jcorporate.expresso.services.job.ClearOldValidation.class);
/* Now add the normal servlets */
addServlet(com.jcorporate.expresso.core.servlet.Test.class);
constructSetupValues();
} catch (Exception e) {
e.printStackTrace();
isInitialized = false;
throw new DBException(e);
}
}
/* if */
}
/* ExpressoSchema() */
/**
* Returns the default component code for this schema. Useful for automated
* component testing/installation
*
* @return the component code string. In this case there is no component
* code so it returns an empty string.
*/
public String getDefaultComponentCode() {
return "";
}
/**
* Returns the default description for this schema. Useful for automated
* component testing/installation
*
* @return the name of the schema
*/
public String getDefaultDescription() {
return "Expresso Framework Schema";
}
/**
* Returns the path to the messages bundle property file
*
* @return the path to the messages bundle
*/
public String getMessageBundlePath() {
return "com/jcorporate/expresso/core";
}
/* getMessageBundlePath() */
/**
* Gets the current version of this Framework
*
* @return the current version in string format
*/
public String getVersion() {
return currentVersionString;
}
/**
* Runs additional setup operations for the Expresso Schema
*
* @param installLog The 'logger' to send informational output to.
* @param dataContext the datacontext to work with.
* @throws com.jcorporate.expresso.core.db.DBException
* upon database access
* error
*/
public synchronized void otherSetup(InstallLog installLog,
String dataContext) throws com.jcorporate.expresso.core.db.DBException {
//Add a recurring 'Clear old validation entries job'
JobQueue jq = new JobQueue(SecuredDBObject.SYSTEM_ACCOUNT);
jq.setDataContext(dataContext);
jq.setField(JobQueue.FLD_JOBCODE,
com.jcorporate.expresso.services.job.ClearOldValidation.class.getName());
if (!jq.find()) {
//Execute every Saturday at midnight
jq.setField(JobQueue.FLD_JOBCRON_PARAMS, "0,0,-1,-1,7,-1");
jq.setField(JobQueue.FLD_SERVERID, 0);
jq.setField(JobQueue.FLD_STATUS_CODE, JobQueue.JOB_STATUS_AVAILABLE);
jq.setField(JobQueue.FLD_JOBCODE,
com.jcorporate.expresso.services.job.ClearOldValidation.class.
getName());
jq.setField(JobQueue.FLD_UID, User.getAdminId(dataContext));
jq.add();
installLog.info("Added " +
com.jcorporate.expresso.services.job.
ClearOldValidation.class.getName() +
" to execute once a week");
} else {
installLog.info("Clear Old Validation Job already exists in jobqueue, skipping add.");
}
super.otherSetup(installLog, dataContext);
}
/**
* Adds the appropriate controllers to the schema
*/
protected void constructControllers() {
/* Controllers */
addController(com.jcorporate.expresso.services.controller.ControllerSecurityMatrix.class);
addController(com.jcorporate.expresso.services.controller.QueueJob.class);
addController(com.jcorporate.expresso.services.controller.SimpleLoginController.class);
addController(com.jcorporate.expresso.services.controller.SimpleRegistration.class);
addController(com.jcorporate.expresso.services.controller.JobSecurityMatrix.class);
addController(com.jcorporate.expresso.services.controller.CacheControl.class);
// addController(com.jcorporate.expresso.ext.controller.TestController.class);
addController(com.jcorporate.expresso.services.controller.DBMaint.class);
addController(com.jcorporate.expresso.services.controller.EditUserPreference.class);
// addController(com.jcorporate.expresso.ext.controller.RunTests.class);
addController(com.jcorporate.expresso.ext.controller.HealthCheck.class);
addController(com.jcorporate.expresso.ext.controller.DataTransfer.class);
addController(com.jcorporate.expresso.services.controller.ValidationController.class);
addController(com.jcorporate.expresso.ext.controller.Download.class);
addController(com.jcorporate.expresso.ext.xml.controller.XMLController.class);
addController(com.jcorporate.expresso.ext.controller.RunSQL.class);
addController(com.jcorporate.expresso.services.controller.Log.class);
addController(com.jcorporate.expresso.services.controller.Status.class);
addController(com.jcorporate.expresso.services.controller.DBSecurityMatrix.class);
addController(com.jcorporate.expresso.ext.controller.Upload.class);
addController(com.jcorporate.expresso.ext.controller.ServeTextFile.class);
addController(com.jcorporate.expresso.ext.controller.ComponentManager.class);
addController(com.jcorporate.expresso.ext.controller.ReportServer.class);
addController(com.jcorporate.expresso.services.controller.CronController.class);
//
//Controllers for managing configuration system
//
addController(com.jcorporate.expresso.services.controller.configuration.CreateSettingsWizard.class);
addController(com.jcorporate.expresso.services.controller.Configuration.class);
addController(com.jcorporate.expresso.services.controller.configuration.UpgradeSettingsWizard.class);
}
/**
* Adds all the Expresso DbObjects
*/
protected void constructDBObjects() {
addDBObject(com.jcorporate.expresso.services.dbobj.Event.class);
addDBObject(com.jcorporate.expresso.services.dbobj.EventMail.class);
addDBObject(com.jcorporate.expresso.services.dbobj.MimeTypes.class);
addDBObject(com.jcorporate.expresso.services.dbobj.DBMessage.class);
addDBObject(com.jcorporate.expresso.services.dbobj.DBOtherMap.class);
addDBObject(com.jcorporate.expresso.services.dbobj.DBObjLimit.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.DownloadFiles.class);
addDBObject(com.jcorporate.expresso.services.dbobj.Setup.class);
addDBObject(com.jcorporate.expresso.services.dbobj.UserPreferenceVal.class);
addDBObject(com.jcorporate.expresso.services.dbobj.UserPreferenceDef.class);
addDBObject(com.jcorporate.expresso.services.dbobj.ControllerDefault.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.ISOCountryCodes.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.ReverseLookupDomains.class);
addDBObject(com.jcorporate.expresso.services.dbobj.ControllerSecurity.class);
addDBObject(com.jcorporate.expresso.services.dbobj.DefaultUserInfo.class);
addDBObject(com.jcorporate.expresso.services.dbobj.UserGroup.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.RegisteredUser.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Person.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Phone.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Address.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.regobj.Contact.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.RestrictedCountries.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.RestrictedOverrides.class);
addDBObject(com.jcorporate.expresso.services.dbobj.DBObjSecurity.class);
addDBObject(com.jcorporate.expresso.services.dbobj.JobSecurity.class);
addDBObject(com.jcorporate.expresso.services.dbobj.GroupMembers.class);
addDBObject(com.jcorporate.expresso.services.dbobj.GroupNest.class);
addDBObject(com.jcorporate.expresso.services.dbobj.RegistrationDomain.class);
addDBObject(com.jcorporate.expresso.services.dbobj.RegistrationObjectMap.class);
addDBObject(com.jcorporate.expresso.services.dbobj.RowPermissions.class);
addDBObject(com.jcorporate.expresso.services.dbobj.RowGroupPerms.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.DownloadLog.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTests.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestStat.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestSet.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.PerfTestSetDet.class);
addDBObject(com.jcorporate.expresso.services.dbobj.JobQueue.class);
addDBObject(com.jcorporate.expresso.services.dbobj.JobQueueParam.class);
addDBObject(com.jcorporate.expresso.services.dbobj.LogEntry.class);
addDBObject(com.jcorporate.expresso.services.dbobj.SchemaList.class);
addDBObject(com.jcorporate.expresso.services.dbobj.JobHandlerRegistry.class);
addDBObject(com.jcorporate.expresso.services.dbobj.JobHandlerControl.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.AppIntegration.class);
addDBObject(com.jcorporate.expresso.services.dbobj.ValidationQueue.class);
addDBObject(com.jcorporate.expresso.services.dbobj.ValidationQueueParam.class);
addDBObject(com.jcorporate.expresso.services.dbobj.UserPreference.class);
addDBObject(com.jcorporate.expresso.ext.xml.dbobj.UserAgent.class);
addDBObject(com.jcorporate.expresso.ext.xml.dbobj.ControllerXSLMap.class);
/** @todo this is required for AuditedSecuredDBObject to work *RD* Mon Jul 27 2004 */
addDBObject(com.jcorporate.expresso.ext.dbobj.AuditLog.class);
addDBObject(com.jcorporate.expresso.ext.dbobj.AuditLogL.class);
/** @todo this is required for change log to work *RD* Mon Jul 27 2004 */
addDBObject(com.jcorporate.expresso.services.dbobj.ChangeLog.class);
}
/**
* Adds the setup values for this schema to the schema's definition
*
* @throws DBException upon database access error
*/
protected void constructSetupValues() throws DBException {
addSetup("DefaultXSL", "Default XSL Stylesheet",
"%web-app%/expresso/xsl/default.xsl");
addSetup("BaseDir",
getString("Web_Document_Root_Director"),
getSetupDefault("BaseDir", "%web-app%"));
addSetup("HTTPServ",
getString("Web_Server_Host_Name"),
getSetupDefault("HTTPServ", "javacorp"));
addSetup("MAILFrom",
getString("Value_for_From_field_in_Ev"),
getSetupDefault("MAILFrom", "none"));
addSetup("MAILPassword",
getString("Password_for_sending_e-mai"),
getSetupDefault("MAILPassword", ""));
addSetup("MAILServer",
getString("SMTP_Server_Name_for_sendi"),
getSetupDefault("MAILServer", "example.org"));
addSetup("MAILUserName",
getString("User_Name_for_sending_e-ma"),
getSetupDefault("MAILUserName", ""));
addSetup("MaxJobs",
getString("Max_Number_of_Server_Jobs_"),
getSetupDefault("MaxJobs", "1"));
addSetup("ServletPath",
getString("Default_path_for_Servlets"),
getSetupDefault("ServletPath", "/servlet"));
addSetup("ServletPort",
getString("Port_Number_for_Servlet_Se"),
getSetupDefault("ServletPort", "80"));
addSetup("TempDir", getString("Temporary_Directory"),
getSetupDefault("TempDir", "%web-app%temp/"));
addSetup("TimerInterval",
getString("Scan_Job_Queue_and_directo"),
getSetupDefault("TimerInterval", "30"));
addSetup("ConnTimeOut",
getString("Database_Connection_Timout"),
getSetupDefault("ConnTimeOut", "60"));
addSetup("DefaultGroup",
getString("Default_User_Group_for_Sel"),
getSetupDefault("DefaultGroup", "Demo"));
addSetup("MaxConnections",
getString("Maximum_connections_to_att"),
getSetupDefault("MaxConnections", "4"));
addSetup("MinConnections",
getString("Minimum_connections_to_att"),
getSetupDefault("MinConnections", "2"));
addSetup("MailList",
getString("Mailing_List_Address"),
getSetupDefault("MailList", "opensource@servlets.net"));
addSetup("RestartServer", getString("RestartServer"),
getSetupDefault("RestartServer", ""));
// Added to better customize standard messages, such as email validations
addSetup("RequireEmailValidate",
getString("RequireEmailValidate"),
getSetupDefault("RequireEmailValidate", "N"));
addSetup("EmailValidateURL",
getString("EmailValidateURL"),
getSetupDefault("EmailValidateURL",
"http://www.yourdomain.com/servlet/EmailValidation"));
addSetup("AdminName", getString("AdminName"),
getSetupDefault("AdminName", "webmaster"));
addSetup("AdminEmail", getString("AdminEmail"),
getSetupDefault("AdminEmail", ""));
addSetup("CompanyName", getString("CompanyName"),
getSetupDefault("CompanyName", ""));
addSetup("HomePageURL", getString("HomePageURL"),
getSetupDefault("HomePageURL", ""));
addSetup("ServletEvent", getString("ServletEvent"),
getSetupDefault("ServletEvent", "Y"));
addSetup("ContextPath", "Context Path for Expresso",
getSetupDefault("ContextPath", "%context%"));
addSetup("Header", "Header URL for Framesets",
getSetupDefault("Header", "%context%/%expresso-dir%/header.jsp"));
addSetup("HeaderHeight",
"Size of Header for Framesets",
getSetupDefault("HeaderHeight", "73"));
addSetup("SecurityDB",
"Database to use for User/Group Security Info",
getSetupDefault("SecurityDB", ""));
addSetup("SecurityDBObjs",
"Database Objects that use the SecurityDB db/context",
getSetupDefault("SecurityDB", ""));
//
//This 'default' is not the same as 'default context'
//
addSetup("defaultRegDomain",
"Default Registration Domain",
getSetupDefault("defaultRegDomain", "default"));
addSetup("defaultCSS", "Default CSS Extension",
getSetupDefault("defaultCSS", ""));
addSetup("privacyPolicy",
"URL To Website Privacy Policy",
getSetupDefault("privacyPolicy", ""));
addSetup("isNotifyOnJobSuccess",
"Boolean flag for whether to send an e-mail notification when a job completes successfully",
"N");
// addSetup("nativeBlob","Native Blob Types (Y/N)", "N");
addSetup("insecureDBMaint",
"Allow DBMaint to Edit Unsecured DBObjects", "N");
addSetup("enableGlobalExceptions",
"Allow all Expresso Controllers to pass unhandled exception to GlobalExceptions as of Struts 1.1",
"N");
//Asynchronous process setup values
addSetup("AsyncClaimTimeout", "Claim Timeout for Asynchronous processes", "30000");
addSetup("AsyncNumThreads", "Number of aysnc handling threads", "10");
addSetup("AsyncQueueSize", "Size of queue for waiting async processes.", "20");
}
}
/* ExpressoSchema */
|