19 package org.sleuthkit.autopsy.casemodule;
22 import java.io.IOException;
23 import java.nio.file.Path;
24 import java.nio.file.Paths;
25 import java.sql.Connection;
26 import java.sql.DriverManager;
27 import java.sql.PreparedStatement;
28 import java.sql.ResultSet;
29 import java.sql.ResultSetMetaData;
30 import java.sql.SQLException;
31 import java.sql.Statement;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
34 import org.apache.commons.io.FileUtils;
35 import org.openide.util.NbBundle;
83 boolean copySourceImages,
86 this.imageInputFolder = imageInput;
87 this.caseInputFolder = caseInput;
88 this.imageOutputFolder = imageOutput;
89 this.caseOutputFolder = caseOutput;
107 Path getImageInputFolder() {
111 Path getImageOutputFolder() {
115 String getOldCaseName() {
119 String getNewCaseName() {
123 boolean getCopySourceImages() {
127 boolean getDeleteCase() {
131 String getPostgreSQLDbName() {
135 String getAutFileName() {
139 String getRawFolderName() {
143 CaseDbConnectionInfo getDb() {
147 void setPostgreSQLDbName(String dbName) {
148 this.postgreSQLDbName = dbName;
163 Class.forName(
"org.postgresql.Driver");
166 Path oldDatabasePath = icd.getCaseInputFolder().resolve(AUTOPSY_DB_FILE);
167 if (
false == oldDatabasePath.toFile().exists()) {
168 throw new Exception(NbBundle.getMessage(
SingleUserCaseConverter.class,
"SingleUserCaseConverter.BadDatabaseFileName"));
174 throw new Exception(NbBundle.getMessage(
SingleUserCaseConverter.class,
"SingleUserCaseConverter.AlreadyMultiUser"));
184 SimpleDateFormat dateFormat =
new SimpleDateFormat(
"yyyyMMdd_HHmmss");
185 Date date =
new Date();
186 String dbName = icd.getNewCaseName() +
"_" + dateFormat.format(date);
187 icd.setPostgreSQLDbName(dbName);
204 icd.getNewCaseName(),
205 icd.getNewCaseName(),
210 newCaseMetadata.setCreatedDate(oldCaseMetadata.getCreatedDate());
211 newCaseMetadata.setCreatedByVersion(oldCaseMetadata.getCreatedByVersion());
217 if (icd.getDeleteCase()) {
218 FileUtils.deleteDirectory(icd.getCaseInputFolder().toFile());
231 File thePath = icd.getImageInputFolder().resolve(icd.getOldCaseName()).toFile();
232 if (thePath.isDirectory()) {
236 thePath = icd.getImageInputFolder().resolve(icd.getRawFolderName()).toFile();
237 if (thePath.isDirectory()) {
241 return icd.getImageInputFolder().toFile();
257 Path source = icd.getCaseInputFolder();
258 if (source.toFile().exists()) {
259 destination = icd.getCaseOutputFolder().resolve(hostName);
260 FileUtils.copyDirectory(source.toFile(), destination.toFile());
263 source = icd.getCaseInputFolder().resolve(TIMELINE_FILE);
264 if (source.toFile().exists()) {
266 FileUtils.copyFile(source.toFile(), destination.toFile());
270 File oldAutopsyFile = Paths.get(icd.getCaseOutputFolder().toString(), hostName, icd.getOldCaseName() +
DOTAUT).toFile();
271 if (oldAutopsyFile.exists()) {
272 oldAutopsyFile.delete();
276 File oldDatabaseFile = Paths.get(icd.getCaseOutputFolder().toString(), hostName,
AUTOPSY_DB_FILE).toFile();
277 if (oldDatabaseFile.exists()) {
278 oldDatabaseFile.delete();
282 File oldTimelineFile = Paths.get(icd.getCaseOutputFolder().toString(), hostName,
TIMELINE_FILE).toFile();
283 if (oldTimelineFile.exists()) {
284 oldTimelineFile.delete();
308 Class.forName(
"org.sqlite.JDBC");
313 Statement inputStatement = sqliteConnection.createStatement();
314 ResultSet inputResultSet = inputStatement.executeQuery(
"SELECT * FROM blackboard_artifact_types");
315 Statement outputStatement;
316 Statement numberingPK;
319 while (inputResultSet.next()) {
321 long value = inputResultSet.getLong(1);
322 if (value > biggestPK) {
325 Statement check = postgreSQLConnection.createStatement();
326 ResultSet checkResult = check.executeQuery(
"SELECT * FROM blackboard_artifact_types WHERE artifact_type_id=" + value +
" AND type_name LIKE '" + inputResultSet.getString(2) +
"' AND display_name LIKE '" + inputResultSet.getString(3) +
"'");
327 if (!checkResult.isBeforeFirst()) {
328 String sql =
"INSERT INTO blackboard_artifact_types (artifact_type_id, type_name, display_name) VALUES ("
332 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
336 }
catch (SQLException ex) {
337 if (ex.getErrorCode() != 0) {
338 throw new SQLException(ex);
342 numberingPK = postgreSQLConnection.createStatement();
343 numberingPK.execute(
"ALTER SEQUENCE blackboard_artifact_types_artifact_type_id_seq RESTART WITH " + (biggestPK + 1));
347 inputStatement = sqliteConnection.createStatement();
348 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM blackboard_attribute_types");
350 while (inputResultSet.next()) {
352 long value = inputResultSet.getLong(1);
353 if (value > biggestPK) {
356 Statement check = postgreSQLConnection.createStatement();
357 ResultSet checkResult = check.executeQuery(
"SELECT * FROM blackboard_attribute_types WHERE attribute_type_id=" + value +
" AND type_name LIKE '" + inputResultSet.getString(2) +
"' AND display_name LIKE '" + inputResultSet.getString(3) +
"'");
358 if (!checkResult.isBeforeFirst()) {
359 String sql =
"INSERT INTO blackboard_attribute_types (attribute_type_id, type_name, display_name) VALUES ("
364 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
368 }
catch (SQLException ex) {
369 if (ex.getErrorCode() != 0) {
370 throw new SQLException(ex);
374 numberingPK = postgreSQLConnection.createStatement();
375 numberingPK.execute(
"ALTER SEQUENCE blackboard_attribute_types_attribute_type_id_seq RESTART WITH " + (biggestPK + 1));
379 inputStatement = sqliteConnection.createStatement();
380 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_objects");
382 while (inputResultSet.next()) {
383 outputStatement = postgreSQLConnection.createStatement();
385 long value = inputResultSet.getLong(1);
386 if (value > biggestPK) {
389 outputStatement.executeUpdate(
"INSERT INTO tsk_objects (obj_id, par_obj_id, type) VALUES ("
392 + inputResultSet.getInt(3) +
")");
393 }
catch (SQLException ex) {
394 if (ex.getErrorCode() != 0) {
395 throw new SQLException(ex);
399 numberingPK = postgreSQLConnection.createStatement();
400 numberingPK.execute(
"ALTER SEQUENCE tsk_objects_obj_id_seq RESTART WITH " + (biggestPK + 1));
403 inputStatement = sqliteConnection.createStatement();
404 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_image_names");
406 while (inputResultSet.next()) {
407 outputStatement = postgreSQLConnection.createStatement();
409 outputStatement.executeUpdate(
"INSERT INTO tsk_image_names (obj_id, name, sequence) VALUES ("
410 + inputResultSet.getLong(1) +
",'"
411 + inputResultSet.getString(2) +
"',"
412 + inputResultSet.getInt(3) +
")");
413 }
catch (SQLException ex) {
414 if (ex.getErrorCode() != 0) {
415 throw new SQLException(ex);
422 inputStatement = sqliteConnection.createStatement();
423 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_image_info");
425 while (inputResultSet.next()) {
427 long value = inputResultSet.getLong(1);
428 if (value > biggestPK) {
431 String sql =
"INSERT INTO tsk_image_info (obj_id, type, ssize, tzone, size, md5, display_name) VALUES ("
440 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
446 }
catch (SQLException ex) {
447 if (ex.getErrorCode() != 0) {
448 throw new SQLException(ex);
452 numberingPK = postgreSQLConnection.createStatement();
453 numberingPK.execute(
"ALTER SEQUENCE tsk_image_info_obj_id_seq RESTART WITH " + (biggestPK + 1));
457 inputStatement = sqliteConnection.createStatement();
458 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_fs_info");
460 while (inputResultSet.next()) {
462 long value = inputResultSet.getLong(1);
463 if (value > biggestPK) {
466 String sql =
"INSERT INTO tsk_fs_info (obj_id, img_offset, fs_type, block_size, block_count, root_inum, first_inum, last_inum, display_name) VALUES ("
468 + inputResultSet.getLong(2) +
","
469 + inputResultSet.getInt(3) +
","
470 + inputResultSet.getLong(4) +
","
471 + inputResultSet.getLong(5) +
","
472 + inputResultSet.getLong(6) +
","
473 + inputResultSet.getLong(7) +
","
474 + inputResultSet.getLong(8) +
","
477 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
481 }
catch (SQLException ex) {
482 if (ex.getErrorCode() != 0) {
483 throw new SQLException(ex);
487 numberingPK = postgreSQLConnection.createStatement();
488 numberingPK.execute(
"ALTER SEQUENCE tsk_fs_info_obj_id_seq RESTART WITH " + (biggestPK + 1));
492 inputStatement = sqliteConnection.createStatement();
493 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_files_path");
495 while (inputResultSet.next()) {
496 outputStatement = postgreSQLConnection.createStatement();
498 long value = inputResultSet.getLong(1);
499 if (value > biggestPK) {
506 ResultSetMetaData rsMetaData = inputResultSet.getMetaData();
507 if (rsMetaData.getColumnCount() == 3) {
508 encoding = inputResultSet.getInt(3);
510 outputStatement.executeUpdate(
"INSERT INTO tsk_files_path (obj_id, path, encoding_type) VALUES ("
514 }
catch (SQLException ex) {
515 if (ex.getErrorCode() != 0) {
516 throw new SQLException(ex);
520 numberingPK = postgreSQLConnection.createStatement();
521 numberingPK.execute(
"ALTER SEQUENCE tsk_files_path_obj_id_seq RESTART WITH " + (biggestPK + 1));
525 inputStatement = sqliteConnection.createStatement();
526 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_files");
528 while (inputResultSet.next()) {
530 long value = inputResultSet.getLong(1);
531 if (value > biggestPK) {
534 String sql =
"INSERT INTO tsk_files (obj_id, fs_obj_id, attr_type, attr_id, name, meta_addr, meta_seq, type, has_layout, has_path, dir_type, meta_type, dir_flags, meta_flags, size, ctime, crtime, atime, mtime, mode, uid, gid, md5, known, parent_path) VALUES ("
561 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
566 }
catch (SQLException ex) {
567 if (ex.getErrorCode() != 0) {
568 throw new SQLException(ex);
572 numberingPK = postgreSQLConnection.createStatement();
573 numberingPK.execute(
"ALTER SEQUENCE tsk_files_obj_id_seq RESTART WITH " + (biggestPK + 1));
576 inputStatement = sqliteConnection.createStatement();
577 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_file_layout");
579 while (inputResultSet.next()) {
580 outputStatement = postgreSQLConnection.createStatement();
582 outputStatement.executeUpdate(
"INSERT INTO tsk_file_layout (obj_id, byte_start, byte_len, sequence) VALUES ("
583 + inputResultSet.getLong(1) +
","
584 + inputResultSet.getLong(2) +
","
585 + inputResultSet.getLong(3) +
","
586 + inputResultSet.getInt(4) +
")");
587 }
catch (SQLException ex) {
588 if (ex.getErrorCode() != 0) {
589 throw new SQLException(ex);
595 inputStatement = sqliteConnection.createStatement();
596 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_db_info");
598 while (inputResultSet.next()) {
599 outputStatement = postgreSQLConnection.createStatement();
601 Statement check = postgreSQLConnection.createStatement();
602 ResultSet checkResult = check.executeQuery(
"SELECT * FROM tsk_db_info WHERE schema_ver=" + inputResultSet.getInt(1) +
" AND tsk_ver=" + inputResultSet.getInt(2));
603 if (!checkResult.isBeforeFirst()) {
604 outputStatement.executeUpdate(
"INSERT INTO tsk_db_info (schema_ver, tsk_ver) VALUES ("
608 }
catch (SQLException ex) {
609 if (ex.getErrorCode() != 0) {
610 throw new SQLException(ex);
617 inputStatement = sqliteConnection.createStatement();
618 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tag_names");
620 while (inputResultSet.next()) {
622 long value = inputResultSet.getLong(1);
623 if (value > biggestPK) {
626 String sql =
"INSERT INTO tag_names (tag_name_id, display_name, description, color) VALUES ("
632 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
636 }
catch (SQLException ex) {
637 if (ex.getErrorCode() != 0) {
638 throw new SQLException(ex);
642 numberingPK = postgreSQLConnection.createStatement();
643 numberingPK.execute(
"ALTER SEQUENCE tag_names_tag_name_id_seq RESTART WITH " + (biggestPK + 1));
647 inputStatement = sqliteConnection.createStatement();
648 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM reports");
650 while (inputResultSet.next()) {
651 outputStatement = postgreSQLConnection.createStatement();
653 long value = inputResultSet.getLong(1);
654 if (value > biggestPK) {
657 outputStatement.executeUpdate(
"INSERT INTO reports (report_id, path, crtime, src_module_name, report_name) VALUES ("
660 + inputResultSet.getInt(3) +
",'"
664 }
catch (SQLException ex) {
665 if (ex.getErrorCode() != 0) {
666 throw new SQLException(ex);
670 numberingPK = postgreSQLConnection.createStatement();
671 numberingPK.execute(
"ALTER SEQUENCE reports_report_id_seq RESTART WITH " + (biggestPK + 1));
674 biggestPK = Long.MIN_VALUE;
675 inputStatement = sqliteConnection.createStatement();
676 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM blackboard_artifacts");
678 while (inputResultSet.next()) {
679 outputStatement = postgreSQLConnection.createStatement();
681 long value = inputResultSet.getLong(1);
682 if (value > biggestPK) {
685 outputStatement.executeUpdate(
"INSERT INTO blackboard_artifacts (artifact_id, obj_id, artifact_type_id) VALUES ("
687 + inputResultSet.getLong(2) +
","
688 + inputResultSet.getLong(3) +
")");
690 }
catch (SQLException ex) {
691 if (ex.getErrorCode() != 0) {
692 throw new SQLException(ex);
696 numberingPK = postgreSQLConnection.createStatement();
697 numberingPK.execute(
"ALTER SEQUENCE blackboard_artifacts_artifact_id_seq RESTART WITH " + (biggestPK + 1));
700 inputStatement = sqliteConnection.createStatement();
701 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM blackboard_attributes");
703 while (inputResultSet.next()) {
705 String sql =
"INSERT INTO blackboard_attributes (artifact_id, artifact_type_id, source, context, attribute_type_id, value_type, value_byte, value_text, value_int32, value_int64, value_double) VALUES ("
706 + inputResultSet.getLong(1) +
","
707 + inputResultSet.getLong(2) +
","
710 + inputResultSet.getLong(5) +
","
711 + inputResultSet.getInt(6) +
","
717 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
725 }
catch (SQLException ex) {
726 if (ex.getErrorCode() != 0) {
727 throw new SQLException(ex);
734 inputStatement = sqliteConnection.createStatement();
735 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_vs_parts");
737 while (inputResultSet.next()) {
739 long value = inputResultSet.getLong(1);
740 if (value > biggestPK) {
743 String sql =
"INSERT INTO tsk_vs_parts (obj_id, addr, start, length, descr, flags) VALUES ("
745 + inputResultSet.getLong(2) +
","
746 + inputResultSet.getLong(3) +
","
747 + inputResultSet.getLong(4) +
","
749 + inputResultSet.getInt(6) +
")";
750 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
754 }
catch (SQLException ex) {
755 if (ex.getErrorCode() != 0) {
756 throw new SQLException(ex);
760 numberingPK = postgreSQLConnection.createStatement();
761 numberingPK.execute(
"ALTER SEQUENCE tsk_vs_parts_obj_id_seq RESTART WITH " + (biggestPK + 1));
765 inputStatement = sqliteConnection.createStatement();
766 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_vs_info");
768 while (inputResultSet.next()) {
769 outputStatement = postgreSQLConnection.createStatement();
771 long value = inputResultSet.getLong(1);
772 if (value > biggestPK) {
775 outputStatement.executeUpdate(
"INSERT INTO tsk_vs_info (obj_id, vs_type, img_offset, block_size) VALUES ("
777 + inputResultSet.getInt(2) +
","
778 + inputResultSet.getLong(3) +
","
779 + inputResultSet.getLong(4) +
")");
781 }
catch (SQLException ex) {
782 if (ex.getErrorCode() != 0) {
783 throw new SQLException(ex);
787 numberingPK = postgreSQLConnection.createStatement();
788 numberingPK.execute(
"ALTER SEQUENCE tsk_vs_info_obj_id_seq RESTART WITH " + (biggestPK + 1));
792 inputStatement = sqliteConnection.createStatement();
793 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_files_derived");
795 while (inputResultSet.next()) {
797 long value = inputResultSet.getLong(1);
798 if (value > biggestPK) {
801 String sql =
"INSERT INTO tsk_files_derived (obj_id, derived_id, rederive) VALUES ("
803 + inputResultSet.getLong(2) +
","
805 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
809 }
catch (SQLException ex) {
810 if (ex.getErrorCode() != 0) {
811 throw new SQLException(ex);
815 numberingPK = postgreSQLConnection.createStatement();
816 numberingPK.execute(
"ALTER SEQUENCE tsk_files_derived_obj_id_seq RESTART WITH " + (biggestPK + 1));
820 inputStatement = sqliteConnection.createStatement();
821 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_files_derived_method");
823 while (inputResultSet.next()) {
825 long value = inputResultSet.getLong(1);
826 if (value > biggestPK) {
829 String sql =
"INSERT INTO tsk_files_derived_method (derived_id, tool_name, tool_version, other) VALUES ("
831 + inputResultSet.getString(2) +
"','"
832 + inputResultSet.getString(3) +
"',"
834 PreparedStatement pst = postgreSQLConnection.prepareStatement(sql);
838 }
catch (SQLException ex) {
839 if (ex.getErrorCode() != 0) {
840 throw new SQLException(ex);
844 numberingPK = postgreSQLConnection.createStatement();
845 numberingPK.execute(
"ALTER SEQUENCE tsk_files_derived_method_derived_id_seq RESTART WITH " + (biggestPK + 1));
849 inputStatement = sqliteConnection.createStatement();
850 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM content_tags");
852 while (inputResultSet.next()) {
853 outputStatement = postgreSQLConnection.createStatement();
855 long value = inputResultSet.getLong(1);
856 if (value > biggestPK) {
859 outputStatement.executeUpdate(
"INSERT INTO content_tags (tag_id, obj_id, tag_name_id, comment, begin_byte_offset, end_byte_offset) VALUES ("
861 + inputResultSet.getLong(2) +
","
862 + inputResultSet.getLong(3) +
",'"
863 + inputResultSet.getString(4) +
"',"
864 + inputResultSet.getLong(5) +
","
865 + inputResultSet.getLong(6) +
")");
867 }
catch (SQLException ex) {
868 if (ex.getErrorCode() != 0) {
869 throw new SQLException(ex);
873 numberingPK = postgreSQLConnection.createStatement();
874 numberingPK.execute(
"ALTER SEQUENCE content_tags_tag_id_seq RESTART WITH " + (biggestPK + 1));
878 inputStatement = sqliteConnection.createStatement();
879 inputResultSet = inputStatement.executeQuery(
"SELECT * FROM blackboard_artifact_tags");
881 while (inputResultSet.next()) {
882 outputStatement = postgreSQLConnection.createStatement();
884 long value = inputResultSet.getLong(1);
885 if (value > biggestPK) {
888 outputStatement.executeUpdate(
"INSERT INTO blackboard_artifact_tags (tag_id, artifact_id, tag_name_id, comment) VALUES ("
890 + inputResultSet.getLong(2) +
","
891 + inputResultSet.getLong(3) +
",'"
892 + inputResultSet.getString(4) +
"')");
894 }
catch (SQLException ex) {
895 if (ex.getErrorCode() != 0) {
896 throw new SQLException(ex);
900 numberingPK = postgreSQLConnection.createStatement();
901 numberingPK.execute(
"ALTER SEQUENCE blackboard_artifact_tags_tag_id_seq RESTART WITH " + (biggestPK + 1));
903 sqliteConnection.close();
904 postgreSQLConnection.close();
923 boolean unique =
false;
924 String sanitizedDbName = icd.getPostgreSQLDbName();
926 sanitizedDbName = sanitizedDbName.substring(0, MAX_DB_NAME_LENGTH);
929 if (postgreSQLConnection != null) {
930 while (unique ==
false) {
931 Statement st = postgreSQLConnection.createStatement();
932 ResultSet answer = st.executeQuery(
"SELECT datname FROM pg_catalog.pg_database WHERE LOWER(datname) LIKE LOWER('" + sanitizedDbName +
"%')");
934 if (!answer.next()) {
938 if (number == Integer.MAX_VALUE) {
940 throw new Exception(NbBundle.getMessage(
SingleUserCaseConverter.class,
"SingleUserCaseConverter.NonUniqueDatabaseName"));
942 sanitizedDbName =
"db_" + Integer.toString(number) +
"_" + icd.getPostgreSQLDbName();
946 sanitizedDbName = sanitizedDbName.substring(0, MAX_DB_NAME_LENGTH);
951 postgreSQLConnection.close();
957 icd.setPostgreSQLDbName(sanitizedDbName);
969 if (icd.getCopySourceImages()) {
971 File imageDestination =
new File(icd.getImageOutputFolder().toString());
974 if (imageSource.exists()) {
975 FileUtils.copyDirectory(imageSource, imageDestination);
978 throw new Exception(NbBundle.getMessage(
SingleUserCaseConverter.class,
"SingleUserCaseConverter.UnableToCopySourceImages"));
995 String input = icd.getImageInputFolder().toString();
996 String output = icd.getImageOutputFolder().toString();
1000 if (postgresqlConnection != null) {
1004 Statement updateStatement = postgresqlConnection.createStatement();
1005 updateStatement.executeUpdate(
"UPDATE reports SET path=CONCAT('" + hostName +
"/', path) WHERE path IS NOT NULL AND path != ''");
1008 updateStatement = postgresqlConnection.createStatement();
1009 updateStatement.executeUpdate(
"UPDATE tsk_files_path SET path=CONCAT('" + hostName +
"\\', path) WHERE path IS NOT NULL AND path != ''");
1011 String caseName = icd.getRawFolderName().toLowerCase();
1013 if (icd.getCopySourceImages()) {
1015 Statement inputStatement = postgresqlConnection.createStatement();
1016 ResultSet inputResultSet = inputStatement.executeQuery(
"SELECT * FROM tsk_image_names");
1018 while (inputResultSet.next()) {
1019 Path oldPath = Paths.get(inputResultSet.getString(2));
1021 for (
int x = 0; x < oldPath.getNameCount(); ++x) {
1022 if (oldPath.getName(x).toString().toLowerCase().equals(caseName)) {
1023 Path newPath = Paths.get(output, oldPath.subpath(x + 1, oldPath.getNameCount()).toString());
1024 updateStatement = postgresqlConnection.createStatement();
1025 updateStatement.executeUpdate(
"UPDATE tsk_image_names SET name='" + newPath.toString() +
"' WHERE obj_id = " + inputResultSet.getInt(1));
1031 postgresqlConnection.close();
1033 throw new Exception(NbBundle.getMessage(
SingleUserCaseConverter.class,
"SingleUserCaseConverter.CanNotOpenDatabase"));
1049 int value = rs.getInt(index);
1053 return Integer.toString(value);
1069 long value = rs.getLong(index);
1073 return Long.toString(value);
1088 private static void populateNullableString(PreparedStatement pst, ResultSet rs,
int rsIndex,
int psIndex)
throws SQLException {
1089 String nullableString = rs.getString(rsIndex);
1091 pst.setNull(psIndex, java.sql.Types.NULL);
1109 byte[] nullableBytes = rs.getBytes(rsIndex);
1111 pst.setNull(psIndex, java.sql.Types.NULL);
1113 pst.setBytes(psIndex, nullableBytes);
1129 double nullableNumeric = rs.getDouble(rsIndex);
1131 pst.setNull(psIndex, java.sql.Types.NULL);
1133 pst.setDouble(psIndex, nullableNumeric);
1161 return DriverManager.getConnection(
"jdbc:postgresql://"
1162 + icd.getDb().getHost() +
":"
1163 + icd.getDb().getPort() +
"/"
1165 icd.getDb().getUserName(),
1166 icd.getDb().getPassword());
1179 return DriverManager.getConnection(
"jdbc:sqlite:" + icd.getCaseInputFolder().resolve(AUTOPSY_DB_FILE).toString(),
"",
"");
static Connection getPostgreSQLConnection(ImportCaseData icd)
final Path caseInputFolder
final Path imageOutputFolder
static void populateNullableNumeric(PreparedStatement pst, ResultSet rs, int rsIndex, int psIndex)
static String getNullableInt(ResultSet rs, int index)
static final int MAX_DB_NAME_LENGTH
static void deconflictDatabaseName(ImportCaseData icd)
static Connection getSQLiteConnection(ImportCaseData icd)
final String rawFolderName
ImportCaseData(Path imageInput, Path caseInput, Path imageOutput, Path caseOutput, String oldCaseName, String newCaseName, String autFileName, String rawFolderName, boolean copySourceImages, boolean deleteCase)
Path getCaseOutputFolder()
static void importCase(ImportCaseData icd)
static final String POSTGRES_DEFAULT_DB_NAME
static CaseDbConnectionInfo getDatabaseConnectionInfo()
static final String TIMELINE_FILE
final CaseDbConnectionInfo db
static void copyImages(ImportCaseData icd)
static String escapeSingleQuotes(String text)
static final String DOTAUT
static final String MODULE_FOLDER
final Path imageInputFolder
final boolean copySourceImages
static void populateNullableString(PreparedStatement pst, ResultSet rs, int rsIndex, int psIndex)
static String getNullableLong(ResultSet rs, int index)
static void populateNullableByteArray(PreparedStatement pst, ResultSet rs, int rsIndex, int psIndex)
static final String AUTOPSY_DB_FILE
static final String TIMELINE_FOLDER
static void copyResults(ImportCaseData icd)
static String getLocalHostName()
static void importDb(ImportCaseData icd)
static SleuthkitCase newCase(String dbPath)
Path getCaseInputFolder()
final Path caseOutputFolder
static void fixPaths(ImportCaseData icd)
static File findInputFolder(ImportCaseData icd)
static Connection getPostgreSQLConnection(ImportCaseData icd, String dbName)