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"),
152 return getClass().getName();
187 private final PropertyChangeListener
pcl =
new PropertyChangeListener() {
189 public void propertyChange(PropertyChangeEvent evt) {
190 String eventType = evt.getPropertyName();
205 }
catch (IllegalStateException notUsed) {
222 }
catch (IllegalStateException notUsed) {
229 if (evt.getNewValue() == null) {
232 maxFilesDialogShown =
false;
245 protected boolean createKeys(List<DeletedContent.DeletedContentFilter> list) {
262 super(Children.create(
new DeletedContentChildren(
filter, skCase, null),
true), Lookups.singleton(
filter.getDisplayName()));
268 super(Children.create(
new DeletedContentChildren(
filter, skCase, o),
true), Lookups.singleton(
filter.getDisplayName()));
271 o.addObserver(
new DeletedContentNodeObserver());
275 super.setName(
filter.getName());
277 String tooltip =
filter.getDisplayName();
278 this.setShortDescription(tooltip);
279 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
287 public void update(Observable o, Object arg) {
294 final long count = DeletedContentChildren.calculateItems(skCase,
filter);
296 super.setDisplayName(
filter.getDisplayName() +
" (" + count +
")");
301 return v.
visit(
this);
306 Sheet s = super.createSheet();
307 Sheet.Set ss = s.get(Sheet.PROPERTIES);
309 ss = Sheet.createPropertiesSet();
314 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.name"),
315 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.displayName"),
316 NbBundle.getMessage(
this.getClass(),
"DeletedContent.createSheet.filterType.desc"),
317 filter.getDisplayName()));
337 static class DeletedContentChildren
extends ChildFactory.Detachable<AbstractFile> {
342 private static final int MAX_OBJECTS = 10001;
347 this.filter = filter;
351 private final Observer observer =
new DeletedContentChildrenObserver();
357 public void update(Observable o, Object arg) {
363 protected void addNotify() {
364 if (notifier != null) {
365 notifier.addObserver(observer);
370 protected void removeNotify() {
371 if (notifier != null) {
372 notifier.deleteObserver(observer);
377 protected boolean createKeys(List<AbstractFile> list) {
378 List<AbstractFile> queryList = runFsQuery();
379 if (queryList.size() == MAX_OBJECTS) {
380 queryList.remove(queryList.size() - 1);
382 if (maxFilesDialogShown ==
false) {
383 maxFilesDialogShown =
true;
384 SwingUtilities.invokeLater(
new Runnable() {
387 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(this.getClass(),
388 "DeletedContent.createKeys.maxObjects.msg",
394 list.addAll(queryList);
398 static private String makeQuery(
DeletedContent.DeletedContentFilter filter) {
401 case FS_DELETED_FILTER:
402 query =
"dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
403 +
" AND meta_flags != " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
404 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType();
407 case ALL_DELETED_FILTER:
410 +
"(dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
412 +
"meta_flags = " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
414 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
416 +
" OR type = " + TskData.TSK_DB_FILES_TYPE_ENUM.CARVED.getFileType()
427 logger.log(Level.SEVERE,
"Unsupported filter type to get deleted content: {0}", filter);
431 query +=
" LIMIT " + MAX_OBJECTS;
435 private List<AbstractFile> runFsQuery() {
436 List<AbstractFile> ret =
new ArrayList<>();
438 String query = makeQuery(filter);
441 }
catch (TskCoreException e) {
442 logger.log(Level.SEVERE,
"Error getting files for the deleted content view using: " + query, e);
454 static long calculateItems(SleuthkitCase sleuthkitCase,
DeletedContent.DeletedContentFilter filter) {
456 return sleuthkitCase.countFilesWhere(makeQuery(filter));
457 }
catch (TskCoreException ex) {
458 logger.log(Level.SEVERE,
"Error getting deleted files search view count", ex);
465 return key.accept(
new ContentVisitor.Default<AbstractNode>() {
466 public FileNode visit(AbstractFile f) {
467 return new FileNode(f, false);
470 public FileNode visit(FsContent f) {
471 return new FileNode(f,
false);
475 public FileNode visit(LayoutFile f) {
476 return new FileNode(f,
false);
480 public FileNode visit(File f) {
481 return new FileNode(f,
false);
485 public FileNode visit(Directory f) {
486 return new FileNode(f,
false);
490 protected AbstractNode defaultVisit(Content di) {
491 throw new UnsupportedOperationException(NbBundle.getMessage(
this.getClass(),
492 "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)
List< AbstractFile > findAllFilesWhere(String sqlWhereClause)
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
Node createNodeForKey(DeletedContent.DeletedContentFilter key)
DeletedContent(SleuthkitCase skCase)
void update(Observable o, Object arg)