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.Node;
|
||||
import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
|
||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||
import org.sleuthkit.datamodel.Directory;
|
||||
import org.sleuthkit.datamodel.File;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.SleuthkitVisitableItem;
|
||||
import org.sleuthkit.datamodel.SleuthkitItemVisitor;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.datamodel.Volume;
|
||||
import org.sleuthkit.datamodel.VolumeSystem;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
|
||||
/**
|
||||
@ -93,6 +91,11 @@ abstract class AbstractContentChildren extends Keys<Object> {
|
||||
return new LayoutFileNode(lf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContentNode visit(LayoutDirectory ld) {
|
||||
return new LayoutDirectoryNode(ld);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractContentNode defaultVisit(SleuthkitVisitableItem di) {
|
||||
throw new UnsupportedOperationException("No Node defined for the given SleuthkitItem");
|
||||
|
@ -9,6 +9,7 @@ import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentVisitor;
|
||||
import org.sleuthkit.datamodel.Directory;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.datamodel.VolumeSystem;
|
||||
|
||||
@ -71,4 +72,10 @@ public class ContentHierarchyVisitor extends ContentVisitor.Default<List<? exten
|
||||
return Collections.singletonList(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Content> visit(LayoutDirectory ldir) {
|
||||
//return getChildren(ldir);
|
||||
return Collections.singletonList(ldir);
|
||||
}
|
||||
}
|
@ -34,6 +34,8 @@ public interface ContentNodeVisitor<T> {
|
||||
|
||||
T visit(LayoutFileNode lcn);
|
||||
|
||||
T visit(LayoutDirectoryNode lcn);
|
||||
|
||||
/**
|
||||
* Visitor with an implementable default behavior for all types. Override
|
||||
* specific visit types to not use the default behavior.
|
||||
@ -72,5 +74,10 @@ public interface ContentNodeVisitor<T> {
|
||||
public T visit(LayoutFileNode 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.FsContent;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
import org.sleuthkit.datamodel.ReadContentInputStream;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
@ -152,6 +153,13 @@ public final class ContentUtils {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> visit(LayoutDirectory ld) {
|
||||
List<String> path = ld.getParent().accept(this);
|
||||
path.add(toString.visit(ld));
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> visit(Directory dir) {
|
||||
List<String> path;
|
||||
@ -301,6 +309,7 @@ public final class ContentUtils {
|
||||
cntnt.accept(new ExtractFscContentVisitor(dest, progress, worker, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(File f) {
|
||||
try {
|
||||
ContentUtils.writeToFile(f, dest, progress, worker, source);
|
||||
|
@ -55,6 +55,7 @@ public interface DisplayableItemNodeVisitor<T> {
|
||||
T visit(ResultsNode rn);
|
||||
T visit(ImagesNode in);
|
||||
T visit(LayoutFileNode lcn);
|
||||
T visit(LayoutDirectoryNode ldn);
|
||||
|
||||
/**
|
||||
* Visitor with an implementable default behavior for all types. Override
|
||||
@ -184,5 +185,10 @@ public interface DisplayableItemNodeVisitor<T> {
|
||||
public T visit(LayoutFileNode 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.FileSystem;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.datamodel.Volume;
|
||||
@ -204,5 +205,10 @@ class ViewContextAction extends AbstractAction {
|
||||
public List<Content> visit(LayoutFile lc) {
|
||||
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.AbstractFile;
|
||||
import org.sleuthkit.datamodel.Directory;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
@ -62,6 +63,11 @@ class GetAllFilesContentVisitor extends GetFilesContentVisitor {
|
||||
return Collections.<AbstractFile>singleton(lf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AbstractFile> visit(LayoutDirectory ld) {
|
||||
return Collections.<AbstractFile>singleton(ld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AbstractFile> visit(FileSystem fs) {
|
||||
// Files in the database have a filesystem field, so it's quick to
|
||||
|
@ -29,6 +29,7 @@ import org.sleuthkit.datamodel.File;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.LayoutDirectory;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
import org.sleuthkit.datamodel.Volume;
|
||||
import org.sleuthkit.datamodel.VolumeSystem;
|
||||
@ -51,6 +52,11 @@ public abstract class GetFilesContentVisitor implements ContentVisitor<Collectio
|
||||
@Override
|
||||
public abstract Collection<AbstractFile> visit(LayoutFile lc);
|
||||
|
||||
@Override
|
||||
public Collection<AbstractFile> visit(LayoutDirectory ld) {
|
||||
return getAllFromChildren(ld);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AbstractFile> visit(Directory drctr) {
|
||||
return getAllFromChildren(drctr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user