Search in sources :

Example 1 with StartupException

use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.

the class AbstractHierarchicalIndexer method setIndexerList.

/**
 * Bean setter method used by spring.
 * @param indexerList
 */
public void setIndexerList(List<Indexer> indexerList) {
    if (indexerList == null) {
        throw new AssertException("null value for indexerList not allowed.");
    }
    try {
        for (Indexer indexer : indexerList) {
            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);
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) StartupException(org.olat.core.logging.StartupException)

Example 2 with StartupException

use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.

the class UserModule method checkMandatoryUserProperty.

private void checkMandatoryUserProperty(String userPropertyIdentifyer) {
    List<UserPropertyHandler> propertyHandlers = userPropertiesConfig.getAllUserPropertyHandlers();
    boolean propertyDefined = false;
    for (UserPropertyHandler propertyHandler : propertyHandlers) {
        if (propertyHandler.getName().equals(userPropertyIdentifyer)) {
            propertyDefined = true;
            break;
        }
    }
    if (!propertyDefined) {
        throw new StartupException("The user property handler for the mandatory user property " + userPropertyIdentifyer + " is not defined. Check your olat_userconfig.xml file!");
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 3 with StartupException

use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.

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.");
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider)

Example 4 with StartupException

use of org.olat.core.logging.StartupException in project OpenOLAT by OpenOLAT.

the class DatabaseUpgradeManager method runAlterDbStatements.

/**
 * @see org.olat.upgrade.UpgradeManager#runAlterDbStatements()
 */
public void runAlterDbStatements() {
    Dialect dialect;
    // only run upgrades on mysql or postgresql
    if (getDbVendor().contains("mysql"))
        dialect = Dialect.mysql;
    else if (getDbVendor().contains("postgresql"))
        dialect = Dialect.postgresql;
    else
        return;
    Statement statement = null;
    try {
        logAudit("+--------------------------------------------------------------+");
        logAudit("+... Pure database upgrade: starting alter DB statements ...+");
        logAudit("+ If it fails, do it manually by applying the content of the alter_X_to_Y.sql files.+");
        logAudit("+ For each file you upgraded to add an entry like this to the [pathToOlat]/olatdata/system/installed_database_upgrades.xml: +");
        logAudit("+ <entry><string>Database update</string><boolean>true</boolean></entry>+");
        logAudit("+--------------------------------------------------------------+");
        statement = getDataSource().getConnection().createStatement();
        Iterator<OLATUpgrade> iter = upgrades.iterator();
        OLATUpgrade upgrade = null;
        while (iter.hasNext()) {
            upgrade = iter.next();
            String alterDbStatementsFilename = upgrade.getAlterDbStatements();
            if (alterDbStatementsFilename != null) {
                UpgradeHistoryData uhd = getUpgradesHistory(upgrade.getVersion());
                if (uhd == null) {
                    // has never been called, initialize
                    uhd = new UpgradeHistoryData();
                }
                if (!uhd.getBooleanDataValue(OLATUpgrade.TASK_DP_UPGRADE)) {
                    loadAndExecuteSqlStatements(statement, alterDbStatementsFilename, dialect);
                    uhd.setBooleanDataValue(OLATUpgrade.TASK_DP_UPGRADE, true);
                    setUpgradesHistory(uhd, upgrade.getVersion());
                    logAudit("Successfully executed alter DB statements for Version::" + upgrade.getVersion());
                }
            }
        }
    } catch (SQLException e) {
        logError("Could not upgrade your database! Please do it manually and add ", e);
        throw new StartupException("Could not execute alter db statements. Please do it manually.", e);
    } catch (Throwable e) {
        logWarn("Error executing alter DB statements::", e);
        abort(e);
    } finally {
        try {
            if (statement != null) {
                statement.close();
            }
        } catch (SQLException e2) {
            logWarn("Could not close sql statement", e2);
            throw new StartupException("Could not close sql statements.", e2);
        }
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) SQLException(java.sql.SQLException) Statement(java.sql.Statement)

Example 5 with StartupException

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);
}
Also used : StartupException(org.olat.core.logging.StartupException) XStream(com.thoughtworks.xstream.XStream) FastHashMap(org.apache.commons.collections.FastHashMap) File(java.io.File)

Aggregations

StartupException (org.olat.core.logging.StartupException)26 File (java.io.File)10 IOException (java.io.IOException)6 SQLException (java.sql.SQLException)6 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 InputStream (java.io.InputStream)4 Statement (java.sql.Statement)4 XStream (com.thoughtworks.xstream.XStream)2 BufferedReader (java.io.BufferedReader)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStreamReader (java.io.InputStreamReader)2 ResultSet (java.sql.ResultSet)2 Properties (java.util.Properties)2 StringTokenizer (java.util.StringTokenizer)2 FastHashMap (org.apache.commons.collections.FastHashMap)2 CoreSpringFactory (org.olat.core.CoreSpringFactory)2 AssertException (org.olat.core.logging.AssertException)2 AuthenticationProvider (org.olat.login.auth.AuthenticationProvider)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2