Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
InstanceDataSourceNode.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2018-2019 Basis Technology Corp.
6  * Contact: carrier <at> sleuthkit <dot> org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.sleuthkit.autopsy.commonpropertiessearch;
21 
22 import java.util.List;
23 import org.openide.nodes.ChildFactory;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Node;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle;
32 
34 
38 public final class InstanceDataSourceNode extends DisplayableItemNode {
39 
40  private static final Logger logger = Logger.getLogger(InstanceDataSourceNode.class.getName());
41 
42  final private String dataSourceName;
44 
53  public InstanceDataSourceNode(String dataSourceName, CommonAttributeValueList attributeValues) {
54  super(Children.create(new FileInstanceNodeFactory(attributeValues), true));
55 
56  this.dataSourceName = dataSourceName;
57  this.dataSourceToValueList = attributeValues;
58 
59  this.setDisplayName(this.dataSourceName);
60  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/image.png"); //NON-NLS
61  }
62 
68  String getDatasourceName() {
69  return this.dataSourceName;
70  }
71 
76  void createChildren() {
77  dataSourceToValueList.displayDelayedMetadata();
78  setChildren(Children.create(new FileInstanceNodeFactory(dataSourceToValueList), true));
79  }
80 
81  @Override
82  public boolean isLeafTypeNode() {
83  return false;
84  }
85 
86  @Override
87  public String getItemType() {
88  return getClass().getName();
89  }
90 
91  @Override
92  protected Sheet createSheet() {
93  Sheet sheet = new Sheet();
94  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
95  if (sheetSet == null) {
96  sheetSet = Sheet.createPropertiesSet();
97  sheet.put(sheetSet);
98  }
99  final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
100  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
101  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_localPath(), Bundle.CommonFilesSearchResultsViewerTable_localPath(), NO_DESCR, ""));
102  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NO_DESCR, ""));
103  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), Bundle.CommonFilesSearchResultsViewerTable_valueColLbl(), NO_DESCR, ""));
104  return sheet;
105  }
106 
107  @Override
108  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
109  return visitor.visit(this);
110  }
111 
115  static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
116 
117  private final CommonAttributeValueList descendants;
118 
119  FileInstanceNodeFactory(CommonAttributeValueList descendants) {
120  this.descendants = descendants;
121  }
122 
123  @Override
124  protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
125  for (CommonAttributeValue value : descendants.getDelayedMetadataSet()) {
126  // This is a bit of a hack to ensure that the AbstractFile instance
127  // has been created before createNodesForKey() is called. Constructing
128  // the AbstractFile in createNodesForKey() was resulting in UI lockups.
129  value.getInstances().forEach((acai) -> {
130  acai.getAbstractFile();
131  });
132 
133  list.addAll(value.getInstances());
134  }
135  return true;
136  }
137 
138  @Override
139  protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
140  return searchResult.generateNodes();
141  }
142 
143  }
144 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
InstanceDataSourceNode(String dataSourceName, CommonAttributeValueList attributeValues)

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