use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class PostgreSQLViewLoader method loadView.
/**
* Loads the graph of a view from the database.
*
* @param provider The SQL provider that provides the connection.
* @param view The view to load.
* @param list A list of all modules that are part of the database.
* @param nodeTagManager Node tag manager of the database.
*
* @return The graph of the view.
*
* @throws CouldntLoadDataException Thrown if the graph of view could not be loaded.
* @throws CPartialLoadException Thrown if the graph could not be loaded because not all required
* modules are loaded.
*/
public static MutableDirectedGraph<INaviViewNode, INaviEdge> loadView(final AbstractSQLProvider provider, final INaviView view, final List<INaviModule> list, final CTagManager nodeTagManager) throws CouldntLoadDataException, CPartialLoadException {
checkArguments(provider, view, list, nodeTagManager);
try {
final List<INaviViewNode> nodes = PostgreSQLNodeLoader.loadNodes(provider, view, list, nodeTagManager);
NodeCache.get(provider).addNodes(nodes);
final List<INaviEdge> edges = PostgreSQLEdgeLoader.loadEdges(provider, view, nodes);
EdgeCache.get(provider).addEdges(edges);
return new MutableDirectedGraph<INaviViewNode, INaviEdge>(nodes, edges);
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class PostgreSQLCommentNotificationParser method parse.
@Override
public Collection<CommentNotification> parse(final Collection<PGNotification> commentNotifications, final SQLProvider provider) {
Preconditions.checkNotNull(commentNotifications, "Error: commentNotifications argument can not be null");
Preconditions.checkNotNull(provider, "IE02524: provider argument can not be null");
for (final PGNotification notification : commentNotifications) {
final String notificationParameter = notification.getParameter();
final String tableName = notificationParameter.split("\\s")[0];
try {
switch(tableName) {
case CTableNames.CODENODE_INSTRUCTIONS_TABLE:
informNotification(processNodeLocalInstructionCommentNotification(notification, provider), provider);
break;
case CTableNames.INSTRUCTIONS_TABLE:
informNotification(processInstructionGlobalCommentNotification(notification, provider), provider);
break;
case CTableNames.CODE_NODES_TABLE:
informNotification(processNodeLocalNodeCommentNotification(notification, provider), provider);
break;
case CTableNames.GLOBAL_NODE_COMMENTS_TABLE:
informNotification(processNodeGlobalCommentNotification(notification, provider), provider);
break;
case CTableNames.EDGES_TABLE:
informNotification(processEdgeLocalCommentNotification(notification, provider), provider);
break;
case CTableNames.GLOBAL_EDGE_COMMENTS_TABLE:
informNotification(processEdgeGlobalCommentNotification(notification, provider), provider);
break;
case CTableNames.FUNCTION_NODES_TABLE:
informNotification(processFunctionNodeCommentNotification(notification, provider), provider);
break;
case CTableNames.FUNCTIONS_TABLE:
informNotification(processFunctionCommentNotification(notification, provider), provider);
break;
case CTableNames.TEXT_NODES_TABLE:
informNotification(processTextNodeCommentNotification(notification, provider), provider);
break;
case CTableNames.GROUP_NODES_TABLE:
informNotification(processGroupNodeCommentNotification(notification, provider), provider);
break;
case CTableNames.TYPE_INSTANCE_TABLE:
informNotification(processTypeInstanceCommentNotification(notification, provider), provider);
break;
case CTableNames.COMMENTS_TABLE:
informNotification(processCommentNotification(notification, provider), provider);
break;
default:
NaviLogger.warning("Table name %s not known", tableName);
}
} catch (CouldntLoadDataException exception) {
NaviLogger.severe("Error: Could not successfully parse the database comment notification: %s", notification.toString());
}
}
// TODO(timkornau): change the interface to not return anything here.
return new ArrayList<>();
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class PostgreSQLHelpers method getTableCount.
/**
* Determines the number of tables known to the database. The given list of table names is used as
* query information source.
*
* @param connection The {@link CConnection} to access the database.
* @param tableNames The List of table names which are queried for in the database.
* @return The number of tables in the database
* @throws CouldntLoadDataException if the query execution failed.
*/
public static int getTableCount(final CConnection connection, final List<String> tableNames) throws CouldntLoadDataException {
Preconditions.checkNotNull(connection, "Error: connection argument can not be null");
final StringBuilder builder = new StringBuilder("SELECT count(*) FROM pg_class WHERE relname in (");
for (String tableName : tableNames) {
builder.append("'" + tableName + "',");
}
builder.deleteCharAt(builder.length() - 1);
builder.append(")");
try (ResultSet result = connection.executeQuery(builder.toString(), true)) {
while (result.next()) {
return result.getInt("count");
}
} catch (final SQLException e) {
throw new CouldntLoadDataException(e);
}
throw new IllegalStateException("Error: Could not retrieve table count from server");
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class RenameTypeInstanceAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
final EditVariableDialog dialog = EditVariableDialog.CreateEditVariableDialog(parent, typeInstance.getName());
dialog.setVisible(true);
if (dialog.wasOkClicked()) {
try {
instanceContainer.setInstanceName(typeInstance, dialog.getVariableName());
} catch (CouldntSaveDataException | CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
}
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method setUp.
@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntSaveDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, LoadCancelledException, FileReadException {
final String[] parts = CConfigLoader.loadPostgreSQL();
database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
database.connect();
database.load();
try {
final Field privateProviderField = CDatabase.class.getDeclaredField("provider");
privateProviderField.setAccessible(true);
provider = (SQLProvider) privateProviderField.get(database);
} catch (final Exception exception) {
throw new RuntimeException(exception);
}
provider.createDebuggerTemplate("Test Debugger", "localhost", 2222);
final CProject project = provider.createProject("Test Project");
provider.createAddressSpace(project, "Test Address Space");
ConfigManager.instance().read();
module = database.getContent().getModules().get(0);
}
Aggregations