Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LocalFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.Action;
28 import org.openide.util.NbBundle;
29 import org.openide.util.Utilities;
41 import org.sleuthkit.datamodel.AbstractFile;
42 import org.sleuthkit.datamodel.BlackboardArtifact;
43 import org.sleuthkit.datamodel.TskCoreException;
44 
48 public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
49 
50  private static final Logger logger = Logger.getLogger(LocalFileNode.class.getName());
51 
52  public LocalFileNode(AbstractFile af) {
53  super(af);
54 
55  this.setDisplayName(af.getName());
56 
57  // set name, display name, and icon
58  if (af.isDir()) {
59  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
60  } else {
61  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
62  }
63 
64  }
65 
66  @Override
67  public Action[] getActions(boolean context) {
68  List<Action> actionsList = new ArrayList<>();
69  actionsList.addAll(Arrays.asList(super.getActions(true)));
70 
71  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
72  actionsList.add(null); // creates a menu separator
73  actionsList.add(new NewWindowViewAction(
74  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
75  final Collection<AbstractFile> selectedFilesList
76  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
77  if (selectedFilesList.size() == 1) {
78  actionsList.add(new ExternalViewerAction(
79  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
80  } else {
81  actionsList.add(ExternalViewerShortcutAction.getInstance());
82  }
83  actionsList.add(null); // creates a menu separator
84 
85  actionsList.add(ExtractAction.getInstance());
86  actionsList.add(ExportCSVAction.getInstance());
87  actionsList.add(null); // creates a menu separator
88  actionsList.add(AddContentTagAction.getInstance());
89 
90  if (selectedFilesList.size() == 1) {
91  actionsList.add(DeleteFileContentTagAction.getInstance());
92  }
93 
94  actionsList.addAll(ContextMenuExtensionPoint.getActions());
95  if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
96  try {
97  if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
98  actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
99  }
100  } catch (TskCoreException ex) {
101  logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
102  }
103  }
104  return actionsList.toArray(new Action[actionsList.size()]);
105  }
106 
107  @Override
108  public <T> T accept(ContentNodeVisitor<T> visitor) {
109  return visitor.visit(this);
110  }
111 
112  @Override
113  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
114  return visitor.visit(this);
115  }
116 
117  @Override
118  public boolean isLeafTypeNode() {
119  // This seems wrong, but it also seems that it is never called
120  // because the visitor to figure out if there are children or
121  // not will check if it has children using the Content API
122  return true;
123  }
124 
125  @Override
126  public String getItemType() {
127  return getClass().getName();
128  }
129 }
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.