Autopsy  4.0
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  actionsList.add(new NewWindowViewAction(
135  NbBundle.getMessage(this.getClass(), "VolumeNode.getActions.viewInNewWin.text"), this));
136  actionsList.addAll(ExplorerNodeActionVisitor.getActions(content));
137 
138  return actionsList.toArray(new Action[0]);
139  }
140 
141  @Override
142  protected Sheet createSheet() {
143  Sheet s = super.createSheet();
144  Sheet.Set ss = s.get(Sheet.PROPERTIES);
145  if (ss == null) {
146  ss = Sheet.createPropertiesSet();
147  s.put(ss);
148  }
149 
150  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.name"),
151  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.displayName"),
152  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.name.desc"),
153  this.getDisplayName()));
154  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.name"),
155  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.displayName"),
156  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.id.desc"),
157  content.getAddr()));
158  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.name"),
159  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.displayName"),
160  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.startSector.desc"),
161  content.getStart()));
162  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.name"),
163  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.displayName"),
164  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.lenSectors.desc"),
165  content.getLength()));
166  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.name"),
167  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.displayName"),
168  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.description.desc"),
169  content.getDescription()));
170  ss.put(new NodeProperty<>(NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.name"),
171  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.displayName"),
172  NbBundle.getMessage(this.getClass(), "VolumeNode.createSheet.flags.desc"),
173  content.getFlagsAsString()));
174 
175  return s;
176  }
177 
178  @Override
179  public <T> T accept(ContentNodeVisitor<T> v) {
180  return v.visit(this);
181  }
182 
183  @Override
184  public boolean isLeafTypeNode() {
185  return false;
186  }
187 
188  @Override
189  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
190  return v.visit(this);
191  }
192 
193  /*
194  * TODO (AUT-1849): Correct or remove peristent column reordering code
195  *
196  * Added to support this feature.
197  */
198 // @Override
199 // public String getItemType() {
200 // return "Volume"; //NON-NLS
201 // }
202 }
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized IngestManager getInstance()
final PropertyChangeListener pcl
Definition: VolumeNode.java:83
static synchronized void removePropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:1305
void addIngestModuleEventListener(final PropertyChangeListener listener)
static synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:1292

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.