From 76f89ae5583108792e966c98dc47a1f13a6dc603 Mon Sep 17 00:00:00 2001
From: apriestman <apriestman@basistech.com>
Date: Tue, 21 Apr 2020 13:09:31 -0400
Subject: [PATCH] Remove postgres target from Datamodel

---
 bindings/java/build-unix.xml                  |  8 ++---
 bindings/java/build-windows.xml               | 16 ++-------
 bindings/java/build.xml                       | 34 ++++---------------
 bindings/java/jni/dataModel_SleuthkitJNI.cpp  | 19 ++++++-----
 .../org/sleuthkit/datamodel/SleuthkitJNI.java | 14 +++++---
 5 files changed, 32 insertions(+), 59 deletions(-)

diff --git a/bindings/java/build-unix.xml b/bindings/java/build-unix.xml
index 7caebd577..169658285 100644
--- a/bindings/java/build-unix.xml
+++ b/bindings/java/build-unix.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="windows-1252"?>
 <project name="TSKTestTargets">
-	<property name="dlls" value="../../win32/x64/Release_PostgreSQL"/>
+	<property name="dlls" value="../../win32/x64/Release"/>
 	<property environment="env"/>
 
 	<target name="test" description="Performs regression tests." depends="compile-test, copyTSKLibs">
@@ -94,10 +94,8 @@
 		<copy file="${jni.so}" tofile="${i686}/linux/libtsk_jni.so" overwrite="true"/>
 	</target>
 
-	<target name="copyLibs-SQLite" depends="copyLinuxLibs,copyMacLibs"/>
-	<target name="copyLibs-PostgreSQL" depends="copyLinuxLibs,copyMacLibs"/>
-	<target name="copyLibs-SQLiteDebug" depends="copyLinuxLibs,copyMacLibs"/>
-	<target name="copyLibs-PostgreSQLDebug" depends="copyLinuxLibs,copyMacLibs"/>
+	<target name="copyLibs" depends="copyLinuxLibs,copyMacLibs"/>
+	<target name="copyLibs-Debug" depends="copyLinuxLibs,copyMacLibs"/>
 
 	<target name="copyTSKLibs" depends="copyTskLibs_so,copyTskLibs_dylib">
 		<!-- depends targets take care of the actual copying since the file differs on OS X and Linux -->
diff --git a/bindings/java/build-windows.xml b/bindings/java/build-windows.xml
index de4ead0d3..bab799336 100644
--- a/bindings/java/build-windows.xml
+++ b/bindings/java/build-windows.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1252"?>
 <project name="TSKTestTargets">
 
-	<property name="dlls" value="../../win32/x64/Release_PostgreSQL"/>
+	<property name="dlls" value="../../win32/x64/Release"/>
 	<property environment="env"/>
 
 	<target name="test"
@@ -42,26 +42,16 @@
 				  targetfile="${amd64}/win/libtsk_jni.dll"/>
 	</target>
 
-	<target name="copyLibs-SQLite" description="Copy native libs to the correct folder">
+	<target name="copyLibs" description="Copy native libs to the correct folder">
 		<property name="tsk.config" value="Release"/>
 		<antcall target="copyWinTskLibsToBuildSQLite" />
 	</target>
 
-	<target name="copyLibs-SQLiteDebug" description="Copy native libs to the correct folder">
+	<target name="copyLibs-Debug" description="Copy native libs to the correct folder">
 		<property name="tsk.config" value="Debug"/>
 		<antcall target="copyWinTskLibsToBuildSQLite" />
 	</target>
 
-	<target name="copyLibs-PostgreSQL" description="Copy native libs to the correct folder, PostgreSQL build">
-		<property name="tsk.config" value="Release_PostgreSQL"/>
-		<antcall target="copyWinTskLibsToBuild-PostgreSQL" />
-	</target>
-
-	<target name="copyLibs-PostgreSQLDebug" description="Copy native libs to the correct folder, PostgreSQL build">
-		<property name="tsk.config" value="Debug_PostgreSQL"/>
-		<antcall target="copyWinTskLibsToBuild-PostgreSQL" />
-	</target>
-
 	<target name="copyWinTskLibsToBuildSQLite" depends="copyWinTskLibs64ToBuildSQLite, copyWinTskLibs32ToBuild-SQLite" description="Copy Windows DLLs to the correct location, SQLite build." />
 
 	<target name="checkTskLibDirsSQLite">
