Autopsy  4.6.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-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.LinkedHashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.logging.Level;
29 import javax.swing.Action;
30 import org.openide.nodes.Sheet;
31 import org.openide.util.NbBundle;
32 import org.openide.util.Utilities;
43 import org.sleuthkit.datamodel.AbstractFile;
44 import org.sleuthkit.datamodel.BlackboardArtifact;
45 import org.sleuthkit.datamodel.TskCoreException;
46 
50 public class LocalFileNode extends AbstractAbstractFileNode<AbstractFile> {
51 
52  private static final Logger logger = Logger.getLogger(LocalFileNode.class.getName());
53 
54  public LocalFileNode(AbstractFile af) {
55  super(af);
56 
57  this.setDisplayName(af.getName());
58 
59  // set name, display name, and icon
60  if (af.isDir()) {
61  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/Folder-icon.png"); //NON-NLS
62  } else {
63  this.setIconBaseWithExtension(FileNode.getIconForFileType(af));
64  }
65 
66  }
67 
68  @Override
69  protected Sheet createSheet() {
70  Sheet sheet = super.createSheet();
71  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
72  if (sheetSet == null) {
73  sheetSet = Sheet.createPropertiesSet();
74  sheet.put(sheetSet);
75  }
76 
77  Map<String, Object> map = new LinkedHashMap<>();
78  fillPropertyMap(map, getContent());
79 
80  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.name"),
81  NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.displayName"),
82  NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.name.desc"),
83  getName()));
84 
85  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "LocalFileNode.createSheet.noDescr.text");
86  for (Map.Entry<String, Object> entry : map.entrySet()) {
87  sheetSet.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
88  }
89 
90  // add tags property to the sheet
91  addTagProperty(sheetSet);
92 
93  return sheet;
94  }
95 
96  @Override
97  public Action[] getActions(boolean context) {
98  List<Action> actionsList = new ArrayList<>();
99 
100  actionsList.addAll(Arrays.asList(super.getActions(true)));
101  actionsList.add(new ViewContextAction(NbBundle.getMessage(this.getClass(), "LocalFileNode.viewFileInDir.text"), this.content));
102  actionsList.add(null); // creates a menu separator
103  actionsList.add(new NewWindowViewAction(
104  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.viewInNewWin.text"), this));
105  actionsList.add(new ExternalViewerAction(
106  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.openInExtViewer.text"), this));
107  actionsList.add(null); // creates a menu separator
108 
109  actionsList.add(ExtractAction.getInstance());
110  actionsList.add(new HashSearchAction(
111  NbBundle.getMessage(this.getClass(), "LocalFileNode.getActions.searchFilesSameMd5.text"), this));
112  actionsList.add(null); // creates a menu separator
113  actionsList.add(AddContentTagAction.getInstance());
114 
115  final Collection<AbstractFile> selectedFilesList
116  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
117  if (selectedFilesList.size() == 1) {
118  actionsList.add(DeleteFileContentTagAction.getInstance());
119  }
120 
121  actionsList.addAll(ContextMenuExtensionPoint.getActions());
122  if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
123  try {
124  if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
125  actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
126  }
127  } catch (TskCoreException ex) {
128  logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
129  }
130  }
131  return actionsList.toArray(new Action[0]);
132  }
133 
134  @Override
135  public <T> T accept(ContentNodeVisitor<T> visitor) {
136  return visitor.visit(this);
137  }
138 
139  @Override
140  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
141  return visitor.visit(this);
142  }
143 
144  @Override
145  public boolean isLeafTypeNode() {
146  // This seems wrong, but it also seems that it is never called
147  // because the visitor to figure out if there are children or
148  // not will check if it has children using the Content API
149  return true;
150  }
151 
152  @Override
153  public String getItemType() {
154  return getClass().getName();
155  }
156 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static synchronized AddContentTagAction getInstance()

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.