From 09f917f21f673595ffb895e1bdd8d2987aefb44b Mon Sep 17 00:00:00 2001 From: Andrew Ziehl Date: Tue, 26 Jun 2018 14:53:19 -0700 Subject: [PATCH] Add class to gather query results for the CommonFilesSearchPanel once wired up. --- .../EamDbAttributeInstanceValuesCallback.java | 40 --------- .../EamDbAttributeInstancesAlgorithm.java | 81 +++++++++++++++++++ 2 files changed, 81 insertions(+), 40 deletions(-) delete mode 100644 Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstanceValuesCallback.java create mode 100644 Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstancesAlgorithm.java diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstanceValuesCallback.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstanceValuesCallback.java deleted file mode 100644 index ab258695c6..0000000000 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstanceValuesCallback.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.sleuthkit.autopsy.commonfilesearch; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.openide.util.Exceptions; -import org.sleuthkit.autopsy.centralrepository.datamodel.InstanceTableCallback; - -/** - * - * @author Andrrew - */ -public class EamDbAttributeInstanceValuesCallback implements InstanceTableCallback { - - List correlationValues = new ArrayList<>(); - - @Override - public void process(ResultSet resultSet) { - try { - while(resultSet.next()){ - correlationValues.add(InstanceTableCallback.getValue(resultSet)); - } - } catch (SQLException ex) { - Exceptions.printStackTrace(ex); - } - } - - public List getCorrelationValues() { - return Collections.unmodifiableList(correlationValues); - } - - - } \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstancesAlgorithm.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstancesAlgorithm.java new file mode 100644 index 0000000000..497c9981ff --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/EamDbAttributeInstancesAlgorithm.java @@ -0,0 +1,81 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.commonfilesearch; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.logging.Level; +import org.openide.util.Exceptions; +import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute; +import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; +import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; +import org.sleuthkit.autopsy.centralrepository.datamodel.InstanceTableCallback; +import org.sleuthkit.autopsy.coreutils.Logger; + +/** + * Used to process and return CorrelationCase md5s from the EamDB for CommonFilesSearch. + */ +class EamDbAttributeInstancesAlgorithm { + + private static final Logger logger = Logger.getLogger(CommonFilesPanel.class.getName()); + + List getCorrelationCaseAttributeValues(Case currentCase) { + List intercaseCommonValues = new ArrayList<>(); + try { + EamDbAttributeInstancesCallback instancetableCallback = new EamDbAttributeInstancesCallback(); + EamDb DbManager = EamDb.getInstance(); + CorrelationAttribute.Type fileType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); + DbManager.processCaseInstancesTable(fileType, DbManager.getCase(currentCase), instancetableCallback); + + intercaseCommonValues = instancetableCallback.getCorrelationValues(); + } catch (EamDbException ex) { + logger.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); + } + return intercaseCommonValues; + } + + /** + * Callback to use with processCaseInstancesTable which generates a list of + * md5s for common files search + */ + private class EamDbAttributeInstancesCallback implements InstanceTableCallback { + + List correlationValues = new ArrayList<>(); + + @Override + public void process(ResultSet resultSet) { + try { + while (resultSet.next()) { + correlationValues.add(InstanceTableCallback.getValue(resultSet)); + } + } catch (SQLException ex) { + Exceptions.printStackTrace(ex); + } + } + + public List getCorrelationValues() { + return Collections.unmodifiableList(correlationValues); + } + + } +}