Autopsy  4.1
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-2014 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.Content;
26 import org.sleuthkit.datamodel.ContentVisitor;
27 import org.sleuthkit.datamodel.Directory;
28 import org.sleuthkit.datamodel.AbstractFile;
29 import org.sleuthkit.datamodel.Image;
30 import org.sleuthkit.datamodel.VirtualDirectory;
31 import org.sleuthkit.datamodel.TskException;
32 import org.sleuthkit.datamodel.Volume;
33 import org.sleuthkit.datamodel.VolumeSystem;
34 
38 abstract class GetFilesContentVisitor implements ContentVisitor<Collection<AbstractFile>> {
39 
40  private static final Logger logger = Logger.getLogger(GetFilesContentVisitor.class.getName());
41 
42  @Override
43  public Collection<AbstractFile> visit(VirtualDirectory ld) {
44  return getAllFromChildren(ld);
45  }
46 
47  @Override
48  public Collection<AbstractFile> visit(Directory drctr) {
49  return getAllFromChildren(drctr);
50  }
51 
52  @Override
53  public Collection<AbstractFile> visit(Image image) {
54  return getAllFromChildren(image);
55  }
56 
57  @Override
58  public Collection<AbstractFile> visit(Volume volume) {
59  return getAllFromChildren(volume);
60  }
61 
62  @Override
63  public Collection<AbstractFile> visit(VolumeSystem vs) {
64  return getAllFromChildren(vs);
65  }
66 
75  protected Collection<AbstractFile> getAllFromChildren(Content parent) {
76  Collection<AbstractFile> all = new ArrayList<>();
77 
78  try {
79  for (Content child : parent.getChildren()) {
80  all.addAll(child.accept(this));
81  }
82  } catch (TskException ex) {
83  logger.log(Level.SEVERE, "Error getting Content children", ex); //NON-NLS
84  }
85 
86  return all;
87  }
88 }

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.