Autopsy  4.12.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 ExtractedContent.RootNode visit(ExtractedContent ec) {
88  return ec.new RootNode(ec.getSleuthkitCase());
89  }
90 
91  @Override
92  public AbstractNode visit(FileTypesByExtension sf) {
93  return sf.new FileTypesByExtNode(sf.getSleuthkitCase(), null);
94  }
95 
96  @Override
97  public AbstractNode visit(RecentFiles rf) {
98  return new RecentFilesNode(rf.getSleuthkitCase());
99  }
100 
101  @Override
102  public AbstractNode visit(DeletedContent dc) {
103  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase(), dc.filteringDataSourceObjId());
104  }
105 
106  @Override
107  public AbstractNode visit(FileSize dc) {
108  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase(), dc.filteringDataSourceObjId());
109  }
110 
111  @Override
112  public AbstractNode visit(KeywordHits kh) {
113  return kh.new RootNode();
114  }
115 
116  @Override
117  public AbstractNode visit(HashsetHits hh) {
118  return hh.new RootNode();
119  }
120 
121  @Override
122  public AbstractNode visit(InterestingHits ih) {
123  return ih.new RootNode();
124  }
125 
126  @Override
127  public AbstractNode visit(EmailExtracted ee) {
128  return ee.new RootNode();
129  }
130 
131  @Override
132  public AbstractNode visit(Tags tagsNodeKey) {
133  return tagsNodeKey.new RootNode(tagsNodeKey.filteringDataSourceObjId());
134  }
135 
136  @Override
137  public AbstractNode visit(DataSources i) {
138  return new DataSourcesNode(i.filteringDataSourceObjId());
139  }
140 
141  @Override
142  public AbstractNode visit(DataSourceGrouping datasourceGrouping) {
143  return new DataSourceGroupingNode(datasourceGrouping.getDataSource());
144  }
145 
146  @Override
147  public AbstractNode visit(Views v) {
148  return new ViewsNode(v.getSleuthkitCase(), v.filteringDataSourceObjId());
149  }
150 
151  @Override
152  public AbstractNode visit(Results results) {
153  return new ResultsNode(results.getSleuthkitCase(), results.filteringDataSourceObjId() );
154  }
155 
156  @Override
157  public AbstractNode visit(FileTypes ft) {
158  return ft.new FileTypesNode();
159  }
160 
161  @Override
162  public AbstractNode visit(Reports reportsItem) {
163  return new Reports.ReportsListNode();
164  }
165 
166  @Override
167  public AbstractNode visit(Accounts accountsItem) {
168  return accountsItem.new AccountsRootNode();
169  }
170 
171  @Override
172  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
173  throw new UnsupportedOperationException(
174  NbBundle.getMessage(this.getClass(),
175  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
176  }
177 
178  @Override
179  public AbstractNode visit(FileTypesByMimeType ftByMimeTypeItem) {
180  return ftByMimeTypeItem.new ByMimeTypeNode();
181  }
182  }
183 }
RootContentChildren(Collection<?extends Object > contentKeys)
final CreateSleuthkitNodeVisitor createSleuthkitNodeVisitor

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