mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
Clean up org.sleuthkit.autopsy.directorytree.ViewContextAction.ReverseHierarchyVisitor code.
This commit is contained in:
parent
a8f6393c8a
commit
2343d091c8
@ -149,102 +149,46 @@ class ViewContextAction extends AbstractAction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The ReverseHierarchyVisitor class is designed to return a list of Content
|
* The ReverseHierarchyVisitor class is designed to return a list of Content
|
||||||
* objects starting with the one the user call 'accept' with and ending at
|
* objects starting with the one the user calls 'accept' with and ending at
|
||||||
* the Image object. Please NOTE that Content objects in this hierarchy of
|
* the Image object. Please NOTE that Content objects in this hierarchy of
|
||||||
* type VolumeSystem and FileSystem are skipped. This seems to be necessary
|
* type VolumeSystem and FileSystem are skipped. This seems to be necessary
|
||||||
* because org.sleuthkit.autopsy.datamodel.AbstractContentChildren.CreateSleuthkitNodeVisitor
|
* because org.sleuthkit.autopsy.datamodel.AbstractContentChildren.CreateSleuthkitNodeVisitor
|
||||||
* does not support these types.
|
* does not support these types.
|
||||||
*/
|
*/
|
||||||
private class ReverseHierarchyVisitor implements ContentVisitor<List<Content>> {
|
private class ReverseHierarchyVisitor extends ContentVisitor.Default<List<Content>> {
|
||||||
|
|
||||||
List<Content> ret = new ArrayList<Content>();
|
List<Content> ret = new ArrayList<Content>();
|
||||||
|
|
||||||
@Override
|
private List<Content> visitParentButDontAddMe(Content content) {
|
||||||
public List<Content> visit(Directory drctr) {
|
|
||||||
ret.add(drctr);
|
|
||||||
Content parent = null;
|
Content parent = null;
|
||||||
try {
|
try {
|
||||||
parent = drctr.getParent();
|
parent = content.getParent();
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of Directory: " + drctr, ex);
|
logger.log(Level.WARNING, "Couldn't get parent of Content object: " + content);
|
||||||
}
|
}
|
||||||
return parent.accept(this);
|
return parent == null ? ret : parent.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Content> visit(File file) {
|
protected List<Content> defaultVisit(Content content) {
|
||||||
ret.add(file);
|
ret.add(content);
|
||||||
Content parent = null;
|
Content parent = null;
|
||||||
try {
|
try {
|
||||||
parent = file.getParent();
|
parent = content.getParent();
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of File: " + file, ex);
|
logger.log(Level.WARNING, "Couldn't get parent of Content object: " + content);
|
||||||
}
|
}
|
||||||
return parent.accept(this);
|
return parent == null ? ret : parent.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Content> visit(FileSystem fs) {
|
public List<Content> visit(FileSystem fs) {
|
||||||
Content parent = null;
|
return visitParentButDontAddMe(fs);
|
||||||
try {
|
|
||||||
parent = fs.getParent();
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of FileSystem: " + fs, ex);
|
|
||||||
}
|
|
||||||
return parent.accept(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Content> visit(Image image) {
|
|
||||||
ret.add(image);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Content> visit(Volume volume) {
|
|
||||||
ret.add(volume);
|
|
||||||
Content parent = null;
|
|
||||||
try {
|
|
||||||
parent = volume.getParent();
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of Volume: " + volume, ex);
|
|
||||||
}
|
|
||||||
return parent.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Content> visit(VolumeSystem vs) {
|
public List<Content> visit(VolumeSystem vs) {
|
||||||
Content parent = null;
|
return visitParentButDontAddMe(vs);
|
||||||
try {
|
|
||||||
parent = vs.getParent();
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of VolumeSystem: " + vs, ex);
|
|
||||||
}
|
|
||||||
return parent.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Content> visit(LayoutFile lc) {
|
|
||||||
ret.add(lc);
|
|
||||||
Content parent = null;
|
|
||||||
try {
|
|
||||||
parent = lc.getParent();
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of LayoutFile: " + lc, ex);
|
|
||||||
}
|
|
||||||
return parent.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Content> visit(VirtualDirectory vd) {
|
|
||||||
ret.add(vd);
|
|
||||||
Content parent = null;
|
|
||||||
try {
|
|
||||||
parent = vd.getParent();
|
|
||||||
} catch (TskCoreException ex) {
|
|
||||||
logger.log(Level.SEVERE, "Couldn't get parent of VirtualDirectory: " + vd, ex);
|
|
||||||
}
|
|
||||||
return parent.accept(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user