19package org.sleuthkit.autopsy.timeline.explorernodes;
21import java.lang.reflect.InvocationTargetException;
22import java.text.MessageFormat;
23import java.util.ArrayList;
24import java.util.Collection;
25import java.util.Collections;
26import java.util.HashSet;
28import java.util.logging.Level;
29import javax.annotation.Nonnull;
30import javax.swing.Action;
31import org.joda.time.DateTime;
32import org.joda.time.DateTimeZone;
33import org.openide.nodes.Children;
34import org.openide.nodes.PropertySupport;
35import org.openide.nodes.Sheet;
36import org.openide.util.NbBundle;
37import org.openide.util.Utilities;
38import org.openide.util.lookup.Lookups;
39import org.sleuthkit.autopsy.actions.AddBlackboardArtifactTagAction;
40import org.sleuthkit.autopsy.actions.DeleteFileBlackboardArtifactTagAction;
41import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
42import org.sleuthkit.autopsy.coreutils.Logger;
43import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
44import org.sleuthkit.autopsy.datamodel.DataModelActionsFactory;
45import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
46import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
47import org.sleuthkit.autopsy.datamodel.NodeProperty;
48import org.sleuthkit.autopsy.timeline.EventsModel;
49import org.sleuthkit.autopsy.timeline.TimeLineController;
50import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
51import org.sleuthkit.autopsy.timeline.ui.EventTypeUtils;
52import org.sleuthkit.datamodel.AbstractFile;
53import org.sleuthkit.datamodel.BlackboardArtifact;
54import org.sleuthkit.datamodel.BlackboardAttribute;
55import org.sleuthkit.datamodel.Content;
56import org.sleuthkit.datamodel.SleuthkitCase;
57import org.sleuthkit.datamodel.TskCoreException;
58import org.sleuthkit.datamodel.TimelineEventType;
59import org.sleuthkit.datamodel.TimelineEvent;
60import org.sleuthkit.datamodel.TimelineLevelOfDetail;
69 private final TimelineEvent
event;
80 EventNode(@Nonnull TimelineEvent
event, @Nonnull Content file, @Nonnull BlackboardArtifact artifact) {
81 super(Children.LEAF, Lookups.fixed(
event, file, artifact));
83 TimelineEventType evenType =
event.getEventType();
93 EventNode(@Nonnull TimelineEvent event, @Nonnull Content file) {
94 super(Children.LEAF, Lookups.fixed(event, file));
96 TimelineEventType evenType =
event.getEventType();
102 "NodeProperty.displayName.icon=Icon",
103 "NodeProperty.displayName.description=Description",
104 "NodeProperty.displayName.eventType=Event Type",
105 "NodeProperty.displayName.known=Known",
106 "NodeProperty.displayName.dateTime=Date/Time"})
108 Sheet sheet = super.createSheet();
109 Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
110 if (properties ==
null) {
111 properties = Sheet.createPropertiesSet();
112 sheet.put(properties);
115 properties.put(
new NodeProperty<>(
"icon", Bundle.NodeProperty_displayName_icon(),
"icon",
true));
117 properties.put(
new NodeProperty<>(
"description", Bundle.NodeProperty_displayName_description(),
"description",
event.getDescription(TimelineLevelOfDetail.HIGH)));
118 properties.put(
new NodeProperty<>(
"eventType", Bundle.NodeProperty_displayName_eventType(),
"event type",
event.getEventType().getDisplayName()));
136 "EventNode.getAction.errorTitle=Error getting actions",
137 "EventNode.getAction.linkedFileMessage=There was a problem getting actions for the selected result. "
138 +
" The 'View File in Timeline' action will not be available."})
140 List<Action> actionsList =
new ArrayList<>();
141 Collections.addAll(actionsList, super.getActions(context));
146 final BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
147 final Content sourceFile = getLookup().lookup(Content.class);
148 if (artifact !=
null) {
151 AbstractFile linkedfile =
findLinked(artifact);
152 if (linkedfile !=
null) {
155 }
catch (TskCoreException ex) {
156 logger.log(Level.SEVERE, MessageFormat.format(
"Error getting linked file from blackboard artifact{0}.", artifact.getArtifactID()), ex);
161 if (sourceFile instanceof AbstractFile) {
168 actionsList.addAll(factoryActions);
169 if (factoryActions.isEmpty()) {
176 return actionsList.toArray(
new Action[actionsList.size()]);
188 private static AbstractFile
findLinked(BlackboardArtifact artifact)
throws TskCoreException {
189 BlackboardAttribute pathIDAttribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID));
190 if (pathIDAttribute !=
null) {
191 long contentID = pathIDAttribute.getValueLong();
192 if (contentID != -1) {
193 return artifact.getSleuthkitCase().getAbstractFileById(contentID);
206 throw new UnsupportedOperationException(
"Not supported yet.");
211 return getClass().getName();
218 final private class TimeProperty
extends PropertySupport.ReadWrite<String> {
227 TimeProperty(String name, String displayName, String shortDescription, String
value) {
228 super(name, String.class, displayName, shortDescription);
229 setValue(
"suppressCustomEditor", Boolean.TRUE);
234 }
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
235 logger.log(Level.SEVERE,
"Unexpected error setting date/time property on EventNode explorer node", ex);
242 public String
getValue() throws IllegalAccessException, InvocationTargetException {
247 public void setValue(String newValue)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
250 firePropertyChange(
"time", oldValue, newValue);
266 SleuthkitCase sleuthkitCase = eventsModel.getSleuthkitCase();
272 final TimelineEvent eventById = eventsModel.getEventById(eventID);
273 Content file = sleuthkitCase.getContentById(eventById.getContentObjID());
275 if (eventById.getArtifactID().isPresent()) {
276 BlackboardArtifact blackboardArtifact = sleuthkitCase.getBlackboardArtifact(eventById.getArtifactID().get());
277 return new EventNode(eventById, file, blackboardArtifact);
279 return new EventNode(eventById, file);
284 final Collection<BlackboardArtifact> selectedArtifactsList
285 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class));
286 return selectedArtifactsList.size() == 1;
static synchronized AddBlackboardArtifactTagAction getInstance()
static synchronized DeleteFileBlackboardArtifactTagAction getInstance()
synchronized static Logger getLogger(String name)
static void error(String title, String message)
static List< Action > getActions(File file, boolean isArtifactSource)
DisplayableItemNode(Children children)
static ReadOnlyObjectProperty< TimeZone > timeZoneProperty()
static DateTimeFormatter getZonedFormatter()
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
void setValue(String newValue)
Action[] getActions(boolean context)
final TimelineEvent event
String getDateTimeString()
static final Logger logger
static EventNode createEventNode(final Long eventID, EventsModel eventsModel)
static AbstractFile findLinked(BlackboardArtifact artifact)
static boolean isExactlyOneArtifactSelected()
static String getImagePath(TimelineEventType type)