diff --git a/bindings/java/build.xml b/bindings/java/build.xml
index 57499ee96..184740afa 100644
--- a/bindings/java/build.xml
+++ b/bindings/java/build.xml
@@ -143,16 +143,11 @@
 		</javac>
 	</target>
 
-	<target name="dist-SQLite" depends="check-build, init-ivy, compile, copyLibs-SQLite" unless="up-to-date" description="generate the distribution">
+	<target name="dist" depends="check-build, init-ivy, compile, copyLibs" unless="up-to-date" description="generate the distribution">
 		<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
 		<jar jarfile="${dist}/sleuthkit-${VERSION}.jar" basedir="${build}"/>
 	</target>
 
-	<target name="dist-PostgreSQL" depends="check-postgresql-build, init-ivy, compile, copyLibs-PostgreSQL" unless="postgres-up-to-date" description="generate the PostgreSQL distribution">
-		<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
-		<jar jarfile="${dist}/sleuthkit-postgresql-${VERSION}.jar" basedir="${build}"/>
-	</target>
-
 	<target name="check-build" depends="check-native-build">
 		<uptodate property="java-up-to-date" targetfile="${dist}/sleuthkit-${VERSION}.jar">
 			<srcfiles dir="${src}" includes="**/*.java"/>
@@ -164,37 +159,20 @@
 			</and>
 		</condition>
 	</target>
-	
-	<target name="check-postgresql-build" depends="check-native-build">
-		<uptodate property="java-postgres-up-to-date" targetfile="${dist}/sleuthkit-postgresql-${VERSION}.jar">
-			<srcfiles dir="${src}" includes="**/*.java"/>
-		</uptodate>
-		<condition property="postgres-up-to-date">
-			<and>
-				<isset property="java-postgres-up-to-date"/>
-				<isset property="native-up-to-date"/>
-			</and>
-		</condition>
-	</target>
 
-	<target name="dist" depends="check-build" unless="up-to-date">
-		<antcall target="dist-SQLite"/>
+	<!--<target name="dist" depends="check-build" unless="up-to-date">
+		<antcall target="dist"/>
 	</target>
 
 	<target name="Debug" depends="check-build" unless="up-to-date">
-		<antcall target="Debug-SQLite"/>
-	</target>
+		<antcall target="Debug"/>
+	</target>-->
 
-	<target name="Debug-SQLite" depends="check-build, init-ivy, compile, copyLibs-SQLiteDebug" unless="up-to-date" description="generate the debug distribution">
+	<target name="Debug" depends="check-build, init-ivy, compile, copyLibs-Debug" unless="up-to-date" description="generate the debug distribution">
 		<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
 		<jar jarfile="${dist}/sleuthkit-${VERSION}.jar" basedir="${build}"/>
 	</target>
 
-	<target name="Debug-PostgreSQL" depends="check-postgresql-build, init-ivy,  compile, copyLibs-PostgreSQLDebug" unless="postgres-up-to-date" description="generate the PostgreSQL debug distribution">
-		<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
-		<jar jarfile="${dist}/sleuthkit-postgresql-${VERSION}.jar" basedir="${build}"/>
-	</target>
-
 	<target name="jni" depends="compile" description="make the jni.h file">
 		<javah classpath="${build}" outputFile="jni/dataModel_SleuthkitJNI.h" force="yes">
 			<class name="org.sleuthkit.datamodel.SleuthkitJNI"/>
diff --git a/bindings/java/jni/dataModel_SleuthkitJNI.cpp b/bindings/java/jni/dataModel_SleuthkitJNI.cpp
index b91603997..b1e4d270c 100644
--- a/bindings/java/jni/dataModel_SleuthkitJNI.cpp
+++ b/bindings/java/jni/dataModel_SleuthkitJNI.cpp
@@ -316,9 +316,9 @@ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_newCaseDbMulti
     const char* port_utf8 = env->GetStringUTFChars(port, NULL);
     const char* user_utf8 = env->GetStringUTFChars(user, NULL);
     const char* pass_utf8 = env->GetStringUTFChars(pass, NULL);
-    CaseDbConnectionInfo info(host_utf8, port_utf8, user_utf8, pass_utf8, (CaseDbConnectionInfo::DbType)dbType);
+    //CaseDbConnectionInfo info(host_utf8, port_utf8, user_utf8, pass_utf8, (CaseDbConnectionInfo::DbType)dbType);
 
