Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
GetFilesContentVisitor.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2018 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.ingest;
20 
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.logging.Level;
25 import org.sleuthkit.datamodel.AbstractContent;
26 import org.sleuthkit.datamodel.Content;
27 import org.sleuthkit.datamodel.ContentVisitor;
28 import org.sleuthkit.datamodel.Directory;
29 import org.sleuthkit.datamodel.AbstractFile;
30 import org.sleuthkit.datamodel.Image;
31 import org.sleuthkit.datamodel.VirtualDirectory;
32 import org.sleuthkit.datamodel.LocalDirectory;
33 import org.sleuthkit.datamodel.Report;
34 import org.sleuthkit.datamodel.TskException;
35 import org.sleuthkit.datamodel.Volume;
36 import org.sleuthkit.datamodel.VolumeSystem;
37 
41 abstract class GetFilesContentVisitor implements ContentVisitor<Collection<AbstractFile>> {
42 
43  private static final Logger logger = Logger.getLogger(GetFilesContentVisitor.class.getName());
44 
45  @Override
46  public Collection<AbstractFile> visit(VirtualDirectory ld) {
47  return getAllFromChildren(ld);
48  }
49 
50  @Override
51  public Collection<AbstractFile> visit(LocalDirectory ld) {
52  return getAllFromChildren(ld);
53  }
54 
55  @Override
56  public Collection<AbstractFile> visit(Directory drctr) {
57  return getAllFromChildren(drctr);
58  }
59 
60  @Override
61  public Collection<AbstractFile> visit(Image image) {
62  return getAllFromChildren(image);
63  }
64 
65  @Override
66  public Collection<AbstractFile> visit(Volume volume) {
67  return getAllFromChildren(volume);
68  }
69 
70  @Override
71  public Collection<AbstractFile> visit(VolumeSystem vs) {
72  return getAllFromChildren(vs);
73  }
74 
75  @Override
76  public Collection<AbstractFile> visit(Report r) {
77  return getAllFromChildren(r);
78  }
79 
88  protected Collection<AbstractFile> getAllFromChildren(Content parent) {
89  Collection<AbstractFile> all = new ArrayList<>();
90 
91  try {
92  for (Content child : parent.getChildren()) {
93  if (child instanceof AbstractContent){
94  all.addAll(child.accept(this));
95  }
96  }
97  } catch (TskException ex) {
98  logger.log(Level.SEVERE, "Error getting Content children", ex); //NON-NLS
99  }
100 
101  return all;
102  }
103 }

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