Autopsy 4.22.1
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 */
20package org.sleuthkit.autopsy.commonpropertiessearch;
21
22import java.util.List;
23import org.openide.nodes.ChildFactory;
24import org.openide.nodes.Children;
25import org.openide.nodes.Node;
26import org.openide.nodes.Sheet;
27import org.openide.util.NbBundle;
28import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
29import static org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.FILES_TYPE_ID;
30import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode;
31import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
32import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
33import org.sleuthkit.autopsy.datamodel.NodeProperty;
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 })
56 super(Children.create(
57 new FileInstanceNodeFactory(data), true));
58 this.commonFileCount = data.getInstanceCount();
59 this.cases = data.getCases();
60 this.dataSources = String.join(", ", data.getDataSources());
61 this.value = data.getValue();
62 //if the type is null (indicating intra-case) or files then make the node name the representitive file name
63 if (type == null || type.getId() == FILES_TYPE_ID) {
64 this.setDisplayName(data.getTokenFileName());
65 } else {
66 this.setDisplayName(String.format(Bundle.CommonAttributeValueNode_CommonAttributeValueNode_format(), this.value));
67 }
68 this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
69 }
70
76 int getCommonFileCount() {
77 return this.commonFileCount;
78 }
79
80 String getCases() {
81 return this.cases;
82 }
83
89 String getDataSources() {
90 return this.dataSources;
91 }
92
98 public String getValue() {
99 return this.value;
100 }
101
102 @NbBundle.Messages({
103 "ValueNode.createSheet.noDescription= "
104 })
105 @Override
106 protected Sheet createSheet() {
107 Sheet sheet = new Sheet();
108 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
109 if (sheetSet == null) {
110 sheetSet = Sheet.createPropertiesSet();
111 sheet.put(sheetSet);
112 }
113
114 final String NO_DESCR = Bundle.ValueNode_createSheet_noDescription();
115 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
116 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
117 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, this.getDataSources()));
118
119 return sheet;
120 }
121
122 @Override
123 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
124 return visitor.visit(this);
125 }
126
127 @Override
128 public boolean isLeafTypeNode() {
129 return false;
130 }
131
132 @Override
133 public String getItemType() {
134 return getClass().getName();
135 }
136
141 static class FileInstanceNodeFactory extends ChildFactory<AbstractCommonAttributeInstance> {
142
143 private final CommonAttributeValue descendants;
144
145 FileInstanceNodeFactory(CommonAttributeValue descendants) {
146 this.descendants = descendants;
147 }
148
149 @Override
150 protected boolean createKeys(List<AbstractCommonAttributeInstance> list) {
151 // This is a bit of a hack to ensure that the AbstractFile instance
152 // has been created before createNodesForKey() is called. Constructing
153 // the AbstractFile in createNodesForKey() was resulting in UI lockups.
154 this.descendants.getInstances().forEach((acai) -> {
155 acai.getAbstractFile();
156 });
157 list.addAll(this.descendants.getInstances());
158 return true;
159 }
160
161 @Override
162 protected Node[] createNodesForKey(AbstractCommonAttributeInstance searchResult) {
163 return searchResult.generateNodes();
164 }
165
166 }
167}
CommonAttributeValueNode(CommonAttributeValue data, CorrelationAttributeInstance.Type type)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.