20 package org.sleuthkit.autopsy.commonfilesearch;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
27 import java.util.Optional;
28 import java.util.logging.Level;
53 this.crFileId = attrInstId;
63 this.currentAttribute = attribute;
67 AbstractFile getAbstractFile() {
70 if (this.currentAttribute != null) {
72 final CorrelationAttributeInstance currentAttributeInstance = this.
currentAttribute;
75 String currentFullPath = currentAttributeInstance.
getFilePath();
76 currentCase = Case.getCurrentCaseThrows();
79 if (currentCase.getName().equals(currentAttributeInstance.getCorrelationCase().getCaseUUID())) {
81 SleuthkitCase tskDb = currentCase.getSleuthkitCase();
84 Optional<DataSource>
dataSource = tskDb.getDataSources().stream()
87 if (! dataSource.isPresent()) {
92 File fileFromPath =
new File(currentFullPath);
93 String fileName = fileFromPath.getName();
96 String parentPath = fileFromPath.getParent();
97 if (! parentPath.endsWith(File.separator)) {
98 parentPath = parentPath + File.separator;
100 parentPath = parentPath.replace(
"\\",
"/");
102 final String whereClause = String.format(
"lower(name) = '%s' AND md5 = '%s' AND lower(parent_path) = '%s' AND data_source_obj_id = %s", fileName, currentAttribute.
getCorrelationValue(), parentPath, dataSource.get().getId());
103 List<AbstractFile> potentialAbstractFiles = tskDb.findAllFilesWhere(whereClause);
105 if (potentialAbstractFiles.isEmpty()) {
107 }
else if (potentialAbstractFiles.size() > 1) {
108 LOGGER.log(Level.WARNING, String.format(
"Unable to find an exact match for AbstractFile for record with filePath: %s. May have returned the wrong file.",
new Object[]{currentFullPath}));
109 return potentialAbstractFiles.get(0);
111 return potentialAbstractFiles.get(0);
116 }
catch (TskCoreException | NoCurrentCaseException ex) {
117 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s. Node not created.",
new Object[]{currentAttributeInstance.getFilePath()}), ex);
129 InterCaseSearchResultsProcessor eamDbAttrInst =
new InterCaseSearchResultsProcessor(
correlationType);
131 List<DisplayableItemNode> attrInstNodeList =
new ArrayList<>(0);
135 this.setCurrentAttributeInst(corrAttr);
137 AbstractFile abstractFileForAttributeInstance = this.getAbstractFile();
139 attrInstNodeList.add(generatedInstNode);
141 }
catch (TskCoreException ex) {
142 LOGGER.log(Level.SEVERE, String.format(
"Unable to get DataSource for record with md5: %s. Node not created.",
new Object[]{corrAttr.getCorrelationValue()}), ex);
CorrelationAttributeInstance currentAttribute
DisplayableItemNode[] generateNodes()
final CorrelationAttributeInstance.Type correlationType
String getCorrelationValue()
CorrelationAttributeInstance.Type getCorrelationAttributeInstanceType()
static final Logger LOGGER
CorrelationDataSource getCorrelationDataSource()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)