mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
some cleanup in AbstractAbstractFileNode, especially using the getNameExtension method of AbstractFile
This commit is contained in:
parent
87e28a833b
commit
886e63973d
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2016 Basis Technology Corp.
|
* Copyright 2011-2017 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -22,11 +22,11 @@ import java.beans.PropertyChangeEvent;
|
|||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.openide.nodes.Children;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.Sheet;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -47,27 +47,22 @@ import org.sleuthkit.datamodel.TskCoreException;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends AbstractContentNode<T> {
|
public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends AbstractContentNode<T> {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(AbstractAbstractFileNode.class.getName());
|
private static final Logger logger = Logger.getLogger(AbstractAbstractFileNode.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T> type of the AbstractFile data to encapsulate
|
* @param abstractFile file to wrap
|
||||||
* @param abstractFile file to encapsulate
|
|
||||||
*/
|
*/
|
||||||
AbstractAbstractFileNode(T abstractFile) {
|
AbstractAbstractFileNode(T abstractFile) {
|
||||||
super(abstractFile);
|
super(abstractFile);
|
||||||
String name = abstractFile.getName();
|
String ext = abstractFile.getNameExtension();
|
||||||
int dotIndex = name.lastIndexOf(".");
|
if (StringUtils.isNotBlank(ext)) {
|
||||||
if (dotIndex > 0) {
|
ext = "." + ext;
|
||||||
String ext = name.substring(dotIndex).toLowerCase();
|
|
||||||
|
|
||||||
// If this is an archive file we will listen for ingest events
|
// If this is an archive file we will listen for ingest events
|
||||||
// that will notify us when new content has been identified.
|
// that will notify us when new content has been identified.
|
||||||
for (String s : FileTypeExtensions.getArchiveExtensions()) {
|
if (FileTypeExtensions.getArchiveExtensions().contains(ext)) {
|
||||||
if (ext.equals(s)) {
|
|
||||||
IngestManager.getInstance().addIngestModuleEventListener(pcl);
|
IngestManager.getInstance().addIngestModuleEventListener(pcl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Listen for case events so that we can detect when case is closed
|
// Listen for case events so that we can detect when case is closed
|
||||||
Case.addPropertyChangeListener(pcl);
|
Case.addPropertyChangeListener(pcl);
|
||||||
}
|
}
|
||||||
@ -263,8 +258,8 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
/**
|
/**
|
||||||
* Fill map with AbstractFile properties
|
* Fill map with AbstractFile properties
|
||||||
*
|
*
|
||||||
* @param map map with preserved ordering, where property names/values are
|
* @param map map with preserved ordering, where property names/values
|
||||||
* put
|
* are put
|
||||||
* @param content to extract properties from
|
* @param content to extract properties from
|
||||||
*/
|
*/
|
||||||
public static void fillPropertyMap(Map<String, Object> map, AbstractFile content) {
|
public static void fillPropertyMap(Map<String, Object> map, AbstractFile content) {
|
||||||
@ -273,7 +268,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
try {
|
try {
|
||||||
path = content.getUniquePath();
|
path = content.getUniquePath();
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Except while calling Content.getUniquePath() on {0}", content); //NON-NLS
|
logger.log(Level.SEVERE, "Except while calling Content.getUniquePath() on {0}", content); //NON-NLS
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put(AbstractFilePropertyType.NAME.toString(), AbstractAbstractFileNode.getContentDisplayName(content));
|
map.put(AbstractFilePropertyType.NAME.toString(), AbstractAbstractFileNode.getContentDisplayName(content));
|
||||||
@ -302,7 +297,9 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
/**
|
/**
|
||||||
* Used by subclasses of AbstractAbstractFileNode to add the tags property
|
* Used by subclasses of AbstractAbstractFileNode to add the tags property
|
||||||
* to their sheets.
|
* to their sheets.
|
||||||
* @param ss the modifiable Sheet.Set returned by Sheet.get(Sheet.PROPERTIES)
|
*
|
||||||
|
* @param ss the modifiable Sheet.Set returned by
|
||||||
|
* Sheet.get(Sheet.PROPERTIES)
|
||||||
*/
|
*/
|
||||||
protected void addTagProperty(Sheet.Set ss) {
|
protected void addTagProperty(Sheet.Set ss) {
|
||||||
final String NO_DESCR = NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.desc");
|
final String NO_DESCR = NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.desc");
|
||||||
@ -311,10 +308,10 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
tags = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(content);
|
tags = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(content);
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException ex) {
|
||||||
tags = new ArrayList<>();
|
tags = new ArrayList<>();
|
||||||
LOGGER.log(Level.SEVERE, "Failed to get tags for content " + content.getName(), ex);
|
logger.log(Level.SEVERE, "Failed to get tags for content " + content.getName(), ex);
|
||||||
}
|
}
|
||||||
ss.put(new NodeProperty<>("Tags", NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.tags.displayName"),
|
ss.put(new NodeProperty<>("Tags", NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.addFileProperty.tags.displayName"),
|
||||||
NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).collect(Collectors.joining(", "))));
|
NO_DESCR, tags.stream().map(t -> t.getName().getDisplayName()).distinct().collect(Collectors.joining(", "))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getContentDisplayName(AbstractFile file) {
|
static String getContentDisplayName(AbstractFile file) {
|
||||||
@ -330,12 +327,11 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private static String getHashSetHitsForFile(AbstractFile content) {
|
private static String getHashSetHitsForFile(AbstractFile content) {
|
||||||
try {
|
try {
|
||||||
return StringUtils.join(content.getHashSetNames(), ", ");
|
return StringUtils.join(content.getHashSetNames(), ", ");
|
||||||
} catch (TskCoreException tskCoreException) {
|
} catch (TskCoreException tskCoreException) {
|
||||||
LOGGER.log(Level.WARNING, "Error getting hashset hits: ", tskCoreException); //NON-NLS
|
logger.log(Level.WARNING, "Error getting hashset hits: ", tskCoreException); //NON-NLS
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user