Autopsy  4.0
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;
37 import org.sleuthkit.datamodel.AbstractFile;
38 import org.sleuthkit.datamodel.BlackboardArtifact;
39 import org.sleuthkit.datamodel.TskCoreException;
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 
73  /*
74  * TODO (AUT-1849): Correct or remove peristent column reordering code
75  *
76  * Added to support this feature.
77  */
78 // @Override
79 // public String getItemType() {
80 // return "EventRoot";
81 // }
82 
88  private static class EventNodeChildFactory extends ChildFactory<Long> {
89 
90  private static final Logger LOGGER = Logger.getLogger(EventNodeChildFactory.class.getName());
91 
92  private final Collection<Long> eventIDs;
93 
95 
96  EventNodeChildFactory(Collection<Long> fileIds, FilteredEventsModel filteredEvents) {
97  this.eventIDs = fileIds;
98  this.filteredEvents = filteredEvents;
99  }
100 
101  @Override
102  protected boolean createKeys(List<Long> toPopulate) {
103  if (eventIDs.size() < MAX_EVENTS_TO_DISPLAY) {
104  toPopulate.addAll(eventIDs);
105  } else {
106  toPopulate.add(-1l);
107  }
108  return true;
109  }
110 
111  @Override
112  protected Node createNodeForKey(Long eventID) {
113  if (eventID >= 0) {
114  final TimeLineEvent eventById = filteredEvents.getEventById(eventID);
115  try {
116  AbstractFile file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(eventById.getFileID());
117  if (file != null) {
118  if (eventById.getType().getSuperType() == BaseTypes.FILE_SYSTEM) {
119  return new EventNode(eventById, file);
120  } else {
121  BlackboardArtifact blackboardArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(eventById.getArtifactID());
122 
123  return new EventNode(eventById, file, blackboardArtifact);
124  }
125  } else {
126  LOGGER.log(Level.WARNING, "Failed to lookup sleuthkit object backing TimeLineEvent."); // NON-NLS
127  return null;
128  }
129 
130  } catch (TskCoreException tskCoreException) {
131  LOGGER.log(Level.WARNING, "Failed to lookup sleuthkit object backing TimeLineEvent.", tskCoreException); // NON-NLS
132  return null;
133  }
134  } else {
135  return new TooManyNode(eventIDs.size());
136  }
137  }
138  }
139 
140  private static class TooManyNode extends AbstractNode {
141 
142  public TooManyNode(int size) {
143  super(Children.LEAF);
144  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/info-icon-16.png"); // NON-NLS
145  setDisplayName(
146  NbBundle.getMessage(this.getClass(),
147  "EventRoodNode.tooManyNode.displayName",
149  size));
150  }
151  }
152 }
EventRootNode(String NAME, Collection< Long > fileIds, FilteredEventsModel filteredEvents)
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.