19package org.sleuthkit.autopsy.datamodel;
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collection;
24import java.util.HashSet;
26import java.util.logging.Level;
27import javax.swing.Action;
28import org.apache.commons.lang3.StringUtils;
29import org.openide.util.NbBundle;
30import org.openide.util.Utilities;
31import org.sleuthkit.autopsy.actions.AddContentTagAction;
32import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
33import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
34import org.sleuthkit.autopsy.coreutils.Logger;
35import org.sleuthkit.autopsy.directorytree.ExportCSVAction;
36import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
37import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
38import org.sleuthkit.autopsy.directorytree.ExtractAction;
39import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
40import org.sleuthkit.autopsy.directorytree.ViewContextAction;
41import org.sleuthkit.autopsy.modules.embeddedfileextractor.ExtractArchiveWithPasswordAction;
42import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
43import org.sleuthkit.datamodel.AbstractFile;
44import org.sleuthkit.datamodel.BlackboardArtifact;
45import org.sleuthkit.datamodel.TskCoreException;
46import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM;
47import org.sleuthkit.datamodel.TskData.TSK_FS_NAME_FLAG_ENUM;
53public class FileNode extends AbstractFsContentNode<AbstractFile> {
65 static String getIconForFileType(AbstractFile file) {
66 String ext = file.getNameExtension();
67 if (StringUtils.isBlank(ext)) {
68 return "org/sleuthkit/autopsy/images/file-icon.png";
73 return "org/sleuthkit/autopsy/images/image-file.png";
76 return "org/sleuthkit/autopsy/images/video-file.png";
79 return "org/sleuthkit/autopsy/images/audio-file.png";
82 return "org/sleuthkit/autopsy/images/doc-file.png";
85 return "org/sleuthkit/autopsy/images/exe-file.png";
88 return "org/sleuthkit/autopsy/images/text-file.png";
91 return "org/sleuthkit/autopsy/images/web-file.png";
94 return "org/sleuthkit/autopsy/images/pdf-file.png";
97 return "org/sleuthkit/autopsy/images/archive-file.png";
99 return "org/sleuthkit/autopsy/images/file-icon.png";
129 if (file.isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
130 if (file.getType().equals(TSK_DB_FILES_TYPE_ENUM.CARVED)) {
131 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/carved-file-x-icon-16.png");
133 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/file-icon-deleted.png");
136 this.setIconBaseWithExtension(getIconForFileType(file));
151 "FileNode.getActions.viewFileInDir.text=View File in Directory",
152 "FileNode.getActions.viewInNewWin.text=View Item in New Window",
153 "FileNode.getActions.openInExtViewer.text=Open in External Viewer Ctrl+E",
154 "FileNode.getActions.searchFilesSameMD5.text=Search for files with the same MD5 hash"})
156 List<Action> actionsList =
new ArrayList<>();
159 actionsList.add(
new ViewContextAction(Bundle.FileNode_getActions_viewFileInDir_text(),
this));
162 actionsList.add(
null);
164 actionsList.add(
new NewWindowViewAction(Bundle.FileNode_getActions_viewInNewWin_text(),
this));
165 final Collection<AbstractFile> selectedFilesList
166 =
new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
167 if (selectedFilesList.size() == 1) {
169 Bundle.FileNode_getActions_openInExtViewer_text(),
this));
174 actionsList.add(
null);
178 actionsList.add(
null);
181 if (1 == selectedFilesList.size()) {
187 if (this.
content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
190 }
catch (TskCoreException ex) {
191 logger.log(Level.WARNING,
"Unable to add unzip with password action to context menus", ex);
195 actionsList.add(
null);
196 actionsList.addAll(Arrays.asList(super.getActions(
true)));
198 return actionsList.toArray(
new Action[actionsList.size()]);
211 return visitor.
visit(
this);
223 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
224 return visitor.visit(
this);
248 return getClass().getName();
static synchronized AddContentTagAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
boolean directoryBrowseMode
boolean getDirectoryBrowseMode()
FileNode(AbstractFile file, boolean directoryBrowseMode)
Action[] getActions(boolean context)
static final Logger logger
FileNode(AbstractFile file)
void setIcon(AbstractFile file)
static List< String > getImageExtensions()
static List< String > getPDFExtensions()
static List< String > getWebExtensions()
static List< String > getAudioExtensions()
static List< String > getVideoExtensions()
static List< String > getDocumentExtensions()
static List< String > getExecutableExtensions()
static List< String > getTextExtensions()
static List< String > getArchiveExtensions()
static synchronized ExportCSVAction getInstance()
static synchronized ExternalViewerShortcutAction getInstance()
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)