20 package org.sleuthkit.autopsy.commonpropertiessearch;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Optional;
26 import java.util.logging.Level;
52 this.crFileId = attrInstId;
63 this.currentAttribute = attribute;
67 AbstractFile getAbstractFile() {
73 if (this.currentAttribute != null) {
75 final CorrelationAttributeInstance currentAttributeInstance = this.
currentAttribute;
78 String currentFullPath = currentAttributeInstance.
getFilePath();
79 currentCase = Case.getCurrentCaseThrows();
82 if (currentCase.getName().equals(currentAttributeInstance.getCorrelationCase().getCaseUUID())) {
83 SleuthkitCase tskDb = currentCase.getSleuthkitCase();
86 Optional<DataSource>
dataSource = tskDb.getDataSources().stream()
89 if (!dataSource.isPresent()) {
97 if (fileId != null && fileId != 0) {
98 AbstractFile file = tskDb.getAbstractFileById(fileId);
100 LOGGER.log(Level.WARNING, String.format(
"Failed to find file with id %s in current case. Will attempt to find file based on path.", fileId));
108 if (currentFullPath == null || currentFullPath.isEmpty()) {
114 File fileFromPath =
new File(currentFullPath);
115 String fileName = fileFromPath.getName();
116 fileName = SleuthkitCase.escapeSingleQuotes(fileName);
119 String parentPath = fileFromPath.getParent();
120 if (!parentPath.endsWith(File.separator)) {
121 parentPath += File.separator;
123 parentPath = parentPath.replace(
"\\",
"/");
124 parentPath = SleuthkitCase.escapeSingleQuotes(parentPath);
125 final String whereClause = String.format(
"lower(name) = '%s' AND lower(parent_path) = '%s' AND data_source_obj_id = %s", fileName, parentPath, dataSource.get().getId());
126 List<AbstractFile> potentialAbstractFiles = tskDb.findAllFilesWhere(whereClause);
128 if (potentialAbstractFiles.isEmpty()) {
129 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s.",
new Object[]{currentAttributeInstance.getFilePath()}));
130 }
else if (potentialAbstractFiles.size() > 1) {
131 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}));
138 }
catch (TskCoreException | NoCurrentCaseException ex) {
139 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s. Node not created.",
new Object[]{currentAttributeInstance.getFilePath()}), ex);
148 List<DisplayableItemNode> attrInstNodeList =
new ArrayList<>(0);
152 attrInstNodeList.add(generatedInstNode);
153 }
catch (TskCoreException ex) {
154 LOGGER.log(Level.SEVERE, String.format(
"Unable to get DataSource for record with md5: %s. Node not created.",
new Object[]{currentAttribute.getCorrelationValue()}), ex);
CorrelationAttributeInstance.Type getCorrelationAttributeInstanceType()
CorrelationAttributeInstance currentAttribute
AbstractFile abstractFile
final CorrelationAttributeInstance.Type correlationType
static final Logger LOGGER
CorrelationDataSource getCorrelationDataSource()
DisplayableItemNode[] generateNodes()
Long getDataSourceObjectID()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)