mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
initial datamodel node support for derived file.
Add comments what to change after sleuthkit datamodel refactor.
This commit is contained in:
parent
20ea5439e9
commit
7c1a2ad4c8
@ -29,6 +29,8 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
/**
|
||||
* Abstract class that implements the commonality between File and Directory
|
||||
* Nodes (same properties).
|
||||
*
|
||||
* TODO type bounds should be T extends AbstractFile after fields/methods are factored up to AbstractFile
|
||||
*/
|
||||
public abstract class AbstractFsContentNode<T extends FsContent> extends AbstractAbstractFileNode<T> {
|
||||
|
||||
|
@ -34,6 +34,8 @@ public interface ContentNodeVisitor<T> {
|
||||
|
||||
T visit(LayoutFileNode lcn);
|
||||
|
||||
T visit(DerivedFileNode dfn);
|
||||
|
||||
T visit(VirtualDirectoryNode lcn);
|
||||
|
||||
/**
|
||||
@ -75,6 +77,11 @@ public interface ContentNodeVisitor<T> {
|
||||
return defaultVisit(lcn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T visit(DerivedFileNode dfn) {
|
||||
return defaultVisit(dfn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T visit(VirtualDirectoryNode ldn) {
|
||||
return defaultVisit(ldn);
|
||||
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.sleuthkit.datamodel.DerivedFile;
|
||||
import org.sleuthkit.datamodel.LayoutFile;
|
||||
|
||||
/**
|
||||
* A Node for a DerivedFile content object.
|
||||
*
|
||||
* TODO should be able to extend FileNode after FileNode extends AbstractFsContentNode<AbstractFile>
|
||||
*/
|
||||
public class DerivedFileNode extends AbstractAbstractFileNode<DerivedFile> {
|
||||
|
||||
public static enum DerivedFilePropertyType {
|
||||
|
||||
NAME {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Name";
|
||||
}
|
||||
},
|
||||
SIZE {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Size";
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
public static String nameForLayoutFile(LayoutFile lf) {
|
||||
return lf.getName();
|
||||
}
|
||||
|
||||
public DerivedFileNode(DerivedFile df) {
|
||||
super(df);
|
||||
|
||||
this.setDisplayName(df.getName());
|
||||
this.setIconBaseWithExtension(FileNode.getIconForFileType(df));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TYPE getDisplayableItemNodeType() {
|
||||
return TYPE.CONTENT;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
//TODO add more
|
||||
private static void fillPropertyMap(Map<String, Object> map, DerivedFile content) {
|
||||
map.put(DerivedFilePropertyType.NAME.toString(), content.getName());
|
||||
map.put(DerivedFilePropertyType.SIZE.toString(), content.getSize());
|
||||
}
|
||||
}
|
@ -60,7 +60,8 @@ public interface DisplayableItemNodeVisitor<T> {
|
||||
T visit(ViewsNode vn);
|
||||
T visit(ResultsNode rn);
|
||||
T visit(ImagesNode in);
|
||||
T visit(LayoutFileNode lcn);
|
||||
T visit(LayoutFileNode lfn);
|
||||
T visit(DerivedFileNode dfn);
|
||||
T visit(VirtualDirectoryNode ldn);
|
||||
|
||||
/**
|
||||
@ -188,8 +189,13 @@ public interface DisplayableItemNodeVisitor<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T visit(LayoutFileNode lcn) {
|
||||
return defaultVisit(lcn);
|
||||
public T visit(LayoutFileNode lfn) {
|
||||
return defaultVisit(lfn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T visit(DerivedFileNode dfn) {
|
||||
return defaultVisit(dfn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,23 +19,26 @@
|
||||
package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import javax.swing.Action;
|
||||
import org.sleuthkit.datamodel.File;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
import org.sleuthkit.datamodel.FsContent;
|
||||
import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
|
||||
|
||||
/**
|
||||
* This class is used to represent the "Node" for the file. It has no children.
|
||||
* This class is used to represent the "Node" for the file.
|
||||
* It may have derived files children.
|
||||
*
|
||||
* TODO should extend AbstractFsContentNode<FsContent> after FsContent fields are moved up
|
||||
*/
|
||||
public class FileNode extends AbstractFsContentNode<File> {
|
||||
public class FileNode extends AbstractFsContentNode<FsContent> {
|
||||
|
||||
/**
|
||||
* @param file underlying Content
|
||||
*/
|
||||
public FileNode(File file) {
|
||||
public FileNode(FsContent file) {
|
||||
this(file, true);
|
||||
}
|
||||
|
||||
public FileNode(File file, boolean directoryBrowseMode) {
|
||||
public FileNode(FsContent file, boolean directoryBrowseMode) {
|
||||
super(file, directoryBrowseMode);
|
||||
|
||||
// set name, display name, and icon
|
||||
@ -69,7 +72,7 @@ public class FileNode extends AbstractFsContentNode<File> {
|
||||
|
||||
// Given a file, returns the correct icon for said
|
||||
// file based off it's extension
|
||||
static String getIconForFileType(File file) {
|
||||
static String getIconForFileType(AbstractFile file) {
|
||||
// Get the name, extension
|
||||
String name = file.getName();
|
||||
int dotIndex = name.lastIndexOf(".");
|
||||
@ -138,7 +141,7 @@ public class FileNode extends AbstractFsContentNode<File> {
|
||||
|
||||
@Override
|
||||
public boolean isLeafTypeNode() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user