use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class ThreadClosedSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ThreadClosedReply reply) {
final ProcessManager processManager = getDebugger().getProcessManager();
final long tid = reply.getThreadId();
try {
processManager.removeThread(processManager.getThread(tid));
} catch (final MaybeNullException e) {
CUtilityFunctions.logException(e);
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class SuspendThreadSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final SuspendThreadReply reply) {
try {
final TargetProcessThread thread = getDebugger().getProcessManager().getThread(reply.getThreadId());
thread.setState(ThreadState.SUSPENDED);
} catch (final MaybeNullException exception) {
// Unlike in the error case, this is really a bug.
NaviLogger.severe("Error: Tried to suspend unknown thread '%d'", reply.getThreadId());
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class PostgreSQLNodeFunctions method deleteLocalCodeNodeComment.
/**
* Deletes a local code node comment from the list of local code node comments associated with the
* given code node.
*
* @param provider The provider to access the database-
* @param codeNode The code node where the comment will be deletes.
* @param commentId The id of the comment which will be deleted.
* @param userId The user id of the currently active user.
*
* @throws CouldntDeleteException Thrown if the comment could not be deleted from the database.
*/
public static void deleteLocalCodeNodeComment(final SQLProvider provider, final INaviCodeNode codeNode, final Integer commentId, final Integer userId) throws CouldntDeleteException {
Preconditions.checkNotNull(provider, "IE02473: provider argument can not be null");
Preconditions.checkNotNull(codeNode, "IE02474: codeNode argument can not be null");
Preconditions.checkNotNull(commentId, "IE02475: comment argument can not be null");
Preconditions.checkNotNull(userId, "IE02476: userId argument can not be null");
final String function = " { ? = call delete_local_code_node_comment(?, ?, ?, ?) } ";
try {
final CallableStatement deleteCommentStatement = provider.getConnection().getConnection().prepareCall(function);
try {
deleteCommentStatement.registerOutParameter(1, Types.INTEGER);
deleteCommentStatement.setInt(2, codeNode.getParentFunction().getModule().getConfiguration().getId());
deleteCommentStatement.setInt(3, codeNode.getId());
deleteCommentStatement.setInt(4, commentId);
deleteCommentStatement.setInt(5, userId);
deleteCommentStatement.execute();
deleteCommentStatement.getInt(1);
if (deleteCommentStatement.wasNull()) {
throw new IllegalArgumentException("Error: the comment id returned from the database was null");
}
} catch (final MaybeNullException exception) {
throw new CouldntDeleteException(exception);
} finally {
deleteCommentStatement.close();
}
} catch (final SQLException exception) {
throw new CouldntDeleteException(exception);
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class PostgreSQLEdgeFunctions method appendGlobalEdgeComment.
/**
* Appends a global edge comment to the list of global edge comments associated with this edge.
*
* @param provider The provider to access the database with.
* @param edge The Edge where to comment is associated with.
* @param commentText The text of the comment which will be appended.
* @param userId The user id of the currently active user.
*
* @throws CouldntSaveDataException If the data could not be stored in the database.
*/
public static Integer appendGlobalEdgeComment(final AbstractSQLProvider provider, final INaviEdge edge, final String commentText, final Integer userId) throws CouldntSaveDataException {
Preconditions.checkNotNull(provider, "IE00482: provider argument can not be null");
Preconditions.checkNotNull(edge, "IE00483: edge argument can not be null");
Preconditions.checkNotNull(commentText, "IE00484: commentText argument can not be null");
Preconditions.checkNotNull(userId, "IE00485: userId argument can not be null");
final Connection connection = provider.getConnection().getConnection();
final String function = "{ ? = call append_global_edge_comment(?, ?, ?, ?, ?, ?) }";
try {
final int sourceModuleId = getModuleId(edge.getSource());
final int destinationModuleId = getModuleId(edge.getTarget());
final IAddress sourceAddress = CViewNodeHelpers.getAddress(edge.getSource());
final IAddress destinationAddress = CViewNodeHelpers.getAddress(edge.getTarget());
try {
final CallableStatement appendCommentFunction = connection.prepareCall(function);
try {
appendCommentFunction.registerOutParameter(1, Types.INTEGER);
appendCommentFunction.setInt(2, sourceModuleId);
appendCommentFunction.setInt(3, destinationModuleId);
appendCommentFunction.setObject(4, sourceAddress.toBigInteger(), Types.BIGINT);
appendCommentFunction.setObject(5, destinationAddress.toBigInteger(), Types.BIGINT);
appendCommentFunction.setInt(6, userId);
appendCommentFunction.setString(7, commentText);
appendCommentFunction.execute();
final int commentId = appendCommentFunction.getInt(1);
if (appendCommentFunction.wasNull()) {
throw new CouldntSaveDataException("Error: Got an comment id of null from the database");
}
return commentId;
} finally {
appendCommentFunction.close();
}
} catch (final SQLException exception) {
throw new CouldntSaveDataException(exception);
}
} catch (final MaybeNullException exception) {
throw new CouldntSaveDataException(exception);
}
}
use of com.google.security.zynamics.binnavi.Exceptions.MaybeNullException in project binnavi by google.
the class PostgreSQLEdgeFunctions method deleteGlobalEdgeComment.
/**
* This function deletes a global edge comment from the database.
*
* @param provider The provider to access the database.
* @param edge The edge to which the comment is associated.
* @param commentId The comment id of the comment to be deleted.
* @param userId The user id of the currently active user.
*
* @throws CouldntDeleteException if the comment could not be deleted from the database.
*/
public static void deleteGlobalEdgeComment(final AbstractSQLProvider provider, final INaviEdge edge, final Integer commentId, final Integer userId) throws CouldntDeleteException {
Preconditions.checkNotNull(provider, "IE00505: provider argument can not be null");
Preconditions.checkNotNull(edge, "IE00506: codeNode argument can not be null");
Preconditions.checkNotNull(commentId, "IE00507: comment argument can not be null");
Preconditions.checkNotNull(userId, "IE00508: userId argument can not be null");
final String function = " { ? = call delete_global_edge_comment(?, ?, ?, ?, ?, ?) } ";
try {
final CallableStatement deleteCommentFunction = provider.getConnection().getConnection().prepareCall(function);
try {
deleteCommentFunction.registerOutParameter(1, Types.INTEGER);
deleteCommentFunction.setInt(2, getModuleId(edge.getSource()));
deleteCommentFunction.setInt(3, getModuleId(edge.getTarget()));
deleteCommentFunction.setObject(4, ((INaviCodeNode) edge.getSource()).getAddress().toBigInteger(), Types.BIGINT);
deleteCommentFunction.setObject(5, ((INaviCodeNode) edge.getTarget()).getAddress().toBigInteger(), Types.BIGINT);
deleteCommentFunction.setInt(6, commentId);
deleteCommentFunction.setInt(7, userId);
deleteCommentFunction.execute();
deleteCommentFunction.getInt(1);
if (deleteCommentFunction.wasNull()) {
throw new IllegalArgumentException("Error: the comment id returned from the database was null");
}
} finally {
deleteCommentFunction.close();
}
} catch (SQLException | MaybeNullException exception) {
throw new CouldntDeleteException(exception);
}
}
Aggregations