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 == null) {
123 if (!parentPath.endsWith(File.separator)) {
124 parentPath += File.separator;
126 parentPath = parentPath.replace(
"\\",
"/");
127 parentPath = SleuthkitCase.escapeSingleQuotes(parentPath);
128 final String whereClause = String.format(
"lower(name) = '%s' AND lower(parent_path) = '%s' AND data_source_obj_id = %s", fileName, parentPath, dataSource.get().getId());
129 List<AbstractFile> potentialAbstractFiles = tskDb.findAllFilesWhere(whereClause);
131 if (potentialAbstractFiles.isEmpty()) {
132 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s.",
new Object[]{currentAttributeInstance.getFilePath()}));
133 }
else if (potentialAbstractFiles.size() > 1) {
134 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}));
141 }
catch (TskCoreException | NoCurrentCaseException ex) {
142 LOGGER.log(Level.SEVERE, String.format(
"Unable to find AbstractFile for record with filePath: %s. Node not created.",
new Object[]{currentAttributeInstance.getFilePath()}), ex);
151 List<DisplayableItemNode> attrInstNodeList =
new ArrayList<>(0);
155 attrInstNodeList.add(generatedInstNode);
156 }
catch (TskCoreException ex) {
157 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)