Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
EventRootNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014-16 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.explorernodes;
20 
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.logging.Level;
24 import org.openide.nodes.AbstractNode;
25 import org.openide.nodes.ChildFactory;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Node;
28 import org.openide.util.NbBundle;
29 import org.openide.util.lookup.Lookups;
34 import org.sleuthkit.datamodel.TskCoreException;
35 
39 public class EventRootNode extends DisplayableItemNode {
40 
41  private static final long serialVersionUID = 1L;
42 
48  public static final int MAX_EVENTS_TO_DISPLAY = 5000;
49 
50  public EventRootNode(Collection<Long> fileIds, FilteredEventsModel filteredEvents) {
51  super(Children.create(new EventNodeChildFactory(fileIds, filteredEvents), true), Lookups.singleton(fileIds));
52  }
53 
54  @Override
55  public boolean isLeafTypeNode() {
56  return false;
57  }
58 
59  @Override
60  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
61  return null;
62  }
63 
64 
65  /*
66  * TODO (AUT-1849): Correct or remove peristent column reordering code
67  *
68  * Added to support this feature.
69  */
70 // @Override
71 // public String getItemType() {
72 // return "EventRoot";
73 // }
77  private static class EventNodeChildFactory extends ChildFactory<Long> {
78 
79  private static final Logger LOGGER = Logger.getLogger(EventNodeChildFactory.class.getName());
80 
84  private final Collection<Long> eventIDs;
85 
90 
91  EventNodeChildFactory(Collection<Long> fileIds, FilteredEventsModel filteredEvents) {
92  this.eventIDs = fileIds;
93  this.filteredEvents = filteredEvents;
94  }
95 
96  @Override
97  protected boolean createKeys(List<Long> toPopulate) {
102  if (eventIDs.size() < MAX_EVENTS_TO_DISPLAY) {
103  toPopulate.addAll(eventIDs);
104  } else {
105  toPopulate.add(-1L);
106  }
107  return true;
108  }
109 
110  @Override
111  protected Node createNodeForKey(Long eventID) {
112  if (eventID < 0) {
113  /*
114  * If the eventId is a the special value ( -1 ), return a node
115  * with a warning that their are too many evens
116  */
117  return new TooManyNode(eventIDs.size());
118  } else {
119  try {
120  return EventNode.createEventNode(eventID, filteredEvents);
121  } catch (IllegalStateException ex) {
122  //Since the case is closed, the user probably doesn't care about this, just log it as a precaution.
123  LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); // NON-NLS
124  return null;
125  } catch (TskCoreException ex) {
126  /*
127  * Just log it: There might be lots of these errors, and we
128  * don't want to flood the user with notifications. It will
129  * be obvious the UI is broken anyways
130  */
131  LOGGER.log(Level.SEVERE, "Failed to lookup Sleuthkit object backing a SingleEvent.", ex); // NON-NLS
132  return null;
133  }
134  }
135  }
136  }
137 
141  private static class TooManyNode extends AbstractNode {
142 
143  @NbBundle.Messages({
144  "# {0} - maximum number of events to display",
145  "# {1} - the number of events that is too many",
146  "EventRoodNode.tooManyNode.displayName=Too many events to display. Maximum = {0}. But there are {1} to display."})
147  TooManyNode(int size) {
148  super(Children.LEAF);
149  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/info-icon-16.png"); // NON-NLS
150  setDisplayName(Bundle.EventRoodNode_tooManyNode_displayName(MAX_EVENTS_TO_DISPLAY, size));
151  }
152  }
153 }
static EventNode createEventNode(final Long eventID, FilteredEventsModel eventsModel)
Definition: EventNode.java:222
EventRootNode(Collection< Long > fileIds, FilteredEventsModel filteredEvents)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.