Autopsy 4.22.1
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 */
19package org.sleuthkit.autopsy.datamodel;
20
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collection;
24import java.util.HashSet;
25import java.util.List;
26import java.util.logging.Level;
27import javax.swing.Action;
28import org.openide.util.NbBundle;
29import org.openide.util.Utilities;
30import org.sleuthkit.autopsy.actions.AddContentTagAction;
31import org.sleuthkit.autopsy.actions.DeleteFileContentTagAction;
32import org.sleuthkit.autopsy.coreutils.ContextMenuExtensionPoint;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.autopsy.directorytree.ExportCSVAction;
35import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
36import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction;
37import org.sleuthkit.autopsy.directorytree.ExtractAction;
38import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
39import org.sleuthkit.autopsy.directorytree.ViewContextAction;
40import org.sleuthkit.autopsy.modules.embeddedfileextractor.ExtractArchiveWithPasswordAction;
41import org.sleuthkit.autopsy.timeline.actions.ViewFileInTimelineAction;
42import org.sleuthkit.datamodel.AbstractFile;
43import org.sleuthkit.datamodel.BlackboardArtifact;
44import org.sleuthkit.datamodel.LayoutFile;
45import org.sleuthkit.datamodel.TskCoreException;
46import org.sleuthkit.datamodel.TskData;
47
51public 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
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.add(new ViewContextAction(Bundle.LayoutFileNode_getActions_viewFileInDir_text(), this));
108 actionsList.add(null); // Creates an item separator
109
110 actionsList.add(new NewWindowViewAction(
111 NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.viewInNewWin.text"), this));
112 final Collection<AbstractFile> selectedFilesList
113 = new HashSet<>(Utilities.actionsGlobalContext().lookupAll(AbstractFile.class));
114 if (selectedFilesList.size() == 1) {
115 actionsList.add(new ExternalViewerAction(
116 NbBundle.getMessage(this.getClass(), "LayoutFileNode.getActions.openInExtViewer.text"), this));
117 } else {
118 actionsList.add(ExternalViewerShortcutAction.getInstance());
119 }
121 actionsList.add(null); // creates a menu separator
122 actionsList.add(ExtractAction.getInstance());
123 actionsList.add(ExportCSVAction.getInstance());
124 actionsList.add(null); // creates a menu separator
125 actionsList.add(AddContentTagAction.getInstance());
126
127 if (selectedFilesList.size() == 1) {
128 actionsList.add(DeleteFileContentTagAction.getInstance());
129 }
130
131 actionsList.addAll(ContextMenuExtensionPoint.getActions());
132 if (FileTypeExtensions.getArchiveExtensions().contains("." + this.content.getNameExtension().toLowerCase())) {
133 try {
134 if (this.content.getArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED).size() > 0) {
135 actionsList.add(new ExtractArchiveWithPasswordAction(this.getContent()));
136 }
137 } catch (TskCoreException ex) {
138 logger.log(Level.WARNING, "Unable to add unzip with password action to context menus", ex);
139 }
140 }
141 actionsList.add(null);
142 actionsList.addAll(Arrays.asList(super.getActions(true)));
143 return actionsList.toArray(new Action[actionsList.size()]);
144 }
145
146 @Override
147 public String getItemType() {
148 return getClass().getName();
149 }
150
151}
static synchronized AddContentTagAction getInstance()
static synchronized DeleteFileContentTagAction getInstance()
synchronized static Logger getLogger(String name)
Definition Logger.java:124
static synchronized ExportCSVAction getInstance()
static synchronized ExtractAction getInstance()
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.