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.Arrays;
25 import java.util.List;
26 import java.util.Observable;
27 import java.util.Observer;
28 import java.util.logging.Level;
29 import javax.swing.JOptionPane;
30 import javax.swing.SwingUtilities;
31 import org.openide.nodes.AbstractNode;
32 import org.openide.nodes.ChildFactory;
33 import org.openide.nodes.Children;
34 import org.openide.nodes.Node;
35 import org.openide.nodes.Sheet;
36 import org.openide.util.NbBundle;
37 import org.openide.util.lookup.Lookups;
38 import org.openide.windows.WindowManager;
64 NbBundle.getMessage(
DeletedContent.class,
"DeletedContent.fsDelFilter.text")),
67 NbBundle.getMessage(
DeletedContent.class,
"DeletedContent.allDelFilter.text"));
75 this.displayName = displayName;
88 return this.displayName;
103 return v.
visit(
this);
113 "DeletedContent.deletedContentsNode.name");
119 super.setDisplayName(NAME);
121 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
131 return v.
visit(
this);
136 Sheet s = super.createSheet();
137 Sheet.Set ss = s.get(Sheet.PROPERTIES);
139 ss = Sheet.createPropertiesSet();
143 ss.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.name.name"),
144 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.name.displayName"),
145 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.name.desc"),
192 private final PropertyChangeListener
pcl =
new PropertyChangeListener() {
194 public void propertyChange(PropertyChangeEvent evt) {
195 String eventType = evt.getPropertyName();
210 }
catch (IllegalStateException notUsed) {
227 }
catch (IllegalStateException notUsed) {
234 if (evt.getNewValue() == null) {
237 maxFilesDialogShown =
false;
250 protected boolean createKeys(List<DeletedContent.DeletedContentFilter> list) {
267 super(Children.create(
new DeletedContentChildren(
filter, skCase, null),
true), Lookups.singleton(
filter.getDisplayName()));
273 super(Children.create(
new DeletedContentChildren(
filter, skCase, o),
true), Lookups.singleton(
filter.getDisplayName()));
276 o.addObserver(
new DeletedContentNodeObserver());
280 super.setName(
filter.getName());
282 String tooltip =
filter.getDisplayName();
283 this.setShortDescription(tooltip);
284 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
302 public void update(Observable o, Object arg) {
309 final long count = DeletedContentChildren.calculateItems(skCase,
filter);
311 super.setDisplayName(
filter.getDisplayName() +
" (" + count +
")");
316 return v.
visit(
this);
321 Sheet s = super.createSheet();
322 Sheet.Set ss = s.get(Sheet.PROPERTIES);
324 ss = Sheet.createPropertiesSet();
329 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.name"),
330 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.displayName"),
331 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.desc"),
332 filter.getDisplayName()));
343 static class DeletedContentChildren
extends ChildFactory.Detachable<AbstractFile> {
345 private final SleuthkitCase
skCase;
348 private static final int MAX_OBJECTS = 10001;
353 this.filter = filter;
357 private final Observer observer =
new DeletedContentChildrenObserver();
363 public void update(Observable o, Object arg) {
369 protected void addNotify() {
370 if (notifier != null) {
371 notifier.addObserver(observer);
376 protected void removeNotify() {
377 if (notifier != null) {
378 notifier.deleteObserver(observer);
383 protected boolean createKeys(List<AbstractFile> list) {
384 List<AbstractFile> queryList = runFsQuery();
385 if (queryList.size() == MAX_OBJECTS) {
386 queryList.remove(queryList.size() - 1);
388 if (maxFilesDialogShown ==
false) {
389 maxFilesDialogShown =
true;
390 SwingUtilities.invokeLater(
new Runnable() {
393 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(this.getClass(),
394 "DeletedContent.createKeys.maxObjects.msg",
400 list.addAll(queryList);
404 static private String makeQuery(
DeletedContent.DeletedContentFilter filter) {
407 case FS_DELETED_FILTER:
408 query =
"dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
409 +
" AND meta_flags != " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
410 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType();
413 case ALL_DELETED_FILTER:
416 +
"(dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
418 +
"meta_flags = " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
420 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
422 +
" OR type = " + TskData.TSK_DB_FILES_TYPE_ENUM.CARVED.getFileType()
433 logger.log(Level.SEVERE,
"Unsupported filter type to get deleted content: {0}", filter);
437 query +=
" LIMIT " + MAX_OBJECTS;
441 private List<AbstractFile> runFsQuery() {
442 List<AbstractFile> ret =
new ArrayList<>();
444 String query = makeQuery(filter);
446 ret = skCase.findAllFilesWhere(query);
447 }
catch (TskCoreException e) {
448 logger.log(Level.SEVERE,
"Error getting files for the deleted content view using: " + query, e);
460 static long calculateItems(SleuthkitCase sleuthkitCase,
DeletedContent.DeletedContentFilter filter) {
462 return sleuthkitCase.countFilesWhere(makeQuery(filter));
463 }
catch (TskCoreException ex) {
464 logger.log(Level.SEVERE,
"Error getting deleted files search view count", ex);
471 return key.accept(
new ContentVisitor.Default<AbstractNode>() {
472 public FileNode visit(AbstractFile f) {
473 return new FileNode(f, false);
476 public FileNode visit(FsContent f) {
477 return new FileNode(f,
false);
481 public FileNode visit(LayoutFile f) {
482 return new FileNode(f,
false);
486 public FileNode visit(File f) {
487 return new FileNode(f,
false);
491 public FileNode visit(Directory f) {
492 return new FileNode(f,
false);
496 protected AbstractNode defaultVisit(Content di) {
497 throw new UnsupportedOperationException(NbBundle.getMessage(
this.getClass(),
498 "DeletedContent.createNodeForKey.typeNotSupported.msg",
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized IngestManager getInstance()
public< T > T accept(AutopsyItemVisitor< T > v)
static void removePropertyChangeListener(PropertyChangeListener listener)
void update(Observable o, Object arg)
static volatile boolean maxFilesDialogShown
T visit(DataSourcesNode in)
final DeletedContent.DeletedContentFilter filter
void removeIngestJobEventListener(final PropertyChangeListener listener)
DeletedContentFilter(int id, String name, String displayName)
boolean createKeys(List< DeletedContent.DeletedContentFilter > list)
SleuthkitCase getSleuthkitCase()
void addIngestJobEventListener(final PropertyChangeListener listener)
final PropertyChangeListener pcl
static void addPropertyChangeListener(PropertyChangeListener listener)
DeletedContentsChildren(SleuthkitCase skCase)
void addIngestModuleEventListener(final PropertyChangeListener listener)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
Node createNodeForKey(DeletedContent.DeletedContentFilter key)
DeletedContent(SleuthkitCase skCase)
void update(Observable o, Object arg)