mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
Formatted file, & minor cleanup
This commit is contained in:
parent
30793eb51f
commit
1f44f08783
@ -45,7 +45,7 @@ public class FileViewer extends javax.swing.JPanel implements DataContentViewer
|
|||||||
|
|
||||||
// TBD: This hardcoded list of viewers should be replaced with a dynamic lookup
|
// TBD: This hardcoded list of viewers should be replaced with a dynamic lookup
|
||||||
private static final FileTypeViewer[] KNOWN_VIEWERS = new FileTypeViewer[]{
|
private static final FileTypeViewer[] KNOWN_VIEWERS = new FileTypeViewer[]{
|
||||||
new JPEGViewerDummy(), // this if for testing only
|
// new JPEGViewerDummy(), // this if for testing only
|
||||||
new SQLiteViewer()
|
new SQLiteViewer()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
* Autopsy Forensic Browser
|
||||||
* To change this template file, choose Tools | Templates
|
*
|
||||||
* and open the template in the editor.
|
* Copyright 2018 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.contentviewers;
|
package org.sleuthkit.autopsy.contentviewers;
|
||||||
|
|
||||||
@ -22,12 +35,10 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamOrganization;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
|
|
||||||
|
|
||||||
public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
||||||
|
|
||||||
public static final String[] SUPPORTED_MIMETYPES = new String[]{"application/x-sqlite3"};
|
public static final String[] SUPPORTED_MIMETYPES = new String[]{"application/x-sqlite3"};
|
||||||
@ -241,12 +252,10 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
|||||||
protected Boolean doInBackground() throws Exception {
|
protected Boolean doInBackground() throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Copy the file to temp folder
|
||||||
tmpDBPathName = Case.getCurrentCase().getTempDirectory() + File.separator + sqliteFile.getName() + "-" + sqliteFile.getId();
|
tmpDBPathName = Case.getCurrentCase().getTempDirectory() + File.separator + sqliteFile.getName() + "-" + sqliteFile.getId();
|
||||||
tmpDBFile = new File(tmpDBPathName);
|
tmpDBFile = new File(tmpDBPathName);
|
||||||
|
|
||||||
// Copy the file to temp folder
|
|
||||||
ContentUtils.writeToFile(sqliteFile, tmpDBFile);
|
ContentUtils.writeToFile(sqliteFile, tmpDBFile);
|
||||||
System.out.println("RAMAN: SQLite file copied to: " + tmpDBPathName);
|
|
||||||
|
|
||||||
// Open copy using JDBC
|
// Open copy using JDBC
|
||||||
Class.forName("org.sqlite.JDBC"); //NON-NLS //load JDBC driver
|
Class.forName("org.sqlite.JDBC"); //NON-NLS //load JDBC driver
|
||||||
@ -273,8 +282,7 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
|||||||
dbTablesMap.keySet().forEach((tableName) -> {
|
dbTablesMap.keySet().forEach((tableName) -> {
|
||||||
tablesDropdownList.addItem(tableName);
|
tablesDropdownList.addItem(tableName);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Populate error message
|
// Populate error message
|
||||||
tablesDropdownList.addItem("No tables found");
|
tablesDropdownList.addItem("No tables found");
|
||||||
tablesDropdownList.setEnabled(false);
|
tablesDropdownList.setEnabled(false);
|
||||||
@ -314,8 +322,8 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
|||||||
rs2 = statement2.executeQuery(query);
|
rs2 = statement2.executeQuery(query);
|
||||||
while (rs2.next()) {
|
while (rs2.next()) {
|
||||||
|
|
||||||
System.out.println("RAMAN: Col Name = " + rs2.getString("name") );
|
// System.out.println("RAMAN: Col Name = " + rs2.getString("name"));
|
||||||
System.out.println("RAMAN: Col Type = " + rs2.getString("type") );
|
// System.out.println("RAMAN: Col Type = " + rs2.getString("type"));
|
||||||
|
|
||||||
// RAMAN TBD: parse and save the table schema
|
// RAMAN TBD: parse and save the table schema
|
||||||
}
|
}
|
||||||
@ -330,10 +338,8 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void readTable(String tableName) {
|
private void readTable(String tableName) {
|
||||||
|
|
||||||
System.out.println("RAMAN: selected table = " + tableName);
|
|
||||||
|
|
||||||
// TBD: need to handle cancelling if one is already in progress
|
// TBD: need to handle cancelling if one is already in progress
|
||||||
|
|
||||||
new SwingWorker<Integer, Void>() {
|
new SwingWorker<Integer, Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Integer doInBackground() throws Exception {
|
protected Integer doInBackground() throws Exception {
|
||||||
@ -343,11 +349,11 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
|
|||||||
ResultSet resultSet = statement.executeQuery(
|
ResultSet resultSet = statement.executeQuery(
|
||||||
"SELECT COUNT(*) as count FROM " + tableName); //NON-NLS
|
"SELECT COUNT(*) as count FROM " + tableName); //NON-NLS
|
||||||
|
|
||||||
System.out.println("Row count = " + resultSet.getInt("count") );
|
// TBD: read the rows here and popluate the ExplorerManager.
|
||||||
// Read all table names and schema
|
|
||||||
return resultSet.getInt("count");
|
return resultSet.getInt("count");
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Failed to Open DB.", ex); //NON-NLS
|
LOGGER.log(Level.SEVERE, "Failed to get data for table.", ex); //NON-NLS
|
||||||
}
|
}
|
||||||
//NON-NLS
|
//NON-NLS
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user