19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.LinkedHashMap;
29 import java.util.List;
31 import java.util.Observable;
32 import java.util.Observer;
34 import java.util.logging.Level;
35 import org.openide.nodes.ChildFactory;
36 import org.openide.nodes.Children;
37 import org.openide.nodes.Node;
38 import org.openide.nodes.Sheet;
39 import org.openide.util.NbBundle;
40 import org.openide.util.lookup.Lookups;
48 import org.
sleuthkit.datamodel.SleuthkitCase.CaseDbQuery;
54 .getMessage(
InterestingHits.class,
"InterestingHits.interestingItems.text");
62 interestingResults.
update();
71 List<String> setNames;
73 setNames =
new ArrayList<>(interestingItemsMap.keySet());
75 Collections.sort(setNames);
81 return interestingItemsMap.get(setName);
87 interestingItemsMap.clear();
89 loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
90 loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
99 @SuppressWarnings(
"deprecation")
101 if (skCase == null) {
105 int setNameId = BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID();
106 int artId = artType.getTypeID();
107 String query =
"SELECT value_text,blackboard_attributes.artifact_id,attribute_type_id "
108 +
"FROM blackboard_attributes,blackboard_artifacts WHERE "
109 +
"attribute_type_id=" + setNameId
110 +
" AND blackboard_attributes.artifact_id=blackboard_artifacts.artifact_id"
111 +
" AND blackboard_artifacts.artifact_type_id=" + artId;
113 try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
115 ResultSet resultSet = dbQuery.getResultSet();
116 while (resultSet.next()) {
117 String value = resultSet.getString(
"value_text");
118 long artifactId = resultSet.getLong(
"artifact_id");
119 if (!interestingItemsMap.containsKey(value)) {
120 interestingItemsMap.put(value,
new HashSet<>());
122 interestingItemsMap.get(value).add(artifactId);
125 }
catch (TskCoreException | SQLException ex) {
126 logger.log(Level.WARNING,
"SQL Exception occurred: ", ex);
133 return v.
visit(
this);
142 super(Children.create(
new SetNameFactory(),
true), Lookups.singleton(DISPLAY_NAME));
143 super.setName(INTERESTING_ITEMS);
144 super.setDisplayName(DISPLAY_NAME);
145 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/interesting_item.png");
155 return v.
visit(
this);
160 Sheet s = super.createSheet();
161 Sheet.Set ss = s.get(Sheet.PROPERTIES);
163 ss = Sheet.createPropertiesSet();
167 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
168 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.displayName"),
169 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.desc"),
186 private class SetNameFactory extends ChildFactory.Detachable<String> implements Observer {
193 private final PropertyChangeListener
pcl =
new PropertyChangeListener() {
195 public void propertyChange(PropertyChangeEvent evt) {
196 String eventType = evt.getPropertyName();
213 if (null != eventData && (eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()
214 || eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID())) {
215 interestingResults.
update();
217 }
catch (IllegalStateException notUsed) {
232 interestingResults.
update();
233 }
catch (IllegalStateException notUsed) {
240 if (evt.getNewValue() == null) {
253 interestingResults.
update();
254 interestingResults.addObserver(
this);
262 interestingResults.deleteObserver(
this);
277 public void update(Observable o, Object arg) {
287 super(Children.create(
new HitFactory(setName),
true), Lookups.singleton(setName));
289 super.setName(setName);
291 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/interesting_item.png");
292 interestingResults.addObserver(
this);
296 super.setDisplayName(setName +
" (" + interestingResults.
getArtifactIds(setName).size() +
")");
306 Sheet s = super.createSheet();
307 Sheet.Set ss = s.get(Sheet.PROPERTIES);
309 ss = Sheet.createPropertiesSet();
313 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
314 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
315 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.desc"),
323 return v.
visit(
this);
327 public void update(Observable o, Object arg) {
342 private class HitFactory extends ChildFactory<Long> implements Observer {
349 interestingResults.addObserver(
this);
362 if (skCase == null) {
367 }
catch (TskCoreException ex) {
368 logger.log(Level.SEVERE,
"Error creating new Blackboard Artifact node", ex);
374 public void update(Observable o, Object arg) {
static final String DISPLAY_NAME
BlackboardArtifact.Type getBlackboardArtifactType()
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static final String INTERESTING_ITEMS
static synchronized IngestManager getInstance()
Node createNodeForKey(Long l)
static void removePropertyChangeListener(PropertyChangeListener listener)
void loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE artType)
void update(Observable o, Object arg)
boolean createKeys(List< String > list)
boolean createKeys(List< Long > list)
List< String > getSetNames()
T visit(DataSourcesNode in)
void removeIngestJobEventListener(final PropertyChangeListener listener)
final PropertyChangeListener pcl
SetNameNode(String setName)
Set< Long > getArtifactIds(String setName)
void addIngestJobEventListener(final PropertyChangeListener listener)
void update(Observable o, Object arg)
static void addPropertyChangeListener(PropertyChangeListener listener)
void update(Observable o, Object arg)
HitFactory(String setName)
void addIngestModuleEventListener(final PropertyChangeListener listener)
final Map< String, Set< Long > > interestingItemsMap
Node createNodeForKey(String key)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
InterestingHits(SleuthkitCase skCase)
final InterestingResults interestingResults
static final Logger logger