Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
CommonAttributeValueNode.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;
34 
40 
41  private final String value;
42  private final int commonFileCount;
43  private final String cases;
44  private final String dataSources;
45 
46  @NbBundle.Messages({
47  "CommonAttributeValueNode.CommonAttributeValueNode.format=Value: %s"
48  })
55  super(Children.create(
56  new FileInstanceNodeFactory(data), true));
57  this.commonFileCount = data.getInstanceCount();
58  this.cases = data.getCases();
59  this.dataSources = String.join(", ", data.getDataSources());
60  this.value = data.getValue();
61  //if the type is null (indicating intra-case) or files then make the node name the representitive file name
62  if (type == null || type.getId() == FILES_TYPE_ID) {
63  this.setDisplayName(data.getTokenFileName());
64  } else {
65  this.setDisplayName(String.format(Bundle.CommonAttributeValueNode_CommonAttributeValueNode_format(), this.value));
66  }
67  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
68  }
69 
75  int getCommonFileCount() {
76  return this.commonFileCount;
77  }
78 
79  String getCases() {
80  return this.cases;
81  }
82 
88  String getDataSources() {
89  return this.dataSources;
90  }
91 
97  public String getValue() {
98  return this.value;
99  }
100 
101  @NbBundle.Messages({
102  "ValueNode.createSheet.noDescription= "
103  })
104  @Override
105  protected Sheet createSheet() {
106  Sheet sheet = new Sheet();
107  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
108  if (sheetSet == null) {
109  sheetSet = Sheet.createPropertiesSet();
110  sheet.put(sheetSet);
111  }
112 
113  final String NO_DESCR = Bundle.ValueNode_createSheet_noDescription();
114  sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
115  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
116  sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, this.getDataSources()));
117 
118  return sheet;
119  }
120 
121  @Override
122  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
123  return visitor.visit(this);
124  }
125 
126  @Override
127  public boolean isLeafTypeNode() {
128  return false;
129  }
130 
131  @Override
132  public String getItemType() {
133  return getClass().getName();
134  }
135 
140  static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
141 
142  private final CommonAttributeValue descendants;
143 
144  FileInstanceNodeFactory(CommonAttributeValue descendants) {
145  this.descendants = descendants;
146  }
147 
148  @Override
149  protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
150  // This is a bit of a hack to ensure that the AbstractFile instance
151  // has been created before createNodesForKey() is called. Constructing
152  // the AbstractFile in createNodesForKey() was resulting in UI lockups.
153  this.descendants.getInstances().forEach((acai) -> {
154  acai.getAbstractFile();
155  });
156  list.addAll(this.descendants.getInstances());
157  return true;
158  }
159 
160  @Override
161  protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
162  return searchResult.generateNodes();
163  }
164 
165  }
166 }
CommonAttributeValueNode(CommonAttributeValue data, CorrelationAttributeInstance.Type type)
Collection< AbstractCommonAttributeInstance > getInstances()

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.