Search in sources :

Example 1 with IDatabaseListener

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener in project binnavi by google.

the class CDatabase method load.

@Override
public void load() throws CouldntLoadDataException, InvalidDatabaseVersionException, LoadCancelledException {
    Preconditions.checkArgument(isConnected(), "IE00686: Not connected to the database");
    try {
        if (!loadReporter.report(LoadEvents.LOADING_DATABASE)) {
            throw new LoadCancelledException();
        }
        if (!loadReporter.report(LoadEvents.DETERMINING_DATABASE_VERSION)) {
            throw new LoadCancelledException();
        }
        final DatabaseVersion databaseVersion = provider.getDatabaseVersion();
        final DatabaseVersion currentVersion = new DatabaseVersion(Constants.PROJECT_VERSION);
        if ((databaseVersion.compareTo(currentVersion) != 0) && currentVersion.needsUpgrading(databaseVersion)) {
            throw new InvalidDatabaseVersionException(databaseVersion);
        }
        if (!loadReporter.report(LoadEvents.LOADING_USERS)) {
            throw new LoadCancelledException();
        }
        loadUserManager();
        if (!loadReporter.report(LoadEvents.LOADING_VIEW_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager viewTagManager = loadViewTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_NODE_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager nodeTagManager = loadNodeTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_DEBUGGERS)) {
            throw new LoadCancelledException();
        }
        final DebuggerTemplateManager debuggerDescriptionManager = provider.loadDebuggers();
        if (!loadReporter.report(LoadEvents.LOADING_PROJECTS)) {
            throw new LoadCancelledException();
        }
        final List<INaviProject> projects = provider.loadProjects();
        if (!loadReporter.report(LoadEvents.LOADING_RAW_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviRawModule> rawModules = provider.loadRawModules();
        if (!loadReporter.report(LoadEvents.LOADING_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviModule> modules = provider.loadModules();
        debuggerDescriptionManager.addListener(internalDebuggerTemplateListener);
        content = new CDatabaseContent(provider, this, listeners, projects, modules, rawModules, viewTagManager, nodeTagManager, debuggerDescriptionManager);
    } catch (final CouldntLoadDataException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } catch (final InvalidDatabaseVersionException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final LoadCancelledException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } finally {
        isLoading = false;
    }
    content.initializeRawModules(content.getModules(), content.getRawModules());
    for (final IDatabaseListener listener : listeners) {
        try {
            listener.loadedDatabase(this);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    loadReporter.report(LoadEvents.LOADING_FINISHED);
}
Also used : InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) DebuggerTemplateManager(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLException(java.sql.SQLException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntUpdateDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Example 2 with IDatabaseListener

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener in project binnavi by google.

the class CDatabaseConfiguration method setDriver.

/**
 * Changes the driver that is used to connect to the database.
 *
 * @param driver The new driver string.
 *
 * @throws IllegalArgumentException Thrown if the given driver is invalid.
 */
public void setDriver(final String driver) {
    Preconditions.checkNotNull(driver, "IE00690: Database driver can not be null");
    if (driver.equals(getDriver())) {
        return;
    }
    m_driver = driver;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedDriver(m_database, driver);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Example 3 with IDatabaseListener

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener in project binnavi by google.

the class CDatabaseConfiguration method setDescription.

/**
 * Changes the description of the database.
 *
 * @param description The new description of the database.
 *
 * @throws IllegalArgumentException Thrown if the given description is invalid.
 */
public void setDescription(final String description) {
    Preconditions.checkNotNull(description, "IE00689: Database description can not be null");
    if (description.equals(m_description)) {
        return;
    }
    m_description = description;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedDescription(m_database, description);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Example 4 with IDatabaseListener

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener in project binnavi by google.

the class CDatabaseConfiguration method setPassword.

/**
 * Changes the password that is used to connect to the database.
 *
 * @param password The new password.
 *
 * @throws IllegalArgumentException Thrown if the given password is invalid.
 */
public void setPassword(final String password) {
    Preconditions.checkNotNull(password, "IE00691: Database password can not be null");
    if (password.equals(getPassword())) {
        return;
    }
    m_password = password;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedPassword(m_database, password);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Example 5 with IDatabaseListener

use of com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener in project binnavi by google.

the class CDatabaseConfiguration method setIdentity.

/**
 * Changes the identity of the current user in this database.
 *
 * @param identity The new identity of the user.
 */
public void setIdentity(final String identity) {
    Preconditions.checkNotNull(identity, "IE00067: identity argument can not be null");
    if (identity.equals(m_identity)) {
        return;
    }
    m_identity = identity;
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.changedIdentity(m_database, identity);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
}
Also used : IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)

Aggregations

IDatabaseListener (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener)15 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)8 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)8 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)5 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)3 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)3 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)3 CouldntUpdateDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException)3 InvalidDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException)3 InvalidDatabaseVersionException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException)3 InvalidExporterDatabaseFormatException (com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException)3 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)3 SQLException (java.sql.SQLException)3 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)2 INaviRawModule (com.google.security.zynamics.binnavi.disassembly.INaviRawModule)2 SQLProvider (com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider)1 PostgreSQLNotificationProvider (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.PostgreSQLNotificationProvider)1 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)1 DebuggerTemplateManager (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager)1