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

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.