Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
LayoutFileNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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;
42 import org.sleuthkit.datamodel.AbstractFile;
43 import org.sleuthkit.datamodel.BlackboardArtifact;
44 import org.sleuthkit.datamodel.LayoutFile;
45 import org.sleuthkit.datamodel.TskCoreException;
46 import org.sleuthkit.datamodel.TskData;
47 
51 public class LayoutFileNode extends AbstractAbstractFileNode<LayoutFile> {
52 
53  private static final Logger logger = Logger.getLogger(LayoutFileNode.class.getName());
54 
55  @Deprecated
56  public static enum LayoutContentPropertyType {
57 
58  PARTS {
59  @Override
60  public String toString() {
61  return NbBundle.getMessage(this.getClass(), "LayoutFileNode.propertyType.parts");
62  }
63  }
64  }
65 
66  public static String nameForLayoutFile(LayoutFile lf) {
67  return lf.getName();
68  }
69 
70  public LayoutFileNode(LayoutFile lf) {
71  super(lf);
72 
73  this.setDisplayName(nameForLayoutFile(lf));
74 
75  if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.CARVED)) {
76  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/carved-file-x-icon-16.png"); //NON-NLS
77  } else if (lf.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.LAYOUT_FILE)) {
78  if (lf.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC)) {
79  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
80  } else {
81  this.setIconBaseWithExtension(FileNode.getIconForFileType(lf));
82  }
83  } else {
84  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/file-icon-deleted.png"); //NON-NLS
85  }
86  }
87 
88  public <T> T accept(ContentNodeVisitor<T> visitor) {
89  return visitor.visit(this);
90  }
91 
92  @Override
93  public boolean isLeafTypeNode() {
94  return false;
95  }
96 
97  @Override
98  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
99  return visitor.visit(this);
100  }
101 
102  @Override
103  @NbBundle.Messages({
104  "LayoutFileNode.getActions.viewFileInDir.text=View File in Directory"})
105  public Action[] getActions(boolean context) {
106  List<Action> actionsList = new ArrayList<>();
107  actionsList.addAll(Arrays.asList(super.getActions(true)));
108  actionsList.add(new ViewContextAction(Bundle.LayoutFileNode_getActions_viewFileInDir_text(), this));
109  actionsList.add(null); // Creates an item separator
110 
111  actionsList.add(new NewWindowViewAction(
112  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
113  final Collection<AbstractFile> selectedFilesList
114  = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
115  if (selectedFilesList.size() == 1) {
116  actionsList.add(new ExternalViewerAction(
117  NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
118  } else {
119  actionsList.add(ExternalViewerShortcutAction.getInstance());
120  }
121  actionsList.add(ViewFileInTimelineAction.createViewFileAction(getContent()));
122  actionsList.add(null); // creates a menu separator
123  actionsList.add(ExtractAction.getInstance());
124  actionsList.add(ExportCSVAction.getInstance());
125  actionsList.add(null); // creates a menu separator
126  actionsList.add(AddContentTagAction.getInstance());
127 
128  if (selectedFilesList.size() == 1) {
129  actionsList.add(DeleteFileContentTagAction.getInstance());
130  }
131 
132  actionsList.addAll(ContextMenuExtensionPoint.getActions());
133  if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
134  try {
135  if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
136  actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
137  }
138  } catch (TskCoreException ex) {
139  logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
140  }
141  }
142  return actionsList.toArray(new Action[actionsList.size()]);
143  }
144 
145  @Override
146  public String getItemType() {
147  return getClass().getName();
148  }
149 
150 }
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
static String nameForLayoutFile(LayoutFile lf)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)
static synchronized AddContentTagAction getInstance()

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