19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.EnumSet;
28 import java.util.List;
29 import java.util.logging.Level;
30 import javax.swing.Action;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
46 import org.
sleuthkit.datamodel.SleuthkitCase.CaseDbQuery;
66 static String nameForImage(Image i) {
77 String imgName = nameForImage(img);
78 this.setDisplayName(imgName);
79 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/hard-drive-icon.jpg");
100 @Messages({
"ImageNode.action.runIngestMods.text=Run Ingest Modules",
101 "ImageNode.getActions.openFileSearchByAttr.text=Open File Search by Attributes",})
104 List<Action> actionsList =
new ArrayList<>();
105 for (Action a : super.getActions(
true)) {
110 Bundle.ImageNode_getActions_openFileSearchByAttr_text()));
113 NbBundle.getMessage(
this.getClass(),
"ImageNode.getActions.viewInNewWin.text"),
this));
114 return actionsList.toArray(
new Action[0]);
118 @Messages({
"ImageNode.createSheet.size.name=Size (Bytes)",
119 "ImageNode.createSheet.size.displayName=Size (Bytes)",
120 "ImageNode.createSheet.size.desc=Size of the data source in bytes.",
121 "ImageNode.createSheet.type.name=Type",
122 "ImageNode.createSheet.type.displayName=Type",
123 "ImageNode.createSheet.type.desc=Type of the image.",
124 "ImageNode.createSheet.type.text=Image",
125 "ImageNode.createSheet.sectorSize.name=Sector Size (Bytes)",
126 "ImageNode.createSheet.sectorSize.displayName=Sector Size (Bytes)",
127 "ImageNode.createSheet.sectorSize.desc=Sector size of the image in bytes.",
128 "ImageNode.createSheet.md5.name=MD5 Hash",
129 "ImageNode.createSheet.md5.displayName=MD5 Hash",
130 "ImageNode.createSheet.md5.desc=MD5 Hash of the image",
131 "ImageNode.createSheet.timezone.name=Timezone",
132 "ImageNode.createSheet.timezone.displayName=Timezone",
133 "ImageNode.createSheet.timezone.desc=Timezone of the image",
134 "ImageNode.createSheet.deviceId.name=Device ID",
135 "ImageNode.createSheet.deviceId.displayName=Device ID",
136 "ImageNode.createSheet.deviceId.desc=Device ID of the image"})
138 Sheet sheet = super.createSheet();
139 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
140 if (sheetSet == null) {
141 sheetSet = Sheet.createPropertiesSet();
145 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ImageNode.createSheet.name.name"),
146 NbBundle.getMessage(
this.getClass(),
"ImageNode.createSheet.name.displayName"),
147 NbBundle.getMessage(
this.getClass(),
"ImageNode.createSheet.name.desc"),
150 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_type_name(),
151 Bundle.ImageNode_createSheet_type_displayName(),
152 Bundle.ImageNode_createSheet_type_desc(),
153 Bundle.ImageNode_createSheet_type_text()));
155 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_size_name(),
156 Bundle.ImageNode_createSheet_size_displayName(),
157 Bundle.ImageNode_createSheet_size_desc(),
158 this.content.getSize()));
159 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_sectorSize_name(),
160 Bundle.ImageNode_createSheet_sectorSize_displayName(),
161 Bundle.ImageNode_createSheet_sectorSize_desc(),
162 this.content.getSsize()));
164 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_md5_name(),
165 Bundle.ImageNode_createSheet_md5_displayName(),
166 Bundle.ImageNode_createSheet_md5_desc(),
167 this.content.getMd5()));
169 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_timezone_name(),
170 Bundle.ImageNode_createSheet_timezone_displayName(),
171 Bundle.ImageNode_createSheet_timezone_desc(),
172 this.content.getTimeZone()));
175 ResultSet deviceIdSet = query.getResultSet();
176 if (deviceIdSet.next()) {
177 sheetSet.put(
new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(),
178 Bundle.ImageNode_createSheet_deviceId_displayName(),
179 Bundle.ImageNode_createSheet_deviceId_desc(),
180 deviceIdSet.getString(
"device_id")));
183 logger.log(Level.SEVERE,
"Failed to get device id for the following image: " +
this.content.getId(), ex);
190 public <T> T accept(ContentNodeVisitor<T> visitor) {
191 return visitor.visit(
this);
201 return visitor.
visit(
this);
206 return getClass().getName();
214 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
215 String eventType = evt.getPropertyName();
223 if ((moduleContentEvent.getSource() instanceof Content) ==
false) {
226 Content newContent = (Content) moduleContentEvent.getSource();
229 Content parent = newContent.getParent();
230 if (parent != null) {
232 if (parent.getName().equals(VirtualDirectory.NAME_CARVED)) {
234 if (parent.getParent().getId() ==
getContent().getId()) {
235 Children children = getChildren();
236 if (children != null) {
237 ((ContentChildren) children).refreshChildren();
238 children.getNodesCount();
243 }
catch (TskCoreException ex) {
247 if (evt.getNewValue() == null) {
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized IngestManager getInstance()
static List< Action > getActions(Content c)
Action[] getActions(boolean context)
T visit(DataSourcesNode in)
SleuthkitCase getSleuthkitCase()
final PropertyChangeListener pcl
static final Logger logger
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)