Search in sources :

Example 91 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTagFunctions method insertTag.

/**
   * Inserts a tag into the tag hierarchy. The new tag is used as the parent tag of the child tags
   * of the old parent tag.
   * 
   * @param parent Parent window used for dialogs.
   * @param tagManager The tag manager that manages the old parent tag and the new tag.
   * @param parentTag The parent tag of the new tag.
   * @param name The name of the new tag.
   */
public static void insertTag(final JFrame parent, final ITagManager tagManager, final TreeNode<CTag> parentTag, final String name) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Inserting new tag" + ": " + name);
                tagManager.insertTag(parentTag, name);
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00147: " + "Could not insert tag";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("BinNavi could not insert a new tag with the name '%s'.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 92 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CTagFunctions method addTag.

/**
   * Adds a new tag to the database.
   * 
   * @param parent Parent window used for dialogs.
   * @param tagManager The tag manager where the tag is stored.
   * @param parentTag The parent tag of the tag. This parameter can be null for root tags.
   * @param name The name of the tag.
   */
public static void addTag(final JFrame parent, final ITagManager tagManager, final ITreeNode<CTag> parentTag, final String name) {
    new Thread() {

        @Override
        public void run() {
            try {
                final CDefaultProgressOperation operation = new CDefaultProgressOperation("", false, false);
                operation.getProgressPanel().setMaximum(1);
                operation.getProgressPanel().setText("Creating new tag" + ": " + name);
                tagManager.addTag(parentTag, name);
                operation.getProgressPanel().next();
                operation.stop();
            } catch (final CouldntSaveDataException exception) {
                CUtilityFunctions.logException(exception);
                final String innerMessage = "E00144: " + "Could not create tag";
                final String innerDescription = CUtilityFunctions.createDescription(String.format("The new tag '%s' could not be created.", name), new String[] { "There was a problem with the database connection." }, new String[] { "The tag was not created." });
                NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
            }
        }
    }.start();
}
Also used : CDefaultProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)

Example 93 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CReilViewCreator method create.

/**
   * Creates a REIL view from a view.
   * 
   * @param container The container in which the new REIL view is created.
   * @param view The view to be translated to REIL code.
   * 
   * @return The created REIL code view.
   * 
   * @throws InternalTranslationException Thrown if the view could not be translated to REIL code.
   * @throws CouldntLoadDataException
   */
public static INaviView create(final INaviModule container, final INaviView view) throws InternalTranslationException, CouldntLoadDataException {
    Preconditions.checkNotNull(container, "IE01768: Container argument can not be null");
    Preconditions.checkNotNull(view, "IE01769: View argument can not be null");
    final Map<IAddress, String> textMap = new HashMap<IAddress, String>();
    for (final CCodeNode node : view.getBasicBlocks()) {
        for (final INaviInstruction instruction : node.getInstructions()) {
            textMap.put(instruction.getAddress(), instruction.toString());
        }
    }
    final INaviView reilView = CReilViewCreator.create(container, view.getContent().getReilCode().getGraph());
    for (final CCodeNode node : reilView.getBasicBlocks()) {
        for (final INaviInstruction reilInstruction : node.getInstructions()) {
            if ((reilInstruction.getAddress().toLong() & 0xFF) == 0) {
                try {
                    node.getComments().appendLocalInstructionComment(reilInstruction, textMap.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())));
                } catch (final CouldntSaveDataException e) {
                    // Not possible for unsaved views.
                    CUtilityFunctions.logException(e);
                }
            }
        }
    }
    return reilView;
}
Also used : INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) HashMap(java.util.HashMap) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 94 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CUserManager method addUser.

/**
   * Adds a user to the user management and saves the information to the database
   *
   * @param userName The name of the user to be added to user management.
   *
   * @return The user.
   * @throws CouldntSaveDataException
   */
public synchronized IUser addUser(final String userName) throws CouldntSaveDataException {
    Preconditions.checkNotNull(userName, "IE02718: user name argument can not be null.");
    if (containsUserName(userName)) {
        throw new IllegalStateException("IE02719: User is already known to user management.");
    }
    final IUser user = provider.addUser(userName);
    users.add(user);
    for (final IUserManagerListener listener : listeners) {
        try {
            listener.addedUser(user);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    return user;
}
Also used : IUserManagerListener(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUserManagerListener) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Example 95 with CouldntSaveDataException

use of com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException in project binnavi by google.

the class CDatabaseContent method addProject.

/**
   * Adds a new project to the database.
   * 
   * This function is guaranteed to be thread-safe. If the new project could not be saved to the
   * database, the state of the database object remains unchanged.
   * 
   * @param name The name of the new project.
   * 
   * @return The added project.
   * 
   * @throws IllegalArgumentException Thrown if the name of the new project is null.
   * @throws CouldntSaveDataException Thrown if the new project could not be saved to the database.
   */
@Override
public INaviProject addProject(final String name) throws CouldntSaveDataException {
    Preconditions.checkNotNull(name, "IE00661: Project name can not be null");
    Preconditions.checkArgument(m_database.isConnected(), "IE00662: Database must be connected before a project can be added");
    Preconditions.checkArgument(m_database.isLoaded(), "IE00663: Database must be loaded before a project can be added");
    final CProject newProject = m_provider.createProject(name);
    m_projects.add(newProject);
    for (final IDatabaseListener listener : m_listeners) {
        try {
            listener.addedProject(m_database, newProject);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    return newProject;
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntDeleteException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)

Aggregations

CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)133 SQLException (java.sql.SQLException)71 PreparedStatement (java.sql.PreparedStatement)38 CConnection (com.google.security.zynamics.binnavi.Database.CConnection)35 CallableStatement (java.sql.CallableStatement)20 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)17 CouldntDeleteException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntDeleteException)13 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)10 CDefaultProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.CDefaultProgressOperation)10 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 ArrayList (java.util.ArrayList)9 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)8 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 BigInteger (java.math.BigInteger)8 Connection (java.sql.Connection)8 ResultSet (java.sql.ResultSet)8 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)7 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)6 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5