use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class GenericCommentsTableModel method editComment.
private IComment editComment(IComment comment, String newComment) {
IComment newlySetComment = null;
try {
if (newComment.isEmpty()) {
commentAccessor.deleteComment(comment);
} else {
newlySetComment = commentAccessor.editComment(comment, newComment);
}
} catch (CouldntSaveDataException | CouldntDeleteException e) {
CUtilityFunctions.logException(e);
}
resetCachedComments();
return newlySetComment;
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class CProjectContentTest method testRemoveTrace.
@Test
public void testRemoveTrace() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CouldntDeleteException {
final CProjectContent projectContent = new CProjectContent(m_project, m_listeners, m_provider, m_addressSpaces, m_views, m_traces);
@SuppressWarnings("unused") final INaviView view = new MockView(m_provider);
@SuppressWarnings("unused") final INaviView view2 = projectContent.createView("Name", "description");
assertNotNull(CViewFilter.getTaggedViews(projectContent.getViews(), new CTag(4, "foo", "bar", TagType.VIEW_TAG, m_provider)));
final CAddressSpace spaceOne = projectContent.createAddressSpace("Address Space 1");
spaceOne.load();
final CAddressSpace spaceTwo = projectContent.createAddressSpace("Address Space 2");
spaceTwo.load();
final CAddressSpace spaceThree = projectContent.createAddressSpace("Address Space 3");
spaceThree.load();
final CAddressSpace spaceFour = projectContent.createAddressSpace("Address Space 4");
spaceFour.load();
m_project.load();
final TraceList trace = new TraceList(3, "name", "desc", m_provider);
projectContent.removeTrace(trace);
try {
projectContent.removeTrace(null);
fail();
} catch (final NullPointerException e) {
}
final TraceList trace2 = new TraceList(3, "name", "desc", new MockSqlProvider());
try {
projectContent.removeTrace(trace2);
fail();
} catch (final Exception e) {
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class CDatabaseContent method delete.
@Override
public void delete(final INaviProject project) throws CouldntDeleteException {
Preconditions.checkNotNull(project, "IE00674: Project can not be null");
Preconditions.checkArgument(m_database.isConnected(), "IE00675: Database must be connected before you can delete projects");
Preconditions.checkArgument(m_database.isLoaded(), "IE00676: Database must be loaded before you can delete projects");
Preconditions.checkArgument(m_projects.contains(project), "IE00677: Project does not belong to the database");
m_provider.deleteProject(project);
m_projects.remove(project);
for (final IDatabaseListener listener : m_listeners) {
try {
listener.deletedProject(m_database, project);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class CGenericSQLUserFunctions method deleteUser.
/**
* Deletes a user from the database.
*
* @param provider The provider used to access the database.
* @param user The user to be deleted.
*
* @throws CouldntDeleteException if the user could not be deleted from the database.
*/
public static void deleteUser(final SQLProvider provider, final IUser user) throws CouldntDeleteException {
Preconditions.checkNotNull(provider, "IE00088: provider argument can not be null");
Preconditions.checkNotNull(user, "IE00106: user argument can not be null");
final Connection connection = provider.getConnection().getConnection();
final String query = "DELETE FROM " + CTableNames.USER_TABLE + " WHERE user_id = ?;";
try (PreparedStatement statement = connection.prepareStatement(query)) {
statement.setInt(1, user.getUserId());
statement.execute();
} catch (final SQLException exception) {
throw new CouldntDeleteException(exception);
}
}
use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException in project binnavi by google.
the class PostgreSQLTraceFunctions method deleteTrace.
/**
* Deletes a trace from the database.
*
* @param provider The SQL provider that provides the connection.
* @param trace The trace to be deleted.
*
* @throws CouldntDeleteException Thrown if the trace could not be deleted.
*/
public static void deleteTrace(final AbstractSQLProvider provider, final TraceList trace) throws CouldntDeleteException {
Preconditions.checkNotNull(provider, "IE00576: Provider argument can not be null");
Preconditions.checkNotNull(trace, "IE00577: Trace argument can not be null");
Preconditions.checkArgument(trace.inSameDatabase(provider), "IE00578: Trace list is not part of this database");
final CConnection connection = provider.getConnection();
final String query = "DELETE FROM " + CTableNames.TRACES_TABLE + " WHERE id = " + trace.getId();
try {
connection.executeUpdate(query, true);
} catch (final SQLException e) {
throw new CouldntDeleteException(e);
}
}
Aggregations