19 package org.sleuthkit.autopsy.directorytree;
21 import java.util.List;
22 import java.util.logging.Level;
24 import org.openide.nodes.Children;
26 import org.openide.nodes.FilterNode;
27 import org.openide.nodes.Node;
42 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
54 class DirectoryTreeFilterChildren
extends FilterNode.Children {
56 private final ShowItemVisitor showItemV =
new ShowItemVisitor();
57 private final IsLeafItemVisitor isLeafItemV =
new IsLeafItemVisitor();
58 private final static Logger logger = Logger.getLogger(DirectoryTreeFilterChildren.class.getName());
63 public DirectoryTreeFilterChildren(Node arg) {
68 protected Node copyNode(Node arg0) {
69 return new DirectoryTreeFilterNode(arg0,
true);
72 protected Node copyNode(Node arg0,
boolean createChildren) {
73 return new DirectoryTreeFilterNode(arg0, createChildren);
85 protected Node[] createNodes(Node origNode) {
86 if (origNode == null || !(origNode instanceof DisplayableItemNode)) {
91 final DisplayableItemNode diNode = (DisplayableItemNode) origNode;
92 if (diNode.accept(showItemV) ==
false) {
100 final boolean isLeaf = diNode.accept(isLeafItemV);
102 return new Node[]{this.copyNode(origNode, !isLeaf)};
113 private static boolean isLeafDirectory(DirectoryNode node) {
114 Directory dir = node.getLookup().lookup(Directory.class);
117 for (Content c : dir.getChildren()) {
118 if (c instanceof Directory && (!((Directory) c).getName().equals(
".")
119 && !((Directory) c).getName().equals(
".."))) {
122 }
else if(AbstractContentNode.contentHasVisibleContentChildren(c)){
128 }
catch (TskException ex) {
129 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
130 .log(Level.WARNING,
"Error getting directory children", ex);
136 private static boolean isLeafVolume(VolumeNode node) {
137 Volume vol = node.getLookup().lookup(Volume.class);
141 for (Content c : vol.getChildren()) {
142 if (!(c instanceof LayoutFile)) {
148 }
catch (TskException ex) {
149 Logger.getLogger(DirectoryTreeFilterChildren.class.getName())
150 .log(Level.WARNING,
"Error getting volume children", ex);
159 private static boolean isDotDirectory(DirectoryNode dir) {
160 String name = dir.getDisplayName();
161 return name.equals(DirectoryNode.DOTDIR) || name.equals(DirectoryNode.DOTDOTDIR);
173 public static Children createInstance(Node arg,
boolean createChildren) {
174 if (createChildren) {
175 return new DirectoryTreeFilterChildren(arg);
177 return Children.LEAF;
190 return isLeafDirectory(dn);
201 for (Content childContent : derivedChildren) {
202 if ((childContent instanceof AbstractFile) && ((AbstractFile) childContent).isDir()) {
235 return isLeafVolume(vn);
256 if ( (bbafn.
getArtifact().getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) ||
257 (bbafn.
getArtifact().getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) ) {
274 if (isDotDirectory(dn)) {
282 return fn.hasVisibleContentChildren();
287 return lfn.hasVisibleContentChildren();
292 return ln.hasVisibleContentChildren();
297 return sfn.hasVisibleContentChildren();
321 if ( (bbafn.
getArtifact().getArtifactTypeID() == ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) ||
322 (bbafn.
getArtifact().getArtifactTypeID() == ARTIFACT_TYPE.TSK_MESSAGE.getTypeID()) ) {
Boolean visit(FileNode fn)
Boolean visit(VirtualDirectoryNode vdn)
Boolean visit(LocalFileNode lfn)
Boolean visit(VirtualDirectoryNode vdn)
abstract boolean isLeafTypeNode()
List< Content > getContentChildren()
Boolean visit(LayoutFileNode fn)
Boolean visit(FileTypesNode fileTypes)
Boolean visit(BlackboardArtifactNode bbafn)
Boolean visit(LocalDirectoryNode ldn)
Boolean visit(LocalFileNode lfn)
Boolean visit(SlackFileNode sfn)
Boolean visit(SlackFileNode sfn)
Boolean defaultVisit(DisplayableItemNode c)
Boolean visit(VolumeNode vn)
boolean hasContentChildren()
Boolean visit(FileTypesNode ft)
Boolean visitDeep(AbstractAbstractFileNode<?extends AbstractFile > node)
Boolean defaultVisit(DisplayableItemNode c)
BlackboardArtifact getArtifact()
Boolean visit(LocalDirectoryNode ldn)
Boolean visit(BlackboardArtifactNode bbafn)
Boolean visit(DirectoryNode dn)
Boolean visit(DirectoryNode dn)
Boolean visit(FileNode fn)
Boolean visit(LayoutFileNode ln)
static boolean contentHasVisibleContentChildren(Content c)