From 530da635dc8e9a63c0d8bd2f935598bf6f86132d Mon Sep 17 00:00:00 2001 From: Dick Fickling Date: Fri, 30 Mar 2012 12:55:07 -0400 Subject: [PATCH 1/2] Add right-click action to File and Directory nodes to open in parent dir --- .../datamodel/AbstractContentChildren.java | 2 +- .../datamodel/AbstractFsContentNode.java | 15 ++- .../datamodel/BlackboardArtifactNode.java | 4 - .../autopsy/datamodel/DirectoryNode.java | 8 +- .../sleuthkit/autopsy/datamodel/FileNode.java | 4 +- .../directorytree/DataResultFilterNode.java | 28 +++--- .../ViewAssociatedContentAction.java | 11 ++- .../directorytree/ViewContextAction.java | 17 ++-- .../filesearch/DataResultFilterChildren.java | 46 --------- .../filesearch/DataResultFilterNode.java | 96 ------------------- .../filesearch/OpenParentFolderAction.java | 88 ----------------- .../autopsy/filesearch/SearchChildren.java | 6 +- 12 files changed, 57 insertions(+), 268 deletions(-) delete mode 100644 FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterChildren.java delete mode 100644 FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterNode.java delete mode 100644 FileSearch/src/org/sleuthkit/autopsy/filesearch/OpenParentFolderAction.java diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java index 7830310690..a9ba79198a 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractContentChildren.java @@ -67,7 +67,7 @@ abstract class AbstractContentChildren extends Keys { /** * Creates appropriate Node for each sub-class of Content */ - static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default { + public static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default { @Override public AbstractContentNode visit(Directory drctr) { diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractFsContentNode.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractFsContentNode.java index 3b3aeb320a..cab3189405 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractFsContentNode.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/AbstractFsContentNode.java @@ -161,16 +161,23 @@ public abstract class AbstractFsContentNode extends Abstrac }, } - private boolean hideParentPath; + private boolean directoryBrowseMode; public static final String HIDE_PARENT = "hide_parent"; AbstractFsContentNode(T fsContent) { this(fsContent, true); } - AbstractFsContentNode(T fsContent, boolean hideParentPath) { + // The param 'directoryBrowseMode' refers to how the user caused this node + // to be created: if by browsing the image contents, it is true. If by + // selecting a file filter (e.g. 'type' or 'recent'), it is false + AbstractFsContentNode(T fsContent, boolean directoryBrowseMode) { super(fsContent); - this.hideParentPath = hideParentPath; + this.directoryBrowseMode = directoryBrowseMode; + } + + public boolean getDirectoryBrowseMode() { + return directoryBrowseMode; } @Override @@ -193,7 +200,7 @@ public abstract class AbstractFsContentNode extends Abstrac final String propString = propType.toString(); ss.put(new NodeProperty(propString, propString, NO_DESCR, map.get(propString))); } - if(hideParentPath) { + if(directoryBrowseMode) { ss.put(new NodeProperty(HIDE_PARENT, HIDE_PARENT, HIDE_PARENT, HIDE_PARENT)); } diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index e3be9129d8..4a21a6de90 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -177,10 +177,6 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI } return null; } - - public Node getContentNode() { - return associated.accept(new AbstractContentChildren.CreateSleuthkitNodeVisitor()); - } private class NameVisitor extends SleuthkitItemVisitor.Default { diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java index 73da5ef668..e64611de72 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/DirectoryNode.java @@ -37,13 +37,17 @@ public class DirectoryNode extends AbstractFsContentNode { static String nameForDirectory(Directory d) { return d.getName(); } + + public DirectoryNode(Directory dir) { + this(dir, true); + } /** * * @param dir Underlying Content instance */ - public DirectoryNode(Directory dir) { - super(dir); + public DirectoryNode(Directory dir, boolean directoryBrowseMode) { + super(dir, directoryBrowseMode); // set name, display name, and icon String dirName = nameForDirectory(dir); diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/FileNode.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/FileNode.java index 938eaaa285..bb92b68821 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/FileNode.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/FileNode.java @@ -48,8 +48,8 @@ public class FileNode extends AbstractFsContentNode { this(file, true); } - public FileNode(File file, boolean hideParentPath) { - super(file, hideParentPath); + public FileNode(File file, boolean directoryBrowseMode) { + super(file, directoryBrowseMode); // set name, display name, and icon String fileName = nameForFile(file); diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java index 5b6ed13c53..f3ec73c2f6 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java @@ -137,7 +137,7 @@ public class DataResultFilterNode extends FilterNode{ @Override public List visit(ImageNode img) { List actions = new ArrayList(); - actions.add(new NewWindowViewAction("View in New Window", getOriginal())); + actions.add(new NewWindowViewAction("View in New Window", img)); actions.addAll(ShowDetailActionVisitor.getActions(img.getLookup().lookup(Content.class))); return actions; } @@ -145,9 +145,9 @@ public class DataResultFilterNode extends FilterNode{ @Override public List visit(VolumeNode vol) { List actions = new ArrayList(); - actions.add(new NewWindowViewAction("View in New Window", getOriginal())); + actions.add(new NewWindowViewAction("View in New Window", vol)); actions.addAll(ShowDetailActionVisitor.getActions(vol.getLookup().lookup(Content.class))); - actions.add(new ChangeViewAction("View", 0, getOriginal())); + actions.add(new ChangeViewAction("View", 0, vol)); return actions; } @@ -155,26 +155,30 @@ public class DataResultFilterNode extends FilterNode{ @Override public List visit(DirectoryNode dir) { List actions = new ArrayList(); - actions.add(new NewWindowViewAction("View in New Window", getOriginal())); - actions.add(new ChangeViewAction("View", 0, getOriginal())); - actions.add(new ExtractAction("Extract Directory", getOriginal())); + actions.add(new NewWindowViewAction("View in New Window", dir)); + actions.add(new ChangeViewAction("View", 0, dir)); + actions.add(new ExtractAction("Extract Directory", dir)); + if(!dir.getDirectoryBrowseMode()) + actions.add(new ViewContextAction("View in Parent Directory", dir)); return actions; } @Override public List visit(FileNode f) { List actions = new ArrayList(); - actions.add(new NewWindowViewAction("View in New Window", getOriginal())); - actions.add(new ExternalViewerAction("Open in External Viewer", getOriginal())); - actions.add(new ExtractAction("Extract File", getOriginal())); + actions.add(new NewWindowViewAction("View in New Window", f)); + actions.add(new ExternalViewerAction("Open in External Viewer", f)); + actions.add(new ExtractAction("Extract File", f)); + if(!f.getDirectoryBrowseMode()) + actions.add(new ViewContextAction("View in Parent Directory", f)); return actions; } @Override public List visit(BlackboardArtifactNode ba) { List actions = new ArrayList(); - actions.add(new ViewAssociatedContentAction("View Associated Content", getOriginal())); - actions.add(new ViewContextAction("View in Directory", getOriginal())); + //actions.add(new ViewAssociatedContentAction("View Associated Content", ba)); + actions.add(new ViewContextAction("View in Directory", ba)); return actions; } @@ -219,7 +223,7 @@ public class DataResultFilterNode extends FilterNode{ @Override public AbstractAction visit(BlackboardArtifactNode ban){ - return new ViewContextAction("View in Directory", getOriginal()); + return new ViewContextAction("View in Directory", ban); } @Override diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewAssociatedContentAction.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewAssociatedContentAction.java index 03a5adcbad..aefde11f20 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewAssociatedContentAction.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewAssociatedContentAction.java @@ -20,24 +20,25 @@ package org.sleuthkit.autopsy.directorytree; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; -import org.openide.nodes.Node; import org.sleuthkit.autopsy.corecomponents.DataContentTopComponent; import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode; +import org.sleuthkit.autopsy.datamodel.RootContentChildren; +import org.sleuthkit.datamodel.Content; /** * View the content associated with the given BlackboardArtifactNode */ class ViewAssociatedContentAction extends AbstractAction { - private BlackboardArtifactNode node; + private Content content; - public ViewAssociatedContentAction(String title, Node node) { + public ViewAssociatedContentAction(String title, BlackboardArtifactNode node) { super(title); - this.node = (BlackboardArtifactNode) node; + this.content = node.getLookup().lookup(Content.class); } @Override public void actionPerformed(ActionEvent e) { - DataContentTopComponent.getDefault().setNode(node.getContentNode()); + DataContentTopComponent.getDefault().setNode(content.accept(new RootContentChildren.CreateSleuthkitNodeVisitor())); } } diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java index 44f140d940..7b9c014e2e 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java @@ -33,6 +33,7 @@ import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent; +import org.sleuthkit.autopsy.datamodel.AbstractFsContentNode; import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode; import org.sleuthkit.autopsy.datamodel.ImagesNode; import org.sleuthkit.autopsy.datamodel.RootContentChildren; @@ -53,12 +54,17 @@ import org.sleuthkit.datamodel.VolumeSystem; */ class ViewContextAction extends AbstractAction { - private BlackboardArtifactNode node; + private Content content; private static final Logger logger = Logger.getLogger(ViewContextAction.class.getName()); - public ViewContextAction(String title, Node node) { + public ViewContextAction(String title, BlackboardArtifactNode node) { super(title); - this.node = (BlackboardArtifactNode) node; + this.content = node.getLookup().lookup(Content.class); + } + + public ViewContextAction(String title, AbstractFsContentNode node) { + super(title); + this.content = node.getLookup().lookup(Content.class); } @Override @@ -68,8 +74,7 @@ class ViewContextAction extends AbstractAction { @Override public void run() { ReverseHierarchyVisitor vtor = new ReverseHierarchyVisitor(); - Content c = node.getLookup().lookup(Content.class); - List hierarchy = c.accept(vtor); + List hierarchy = content.accept(vtor); Collections.reverse(hierarchy); Node generated = new DirectoryTreeFilterNode(new AbstractNode(new RootContentChildren(hierarchy)), true); Children genChilds = generated.getChildren(); @@ -115,7 +120,7 @@ class ViewContextAction extends AbstractAction { DataResultTopComponent dataResult = directoryTree.getDirectoryListing(); Node resultRoot = dataResult.getRootNode(); Children resultChilds = resultRoot.getChildren(); - Node generated = node.getContentNode(); + Node generated = content.accept(new RootContentChildren.CreateSleuthkitNodeVisitor()); for (int i = 0; i < resultChilds.getNodesCount(); i++) { Node current = resultChilds.getNodeAt(i); if (generated.getName().equals(current.getName())) { diff --git a/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterChildren.java b/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterChildren.java deleted file mode 100644 index 30b56966ca..0000000000 --- a/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterChildren.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.filesearch; - -import org.openide.nodes.FilterNode; -import org.openide.nodes.Node; - -/** - * This class is used for the creation of all the children for the - * DataResultFilterNode that created in the DataResultFilterNode.java. - * - * @author jantonius - */ -public class DataResultFilterChildren extends FilterNode.Children { - - /** the constructor */ - public DataResultFilterChildren(Node arg) { - super(arg); - } - - @Override - protected Node copyNode(Node arg0) { - return new DataResultFilterNode(arg0); - } - - @Override - protected Node[] createNodes(Node arg0) { - return new Node[]{this.copyNode(arg0)}; - } -} \ No newline at end of file diff --git a/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterNode.java b/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterNode.java deleted file mode 100644 index 6bba0a15e1..0000000000 --- a/FileSearch/src/org/sleuthkit/autopsy/filesearch/DataResultFilterNode.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.filesearch; - -import javax.swing.Action; -import org.openide.nodes.FilterNode; -import org.openide.nodes.Node; -import org.sleuthkit.autopsy.datamodel.ContentUtils; -import org.sleuthkit.autopsy.directorytree.ChangeViewAction; -import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; -import org.sleuthkit.autopsy.directorytree.ExtractAction; -import org.sleuthkit.datamodel.Content; -import org.sleuthkit.datamodel.ContentVisitor; -import org.sleuthkit.datamodel.Directory; -import org.sleuthkit.datamodel.File; - -/** - * This class wraps nodes as they are passed to the DataResult viewers. It - * defines the actions that the node should have. - */ -public class DataResultFilterNode extends FilterNode { - - - /** the constructor */ - public DataResultFilterNode(Node arg) { - super(arg, new DataResultFilterChildren(arg)); - } - - /** - * Right click action for the nodes that we want to pass to the directory - * table and the output view. - * - * @param popup - * @return actions - */ - @Override - public Action[] getActions(boolean popup) { - - Content content = getOriginal().getLookup().lookup(Content.class); - return content.accept(new GetActionContentVisitor()); - } - - private class GetActionContentVisitor extends ContentVisitor.Default { - @Override - public Action[] visit(Directory dir) { - return new Action[]{ - new ExtractAction("Extract Directory", getOriginal()), - new ChangeViewAction("View", 0, getOriginal()), - new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath(dir)) - }; - } - - @Override - public Action[] visit(File f) { - return new Action[]{ - new ExternalViewerAction("Open in External Viewer", getOriginal()), - new ExtractAction("Extract File", getOriginal()), - new ChangeViewAction("View", 0, getOriginal()), - new OpenParentFolderAction("Open Parent Directory", ContentUtils.getSystemPath(f)) - }; - } - - @Override - protected Action[] defaultVisit(Content cntnt) { - return new Action[]{}; - } - } - - - /** - * Double click action for the nodes that we want to pass to the directory - * table and the output view. - * - * @return action - */ - @Override - public Action getPreferredAction() { - return null; - } -} diff --git a/FileSearch/src/org/sleuthkit/autopsy/filesearch/OpenParentFolderAction.java b/FileSearch/src/org/sleuthkit/autopsy/filesearch/OpenParentFolderAction.java deleted file mode 100644 index 81e95e6c15..0000000000 --- a/FileSearch/src/org/sleuthkit/autopsy/filesearch/OpenParentFolderAction.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2011 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.sleuthkit.autopsy.filesearch; - - -import java.awt.event.ActionEvent; -import java.util.Arrays; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import org.openide.explorer.ExplorerManager; -import org.openide.nodes.Node; -import org.openide.nodes.NodeOp; -import org.openide.windows.TopComponent; -import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent; -import org.sleuthkit.autopsy.coreutils.Log; - - -/** - * The action to open the parent folder of the given Node - */ -public class OpenParentFolderAction extends AbstractAction{ - - private String[] paths; - - // for error handling - private String className = this.getClass().toString(); - - public OpenParentFolderAction(String title, String[] paths){ - super(title); - this.paths = paths; - } - - @Override - public void actionPerformed(ActionEvent e) { - Log.noteAction(this.getClass()); - - try { - - ExplorerManager em = DirectoryTreeTopComponent.findInstance().getExplorerManager(); - Node root = em.getRootContext(); - - if(paths.length > 1 && root != null) { - String[] parentPath = Arrays.copyOf(paths, paths.length - 1); - - Node parentNode = NodeOp.findPath(root, parentPath); - - em.setExploredContextAndSelection(parentNode, new Node[]{parentNode}); - TopComponent dirTree = DirectoryTreeTopComponent.findInstance(); - if(!dirTree.isOpened()){ dirTree.open(); } - dirTree.requestActive(); // make the directory tree the active top component - -// TopComponent resultTable = new DataResultTopComponent(); -// if(!resultTable.isOpened()){ resultTable.open(); } -// resultTable.requestActive(); // make the directory tree the active top component - ((DirectoryTreeTopComponent)dirTree).setDirectoryListingActive(); - - // make the node table the active top component - // @@@ Make the node table the active top component - - - } - - } catch (Exception ex) { - // throw an error here - Logger.getLogger(this.className).log(Level.WARNING, "Error: error while trying to open the parent directory.", ex); - } - } - -} diff --git a/FileSearch/src/org/sleuthkit/autopsy/filesearch/SearchChildren.java b/FileSearch/src/org/sleuthkit/autopsy/filesearch/SearchChildren.java index d13811e214..5baebd65f0 100644 --- a/FileSearch/src/org/sleuthkit/autopsy/filesearch/SearchChildren.java +++ b/FileSearch/src/org/sleuthkit/autopsy/filesearch/SearchChildren.java @@ -27,6 +27,8 @@ import org.sleuthkit.datamodel.Directory; import org.sleuthkit.autopsy.datamodel.DirectoryNode; import org.sleuthkit.datamodel.File; import org.sleuthkit.autopsy.datamodel.FileNode; +import org.sleuthkit.autopsy.directorytree.DataResultFilterNode; +import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent; import org.sleuthkit.datamodel.FsContent; @@ -45,13 +47,13 @@ class SearchChildren extends Children.Keys { protected Node[] createNodes(FsContent t) { Node[] node = new Node[1]; if(t.isDir()){ - node[0] = new DataResultFilterNode(new DirectoryNode((Directory) t)); + node[0] = new DataResultFilterNode(new DirectoryNode((Directory) t, false), DirectoryTreeTopComponent.findInstance().getExplorerManager()); //node[0] = new DirectoryNode((Directory)t); return node; } else{ - node[0] = new DataResultFilterNode(new FileNode((File)t)); + node[0] = new DataResultFilterNode(new FileNode((File)t, false), DirectoryTreeTopComponent.findInstance().getExplorerManager()); //node[0] = new FileNode((File)t); return node; } From 5c85599c08599af3e24890dcecd9970da67de5f8 Mon Sep 17 00:00:00 2001 From: Dick Fickling Date: Fri, 30 Mar 2012 12:55:56 -0400 Subject: [PATCH 2/2] TSK-367: Refresh only specific nodes in Directory Tree --- .../datamodel/RootContentChildren.java | 19 ++++- .../DirectoryTreeTopComponent.java | 82 +++++++++++-------- .../autopsy/recentactivity/Chrome.java | 10 ++- .../autopsy/recentactivity/ExtractIE.java | 7 ++ .../autopsy/recentactivity/Firefox.java | 6 ++ .../recentactivity/RAImageIngestService.java | 3 - 6 files changed, 84 insertions(+), 43 deletions(-) diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/RootContentChildren.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/RootContentChildren.java index fe807866b4..421096b5cf 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/RootContentChildren.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/RootContentChildren.java @@ -21,6 +21,8 @@ package org.sleuthkit.autopsy.datamodel; import java.util.Collection; import java.util.Collections; +import java.util.logging.Logger; +import org.sleuthkit.datamodel.BlackboardArtifact; /** * Children implementation for the root node of a ContentNode tree. Accepts a @@ -47,9 +49,22 @@ public class RootContentChildren extends AbstractContentChildren { setKeys(Collections.emptySet()); } - public void refreshKeys() { + public void refreshKeys(BlackboardArtifact.ARTIFACT_TYPE type) { for(Object o : contentKeys){ - this.refreshKey(o); + switch(type) { + case TSK_HASHSET_HIT: + if(o instanceof HashsetHits) + this.refreshKey(o); + break; + case TSK_KEYWORD_HIT: + if(o instanceof KeywordHits) + this.refreshKey(o); + break; + default: + if(o instanceof ExtractedContent) + this.refreshKey(o); + break; + } } } } diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index 2b64b3c52a..2f5419da92 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -62,6 +62,7 @@ import org.sleuthkit.autopsy.datamodel.RootContentChildren; import org.sleuthkit.autopsy.datamodel.Views; import org.sleuthkit.autopsy.datamodel.ViewsNode; import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.ServiceDataEvent; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.Content; @@ -673,7 +674,14 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat } if (changed.equals(IngestManager.SERVICE_HAS_DATA_EVT)) { - refreshTree(); + final ServiceDataEvent event = (ServiceDataEvent) oldValue; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + refreshTree(event.getArtifactType()); + } + } + ); } } @@ -710,47 +718,49 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat /** * Refreshes the nodes in the tree to reflect updates in the database - * + * should be called in the gui thread */ - public void refreshTree() { + private void refreshTree(final BlackboardArtifact.ARTIFACT_TYPE type) { + + Node selected = getSelectedNode(); + final String[] path = NodeOp.createPath(selected, em.getRootContext()); + + //TODO: instead, we should choose a specific key to refresh? Maybe? + //contentChildren.refreshKeys(); + + Children dirChilds = em.getRootContext().getChildren(); + + Node results = dirChilds.findChild(ResultsNode.NAME); + + OriginalNode original = results.getLookup().lookup(OriginalNode.class); + ResultsNode resultsNode = (ResultsNode) original.getNode(); + RootContentChildren resultsNodeChilds = (RootContentChildren) resultsNode.getChildren(); + resultsNodeChilds.refreshKeys(type); + + final TreeView tree = getTree(); + + tree.expandNode(results); + + Children resultsChilds = results.getChildren(); + tree.expandNode(resultsChilds.findChild(KeywordHits.NAME)); + tree.expandNode(resultsChilds.findChild(ExtractedContentNode.NAME)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - Node selected = getSelectedNode(); - String[] path = NodeOp.createPath(selected, em.getRootContext()); - //TODO: instead, we should choose a specific key to refresh? Maybe? - contentChildren.refreshKeys(); - - Children dirChilds = em.getRootContext().getChildren(); - TreeView tree = getTree(); - - Node results = dirChilds.findChild(ResultsNode.NAME); - tree.expandNode(results); - - Children resultsChilds = results.getChildren(); - tree.expandNode(resultsChilds.findChild(KeywordHits.NAME)); - tree.expandNode(resultsChilds.findChild(ExtractedContentNode.NAME)); - - Node views = dirChilds.findChild(ViewsNode.NAME); - Children viewsChilds = views.getChildren(); - for(Node n : viewsChilds.getNodes()) { - tree.expandNode(n); - } - - tree.collapseNode(views); - - try { - Node newSelection = NodeOp.findPath(em.getRootContext(), path); - resetHistoryListAndButtons(); - tree.expandNode(newSelection); - em.setExploredContextAndSelection(newSelection, new Node[]{newSelection}); - // We need to set the selection, which will refresh dataresult and get rid of the oob exception - } catch (NodeNotFoundException ex) { - logger.log(Level.WARNING, "Node not found", ex); - } catch (PropertyVetoException ex) { - logger.log(Level.WARNING, "Property Veto", ex); + if (path.length > 0 && path[0].equals(ResultsNode.NAME)) { + try { + Node newSelection = NodeOp.findPath(em.getRootContext(), path); + resetHistoryListAndButtons(); + tree.expandNode(newSelection); + em.setExploredContextAndSelection(newSelection, new Node[]{newSelection}); + // We need to set the selection, which will refresh dataresult and get rid of the oob exception + } catch (NodeNotFoundException ex) { + logger.log(Level.WARNING, "Node not found", ex); + } catch (PropertyVetoException ex) { + logger.log(Level.WARNING, "Property Veto", ex); + } } } }); diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java index 73e46e7077..ce51b19478 100755 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java @@ -18,8 +18,9 @@ import java.util.*; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.util.Map.Entry; import org.sleuthkit.autopsy.ingest.IngestImageWorkerController; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.ServiceDataEvent; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE; import org.sleuthkit.datamodel.BlackboardAttribute; @@ -107,6 +108,7 @@ public class Chrome { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY)); } catch (SQLException ex) { @@ -172,6 +174,7 @@ public class Chrome { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE)); } catch (SQLException ex) { @@ -236,7 +239,7 @@ public class Chrome { bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity","",name)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(),"RecentActivity","","Chrome")); bbart.addAttributes(bbattributes); - } + } } @@ -247,6 +250,7 @@ public class Chrome { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK)); } catch (SQLException ex) { @@ -305,6 +309,7 @@ public class Chrome { } tempdbconnect.closeConnection(); temprs.close(); + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD)); } catch (Exception ex) @@ -381,6 +386,7 @@ public class Chrome { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY)); } catch (SQLException ex) { diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java index fdf7d76cc7..0fd4f4eda6 100755 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java @@ -46,6 +46,8 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.autopsy.datamodel.KeyValue; import org.sleuthkit.autopsy.ingest.IngestImageWorkerController; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.ServiceDataEvent; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE; import org.sleuthkit.datamodel.BlackboardAttribute; @@ -127,6 +129,7 @@ public class ExtractIE { // implements BrowserActivity { bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME.getTypeID(), "RecentActivity","",name)); bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_PROG_NAME.getTypeID(),"RecentActivity","","Internet Explorer")); bbart.addAttributes(bbattributes); + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK)); } } @@ -182,6 +185,8 @@ public class ExtractIE { // implements BrowserActivity { bbart.addAttributes(bbattributes); } + + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE)); } catch(TskException ex) { @@ -423,5 +428,7 @@ public class ExtractIE { // implements BrowserActivity { } } + + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY)); } } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java index a2d4dcfb12..42c3d8e5e2 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java @@ -17,6 +17,8 @@ import java.util.*; import java.io.File; import java.io.IOException; import org.sleuthkit.autopsy.ingest.IngestImageWorkerController; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.ServiceDataEvent; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact.*; import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE; @@ -131,6 +133,8 @@ public class Firefox { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY)); + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK)); } catch (SQLException ex) { @@ -198,6 +202,7 @@ public class Firefox { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE)); } catch (SQLException ex) { @@ -266,6 +271,7 @@ public class Firefox { j++; dbFile.delete(); } + IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD)); } catch (SQLException ex) { diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestService.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestService.java index eb4a6429b8..850e303e23 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestService.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestService.java @@ -117,9 +117,6 @@ public final class RAImageIngestService implements IngestServiceImage { @Override public void complete() { logger.log(Level.INFO, "complete() " + this.toString()); - IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK)); - IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE)); - IngestManager.fireServiceDataEvent(new ServiceDataEvent("Recent Activity", BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY)); final IngestMessage msg = IngestMessage.createMessage(++messageId, MessageType.INFO, this, "Completed"); managerProxy.postMessage(msg);