Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
VirtualDirectoryNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.sql.ResultSet;
22 import java.sql.SQLException;
23 import java.util.LinkedHashMap;
24 import java.util.Map;
25 import java.util.logging.Level;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
31 import org.sleuthkit.datamodel.SleuthkitCase;
32 import org.sleuthkit.datamodel.TskCoreException;
33 import org.sleuthkit.datamodel.VirtualDirectory;
34 
39 
40  private static final Logger logger = Logger.getLogger(VirtualDirectoryNode.class.getName());
41  //prefix for special VirtualDirectory root nodes grouping local files
42  public final static String LOGICAL_FILE_SET_PREFIX = "LogicalFileSet"; //NON-NLS
43 
44  public static String nameForVirtualDirectory(VirtualDirectory ld) {
45  return ld.getName();
46  }
47 
48  public VirtualDirectoryNode(VirtualDirectory ld) {
49  super(ld);
50 
51  this.setDisplayName(nameForVirtualDirectory(ld));
52 
53  //set icon for name, special case for logical file set
54  if (ld.isDataSource()) {
55  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
56  } else {
57  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-virtual.png"); //TODO NON-NLS
58  }
59  }
60 
61  @Override
62  @NbBundle.Messages({"VirtualDirectoryNode.createSheet.size.name=Size (Bytes)",
63  "VirtualDirectoryNode.createSheet.size.displayName=Size (Bytes)",
64  "VirtualDirectoryNode.createSheet.size.desc=Size of the data source in bytes.",
65  "VirtualDirectoryNode.createSheet.type.name=Type",
66  "VirtualDirectoryNode.createSheet.type.displayName=Type",
67  "VirtualDirectoryNode.createSheet.type.desc=Type of the image.",
68  "VirtualDirectoryNode.createSheet.type.text=Logical File Set",
69  "VirtualDirectoryNode.createSheet.timezone.name=Timezone",
70  "VirtualDirectoryNode.createSheet.timezone.displayName=Timezone",
71  "VirtualDirectoryNode.createSheet.timezone.desc=Timezone of the image",
72  "VirtualDirectoryNode.createSheet.deviceId.name=Device ID",
73  "VirtualDirectoryNode.createSheet.deviceId.displayName=Device ID",
74  "VirtualDirectoryNode.createSheet.deviceId.desc=Device ID of the image"})
75  protected Sheet createSheet() {
76  //Do a special strategy for virtual directories..
77  if(this.content.isDataSource()){
78  Sheet sheet = new Sheet();
79  Sheet.Set sheetSet = Sheet.createPropertiesSet();
80  sheet.put(sheetSet);
81 
82  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.name"),
83  NbBundle.getMessage(this.getClass(),
84  "VirtualDirectoryNode.createSheet.name.displayName"),
85  NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.desc"),
86  getName()));
87 
88  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_type_name(),
89  Bundle.VirtualDirectoryNode_createSheet_type_displayName(),
90  Bundle.VirtualDirectoryNode_createSheet_type_desc(),
91  Bundle.VirtualDirectoryNode_createSheet_type_text()));
92  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_size_name(),
93  Bundle.VirtualDirectoryNode_createSheet_size_displayName(),
94  Bundle.VirtualDirectoryNode_createSheet_size_desc(),
95  this.content.getSize()));
96  try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) {
97  ResultSet timeZoneSet = query.getResultSet();
98  if (timeZoneSet.next()) {
99  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_timezone_name(),
100  Bundle.VirtualDirectoryNode_createSheet_timezone_displayName(),
101  Bundle.VirtualDirectoryNode_createSheet_timezone_desc(),
102  timeZoneSet.getString("time_zone")));
103  }
104  } catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
105  logger.log(Level.SEVERE, "Failed to get time zone for the following image: " + this.content.getId(), ex);
106  }
107  try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
108  ResultSet deviceIdSet = query.getResultSet();
109  if (deviceIdSet.next()) {
110  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_deviceId_name(),
111  Bundle.VirtualDirectoryNode_createSheet_deviceId_displayName(),
112  Bundle.VirtualDirectoryNode_createSheet_deviceId_desc(),
113  deviceIdSet.getString("device_id")));
114  }
115  } catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
116  logger.log(Level.SEVERE, "Failed to get device id for the following image: " + this.content.getId(), ex);
117  }
118  return sheet;
119  }
120 
121  //Otherwise default to the AAFN createSheet method.
122  return super.createSheet();
123  }
124 
125  @Override
126  public <T> T accept(ContentNodeVisitor<T> visitor) {
127  return visitor.visit(this);
128  }
129 
130  @Override
131  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
132  return visitor.visit(this);
133  }
134 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static String nameForVirtualDirectory(VirtualDirectory ld)

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.