Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FileInstanceNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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.util.LinkedHashMap;
22 import java.util.Map;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.NbBundle;
26 import org.sleuthkit.datamodel.AbstractFile;
27 
32 public class FileInstanceNode extends FileNode {
33 
34  private final String dataSource;
35 
36  public FileInstanceNode(AbstractFile fsContent, String dataSource) {
37  super(fsContent);
38  this.content = fsContent;
39  this.dataSource = dataSource;
40  }
41 
42  @Override
43  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
44  return visitor.visit(this);
45  }
46 
47  @Override
48  public AbstractFile getContent() {
49  return this.content;
50  }
51 
52  String getDataSource() {
53  return this.dataSource;
54  }
55 
56  @Override
57  protected Sheet createSheet() {
58  Sheet sheet = new Sheet();
59  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
60  if (sheetSet == null) {
61  sheetSet = Sheet.createPropertiesSet();
62  sheet.put(sheetSet);
63  }
64 
65  Map<String, Object> map = new LinkedHashMap<>();
66  fillPropertyMap(map, this);
67 
68  final String NO_DESCR = Bundle.AbstractFsContentNode_noDesc_text();
69  for (CommonFilePropertyType propType : CommonFilePropertyType.values()) {
70  final String propString = propType.toString();
71  final Object property = map.get(propString);
72  final NodeProperty<Object> nodeProperty = new NodeProperty<>(propString, propString, NO_DESCR, property);
73  sheetSet.put(nodeProperty);
74  }
75 
76  this.addTagProperty(sheetSet);
77 
78  return sheet;
79  }
80 
88  static private void fillPropertyMap(Map<String, Object> map, FileInstanceNode node) {
89 
90  map.put(CommonFilePropertyType.File.toString(), node.getName());
91  map.put(CommonFilePropertyType.ParentPath.toString(), node.getContent().getParentPath());
92  map.put(CommonFilePropertyType.HashsetHits.toString(), getHashSetHitsForFile(node.getContent()));
93  map.put(CommonFilePropertyType.DataSource.toString(), node.getDataSource());
94  map.put(CommonFilePropertyType.MimeType.toString(), StringUtils.defaultString(node.content.getMIMEType()));
95  }
96 
101  @NbBundle.Messages({
102  "CommonFilePropertyType.fileColLbl=File",
103  "CommonFilePropertyType.pathColLbl=Parent Path",
104  "CommonFilePropertyType.hashsetHitsColLbl=Hash Set Hits",
105  "CommonFilePropertyType.dataSourceColLbl=Data Source",
106  "CommonFilePropertyType.mimeTypeColLbl=MIME Type"
107  })
109 
110  File(Bundle.CommonFilePropertyType_fileColLbl()),
111  ParentPath(Bundle.CommonFilePropertyType_pathColLbl()),
112  HashsetHits(Bundle.CommonFilePropertyType_hashsetHitsColLbl()),
113  DataSource(Bundle.CommonFilePropertyType_dataSourceColLbl()),
114  MimeType(Bundle.CommonFilePropertyType_mimeTypeColLbl());
115 
116  final private String displayString;
117 
118  private CommonFilePropertyType(String displayString) {
119  this.displayString = displayString;
120  }
121 
122  @Override
123  public String toString() {
124  return displayString;
125  }
126  }
127 }
FileInstanceNode(AbstractFile fsContent, String dataSource)
static void fillPropertyMap(Map< String, Object > map, FileInstanceNode node)

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.