19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.Calendar;
23 import java.util.List;
24 import java.util.logging.Level;
26 import org.openide.util.NbBundle;
28 import org.openide.nodes.AbstractNode;
29 import org.openide.nodes.ChildFactory;
30 import org.openide.nodes.Node;
47 class RecentFilesFilterChildren
extends ChildFactory<Content> {
49 private SleuthkitCase skCase;
50 private RecentFilesFilter filter;
51 private Calendar prevDay;
52 private final static Logger logger = Logger.getLogger(RecentFilesFilterChildren.class.getName());
55 RecentFilesFilterChildren(RecentFilesFilter filter, SleuthkitCase skCase, Calendar lastDay) {
58 this.prevDay = (Calendar) lastDay.clone();
59 prevDay.add(Calendar.DATE, -filter.getDurationDays());
63 protected boolean createKeys(List<Content> list) {
64 list.addAll(runQuery());
68 private String createQuery() {
69 Calendar prevDayQuery = (Calendar) prevDay.clone();
70 String query =
"(dir_type = " + TskData.TSK_FS_NAME_TYPE_ENUM.REG.getValue() +
")"
71 +
" AND (known IS NULL OR known != 1) AND (";
72 long lowerLimit = prevDayQuery.getTimeInMillis() / 1000;
73 prevDayQuery.add(Calendar.DATE, 1);
74 prevDayQuery.add(Calendar.MILLISECOND, -1);
75 long upperLimit = prevDayQuery.getTimeInMillis() / 1000;
76 query +=
"(crtime BETWEEN " + lowerLimit +
" AND " + upperLimit +
") OR ";
77 query +=
"(ctime BETWEEN " + lowerLimit +
" AND " + upperLimit +
") OR ";
79 query +=
"(mtime BETWEEN " + lowerLimit +
" AND " + upperLimit +
"))";
84 private List<AbstractFile> runQuery() {
85 List<AbstractFile> ret =
new ArrayList<AbstractFile>();
87 List<AbstractFile> found = skCase.findAllFilesWhere(createQuery());
88 for (AbstractFile c : found) {
92 }
catch (TskCoreException ex) {
93 logger.log(Level.WARNING,
"Couldn't get search results", ex);
104 long calculateItems() {
106 return skCase.countFilesWhere(createQuery());
107 }
catch (TskCoreException ex) {
108 logger.log(Level.SEVERE,
"Error getting recent files search view count", ex);
114 protected Node createNodeForKey(Content key) {
115 return key.accept(
new ContentVisitor.Default<AbstractNode>() {
117 public FileNode visit(File f) {
118 return new FileNode(f, false);
122 public DirectoryNode visit(Directory d) {
123 return new DirectoryNode(d);
127 public LocalFileNode visit(DerivedFile f) {
128 return new LocalFileNode(f);
132 public LocalFileNode visit(LocalFile f) {
133 return new LocalFileNode(f);
137 protected AbstractNode defaultVisit(Content di) {
138 throw new UnsupportedOperationException(
139 NbBundle.getMessage(
this.getClass(),
140 "RecentFilesFilterChildren.exception.defaultVisit.msg",