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);
 
   96             this.indexArtifact(bbart);
 
   99             logger.log(Level.SEVERE, 
"Error while trying to add an artifact", ex); 
 
  109     @Messages({
"Extract.indexError.message=Failed to index artifact for keyword search."})
 
  111         Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
 
  114             blackboard.indexArtifact(bbart);
 
  115         } 
catch (Blackboard.BlackboardException ex) {
 
  116             logger.log(Level.SEVERE, 
"Unable to index blackboard artifact " + bbart.
getDisplayName(), ex); 
 
  117             MessageNotifyUtil.Notify.error(Bundle.Extract_indexError_message(), bbart.
getDisplayName());
 
  132     protected List<HashMap<String, Object>> dbConnect(String path, String query) {
 
  134         List<HashMap<String, Object>> list;
 
  135         String connectionString = 
"jdbc:sqlite:" + path; 
 
  137             SQLiteDBConnect tempdbconnect = 
new SQLiteDBConnect(
"org.sqlite.JDBC", connectionString); 
 
  138             temprs = tempdbconnect.executeQry(query);
 
  139             list = this.resultSetToArrayList(temprs);
 
  140             tempdbconnect.closeConnection();
 
  141         } 
catch (SQLException ex) {
 
  142             logger.log(Level.SEVERE, 
"Error while trying to read into a sqlite db." + connectionString, ex); 
 
  143             errorMessages.add(NbBundle.getMessage(
this.getClass(), 
"Extract.dbConn.errMsg.failedToQueryDb", getName()));
 
  144             return Collections.<HashMap<String, Object>>emptyList();
 
  156     private List<HashMap<String, Object>> resultSetToArrayList(ResultSet rs) 
throws SQLException {
 
  157         ResultSetMetaData md = rs.getMetaData();
 
  158         int columns = md.getColumnCount();
 
  159         List<HashMap<String, Object>> list = 
new ArrayList<>(50);
 
  161             HashMap<String, Object> row = 
new HashMap<>(columns);
 
  162             for (
int i = 1; i <= columns; ++i) {
 
  163                 if (rs.getObject(i) == null) {
 
  164                     row.put(md.getColumnName(i), 
"");
 
  166                     row.put(md.getColumnName(i), rs.getObject(i));
 
  180     protected String getName() {
 
  184     public boolean foundData() {
 
void addAttributes(Collection< BlackboardAttribute > attributes)
 
BlackboardArtifact newArtifact(int artifactTypeID)