Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
VolumeNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.List;
25 import javax.swing.Action;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
34 import org.sleuthkit.datamodel.Content;
35 import org.sleuthkit.datamodel.TskCoreException;
36 import org.sleuthkit.datamodel.VirtualDirectory;
37 import org.sleuthkit.datamodel.Volume;
38 
43 public class VolumeNode extends AbstractContentNode<Volume> {
44 
53  static String nameForVolume(Volume vol) {
54  return "vol" + Long.toString(vol.getAddr()); //NON-NLS
55  }
56 
61  public VolumeNode(Volume vol) {
62  super(vol);
63 
64  // set name, display name, and icon
65  String volName = nameForVolume(vol);
66 
67  long end = vol.getStart() + (vol.getLength() - 1);
68  String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")";
69  this.setDisplayName(tempVolName);
70 
71  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/vol-icon.png"); //NON-NLS
72  // Listen for ingest events so that we can detect new added files (e.g. carved)
74  // Listen for case events so that we can detect when case is closed
76  }
77 
78  private void removeListeners() {
81  }
82 
83  private final PropertyChangeListener pcl = (PropertyChangeEvent evt) -> {
84  String eventType = evt.getPropertyName();
85 
86  // See if the new file is a child of ours
87  if (eventType.equals(IngestManager.IngestModuleEvent.CONTENT_CHANGED.toString())) {
88  if ((evt.getOldValue() instanceof ModuleContentEvent) == false) {
89  return;
90  }
91  ModuleContentEvent moduleContentEvent = (ModuleContentEvent) evt.getOldValue();
92  if ((moduleContentEvent.getSource() instanceof Content) == false) {
93  return;
94  }
95  Content newContent = (Content) moduleContentEvent.getSource();
96 
97  try {
98  Content parent = newContent.getParent();
99  if (parent != null) {
100  // Is this a new carved file?
101  if (parent.getName().equals(VirtualDirectory.NAME_CARVED)) {
102  // Was this new carved file produced from this volume?
103  if (parent.getParent().getId() == getContent().getId()) {
104  Children children = getChildren();
105  if (children != null) {
106  ((ContentChildren) children).refreshChildren();
107  children.getNodesCount();
108  }
109  }
110  }
111  }
112  } catch (TskCoreException ex) {
113  // Do nothing.
114  }
115  } else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
116  if (evt.getNewValue() == null) {
117  // case was closed. Remove listeners so that we don't get called with a stale case handle
118  removeListeners();
119  }
120  }
121  };
122 
130  @Override
131  public Action[] getActions(boolean popup) {
132  List<Action> actionsList = new ArrayList<>();
133 
134  for (Action a : super.getActions(true)) {
135  actionsList.add(a);
136  }
137 
138  actionsList.add(new NewWindowViewAction(
139  NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this));
140  actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
141 
142  return actionsList.toArray(new Action[0]);
143  }
144 
145  @Override
146  protected Sheet createSheet() {
147  Sheet s = super.createSheet();
148  Sheet.Set ss = s.get(Sheet.PROPERTIES);
149  if (ss == null) {
150  ss = Sheet.createPropertiesSet();
151  s.put(ss);
152  }
153 
154  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.name"),
155  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.displayName"),
156  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.desc"),
157  this.getDisplayName()));
158  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.name"),
159  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.displayName"),
160  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.desc"),
161  content.getAddr()));
162  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.name"),
163  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.displayName"),
164  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.desc"),
165  content.getStart()));
166  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.name"),
167  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.displayName"),
168  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.desc"),
169  content.getLength()));
170  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.name"),
171  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.displayName"),
172  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.desc"),
173  content.getDescription()));
174  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.name"),
175  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.displayName"),
176  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.desc"),
177  content.getFlagsAsString()));
178 
179  return s;
180  }
181 
182  @Override
183  public <T> T accept(ContentNodeVisitor<T> v) {
184  return v.visit(this);
185  }
186 
187  @Override
188  public boolean isLeafTypeNode() {
189  return false;
190  }
191 
192  @Override
193  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
194  return v.visit(this);
195  }
196 
197  /*
198  * TODO (AUT-1849): Correct or remove peristent column reordering code
199  *
200  * Added to support this feature.
201  */
202 // @Override
203 // public String getItemType() {
204 // return "Volume"; //NON-NLS
205 // }
206 }
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized IngestManager getInstance()
static void removePropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:318
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:306
final PropertyChangeListener pcl
Definition: VolumeNode.java:83
void addIngestModuleEventListener(final PropertyChangeListener listener)

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.