19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.Comparator;
26 import java.util.EnumSet;
27 import java.util.HashMap;
28 import java.util.List;
30 import java.util.logging.Level;
31 import org.openide.nodes.ChildFactory;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34 import org.openide.nodes.Sheet;
35 import org.openide.util.NbBundle;
36 import org.openide.util.lookup.Lookups;
45 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ACCOUNT;
46 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
47 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_TL_EVENT;
48 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_DATA_SOURCE_USAGE;
49 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
50 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO;
51 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT;
52 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT;
53 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT;
54 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT;
55 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_DOWNLOAD_SOURCE;
66 public static final String
NAME = NbBundle.getMessage(
RootNode.class,
"ExtractedContentNode.name.text");
88 this.filteringDSObjId = objId;
89 this.blackboard = skCase.getBlackboard();
94 return visitor.
visit(
this);
104 super(Children.create(
new TypeFactory(),
true), Lookups.singleton(NAME));
106 super.setDisplayName(NAME);
107 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/extracted_content.png");
117 return visitor.
visit(
this);
122 Sheet sheet = super.createSheet();
123 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
124 if (sheetSet == null) {
125 sheetSet = Sheet.createPropertiesSet();
129 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ExtractedContentNode.createSheet.name.name"),
130 NbBundle.getMessage(
this.getClass(),
"ExtractedContentNode.createSheet.name.displayName"),
131 NbBundle.getMessage(
this.getClass(),
"ExtractedContentNode.createSheet.name.desc"),
138 return getClass().getName();
147 private class TypeFactory extends ChildFactory.Detachable<BlackboardArtifact.Type> implements RefreshThrottler.Refresher {
149 private final ArrayList<BlackboardArtifact.Type>
doNotShow =
new ArrayList<>();
160 @SuppressWarnings(
"deprecation")
165 doNotShow.add(
new BlackboardArtifact.Type(TSK_GEN_INFO));
166 doNotShow.add(
new BlackboardArtifact.Type(TSK_EMAIL_MSG));
167 doNotShow.add(
new BlackboardArtifact.Type(TSK_HASHSET_HIT));
168 doNotShow.add(
new BlackboardArtifact.Type(TSK_KEYWORD_HIT));
169 doNotShow.add(
new BlackboardArtifact.Type(TSK_INTERESTING_FILE_HIT));
170 doNotShow.add(
new BlackboardArtifact.Type(TSK_INTERESTING_ARTIFACT_HIT));
171 doNotShow.add(
new BlackboardArtifact.Type(TSK_ACCOUNT));
172 doNotShow.add(
new BlackboardArtifact.Type(TSK_DATA_SOURCE_USAGE));
173 doNotShow.add(
new BlackboardArtifact.Type(TSK_DOWNLOAD_SOURCE));
174 doNotShow.add(
new BlackboardArtifact.Type(TSK_TL_EVENT));
177 doNotShow.add(
new BlackboardArtifact.Type(TSK_ASSOCIATED_OBJECT));
180 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
181 String eventType = evt.getPropertyName();
184 if (evt.getNewValue() == null) {
208 refreshThrottler.registerForIngestModuleEvents();
215 refreshThrottler.unregisterEventListener();
218 typeNodeList.clear();
222 protected boolean createKeys(List<BlackboardArtifact.Type> list) {
223 if (skCase != null) {
225 List<BlackboardArtifact.Type> types = (filteringDSObjId > 0)
226 ? blackboard.getArtifactTypesInUse(filteringDSObjId)
227 : skCase.getArtifactTypesInUse();
230 Collections.sort(types,
231 new Comparator<BlackboardArtifact.Type>() {
233 public int compare(BlackboardArtifact.Type a, BlackboardArtifact.Type b) {
234 return a.getDisplayName().compareTo(b.getDisplayName());
241 for (BlackboardArtifact.Type art : types) {
242 TypeNode node = typeNodeList.get(art);
244 node.updateDisplayName();
247 }
catch (TskCoreException ex) {
248 Logger.
getLogger(
TypeFactory.class.getName()).log(Level.SEVERE,
"Error getting list of artifacts in use: " + ex.getLocalizedMessage());
257 typeNodeList.put(key, node);
268 String eventType = evt.getPropertyName();
283 if (null != event && !(this.
doNotShow.contains(event.getBlackboardArtifactType()))) {
304 private final BlackboardArtifact.Type
type;
309 super.setName(
type.getTypeName());
312 setIconBaseWithExtension(iconPath != null && iconPath.charAt(0) ==
'/' ? iconPath.substring(1) : iconPath);
316 final void updateDisplayName() {
317 if (skCase == null) {
325 this.childCount = (filteringDSObjId > 0)
327 : skCase.getBlackboardArtifactsTypeCount(
type.getTypeID());
328 }
catch (TskCoreException ex) {
329 Logger.getLogger(TypeNode.class.getName())
330 .log(Level.WARNING,
"Error getting child count", ex);
332 super.setDisplayName(
type.
getDisplayName() +
" \u200E(\u200E" + childCount +
")\u200E");
337 Sheet sheet = super.createSheet();
338 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
339 if (sheetSet == null) {
340 sheetSet = Sheet.createPropertiesSet();
344 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.artType.name"),
345 NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.artType.displayName"),
346 NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.artType.desc"),
349 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.childCnt.name"),
350 NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.childCnt.displayName"),
351 NbBundle.getMessage(
this.getClass(),
"ArtifactTypeNode.createSheet.childCnt.desc"),
359 return visitor.
visit(
this);
378 private final BlackboardArtifact.Type
type;
385 private final RefreshThrottler refreshThrottler =
new RefreshThrottler(
this);
388 super(
type.getTypeName());
392 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
393 String eventType = evt.getPropertyName();
415 refreshThrottler.registerForIngestModuleEvents();
421 refreshThrottler.unregisterEventListener();
432 if (skCase != null) {
434 List<BlackboardArtifact> arts;
435 if (filteringDSObjId > 0) {
438 arts = skCase.getBlackboardArtifacts(
type.getTypeID());
440 for (BlackboardArtifact art : arts) {
446 }
catch (TskCoreException ex) {
450 return Collections.emptyList();
460 String eventType = evt.getPropertyName();
478 if (null != event && event.getBlackboardArtifactType().equals(
type)) {
static synchronized IngestManager getInstance()
T visit(DataSourcesNode in)
void removeIngestJobEventListener(final PropertyChangeListener listener)
void addIngestJobEventListener(final PropertyChangeListener listener)
static String getIconFilePath(int typeID)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)