use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.
the class UpgradeManager method abort.
/**
* On any RuntimeExceptions during init. Abort loading of application.
* Modules should throw RuntimeExceptions if they can't live with a the
* given state of configuration.
* @param e
*/
protected void abort(Throwable e) {
if (e instanceof StartupException) {
StartupException se = (StartupException) e;
logWarn("Message: " + se.getLogMsg(), se);
Throwable cause = se.getCause();
logWarn("Cause: " + (cause != null ? cause.getMessage() : "n/a"), se);
}
throw new RuntimeException("*** CRITICAL ERROR IN UPGRADE MANAGER. Loading aborted.", e);
}
use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.
the class WebappHelper method setUserDataRoot.
/**
* [spring]
* @param userDataRoot
*/
public void setUserDataRoot(String userDataRoot) {
if (!StringHelper.containsNonWhitespace(userDataRoot)) {
userDataRoot = System.getProperty("java.io.tmpdir") + "/olatdata";
log.info("using java.io.tmpdir as userdata. this is the default if userdata.dir is not set");
}
File fUserData = new File(userDataRoot);
if (!fUserData.exists()) {
if (!fUserData.mkdirs())
throw new StartupException("Unable to create userdata dir '" + userDataRoot + "'. Please fix!");
}
// fxdiff: reset tmp-dir from within application to circumvent startup-params.
// do not write to system default (/var/tmp) as this leads to permission problems with multiple instances on one host!
log.info("Setting userdata root to: " + userDataRoot);
WebappHelper.userDataRoot = userDataRoot;
}
use of org.olat.core.logging.StartupException in project openolat by klemens.
the class AbstractHierarchicalIndexer method addIndexer.
public void addIndexer(Indexer indexer) {
try {
childIndexers.add(indexer);
logDebug("Adding indexer from configuraton. TypeName=" + indexer.getSupportedTypeName());
} catch (ClassCastException cce) {
throw new StartupException("Configured indexer is not of type Indexer", cce);
}
}
use of org.olat.core.logging.StartupException in project openolat by klemens.
the class DatabaseUpgradeManager method loadAndExecuteSqlStatements.
/**
* load file with alter statements and add to batch
* @param statements
* @param alterDbStatements
*/
private void loadAndExecuteSqlStatements(Statement statement, String alterDbStatements, Dialect dialect) {
try {
Resource setupDatabaseFile = new ClassPathResource("/database/" + dialect + "/" + alterDbStatements);
if (!setupDatabaseFile.exists()) {
throw new StartupException("The database upgrade file was not found on the classpath: " + "/database/" + dialect + "/" + alterDbStatements);
}
InputStream in = setupDatabaseFile.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
StringBuilder sb = new StringBuilder();
// Read File Line By Line
while ((strLine = br.readLine()) != null) {
if (strLine.length() > 1 && (!strLine.startsWith("--") && !strLine.startsWith("#"))) {
sb.append(strLine.trim()).append(' ');
}
}
StringTokenizer tokenizer = new StringTokenizer(sb.toString(), ";");
String sql = null;
while (tokenizer.hasMoreTokens()) {
try {
String token = tokenizer.nextToken();
if (!StringHelper.containsNonWhitespace(token)) {
continue;
}
sql = token + ";".toLowerCase();
if (sql.startsWith("update") || sql.startsWith("delete") || sql.startsWith("alter") || sql.startsWith("insert")) {
statement.executeUpdate(sql);
} else {
statement.execute(sql);
}
logInfo("Successfully upgraded database with the following sql: " + sql);
} catch (SQLException e) {
if (isErrorFatal(dialect, sql, e)) {
throw new StartupException("Fatal error trying to update database.", e);
}
} catch (Exception e) {
// handle non sql errors
logError("Could not upgrade your database!", e);
throw new StartupException("Could not add alter db statements to batch.", e);
}
}
in.close();
} catch (FileNotFoundException e1) {
logError("could not find deleteDatabase.sql file!", e1);
abort(e1);
} catch (IOException e) {
logError("could not read deleteDatabase.sql file!", e);
abort(e);
}
}
use of org.olat.core.logging.StartupException in project openolat by klemens.
the class FilePathHandler method init.
/**
* @see org.olat.commons.servlets.pathhandlers.PathHandler#init(com.anthonyeden.lib.config.Configuration)
*/
public void init(String config) {
String rootConf = config;
if (rootConf == null)
throw new StartupException("child 'root' missing in config for filepathhandler");
File f = new File(rootConf);
if (f.isAbsolute()) {
setRoot(rootConf);
} else {
setRoot(WebappHelper.getContextRealPath("/" + rootConf));
}
}
Aggregations