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.EnumSet;
26 import java.util.List;
27 import java.util.Observable;
28 import java.util.Observer;
30 import java.util.logging.Level;
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;
63 @NbBundle.Messages({
"DeletedContent.fsDelFilter.text=File System",
64 "DeletedContent.allDelFilter.text=All"})
67 FS_DELETED_FILTER(0,
"FS_DELETED_FILTER",
68 Bundle.DeletedContent_fsDelFilter_text()),
69 ALL_DELETED_FILTER(1,
"ALL_DELETED_FILTER",
70 Bundle.DeletedContent_allDelFilter_text());
79 this.displayName = displayName;
92 return this.displayName;
97 return visitor.
visit(
this);
107 this.filteringDSObjId = dsObjId;
110 long filteringDataSourceObjId() {
115 public <T> T accept(AutopsyItemVisitor<T> visitor) {
116 return visitor.visit(
this);
125 @NbBundle.Messages(
"DeletedContent.deletedContentsNode.name=Deleted Files")
126 private static final String
NAME = Bundle.DeletedContent_deletedContentsNode_name();
131 super.setDisplayName(NAME);
132 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
142 return visitor.
visit(
this);
147 "DeletedContent.createSheet.name.displayName=Name",
148 "DeletedContent.createSheet.name.desc=no description"})
150 Sheet sheet = super.createSheet();
151 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
152 if (sheetSet == null) {
153 sheetSet = Sheet.createPropertiesSet();
158 Bundle.DeletedContent_createSheet_name_displayName(),
159 Bundle.DeletedContent_createSheet_name_desc(),
166 return getClass().getName();
180 this.datasourceObjId = dsObjId;
210 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
211 String eventType = evt.getPropertyName();
249 if (evt.getNewValue() == null) {
252 maxFilesDialogShown =
false;
264 protected boolean createKeys(List<DeletedContent.DeletedContentFilter> list) {
282 super(Children.create(
new DeletedContentChildren(
filter, skCase, null, dsObjId),
true), Lookups.singleton(
filter.getDisplayName()));
284 this.datasourceObjId = dsObjId;
289 super(Children.create(
new DeletedContentChildren(
filter, skCase, o, dsObjId),
true), Lookups.singleton(
filter.getDisplayName()));
291 this.datasourceObjId = dsObjId;
293 o.addObserver(
new DeletedContentNodeObserver());
297 super.setName(
filter.getName());
299 String tooltip =
filter.getDisplayName();
300 this.setShortDescription(tooltip);
301 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
309 public void update(Observable o, Object arg) {
316 final long count = DeletedContentChildren.calculateItems(skCase,
filter, datasourceObjId);
318 super.setDisplayName(
filter.getDisplayName() +
" (" + count +
")");
323 return visitor.
visit(
this);
328 "DeletedContent.createSheet.filterType.displayName=Type",
329 "DeletedContent.createSheet.filterType.desc=no description"})
331 Sheet sheet = super.createSheet();
332 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
333 if (sheetSet == null) {
334 sheetSet = Sheet.createPropertiesSet();
339 Bundle.DeletedContent_createSheet_filterType_displayName(),
340 Bundle.DeletedContent_createSheet_filterType_desc(),
341 filter.getDisplayName()));
361 static class DeletedContentChildren
extends BaseChildFactory<AbstractFile> {
363 private final SleuthkitCase
skCase;
371 super(filter.getName(),
new ViewsKnownAndSlackFilter<>());
373 this.filter = filter;
378 private final Observer observer =
new DeletedContentChildrenObserver();
381 protected List<AbstractFile> makeKeys() {
389 public void update(Observable o, Object arg) {
395 protected void onAdd() {
396 if (notifier != null) {
397 notifier.addObserver(observer);
402 protected void onRemove() {
403 if (notifier != null) {
404 notifier.deleteObserver(observer);
408 static private String makeQuery(
DeletedContent.DeletedContentFilter filter,
long filteringDSObjId) {
411 case FS_DELETED_FILTER:
412 query =
"dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
413 +
" AND meta_flags != " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
414 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType();
417 case ALL_DELETED_FILTER:
420 +
"(dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
422 +
"meta_flags = " + TskData.TSK_FS_META_FLAG_ENUM.ORPHAN.getValue()
424 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
426 +
" OR type = " + TskData.TSK_DB_FILES_TYPE_ENUM.CARVED.getFileType()
427 +
" OR (dir_flags = " + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue()
428 +
" AND type = " + TskData.TSK_DB_FILES_TYPE_ENUM.LAYOUT_FILE.getFileType() +
" )"
439 logger.log(Level.SEVERE,
"Unsupported filter type to get deleted content: {0}", filter);
443 if (filteringDSObjId > 0) {
449 private List<AbstractFile> runFsQuery() {
450 List<AbstractFile> ret =
new ArrayList<>();
452 String query = makeQuery(filter, datasourceObjId);
454 ret = skCase.findAllFilesWhere(query);
455 }
catch (TskCoreException e) {
456 logger.log(Level.SEVERE,
"Error getting files for the deleted content view using: " + query, e);
471 static long calculateItems(SleuthkitCase sleuthkitCase,
DeletedContent.DeletedContentFilter filter,
long datasourceObjId) {
473 return sleuthkitCase.countFilesWhere(makeQuery(filter, datasourceObjId));
474 }
catch (TskCoreException ex) {
475 logger.log(Level.SEVERE,
"Error getting deleted files search view count", ex);
482 return key.accept(
new ContentVisitor.Default<AbstractNode>() {
483 public FileNode visit(AbstractFile f) {
484 return new FileNode(f, false);
487 public FileNode visit(FsContent f) {
488 return new FileNode(f,
false);
492 public FileNode visit(LayoutFile f) {
493 return new FileNode(f,
false);
497 public FileNode visit(File f) {
498 return new FileNode(f,
false);
502 public FileNode visit(Directory f) {
503 return new FileNode(f,
false);
507 public FileNode visit(VirtualDirectory f) {
508 return new FileNode(f,
false);
512 protected AbstractNode defaultVisit(Content di) {
513 throw new UnsupportedOperationException(
"Not supported for this type of Displayable Item: " + di.toString());
final long filteringDSObjId
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized IngestManager getInstance()
public< T > T accept(AutopsyItemVisitor< T > visitor)
void update(Observable o, Object arg)
static volatile boolean maxFilesDialogShown
static final Set< Case.Events > CASE_EVENTS_OF_INTEREST
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
final long datasourceObjId
static final Set< IngestManager.IngestModuleEvent > INGEST_MODULE_EVENTS_OF_INTEREST
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Node createNodeForKey(DeletedContent.DeletedContentFilter key)
DeletedContent(SleuthkitCase skCase)
static final Set< IngestManager.IngestJobEvent > INGEST_JOB_EVENTS_OF_INTEREST
DeletedContentsChildren(SleuthkitCase skCase, long dsObjId)
final long datasourceObjId
void update(Observable o, Object arg)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
DeletedContent(SleuthkitCase skCase, long dsObjId)