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;
28 import org.sleuthkit.datamodel.Content;
29 import org.sleuthkit.datamodel.DerivedFile;
30 import org.sleuthkit.datamodel.Directory;
31 import org.sleuthkit.datamodel.File;
32 import org.sleuthkit.datamodel.Image;
33 import org.sleuthkit.datamodel.LayoutFile;
34 import org.sleuthkit.datamodel.LocalFile;
35 import org.sleuthkit.datamodel.SlackFile;
36 import org.sleuthkit.datamodel.SleuthkitItemVisitor;
37 import org.sleuthkit.datamodel.SleuthkitVisitableItem;
38 import org.sleuthkit.datamodel.VirtualDirectory;
39 import org.sleuthkit.datamodel.Volume;
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  super(true); // use lazy behavior
55  }
56 
57  @Override
58  protected Node[] createNodes(T key) {
59  if (key instanceof SleuthkitVisitableItem) {
60  return new Node[]{((SleuthkitVisitableItem) key).accept(createSleuthkitNodeVisitor)};
61  } else {
62  return new Node[]{((AutopsyVisitableItem) key).accept(createAutopsyNodeVisitor)};
63  }
64  }
65 
69  public static class CreateSleuthkitNodeVisitor extends SleuthkitItemVisitor.Default<AbstractContentNode<? extends Content>> {
70 
71  @Override
73  return new DirectoryNode(drctr);
74  }
75 
76  @Override
78  return new FileNode(file);
79  }
80 
81  @Override
83  return new ImageNode(image);
84  }
85 
86  @Override
88  return new VolumeNode(volume);
89  }
90 
91  @Override
93  return new LayoutFileNode(lf);
94  }
95 
96  @Override
98  return new LocalFileNode(df);
99  }
100 
101  @Override
103  return new LocalFileNode(lf);
104  }
105 
106  @Override
107  public AbstractContentNode<? extends Content> visit(VirtualDirectory ld) {
108  return new VirtualDirectoryNode(ld);
109  }
110 
111  @Override
113  return new SlackFileNode(sf);
114  }
115 
116  @Override
117  protected AbstractContentNode<? extends Content> defaultVisit(SleuthkitVisitableItem di) {
118  throw new UnsupportedOperationException(NbBundle.getMessage(this.getClass(),
119  "AbstractContentChildren.CreateTSKNodeVisitor.exception.noNodeMsg"));
120  }
121  }
122 
130  static class CreateAutopsyNodeVisitor extends AutopsyItemVisitor.Default<AbstractNode> {
131 
132  @Override
133  public ExtractedContent.RootNode visit(ExtractedContent ec) {
134  return ec.new RootNode(ec.getSleuthkitCase());
135  }
136 
137  @Override
138  public AbstractNode visit(FileTypesByExtension sf) {
139  return new org.sleuthkit.autopsy.datamodel.FileTypesByExtension.FileTypesByExtNode(sf.getSleuthkitCase(), null);
140  }
141 
142  @Override
143  public AbstractNode visit(RecentFiles rf) {
144  return new RecentFilesNode(rf.getSleuthkitCase());
145  }
146 
147  @Override
148  public AbstractNode visit(DeletedContent dc) {
149  return new DeletedContent.DeletedContentsNode(dc.getSleuthkitCase());
150  }
151 
152  @Override
153  public AbstractNode visit(FileSize dc) {
154  return new FileSize.FileSizeRootNode(dc.getSleuthkitCase());
155  }
156 
157  @Override
158  public AbstractNode visit(KeywordHits kh) {
159  return kh.new RootNode();
160  }
161 
162  @Override
163  public AbstractNode visit(HashsetHits hh) {
164  return hh.new RootNode();
165  }
166 
167  @Override
168  public AbstractNode visit(InterestingHits ih) {
169  return ih.new RootNode();
170  }
171 
172  @Override
173  public AbstractNode visit(EmailExtracted ee) {
174  return ee.new RootNode();
175  }
176 
177  @Override
178  public AbstractNode visit(Tags tagsNodeKey) {
179  return tagsNodeKey.new RootNode();
180  }
181 
182  @Override
183  public AbstractNode visit(DataSources i) {
184  return new DataSourcesNode();
185  }
186 
187  @Override
188  public AbstractNode visit(Views v) {
189  return new ViewsNode(v.getSleuthkitCase());
190  }
191 
192  @Override
193  public AbstractNode visit(Results r) {
194  return new ResultsNode(r.getSleuthkitCase());
195  }
196 
197  @Override
198  public AbstractNode visit(FileTypes ft) {
199  return new FileTypesNode(ft.getSleuthkitCase());
200  }
201 
202  @Override
203  public AbstractNode visit(Reports reportsItem) {
204  return new Reports.ReportsListNode();
205  }
206 
207  @Override
208  public AbstractNode visit(Accounts accountsItem) {
209  return accountsItem.new AccountsRootNode();
210  }
211 
212  @Override
213  protected AbstractNode defaultVisit(AutopsyVisitableItem di) {
214  throw new UnsupportedOperationException(
215  NbBundle.getMessage(this.getClass(),
216  "AbstractContentChildren.createAutopsyNodeVisitor.exception.noNodeMsg"));
217  }
218 
219  @Override
220  public AbstractNode visit(FileTypesByMimeType ftByMimeTypeItem) {
221  return ftByMimeTypeItem.new ByMimeTypeNode();
222  }
223  }
224 }
AbstractContentNode<?extends Content > defaultVisit(SleuthkitVisitableItem di)

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