mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
data model, node, visitor changes to add LayoutDirectory
This commit is contained in:
parent
e26ffc73de
commit
b9caa40115
@ -23,16 +23,14 @@ import org.openide.nodes.AbstractNode;
|
|||||||
import org.openide.nodes.Children.Keys;
|
import org.openide.nodes.Children.Keys;
|
||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
|
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
|
||||||
import org.sleuthkit.datamodel.Directory;
|
import org.sleuthkit.datamodel.Directory;
|
||||||
import org.sleuthkit.datamodel.File;
|
import org.sleuthkit.datamodel.File;
|
||||||
import org.sleuthkit.datamodel.FileSystem;
|
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
||||||
import org.sleuthkit.datamodel.SleuthkitItemVisitor;
|
import org.sleuthkit.datamodel.SleuthkitItemVisitor;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
import org.sleuthkit.datamodel.Volume;
|
import org.sleuthkit.datamodel.Volume;
|
||||||
import org.sleuthkit.datamodel.VolumeSystem;
|
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,6 +90,11 @@ abstract class AbstractContentChildren extends Keys<Object> {
|
|||||||
public AbstractContentNode visit(LayoutFile lf) {
|
public AbstractContentNode visit(LayoutFile lf) {
|
||||||
return new LayoutFileNode(lf);
|
return new LayoutFileNode(lf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AbstractContentNode visit(LayoutDirectory ld) {
|
||||||
|
return new LayoutDirectoryNode(ld);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractContentNode defaultVisit(SleuthkitVisitableItem di) {
|
protected AbstractContentNode defaultVisit(SleuthkitVisitableItem di) {
|
||||||
|
@ -9,6 +9,7 @@ import org.sleuthkit.datamodel.Content;
|
|||||||
import org.sleuthkit.datamodel.ContentVisitor;
|
import org.sleuthkit.datamodel.ContentVisitor;
|
||||||
import org.sleuthkit.datamodel.Directory;
|
import org.sleuthkit.datamodel.Directory;
|
||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
import org.sleuthkit.datamodel.VolumeSystem;
|
import org.sleuthkit.datamodel.VolumeSystem;
|
||||||
|
|
||||||
@ -71,4 +72,10 @@ public class ContentHierarchyVisitor extends ContentVisitor.Default<List<? exten
|
|||||||
return Collections.singletonList(dir);
|
return Collections.singletonList(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Content> visit(LayoutDirectory ldir) {
|
||||||
|
//return getChildren(ldir);
|
||||||
|
return Collections.singletonList(ldir);
|
||||||
|
}
|
||||||
}
|
}
|
@ -33,6 +33,8 @@ public interface ContentNodeVisitor<T> {
|
|||||||
T visit(VolumeNode vn);
|
T visit(VolumeNode vn);
|
||||||
|
|
||||||
T visit(LayoutFileNode lcn);
|
T visit(LayoutFileNode lcn);
|
||||||
|
|
||||||
|
T visit(LayoutDirectoryNode lcn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor with an implementable default behavior for all types. Override
|
* Visitor with an implementable default behavior for all types. Override
|
||||||
@ -72,5 +74,10 @@ public interface ContentNodeVisitor<T> {
|
|||||||
public T visit(LayoutFileNode lcn) {
|
public T visit(LayoutFileNode lcn) {
|
||||||
return defaultVisit(lcn);
|
return defaultVisit(lcn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T visit(LayoutDirectoryNode ldn) {
|
||||||
|
return defaultVisit(ldn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ import org.sleuthkit.datamodel.File;
|
|||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
import org.sleuthkit.datamodel.FsContent;
|
import org.sleuthkit.datamodel.FsContent;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
import org.sleuthkit.datamodel.ReadContentInputStream;
|
import org.sleuthkit.datamodel.ReadContentInputStream;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
@ -151,6 +152,13 @@ public final class ContentUtils {
|
|||||||
path.add(toString.visit(lay));
|
path.add(toString.visit(lay));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> visit(LayoutDirectory ld) {
|
||||||
|
List<String> path = ld.getParent().accept(this);
|
||||||
|
path.add(toString.visit(ld));
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> visit(Directory dir) {
|
public List<String> visit(Directory dir) {
|
||||||
@ -301,6 +309,7 @@ public final class ContentUtils {
|
|||||||
cntnt.accept(new ExtractFscContentVisitor(dest, progress, worker, true));
|
cntnt.accept(new ExtractFscContentVisitor(dest, progress, worker, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Void visit(File f) {
|
public Void visit(File f) {
|
||||||
try {
|
try {
|
||||||
ContentUtils.writeToFile(f, dest, progress, worker, source);
|
ContentUtils.writeToFile(f, dest, progress, worker, source);
|
||||||
|
@ -55,6 +55,7 @@ public interface DisplayableItemNodeVisitor<T> {
|
|||||||
T visit(ResultsNode rn);
|
T visit(ResultsNode rn);
|
||||||
T visit(ImagesNode in);
|
T visit(ImagesNode in);
|
||||||
T visit(LayoutFileNode lcn);
|
T visit(LayoutFileNode lcn);
|
||||||
|
T visit(LayoutDirectoryNode ldn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor with an implementable default behavior for all types. Override
|
* Visitor with an implementable default behavior for all types. Override
|
||||||
@ -184,5 +185,10 @@ public interface DisplayableItemNodeVisitor<T> {
|
|||||||
public T visit(LayoutFileNode lcn) {
|
public T visit(LayoutFileNode lcn) {
|
||||||
return defaultVisit(lcn);
|
return defaultVisit(lcn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T visit(LayoutDirectoryNode ldn) {
|
||||||
|
return defaultVisit(ldn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2011 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> 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.datamodel;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.openide.nodes.Sheet;
|
||||||
|
import org.sleuthkit.autopsy.datamodel.LayoutFileNode.LayoutContentPropertyType;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Node for layout dir
|
||||||
|
*/
|
||||||
|
public class LayoutDirectoryNode extends AbstractAbstractFileNode<LayoutDirectory> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String nameForLayoutFile(LayoutDirectory ld) {
|
||||||
|
return ld.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayoutDirectoryNode(LayoutDirectory ld) {
|
||||||
|
super(ld);
|
||||||
|
|
||||||
|
this.setDisplayName(nameForLayoutFile(ld));
|
||||||
|
this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Sheet createSheet() {
|
||||||
|
Sheet s = super.createSheet();
|
||||||
|
Sheet.Set ss = s.get(Sheet.PROPERTIES);
|
||||||
|
if (ss == null) {
|
||||||
|
ss = Sheet.createPropertiesSet();
|
||||||
|
s.put(ss);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||||
|
fillPropertyMap(map, content);
|
||||||
|
|
||||||
|
ss.put(new NodeProperty("Name", "Name", "no description", getName()));
|
||||||
|
|
||||||
|
final String NO_DESCR = "no description";
|
||||||
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
|
ss.put(new NodeProperty(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
|
||||||
|
}
|
||||||
|
// @@@ add more properties here...
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T accept(ContentNodeVisitor<T> v) {
|
||||||
|
return v.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T accept(DisplayableItemNodeVisitor<T> v) {
|
||||||
|
return v.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fillPropertyMap(Map<String, Object> map, LayoutDirectory content) {
|
||||||
|
map.put(LayoutContentPropertyType.NAME.toString(), content.getName());
|
||||||
|
map.put(LayoutContentPropertyType.SIZE.toString(), content.getSize());
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,7 @@ import org.sleuthkit.datamodel.Directory;
|
|||||||
import org.sleuthkit.datamodel.File;
|
import org.sleuthkit.datamodel.File;
|
||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
import org.sleuthkit.datamodel.Volume;
|
import org.sleuthkit.datamodel.Volume;
|
||||||
@ -204,5 +205,10 @@ class ViewContextAction extends AbstractAction {
|
|||||||
public List<Content> visit(LayoutFile lc) {
|
public List<Content> visit(LayoutFile lc) {
|
||||||
return lc.getParent().accept(this);
|
return lc.getParent().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Content> visit(LayoutDirectory ld) {
|
||||||
|
return ld.getParent().accept(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import org.sleuthkit.datamodel.File;
|
|||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.Directory;
|
import org.sleuthkit.datamodel.Directory;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.LayoutFile;
|
import org.sleuthkit.datamodel.LayoutFile;
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
import org.sleuthkit.datamodel.TskData;
|
import org.sleuthkit.datamodel.TskData;
|
||||||
@ -61,6 +62,11 @@ class GetAllFilesContentVisitor extends GetFilesContentVisitor {
|
|||||||
public Collection<AbstractFile> visit(LayoutFile lf) {
|
public Collection<AbstractFile> visit(LayoutFile lf) {
|
||||||
return Collections.<AbstractFile>singleton(lf);
|
return Collections.<AbstractFile>singleton(lf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<AbstractFile> visit(LayoutDirectory ld) {
|
||||||
|
return Collections.<AbstractFile>singleton(ld);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<AbstractFile> visit(FileSystem fs) {
|
public Collection<AbstractFile> visit(FileSystem fs) {
|
||||||
|
@ -29,6 +29,7 @@ import org.sleuthkit.datamodel.File;
|
|||||||
import org.sleuthkit.datamodel.FileSystem;
|
import org.sleuthkit.datamodel.FileSystem;
|
||||||
import org.sleuthkit.datamodel.AbstractFile;
|
import org.sleuthkit.datamodel.AbstractFile;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.datamodel.Image;
|
||||||
|
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||||
import org.sleuthkit.datamodel.TskException;
|
import org.sleuthkit.datamodel.TskException;
|
||||||
import org.sleuthkit.datamodel.Volume;
|
import org.sleuthkit.datamodel.Volume;
|
||||||
import org.sleuthkit.datamodel.VolumeSystem;
|
import org.sleuthkit.datamodel.VolumeSystem;
|
||||||
@ -51,6 +52,11 @@ public abstract class GetFilesContentVisitor implements ContentVisitor<Collectio
|
|||||||
@Override
|
@Override
|
||||||
public abstract Collection<AbstractFile> visit(LayoutFile lc);
|
public abstract Collection<AbstractFile> visit(LayoutFile lc);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<AbstractFile> visit(LayoutDirectory ld) {
|
||||||
|
return getAllFromChildren(ld);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<AbstractFile> visit(Directory drctr) {
|
public Collection<AbstractFile> visit(Directory drctr) {
|
||||||
return getAllFromChildren(drctr);
|
return getAllFromChildren(drctr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user