Autopsy  4.10.0
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;
40 import org.sleuthkit.datamodel.AbstractFile;
41 import org.sleuthkit.datamodel.BlackboardArtifact;
42 import org.sleuthkit.datamodel.TskCoreException;
43 
47 public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
48 
49  private static final Logger logger = Logger.getLogger(LocalFileNode.class.getName());
50 
51  public LocalFileNode(AbstractFile af) {
52  super(af);
53 
54  this.setDisplayName(af.getName());
55 
56  // set name, display name, and icon
57  if (af.isDir()) {
58  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
59  } else {
60  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
61  }
62 
63  }
64 
65  @Override
66  public Action[] getActions(boolean context) {
67  List<Action> actionsList = new ArrayList<>();
68  actionsList.addAll(Arrays.asList(super.getActions(true)));
69 
70  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
71  actionsList.add(null); // creates a menu separator
72  actionsList.add(new NewWindowViewAction(
73  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
74  final Collection<AbstractFile> selectedFilesList
75  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
76  if (selectedFilesList.size() == 1) {
77  actionsList.add(new ExternalViewerAction(
78  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
79  } else {
80  actionsList.add(ExternalViewerShortcutAction.getInstance());
81  }
82  actionsList.add(null); // creates a menu separator
83 
84  actionsList.add(ExtractAction.getInstance());
85  actionsList.add(null); // creates a menu separator
86  actionsList.add(AddContentTagAction.getInstance());
87 
88  if (selectedFilesList.size() == 1) {
89  actionsList.add(DeleteFileContentTagAction.getInstance());
90  }
91 
92  actionsList.addAll(ContextMenuExtensionPoint.getActions());
93  if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
94  try {
95  if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
96  actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
97  }
98  } catch (TskCoreException ex) {
99  logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
100  }
101  }
102  return actionsList.toArray(new Action[actionsList.size()]);
103  }
104 
105  @Override
106  public <T> T accept(ContentNodeVisitor<T> visitor) {
107  return visitor.visit(this);
108  }
109 
110  @Override
111  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
112  return visitor.visit(this);
113  }
114 
115  @Override
116  public boolean isLeafTypeNode() {
117  // This seems wrong, but it also seems that it is never called
118  // because the visitor to figure out if there are children or
119  // not will check if it has children using the Content API
120  return true;
121  }
122 
123  @Override
124  public String getItemType() {
125  return getClass().getName();
126  }
127 }
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.