23 package org.sleuthkit.autopsy.recentactivity;
 
   25 import java.sql.ResultSet;
 
   26 import java.sql.ResultSetMetaData;
 
   27 import java.sql.SQLException;
 
   29 import java.util.logging.Level;
 
   30 import org.openide.util.NbBundle;
 
   31 import org.openide.util.NbBundle.Messages;
 
   41 abstract class Extract {
 
   43     protected Case currentCase = Case.getCurrentCase();
 
   44     protected SleuthkitCase tskCase = currentCase.getSleuthkitCase();
 
   45     private final Logger logger = Logger.getLogger(this.getClass().getName());
 
   46     private final ArrayList<String> errorMessages = 
new ArrayList<>();
 
   47     String moduleName = 
"";
 
   48     boolean dataFound = 
false;
 
   53     void init() throws IngestModuleException {
 
   56     abstract void process(Content dataSource, IngestJobContext context);
 
   66     List<String> getErrorMessages() {
 
   75     protected void addErrorMessage(String message) {
 
   76         errorMessages.add(message);
 
   90     protected void addArtifact(BlackboardArtifact.ARTIFACT_TYPE type, AbstractFile content, Collection<BlackboardAttribute> bbattributes) {
 
   92             BlackboardArtifact bbart = content.newArtifact(type);
 
   93             bbart.addAttributes(bbattributes);
 
   95             this.indexArtifact(bbart);
 
   96         } 
catch (TskException ex) {
 
   97             logger.log(Level.SEVERE, 
"Error while trying to add an artifact", ex); 
 
  106     @Messages({
"Extract.indexError.message=Failed to index artifact for keyword search."})
 
  107     void indexArtifact(BlackboardArtifact bbart) {
 
  108         Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
 
  111             blackboard.indexArtifact(bbart);
 
  112         } 
catch (Blackboard.BlackboardException ex) {
 
  113             logger.log(Level.SEVERE, 
"Unable to index blackboard artifact " + bbart.getDisplayName(), ex); 
 
  114             MessageNotifyUtil.Notify.error(Bundle.Extract_indexError_message(), bbart.getDisplayName());
 
  129     protected List<HashMap<String, Object>> dbConnect(String path, String query) {
 
  131         List<HashMap<String, Object>> list;
 
  132         String connectionString = 
"jdbc:sqlite:" + path; 
 
  134             SQLiteDBConnect tempdbconnect = 
new SQLiteDBConnect(
"org.sqlite.JDBC", connectionString); 
 
  135             temprs = tempdbconnect.executeQry(query);
 
  136             list = this.resultSetToArrayList(temprs);
 
  137             tempdbconnect.closeConnection();
 
  138         } 
catch (SQLException ex) {
 
  139             logger.log(Level.SEVERE, 
"Error while trying to read into a sqlite db." + connectionString, ex); 
 
  140             errorMessages.add(NbBundle.getMessage(
this.getClass(), 
"Extract.dbConn.errMsg.failedToQueryDb", getName()));
 
  141             return Collections.<HashMap<String, Object>>emptyList();
 
  153     private List<HashMap<String, Object>> resultSetToArrayList(ResultSet rs) 
throws SQLException {
 
  154         ResultSetMetaData md = rs.getMetaData();
 
  155         int columns = md.getColumnCount();
 
  156         List<HashMap<String, Object>> list = 
new ArrayList<>(50);
 
  158             HashMap<String, Object> row = 
new HashMap<>(columns);
 
  159             for (
int i = 1; i <= columns; ++i) {
 
  160                 if (rs.getObject(i) == null) {
 
  161                     row.put(md.getColumnName(i), 
"");
 
  163                     row.put(md.getColumnName(i), rs.getObject(i));
 
  177     protected String getName() {
 
  181     public boolean foundData() {