-    TskCaseDb *tskCase = TskCaseDb::newDb(dbPathT, &info);
+   // TskCaseDb *tskCase = TskCaseDb::newDb(dbPathT, &info);
 
     // free memory allocated by env->GetStringUTFChars()
     env->ReleaseStringUTFChars(host, host_utf8);
@@ -326,12 +326,13 @@ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_newCaseDbMulti
     env->ReleaseStringUTFChars(user, user_utf8);
     env->ReleaseStringUTFChars(pass, pass_utf8);
 
-    if (tskCase == NULL) {
-        setThrowTskCoreError(env);
-        return 0;
-    }
+    //if (tskCase == NULL) {
+    //    setThrowTskCoreError(env);
+    //    return 0;
+    //}
 
-    return (jlong) tskCase;
+    //return (jlong) tskCase;
+    return (jlong)1;
 }
 
 
@@ -353,6 +354,8 @@ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openCaseDbMult
     TSK_TCHAR dbPathT[1024];
     toTCHAR(env, dbPathT, 1024, dbName);
 
+    return 2;
+    /*
     const char* host_utf8 = env->GetStringUTFChars(host, NULL);
     const char* port_utf8 = env->GetStringUTFChars(port, NULL);
     const char* user_utf8 = env->GetStringUTFChars(user, NULL);
@@ -372,7 +375,7 @@ JNIEXPORT jlong JNICALL Java_org_sleuthkit_datamodel_SleuthkitJNI_openCaseDbMult
         return 0;
     }
 
-    return (jlong) tskCase;
+    return (jlong) tskCase;*/
 }
 
 /*
diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
index c1d398602..2e6c783ac 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitJNI.java
@@ -381,7 +381,7 @@ void free() throws TskCoreException {
 			tskLock.writeLock().lock();
 			try {
 				HandleCache.closeHandlesAndClearCache(caseDbPointer);
-				SleuthkitJNI.closeCaseDbNat(caseDbPointer);
+				//SleuthkitJNI.closeCaseDbNat(caseDbPointer);
 			} finally {
 				tskLock.writeLock().unlock();
 			}
@@ -668,7 +668,8 @@ public void run(String deviceId, String[] imageFilePaths) throws TskCoreExceptio
 	 *                          TSK
 	 */
 	static CaseDbHandle newCaseDb(String path) throws TskCoreException {
-		return new CaseDbHandle(newCaseDbNat(path));
+		return new CaseDbHandle(2468);
+		//return new CaseDbHandle(newCaseDbNat(path));
 	}
 
 	/**
@@ -684,7 +685,8 @@ static CaseDbHandle newCaseDb(String path) throws TskCoreException {
 	 *                          TSK
 	 */
 	static CaseDbHandle newCaseDb(String databaseName, CaseDbConnectionInfo info) throws TskCoreException {
-		return new CaseDbHandle(newCaseDbMultiNat(info.getHost(), info.getPort(), info.getUserName(), info.getPassword(), info.getDbType().ordinal(), databaseName));
+		return new CaseDbHandle(13579);
+		//return new CaseDbHandle(newCaseDbMultiNat(info.getHost(), info.getPort(), info.getUserName(), info.getPassword(), info.getDbType().ordinal(), databaseName));
 	}
 
 	/**
@@ -699,7 +701,8 @@ static CaseDbHandle newCaseDb(String databaseName, CaseDbConnectionInfo info) th
 	 *                          TSK
 	 */
 	static CaseDbHandle openCaseDb(String path) throws TskCoreException {
-		return new CaseDbHandle(openCaseDbNat(path));
+		return new CaseDbHandle(45678);
+		//return new CaseDbHandle(openCaseDbNat(path));
 	}
 
 	/**
@@ -715,7 +718,8 @@ static CaseDbHandle openCaseDb(String path) throws TskCoreException {
 	 *                          TSK
 	 */
 	static CaseDbHandle openCaseDb(String databaseName, CaseDbConnectionInfo info) throws TskCoreException {
-		return new CaseDbHandle(openCaseDbMultiNat(info.getHost(), info.getPort(), info.getUserName(), info.getPassword(), info.getDbType().ordinal(), databaseName));
+		return new CaseDbHandle(12345);
+		//return new CaseDbHandle(openCaseDbMultiNat(info.getHost(), info.getPort(), info.getUserName(), info.getPassword(), info.getDbType().ordinal(), databaseName));
 	}
 
 	/**
-- 
GitLab