Autopsy  4.6.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-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  String name = ld.getName();
54 
55  //set icon for name, special case for logical file set
56  if (ld.isDataSource()) {
57  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
58  } else {
59  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/folder-icon-virtual.png"); //TODO NON-NLS
60  }
61  }
62 
63  @Override
64  @NbBundle.Messages({"VirtualDirectoryNode.createSheet.size.name=Size (Bytes)",
65  "VirtualDirectoryNode.createSheet.size.displayName=Size (Bytes)",
66  "VirtualDirectoryNode.createSheet.size.desc=Size of the data source in bytes.",
67  "VirtualDirectoryNode.createSheet.type.name=Type",
68  "VirtualDirectoryNode.createSheet.type.displayName=Type",
69  "VirtualDirectoryNode.createSheet.type.desc=Type of the image.",
70  "VirtualDirectoryNode.createSheet.type.text=Logical File Set",
71  "VirtualDirectoryNode.createSheet.timezone.name=Timezone",
72  "VirtualDirectoryNode.createSheet.timezone.displayName=Timezone",
73  "VirtualDirectoryNode.createSheet.timezone.desc=Timezone of the image",
74  "VirtualDirectoryNode.createSheet.deviceId.name=Device ID",
75  "VirtualDirectoryNode.createSheet.deviceId.displayName=Device ID",
76  "VirtualDirectoryNode.createSheet.deviceId.desc=Device ID of the image"})
77  protected Sheet createSheet() {
78  Sheet sheet = super.createSheet();
79  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
80  if (sheetSet == null) {
81  sheetSet = Sheet.createPropertiesSet();
82  sheet.put(sheetSet);
83  }
84 
85  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.name"),
86  NbBundle.getMessage(this.getClass(),
87  "VirtualDirectoryNode.createSheet.name.displayName"),
88  NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.name.desc"),
89  getName()));
90 
91  if (!this.content.isDataSource()) {
92  Map<String, Object> map = new LinkedHashMap<>();
93  fillPropertyMap(map, getContent());
94 
95  final String NO_DESCR = NbBundle.getMessage(this.getClass(), "VirtualDirectoryNode.createSheet.noDesc");
96  for (Map.Entry<String, Object> entry : map.entrySet()) {
97  sheetSet.put(new NodeProperty<>(entry.getKey(), entry.getKey(), NO_DESCR, entry.getValue()));
98  }
99  addTagProperty(sheetSet);
100  } else {
101  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_type_name(),
102  Bundle.VirtualDirectoryNode_createSheet_type_displayName(),
103  Bundle.VirtualDirectoryNode_createSheet_type_desc(),
104  Bundle.VirtualDirectoryNode_createSheet_type_text()));
105  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_size_name(),
106  Bundle.VirtualDirectoryNode_createSheet_size_displayName(),
107  Bundle.VirtualDirectoryNode_createSheet_size_desc(),
108  this.content.getSize()));
109  try (SleuthkitCase.CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) {
110  ResultSet timeZoneSet = query.getResultSet();
111  if (timeZoneSet.next()) {
112  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_timezone_name(),
113  Bundle.VirtualDirectoryNode_createSheet_timezone_displayName(),
114  Bundle.VirtualDirectoryNode_createSheet_timezone_desc(),
115  timeZoneSet.getString("time_zone")));
116  }
117  } catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
118  logger.log(Level.SEVERE, "Failed to get time zone for the following image: " + this.content.getId(), ex);
119  }
120  try (SleuthkitCase.CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
121  ResultSet deviceIdSet = query.getResultSet();
122  if (deviceIdSet.next()) {
123  sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_deviceId_name(),
124  Bundle.VirtualDirectoryNode_createSheet_deviceId_displayName(),
125  Bundle.VirtualDirectoryNode_createSheet_deviceId_desc(),
126  deviceIdSet.getString("device_id")));
127  }
128  } catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
129  logger.log(Level.SEVERE, "Failed to get device id for the following image: " + this.content.getId(), ex);
130  }
131 
132  }
133 
134  return sheet;
135  }
136 
137  @Override
138  public <T> T accept(ContentNodeVisitor<T> visitor) {
139  return visitor.visit(this);
140  }
141 
142  @Override
143  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
144  return visitor.visit(this);
145  }
146 }
static void fillPropertyMap(Map< String, Object > map, AbstractFile content)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static String nameForVirtualDirectory(VirtualDirectory ld)

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.