Autopsy  3.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 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;
40 
44 public class EventRootNode extends DisplayableItemNode {
45 
46  public static final int MAX_EVENTS_TO_DISPLAY = 5000;
47 
48  private final int childCount;
49 
50  public EventRootNode(String NAME, Collection<Long> fileIds, FilteredEventsModel filteredEvents) {
51  super(Children.create(new EventNodeChildFactory(fileIds, filteredEvents), true), Lookups.singleton(fileIds));
52 
53  super.setName(NAME);
54  super.setDisplayName(NAME);
55 
56  childCount = fileIds.size();
57  }
58 
59  @Override
60  public boolean isLeafTypeNode() {
61  return false;
62  }
63 
64  @Override
65  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
66  return null;
67  }
68 
69  public int getChildCount() {
70  return childCount;
71  }
72 
76  private static class EventNodeChildFactory extends ChildFactory<Long> {
77 
78  private static final Logger LOGGER = Logger.getLogger(EventNodeChildFactory.class.getName());
79 
80  private final Collection<Long> eventIDs;
81 
83 
84  EventNodeChildFactory(Collection<Long> fileIds, FilteredEventsModel filteredEvents) {
85  this.eventIDs = fileIds;
86  this.filteredEvents = filteredEvents;
87  }
88 
89  @Override
90  protected boolean createKeys(List<Long> toPopulate) {
91  if (eventIDs.size() < MAX_EVENTS_TO_DISPLAY) {
92  toPopulate.addAll(eventIDs);
93  } else {
94  toPopulate.add(-1l);
95  }
96  return true;
97  }
98 
99  @Override
100  protected Node createNodeForKey(Long eventID) {
101  if (eventID >= 0) {
102  final TimeLineEvent eventById = filteredEvents.getEventById(eventID);
103  try {
105  if(file != null){
106  if (eventById.getType().getSuperType() == BaseTypes.FILE_SYSTEM) {
107  return new EventNode(eventById, file);
108  } else {
110 
111  return new EventNode(eventById, file, blackboardArtifact);
112  }
113  } else {
114  LOGGER.log(Level.WARNING, "Failed to lookup sleuthkit object backing TimeLineEvent."); // NON-NLS
115  return null;
116  }
117 
118  } catch (TskCoreException tskCoreException) {
119  LOGGER.log(Level.WARNING, "Failed to lookup sleuthkit object backing TimeLineEvent.", tskCoreException); // NON-NLS
120  return null;
121  }
122  } else {
123  return new TooManyNode(eventIDs.size());
124  }
125  }
126  }
127 
128  private static class TooManyNode extends AbstractNode {
129 
130  public TooManyNode(int size) {
131  super(Children.LEAF);
132  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/info-icon-16.png"); // NON-NLS
133  setDisplayName(
134  NbBundle.getMessage(this.getClass(),
135  "EventRoodNode.tooManyNode.displayName",
137  size));
138  }
139  }
140 }
BlackboardArtifact getBlackboardArtifact(long artifactID)
AbstractFile getAbstractFileById(long id)
EventRootNode(String NAME, Collection< Long > fileIds, FilteredEventsModel filteredEvents)
static Logger getLogger(String name)
Definition: Logger.java:131

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