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));
109 File fileFromPath =
new File(currentFullPath);
110 String fileName = fileFromPath.getName();
111 fileName = SleuthkitCase.escapeSingleQuotes(fileName);
114 String parentPath = fileFromPath.getParent();
115 if (!parentPath.endsWith(File.separator)) {
116 parentPath += File.separator;
118 parentPath = parentPath.replace(
"\\",
"/");
119 parentPath = SleuthkitCase.escapeSingleQuotes(parentPath);
120 final String whereClause = String.format(
"lower(name) = '%s' AND lower(parent_path) = '%s' AND data_source_obj_id = %s", fileName, parentPath, dataSource.get().getId());
121 List<AbstractFile> potentialAbstractFiles = tskDb.findAllFilesWhere(whereClause);
123 if (potentialAbstractFiles.isEmpty()) {
124 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s.",
new Object[]{currentAttributeInstance.getFilePath()}));
125 }
else if (potentialAbstractFiles.size() > 1) {
126 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}));
133 }
catch (TskCoreException | NoCurrentCaseException ex) {
134 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s. Node not created.",
new Object[]{currentAttributeInstance.getFilePath()}), ex);
143 List<DisplayableItemNode> attrInstNodeList =
new ArrayList<>(0);
147 attrInstNodeList.add(generatedInstNode);
148 }
catch (TskCoreException ex) {
149 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)