use of org.olat.core.logging.StartupException in project openolat by klemens.
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 LoginModule method init.
@Override
public void init() {
// configure timed cache default params: refresh 1 minute, timeout according to configuration
failedLoginCache = coordinatorManager.getCoordinator().getCacher().getCache(LoginModule.class.getSimpleName(), "blockafterfailedattempts");
updateProperties();
boolean defaultProviderFound = false;
for (Iterator<AuthenticationProvider> iterator = authenticationProviders.iterator(); iterator.hasNext(); ) {
AuthenticationProvider provider = iterator.next();
if (provider.isDefault()) {
defaultProviderFound = true;
defaultProviderName = provider.getName();
log.info("Using default authentication provider '" + defaultProviderName + "'.");
}
}
if (!defaultProviderFound) {
throw new StartupException("Defined DefaultAuthProvider::" + defaultProviderName + " not existent or not enabled. Please fix.");
}
}
use of org.olat.core.logging.StartupException in project openolat by klemens.
the class InstitutionConfiguration method init.
/**
* initializes the institution portlet config
*/
public void init() {
institutions = new FastHashMap();
File configurationFile = new File(WebappHelper.getContextRealPath(CONFIG_FILE));
XStream xstream = getInstitutionConfigXStream();
InstitutionConfiguration configuration = (InstitutionConfiguration) xstream.fromXML(configurationFile);
for (InstitutionPortletEntry institution : configuration.getInstitution()) {
String shortName = institution.shortname;
if (shortName == null) {
throw new StartupException("Institution portlet startup: No shortname given for one entry!");
}
institutions.put(shortName.toLowerCase(), institution);
}
// from now on optimize for non-synchronized read access
institutions.setFast(true);
}
use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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);
}
}
Aggregations