Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractContentChildren.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 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 org.openide.nodes.AbstractNode;
22 import org.openide.nodes.Children.Keys;
23 import org.openide.nodes.Node;
24 import org.openide.util.NbBundle;
40 
45 abstract class AbstractContentChildren<T> extends Keys<T> {
46 
47  private final CreateSleuthkitNodeVisitor createSleuthkitNodeVisitor = new CreateSleuthkitNodeVisitor();
48  private final CreateAutopsyNodeVisitor createAutopsyNodeVisitor = new CreateAutopsyNodeVisitor();
49 
53  AbstractContentChildren() {
54  /*This was turned off because we were getting out of memory errors when the
55  filter nodes were hiding nodes. Turning this off seemed to help */
56  super(false); //don't use lazy behavior
57  }
58 
59  @Override
60  protected Node[] createNodes(T key) {
61  if (key instanceof SleuthkitVisitableItem) {
62  return new Node[]{((SleuthkitVisitableItem) key).accept(createSleuthkitNodeVisitor)};
63  } else {
64  return new Node[]{((AutopsyVisitableItem) key).accept(createAutopsyNodeVisitor)};
65  }
66  }
67 
71  public static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default<AbstractContentNode<? extends Content>> {
72 
73  @Override
75  return new DirectoryNode(drctr);
76  }
77 
78  @Override
80  return new FileNode(file);
81  }
82 
83  @Override
85  return new ImageNode(image);
86  }
87 
88  @Override
90  return new VolumeNode(volume);
91  }
92 
93  @Override
95  return new LayoutFileNode(lf);
96  }
97 
98  @Override
100  return new LocalFileNode(df);
101  }
102 
103  @Override
105  return new LocalFileNode(lf);
106  }
107 
108  @Override
110  return new VirtualDirectoryNode(ld);
111  }
112 
113  @Override
115  return new SlackFileNode(sf);
116  }
117 
118  @Override
119  protected AbstractContentNode<? extends Content> defaultVisit(SleuthkitVisitableItem di) {
120  throw new UnsupportedOperationException(NbBundle.getMessage(this.getClass(),
121  "AbstractContentChildren.CreateTSKNodeVisitor.exception.noNodeMsg"));
122  }
123  }
124 
132  static class CreateAutopsyNodeVisitor extends AutopsyItemVisitor.Default<AbstractNode> {
133 
134  @Override
135  public ExtractedContent.RootNode visit(ExtractedContent ec) {
136  return ec.new RootNode(ec.getSleuthkitCase());
137  }
138 
139  @Override
140  public AbstractNode visit(FileTypesByExtension sf) {
141  return new org.sleuthkit.autopsy.datamodel.FileTypesByExtension.FileTypesByExtNode(sf.getSleuthkitCase(), null);
142  }
143 
144  @Override
145  public AbstractNode visit(RecentFiles rf) {
146  return new RecentFilesNode(rf.getSleuthkitCase());
147  }
148 
149  @Override
150  public AbstractNode visit(DeletedContent dc) {
151  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase());
152  }
153 
154  @Override
155  public AbstractNode visit(FileSize dc) {
156  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase());
157  }
158 
159  @Override
160  public AbstractNode visit(KeywordHits kh) {
161  return kh.new RootNode();
162  }
163 
164  @Override
165  public AbstractNode visit(HashsetHits hh) {
166  return hh.new RootNode();
167  }
168 
169  @Override
170  public AbstractNode visit(InterestingHits ih) {
171  return ih.new RootNode();
172  }
173 
174  @Override
175  public AbstractNode visit(EmailExtracted ee) {
176  return ee.new RootNode();
177  }
178 
179  @Override
180  public AbstractNode visit(Tags tagsNodeKey) {
181  return tagsNodeKey.new RootNode();
182  }
183 
184  @Override
185  public AbstractNode visit(DataSources i) {
186  return new DataSourcesNode();
187  }
188 
189  @Override
190  public AbstractNode visit(Views v) {
191  return new ViewsNode(v.getSleuthkitCase());
192  }
193 
194  @Override
195  public AbstractNode visit(Results r) {
196  return new ResultsNode(r.getSleuthkitCase());
197  }
198 
199  @Override
200  public AbstractNode visit(FileTypes ft) {
201  return new FileTypesNode(ft.getSleuthkitCase());
202  }
203 
204  @Override
205  public AbstractNode visit(Reports reportsItem) {
206  return new Reports.ReportsListNode();
207  }
208 
209  @Override
210  public AbstractNode visit(Accounts accountsItem) {
211  return accountsItem.new AccountsRootNode();
212  }
213 
214  @Override
215  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
216  throw new UnsupportedOperationException(
217  NbBundle.getMessage(this.getClass(),
218  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
219  }
220 
221  @Override
222  public AbstractNode visit(FileTypesByMimeType ftByMimeTypeItem) {
223  return ftByMimeTypeItem.new ByMimeTypeNode();
224  }
225  }
226 }
AbstractContentNode<?extends Content > defaultVisit(SleuthkitVisitableItem di)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.