private static final long serialVersionUID = -5724816778527823325L;
ServletContext context = null;
public void init(ServletConfig config) {
String contextPath = null;
Installer installer = null;
context = config.getServletContext();
try {
URL rootURL = context.getResource ("/");
File rootFile = new File(rootURL.toString());
contextPath = rootFile.getName ();
ApplicationGlobal.setContextPath(contextPath);
}
catch (Exception e) {
log("Problem initializing JadaSite.", e);
log("JadaSite startup aborted.");
return;
}
String filename = Utility.getServletLocation(config.getServletContext()) + "jada.properties";
File file = new File(filename);
if (file.exists()) {
try {
if (!file.delete()) {
log("Unable to remove " + filename);
log("This file can be removed manually");
return;
}
}
catch (SecurityException e) {
log("Unable to remove " + filename, e);
log("This file can be removed manually");
return;
}
}
installer = Installer.getInstance();
installer.init(config.getServletContext());
ApplicationGlobal.setVersion(config.getInitParameter("version"));
ApplicationGlobal.setDbVersion(config.getInitParameter("dbVersion"));
String debug = config.getInitParameter(Constants.CONFIG_PROPERTY_LOCALTESTING);
if (debug != null && debug.toLowerCase().equals("true")) {
ApplicationGlobal.setLocalTesting(true);
}
String driver = config.getInitParameter(Constants.CONFIG_PROPERTY_DRIVER);
String url = config.getInitParameter(Constants.CONFIG_PROPERTY_URL);
String user = config.getInitParameter(Constants.CONFIG_PROPERTY_USER);
String pass = config.getInitParameter(Constants.CONFIG_PROPERTY_PASS);
String encryptionKey = config.getInitParameter(Constants.CONFIG_PROPERTY_ENCRYPTIONKEY);
String workingDirectory = config.getInitParameter(Constants.CONFIG_PROPERTY_WORKINGDIRECTORY);
String log4jDirectory = config.getInitParameter(Constants.CONFIG_PROPERTY_LOGDIRECTORY);
boolean requireInstall = false;
boolean installCompleted = installer.isInstallCompleted();
ApplicationGlobal.setInstallCompleted(installCompleted);
String value = config.getInitParameter(Constants.CONFIG_PROPERTY_REQUIREINSTALL);
if (value != null && value.toLowerCase().equals("true")) {
requireInstall = true;
ApplicationGlobal.setRequireInstall(true);
}
if (requireInstall) {
if (!installCompleted) {
log("Installation has not been done. Skipping custom initialization.");
log("Please proceed to installation and remmember to restart before continue.");
log("Awaiting installation....");
return;
}
try {
Properties installProperties = installer.getConfigProperties();
driver = installProperties.getProperty(Constants.CONFIG_PROPERTY_DRIVER);
url = installProperties.getProperty(Constants.CONFIG_PROPERTY_URL);
user = installProperties.getProperty(Constants.CONFIG_PROPERTY_USER);
pass = installProperties.getProperty(Constants.CONFIG_PROPERTY_PASS);
encryptionKey = installProperties.getProperty(Constants.CONFIG_PROPERTY_ENCRYPTIONKEY);