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

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.