23 package org.sleuthkit.autopsy.recentactivity;
26 import java.sql.ResultSet;
27 import java.sql.ResultSetMetaData;
28 import java.sql.SQLException;
30 import java.util.logging.Level;
32 import org.openide.util.NbBundle;
39 abstract class Extract {
41 protected Case currentCase = Case.getCurrentCase();
42 protected SleuthkitCase tskCase = currentCase.getSleuthkitCase();
43 private final Logger logger = Logger.getLogger(this.getClass().getName());
44 private final ArrayList<String> errorMessages =
new ArrayList<>();
45 String moduleName =
"";
46 boolean dataFound =
false;
51 void init() throws IngestModuleException {
54 abstract void process(
Content dataSource, IngestJobContext context);
65 List<String> getErrorMessages() {
74 protected void addErrorMessage(String message) {
75 errorMessages.add(message);
93 logger.log(Level.SEVERE,
"Error while trying to add an artifact", ex);
107 protected List<HashMap<String, Object>> dbConnect(String path, String query) {
109 List<HashMap<String, Object>> list;
110 String connectionString =
"jdbc:sqlite:" + path;
112 SQLiteDBConnect tempdbconnect =
new SQLiteDBConnect(
"org.sqlite.JDBC", connectionString);
113 temprs = tempdbconnect.executeQry(query);
114 list = this.resultSetToArrayList(temprs);
115 tempdbconnect.closeConnection();
116 }
catch (SQLException ex) {
117 logger.log(Level.SEVERE,
"Error while trying to read into a sqlite db." + connectionString, ex);
118 errorMessages.add(NbBundle.getMessage(
this.getClass(),
"Extract.dbConn.errMsg.failedToQueryDb", getName()));
119 return Collections.<HashMap<String,Object>>emptyList();
130 private List<HashMap<String, Object>> resultSetToArrayList(ResultSet rs)
throws SQLException {
131 ResultSetMetaData md = rs.getMetaData();
132 int columns = md.getColumnCount();
133 List<HashMap<String, Object>> list =
new ArrayList<>(50);
135 HashMap<String, Object> row =
new HashMap<>(columns);
136 for (
int i = 1; i <= columns; ++i) {
137 if (rs.getObject(i) == null) {
138 row.put(md.getColumnName(i),
"");
140 row.put(md.getColumnName(i), rs.getObject(i));
154 protected String getName() {
158 public boolean foundData() {
void addAttributes(Collection< BlackboardAttribute > attributes)
BlackboardArtifact newArtifact(int artifactTypeID)