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