19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.text.MessageFormat;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.LinkedHashMap;
27 import java.util.List;
29 import java.util.logging.Level;
30 import java.util.stream.Collectors;
31 import javax.swing.Action;
32 import org.apache.commons.lang3.StringUtils;
33 import org.openide.nodes.Children;
34 import org.openide.nodes.Sheet;
35 import org.openide.util.Lookup;
36 import org.openide.util.NbBundle;
37 import org.openide.util.lookup.Lookups;
82 private final PropertyChangeListener
pcl =
new PropertyChangeListener() {
84 public void propertyChange(PropertyChangeEvent evt) {
85 String eventType = evt.getPropertyName();
88 if (event.getAddedTag().getArtifact().equals(artifact)) {
93 if (event.getDeletedTagInfo().getArtifactID() == artifact.
getArtifactID()) {
98 if (event.getAddedTag().getContent().equals(associated)) {
103 if (event.getDeletedTagInfo().getContentID()== associated.
getId()) {
107 if (evt.getNewValue() == null) {
127 this.associated = this.getLookup().lookup(
Content.class);
130 this.setIconBaseWithExtension(iconPath);
145 this.associated = this.getLookup().lookup(
Content.class);
158 "BlackboardArtifactNode.getAction.errorTitle=Error getting actions",
159 "BlackboardArtifactNode.getAction.resultErrorMessage=There was a problem getting actions for the selected result."
160 +
" The 'View Result in Timeline' action will not be available.",
161 "BlackboardArtifactNode.getAction.linkedFileMessage=There was a problem getting actions for the selected result. "
162 +
" The 'View File in Timeline' action will not be available."})
164 List<Action> actionsList =
new ArrayList<>();
165 actionsList.addAll(Arrays.asList(super.getActions(context)));
173 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting arttribute(s) from blackboard artifact{0}.", artifact.
getArtifactID()), ex);
174 MessageNotifyUtil.
Notify.
error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_resultErrorMessage());
184 LOGGER.log(Level.SEVERE, MessageFormat.format(
"Error getting linked file from blackboard artifact{0}.", artifact.
getArtifactID()), ex);
185 MessageNotifyUtil.
Notify.
error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_linkedFileMessage());
194 return actionsList.toArray(
new Action[actionsList.size()]);
203 String displayName =
"";
204 if (associated != null) {
205 displayName = associated.
getName();
211 if (artifact != null &&
218 if (associatedArtifact != null) {
232 Sheet s = super.createSheet();
233 Sheet.Set ss = s.get(Sheet.PROPERTIES);
235 ss = Sheet.createPropertiesSet();
238 final String NO_DESCR = NbBundle.getMessage(
BlackboardArtifactNode.class,
"BlackboardArtifactNode.noDesc.text");
240 Map<String, Object> map =
new LinkedHashMap<>();
244 NbBundle.getMessage(
BlackboardArtifactNode.class,
"BlackboardArtifactNode.createSheet.srcFile.displayName"),
246 this.getDisplayName()));
248 for (Map.Entry<String, Object> entry : map.entrySet()) {
256 if (customProperties != null) {
267 String actualMimeType =
"";
269 AbstractFile af = (AbstractFile) associated;
272 if (actualMimeType == null) {
282 NbBundle.getMessage(
BlackboardArtifactNode.class,
"BlackboardArtifactNode.createSheet.mimeType.displayName"),
287 if (Arrays.asList(SHOW_UNIQUE_PATH).contains(artifactTypeId)) {
288 String sourcePath =
"";
292 LOGGER.log(Level.WARNING,
"Failed to get unique path from: {0}", associated.
getName());
295 if (sourcePath.isEmpty() ==
false) {
298 NbBundle.getMessage(
BlackboardArtifactNode.class,
"BlackboardArtifactNode.createSheet.filePath.displayName"),
303 if (Arrays.asList(SHOW_FILE_METADATA).contains(artifactTypeId)) {
306 NbBundle.getMessage(
BlackboardArtifactNode.class,
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
310 NbBundle.getMessage(
BlackboardArtifactNode.class,
"ContentTagNode.createSheet.fileChangedTime.displayName"),
314 NbBundle.getMessage(
BlackboardArtifactNode.class,
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
318 NbBundle.getMessage(
BlackboardArtifactNode.class,
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
327 String dataSourceStr =
"";
330 if (dataSource != null) {
331 dataSourceStr = dataSource.
getName();
336 LOGGER.log(Level.WARNING,
"Failed to get image name from {0}", associated.
getName());
339 if (dataSourceStr.isEmpty() ==
false) {
342 NbBundle.getMessage(
BlackboardArtifactNode.class,
"BlackboardArtifactNode.createSheet.dataSrc.displayName"),
349 List<Tag> tags =
new ArrayList<>();
354 LOGGER.log(Level.SEVERE,
"Failed to get tags for artifact " + artifact.
getDisplayName(), ex);
357 NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(
", "))));
367 String parentName = associated.
getName();
370 while ((parent = parent.
getParent()) != null) {
374 LOGGER.log(Level.WARNING,
"Failed to get parent name from {0}", associated.
getName());
387 if (null == customProperties) {
389 customProperties =
new ArrayList<>();
391 customProperties.add(np);
401 @SuppressWarnings(
"deprecation")
405 final int attributeTypeID = attribute.getAttributeType().getTypeID();
423 String value = attribute.getDisplayString();
424 if (value.length() > 512) {
425 value = value.substring(0, 512);
427 map.put(attribute.getAttributeType().getDisplayName(), value);
429 map.put(attribute.getAttributeType().getDisplayName(), attribute.getDisplayString());
433 LOGGER.log(Level.SEVERE,
"Getting attributes failed", ex);
439 return v.
visit(
this);
450 List<Object> forLookup =
new ArrayList<>();
451 forLookup.add(artifact);
455 if (content != null) {
456 forLookup.add(content);
459 return Lookups.fixed(forLookup.toArray(
new Object[forLookup.size()]));
466 LOGGER.log(Level.WARNING,
"Getting file failed", ex);
468 throw new IllegalArgumentException(
480 return getClass().getName();
TSK_INTERESTING_ARTIFACT_HIT
void fillPropertyMap(Map< String, Object > map, BlackboardArtifact artifact)
static String getStringTime(long epochSeconds, TimeZone tzone)
static boolean hasSupportedTimeStamp(BlackboardArtifact artifact)
final PropertyChangeListener pcl
static void removePropertyChangeListener(PropertyChangeListener listener)
TSK_EXT_MISMATCH_DETECTED
Content getContentById(long id)
BlackboardArtifactNode(BlackboardArtifact artifact, String iconPath)
static Lookup createLookup(BlackboardArtifact artifact)
String getNameExtension()
static final Integer[] SHOW_FILE_METADATA
SleuthkitCase getSleuthkitCase()
BlackboardArtifact getBlackboardArtifact(long artifactID)
T visit(DataSourcesNode in)
Action[] getActions(boolean context)
static Content getAssociatedContent(BlackboardArtifact artifact)
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
TagsManager getTagsManager()
List< NodeProperty<?extends Object > > customProperties
static final Logger LOGGER
String getRootParentName()
final BlackboardArtifact artifact
SleuthkitCase getSleuthkitCase()
static void addPropertyChangeListener(PropertyChangeListener listener)
List< BlackboardAttribute > getAttributes()
BLACKBOARD_ARTIFACT_TAG_ADDED
static void error(String title, String message)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
void addNodeProperty(NodeProperty<?> np)
BlackboardArtifactNode(BlackboardArtifact artifact)
static final Integer[] SHOW_UNIQUE_PATH
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
BLACKBOARD_ARTIFACT_TAG_DELETED