diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp index d2764cf5087c839c39bf74e9b832d14fec373ae8..a0563a79f6fd0a31280f612588ec86e405a7fde1 100644 --- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp +++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp @@ -370,7 +370,11 @@ JNIEXPORT void JNICALL "revertAddImgNat: Invalid TskAutoDb object passed in"); return; } - tskAuto->revertAddImage(); + if (tskAuto->revertAddImage()) { + throwTskError(env, + "revertAddImgNat: Error reverting transaction"); + return; + } delete tskAuto; } @@ -392,6 +396,11 @@ JNIEXPORT jlong JNICALL } int64_t imgId = tskAuto->commitAddImage(); delete tskAuto; + if (imgId == -1) { + throwTskError(env, + "commit addImgNat: Error commiting image"); + return -1; + } return imgId; } diff --git a/bindings/java/nbproject/project.xml b/bindings/java/nbproject/project.xml old mode 100644 new mode 100755 index 7a8a1be236f8c6f81b6021668341423fedb3eacb..6cf7672204bd5be3d65f32f154a26d6d44f577b4 --- a/bindings/java/nbproject/project.xml +++ b/bindings/java/nbproject/project.xml @@ -1,151 +1,151 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.ant.freeform</type> - <configuration> - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1"> - <name>DataModel</name> - </general-data> - <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2"> - <!-- Do not use Project Properties customizer when editing this file manually. --> - <name>DataModel</name> - <properties/> - <folders> - <source-folder> - <label>DataModel</label> - <location>.</location> - <encoding>windows-1252</encoding> - </source-folder> - <source-folder> - <label>src</label> - <type>java</type> - <location>src</location> - <encoding>windows-1252</encoding> - </source-folder> - <source-folder> - <label>test</label> - <type>java</type> - <location>test</location> - <encoding>windows-1252</encoding> - </source-folder> - </folders> - <ide-actions> - <action name="build"> - <target>compile</target> - </action> - <action name="clean"> - <target>clean</target> - </action> - <action name="rebuild"> - <target>clean</target> - <target>compile</target> - </action> - <action name="run.single"> - <script>nbproject/ide-file-targets.xml</script> - <target>run-selected-file-in-test</target> - <context> - <property>run.class</property> - <folder>test</folder> - <pattern>\.java$</pattern> - <format>java-name</format> - <arity> - <one-file-only/> - </arity> - </context> - </action> - <action name="compile.single"> - <script>nbproject/ide-file-targets.xml</script> - <target>compile-selected-files-in-test</target> - <context> - <property>files</property> - <folder>test</folder> - <pattern>\.java$</pattern> - <format>relative-path</format> - <arity> - <separated-files>,</separated-files> - </arity> - </context> - </action> - <action name="test"> - <target>test</target> - </action> - </ide-actions> - <export> - <type>folder</type> - <location>build</location> - <build-target>compile</build-target> - </export> - <export> - <type>folder</type> - <location>build</location> - <build-target>compile</build-target> - </export> - <export> - <type>folder</type> - <location>test</location> - <build-target>compile</build-target> - </export> - <view> - <items> - <source-folder style="packages"> - <label>src</label> - <location>src</location> - </source-folder> - <source-folder style="packages"> - <label>test</label> - <location>test</location> - </source-folder> - <source-file> - <location>build.xml</location> - </source-file> - </items> - <context-menu> - <ide-action name="build"/> - <ide-action name="rebuild"/> - <ide-action name="clean"/> - <ide-action name="test"/> - </context-menu> - </view> - <subprojects/> - </general-data> - <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3"> - <compilation-unit> - <package-root>src</package-root> - <classpath mode="compile">lib;lib/diffutils-1.2.1.jar</classpath> - <built-to>build</built-to> - <source-level>1.6</source-level> - </compilation-unit> - <compilation-unit> - <package-root>test</package-root> - <unit-tests/> - <classpath mode="compile">build;lib/diffutils-1.2.1.jar;lib/diffutils-1.2.1-javadoc.jar;lib/diffutils-1.2.1-sources.jar;lib/junit-4.8.2.jar</classpath> - <built-to>build</built-to> - <built-to>test</built-to> - <source-level>1.6</source-level> - </compilation-unit> - </java-data> - <preferences xmlns="http://www.netbeans.org/ns/auxiliary-configuration-preferences/1"> - <module name="org-netbeans-modules-html-editor-lib"/> - <module name="org-netbeans-modules-editor-indent"> - <node name="CodeStyle"> - <property name="usedProfile" value="project"/> - <node name="project"> - <property name="spaces-per-tab" value="4"/> - <property name="tab-size" value="4"/> - <property name="indent-shift-width" value="4"/> - <property name="expand-tabs" value="false"/> - <property name="text-limit-width" value="80"/> - <property name="text-line-wrap" value="none"/> - </node> - </node> - <node name="text"> - <node name="x-java"> - <node name="CodeStyle"> - <node name="project"/> - </node> - </node> - </node> - </module> - <module name="org-netbeans-modules-projectimport-eclipse-core"/> - </preferences> - </configuration> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.ant.freeform</type> + <configuration> + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1"> + <name>DataModel</name> + </general-data> + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2"> + <!-- Do not use Project Properties customizer when editing this file manually. --> + <name>DataModel</name> + <properties/> + <folders> + <source-folder> + <label>DataModel</label> + <location>.</location> + <encoding>windows-1252</encoding> + </source-folder> + <source-folder> + <label>src</label> + <type>java</type> + <location>src</location> + <encoding>windows-1252</encoding> + </source-folder> + <source-folder> + <label>test</label> + <type>java</type> + <location>test</location> + <encoding>windows-1252</encoding> + </source-folder> + </folders> + <ide-actions> + <action name="build"> + <target>dist</target> + </action> + <action name="clean"> + <target>clean</target> + </action> + <action name="rebuild"> + <target>clean</target> + <target>dist</target> + </action> + <action name="run.single"> + <script>nbproject/ide-file-targets.xml</script> + <target>run-selected-file-in-test</target> + <context> + <property>run.class</property> + <folder>test</folder> + <pattern>\.java$</pattern> + <format>java-name</format> + <arity> + <one-file-only/> + </arity> + </context> + </action> + <action name="compile.single"> + <script>nbproject/ide-file-targets.xml</script> + <target>compile-selected-files-in-test</target> + <context> + <property>files</property> + <folder>test</folder> + <pattern>\.java$</pattern> + <format>relative-path</format> + <arity> + <separated-files>,</separated-files> + </arity> + </context> + </action> + <action name="test"> + <target>test</target> + </action> + </ide-actions> + <export> + <type>folder</type> + <location>build</location> + <build-target>compile</build-target> + </export> + <export> + <type>folder</type> + <location>build</location> + <build-target>compile</build-target> + </export> + <export> + <type>folder</type> + <location>test</location> + <build-target>compile</build-target> + </export> + <view> + <items> + <source-folder style="packages"> + <label>src</label> + <location>src</location> + </source-folder> + <source-folder style="packages"> + <label>test</label> + <location>test</location> + </source-folder> + <source-file> + <location>build.xml</location> + </source-file> + </items> + <context-menu> + <ide-action name="build"/> + <ide-action name="rebuild"/> + <ide-action name="clean"/> + <ide-action name="test"/> + </context-menu> + </view> + <subprojects/> + </general-data> + <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3"> + <compilation-unit> + <package-root>src</package-root> + <classpath mode="compile">lib;lib/diffutils-1.2.1.jar</classpath> + <built-to>build</built-to> + <source-level>1.6</source-level> + </compilation-unit> + <compilation-unit> + <package-root>test</package-root> + <unit-tests/> + <classpath mode="compile">build;lib/diffutils-1.2.1.jar;lib/diffutils-1.2.1-javadoc.jar;lib/diffutils-1.2.1-sources.jar;lib/junit-4.8.2.jar</classpath> + <built-to>build</built-to> + <built-to>test</built-to> + <source-level>1.6</source-level> + </compilation-unit> + </java-data> + <preferences xmlns="http://www.netbeans.org/ns/auxiliary-configuration-preferences/1"> + <module name="org-netbeans-modules-html-editor-lib"/> + <module name="org-netbeans-modules-editor-indent"> + <node name="CodeStyle"> + <property name="usedProfile" value="project"/> + <node name="project"> + <property name="spaces-per-tab" value="4"/> + <property name="tab-size" value="4"/> + <property name="indent-shift-width" value="4"/> + <property name="expand-tabs" value="false"/> + <property name="text-limit-width" value="80"/> + <property name="text-line-wrap" value="none"/> + </node> + </node> + <node name="text"> + <node name="x-java"> + <node name="CodeStyle"> + <node name="project"/> + </node> + </node> + </node> + </module> + <module name="org-netbeans-modules-projectimport-eclipse-core"/> + </preferences> + </configuration> +</project> diff --git a/tsk3/auto/auto_db.cpp b/tsk3/auto/auto_db.cpp index cc4f82cfb1adc9dc1f2b9e4f1f581d22e16bf111..09cb7872e0eaac0ce33e7e82c88a1e318625a6bf 100644 --- a/tsk3/auto/auto_db.cpp +++ b/tsk3/auto/auto_db.cpp @@ -362,10 +362,18 @@ void /** * Revert all changes after the process has run sucessfully. + * @returns 1 on error, 0 on success */ int TskAutoDb::revertAddImage() { + if (m_imgTransactionOpen == false) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("revertAddImage(): transaction is already closed"); + return 1; + } + int retval = m_db->revertSavepoint(TSK_ADD_IMAGE_SAVEPOINT); m_imgTransactionOpen = false; return retval; @@ -373,13 +381,23 @@ int /** * Finish the process after it has run sucessfully by committing the changes. - * Returns the id of the image that was added. + * @returns Id of the image that was added or -1 on error */ int64_t TskAutoDb::commitAddImage() { - m_db->releaseSavepoint(TSK_ADD_IMAGE_SAVEPOINT); + if (m_imgTransactionOpen == false) { + tsk_error_reset(); + tsk_error_set_errno(TSK_ERR_AUTO_DB); + tsk_error_set_errstr("commitAddImage(): transaction is already closed"); + return -1; + } + + int retval = m_db->releaseSavepoint(TSK_ADD_IMAGE_SAVEPOINT); m_imgTransactionOpen = false; + if (retval == 1) { + return -1; + } return m_curImgId; }