Search in sources :

Example 21 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager 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 22 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTestTeardown method testDeleteTag3.

@Test
public void testDeleteTag3() throws CouldntDeleteException, CouldntLoadDataException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    getProvider().deleteTag(tagManager.getRootTag().getChildren().get(0));
    getProvider().deleteTag(tagManager.getRootTag().getChildren().get(0));
}
Also used : CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 23 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTestTeardown method testDeleteTagSubtree.

@Test
public void testDeleteTagSubtree() throws CouldntLoadDataException, CouldntDeleteException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    getProvider().deleteTagSubtree(tagManager.getRootTag().getChildren().get(0));
    getProvider().deleteTagSubtree(tagManager.getRootTag().getChildren().get(0));
}
Also used : CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 24 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTestTeardown method testDeleteTagSubtree2.

@Test(expected = NullPointerException.class)
public void testDeleteTagSubtree2() throws CouldntDeleteException, CouldntLoadDataException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    getProvider().deleteTagSubtree(tagManager.getRootTag());
}
Also used : CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 25 with CTagManager

use of com.google.security.zynamics.binnavi.Tagging.CTagManager in project binnavi by google.

the class PostgreSQLProviderTestTeardown method testDeleteTag2.

@Test(expected = NullPointerException.class)
public void testDeleteTag2() throws CouldntDeleteException, CouldntLoadDataException {
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    getProvider().deleteTag(tagManager.getRootTag());
}
Also used : CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)46 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)34 Test (org.junit.Test)31 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)23 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)17 Tree (com.google.security.zynamics.zylib.types.trees.Tree)15 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)13 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)12 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)12 Date (java.util.Date)12 TreeNode (com.google.security.zynamics.zylib.types.trees.TreeNode)10 Before (org.junit.Before)9 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)8 ITreeNode (com.google.security.zynamics.zylib.types.trees.ITreeNode)8 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)7 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)7 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)6 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)5 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)5