Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
RootContentChildren.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2019 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.Collection;
22 import java.util.Collections;
23 import org.openide.nodes.AbstractNode;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Node;
26 import org.openide.util.NbBundle;
30 import org.sleuthkit.datamodel.SleuthkitVisitableItem;
31 
36 public class RootContentChildren extends Children.Keys<Object> {
37 
38  private final Collection<? extends Object> contentKeys;
39  private final CreateAutopsyNodeVisitor createAutopsyNodeVisitor = new CreateAutopsyNodeVisitor();
41 
45  public RootContentChildren(Collection<? extends Object> contentKeys) {
46  super();
47  this.contentKeys = contentKeys;
48  }
49 
50  @Override
51  protected void addNotify() {
52  setKeys(contentKeys);
53  }
54 
55  @Override
56  protected void removeNotify() {
57  setKeys(Collections.<Object>emptySet());
58  }
59 
66  public void refreshContentKeys() {
67  contentKeys.forEach(this::refreshKey);
68  }
69 
70  @Override
71  protected Node[] createNodes(Object key) {
72  if (key instanceof AutopsyVisitableItem) {
73  return new Node[]{((AutopsyVisitableItem) key).accept(createAutopsyNodeVisitor)};
74  } else {
75  return new Node[]{((SleuthkitVisitableItem) key).accept(createSleuthkitNodeVisitor)};
76  }
77  }
78 
86  static class CreateAutopsyNodeVisitor extends AutopsyItemVisitor.Default<AbstractNode> {
87 
88  @Override
89  public AbstractNode visit(FileTypesByExtension sf) {
90  return sf.new FileTypesByExtNode(sf.getSleuthkitCase(), null);
91  }
92 
93  @Override
94  public AbstractNode visit(RecentFiles rf) {
95  return new RecentFilesNode(rf.getSleuthkitCase());
96  }
97 
98  @Override
99  public AbstractNode visit(DeletedContent dc) {
100  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase(), dc.filteringDataSourceObjId());
101  }
102 
103  @Override
104  public AbstractNode visit(ScoreContent sc) {
105  return new ScoreContent.ScoreContentsNode(sc.getSleuthkitCase(), sc.filteringDataSourceObjId());
106  }
107 
108  @Override
109  public AbstractNode visit(FileSize dc) {
110  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase(), dc.filteringDataSourceObjId());
111  }
112 
113  @Override
114  public AbstractNode visit(KeywordHits kh) {
115  return kh.new RootNode();
116  }
117 
118  @Override
119  public AbstractNode visit(HashsetHits hh) {
120  return hh.new RootNode();
121  }
122 
123  @Override
124  public AbstractNode visit(InterestingHits ih) {
125  return ih.new RootNode();
126  }
127 
128  @Override
129  public AbstractNode visit(EmailExtracted ee) {
130  return ee.new RootNode();
131  }
132 
133  @Override
134  public AbstractNode visit(Tags tagsNodeKey) {
135  return tagsNodeKey.new RootNode(tagsNodeKey.filteringDataSourceObjId());
136  }
137 
138  @Override
139  public AbstractNode visit(DataSources i) {
140  return new DataSourceFilesNode(i.filteringDataSourceObjId());
141  }
142 
143  @Override
144  public AbstractNode visit(DataSourceGrouping datasourceGrouping) {
145  return new DataSourceGroupingNode(datasourceGrouping.getDataSource());
146  }
147 
148  @Override
149  public AbstractNode visit(Views v) {
150  return new ViewsNode(v.getSleuthkitCase(), v.filteringDataSourceObjId());
151  }
152 
153  @Override
154  public AbstractNode visit(FileTypes ft) {
155  return ft.new FileTypesNode();
156  }
157 
158  @Override
159  public AbstractNode visit(Reports reportsItem) {
160  return new Reports.ReportsListNode();
161  }
162 
163  @Override
164  public AbstractNode visit(Accounts accountsItem) {
165  return accountsItem.new AccountsRootNode();
166  }
167 
168  @Override
169  public AbstractNode visit(OsAccounts osAccountsItem) {
170  return osAccountsItem.new OsAccountListNode();
171  }
172 
173  @Override
174  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
175  throw new UnsupportedOperationException(
176  NbBundle.getMessage(this.getClass(),
177  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
178  }
179 
180  @Override
181  public AbstractNode visit(FileTypesByMimeType ftByMimeTypeItem) {
182  return ftByMimeTypeItem.new ByMimeTypeNode();
183  }
184 
185  @Override
186  public AbstractNode visit(PersonGrouping personGrouping) {
187  return new PersonNode(personGrouping.getPerson());
188  }
189 
190  @Override
191  public AbstractNode visit(HostDataSources hosts) {
192  return new HostNode(hosts);
193  }
194 
195  @Override
196  public AbstractNode visit(HostGrouping hostGrouping) {
197  return new HostNode(hostGrouping);
198  }
199 
200  @Override
201  public AbstractNode visit(DataSourcesByType dataSourceHosts) {
202  return new DataSourcesNode();
203  }
204 
205  @Override
206  public AbstractNode visit(AnalysisResults analysisResults) {
207  return new AnalysisResults.RootNode(
208  analysisResults.getFilteringDataSourceObjId());
209  }
210 
211  @Override
212  public AbstractNode visit(DataArtifacts dataArtifacts) {
213  return new DataArtifacts.RootNode(
214  dataArtifacts.getFilteringDataSourceObjId());
215  }
216  }
217 }
RootContentChildren(Collection<?extends Object > contentKeys)
final CreateSleuthkitNodeVisitor createSleuthkitNodeVisitor

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.