Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ContentChildren.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.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.logging.Level;
31 
38 class ContentChildren extends AbstractContentChildren<Content> {
39 
40  private static final Logger logger = Logger.getLogger(ContentChildren.class.getName());
41  //private static final int MAX_CHILD_COUNT = 1000000;
42 
43  private final Content parent;
44 
45  ContentChildren(Content parent) {
46  super(); //initialize lazy behavior
47  this.parent = parent;
48  }
49 
59  private static List<Content> getDisplayChildren(Content parent) {
60  // what does the content think its children are?
61  List<Content> tmpChildren;
62  try {
63  tmpChildren = parent.getChildren();
64  } catch (TskCoreException ex) {
65  logger.log(Level.WARNING, "Error getting Content children.", ex); //NON-NLS
66  tmpChildren = Collections.emptyList();
67  }
68 
69  // Cycle through the list and make a new one based
70  // on what we actually want to display.
71  List<Content> children = new ArrayList<>();
72  for (Content c : tmpChildren) {
73  if (c instanceof VolumeSystem) {
74  children.addAll(getDisplayChildren(c));
75  } else if (c instanceof FileSystem) {
76  children.addAll(getDisplayChildren(c));
77  } else if (c instanceof Directory) {
78  Directory dir = (Directory) c;
79  /* For root directories, we want to return their contents.
80  * Special case though for '.' and '..' entries, because they should
81  * not have children (and in fact don't in the DB). Other drs
82  * get treated as files and added as is. */
83  if ((dir.isRoot()) && (dir.getName().equals(".") == false)
84  && (dir.getName().equals("..") == false)) {
85  children.addAll(getDisplayChildren(dir));
86  } else {
87  children.add(c);
88  }
89  } else {
90  children.add(c);
91  }
92  }
93  return children;
94  }
95 
96 
97  @Override
98  protected void addNotify() {
99  super.addNotify();
100 
101  //TODO check global settings
102  //if above limit, query and return subrange
103 
104  //StopWatch s2 = new StopWatch();
105  //s2.start();
106  //logger.log(Level.INFO, "GETTING CHILDREN CONTENT for parent: " + parent.getName());
107  List<Content> children = getDisplayChildren(parent);
108  //s2.stop();
109  //logger.log(Level.INFO, "GOT CHILDREN CONTENTS:" + children.size() + ", took: " + s2.getElapsedTime());
110 
111 
112  //limit number children
113  //setKeys(children.subList(0, Math.min(children.size(), MAX_CHILD_COUNT)));
114 
115  setKeys(children);
116  }
117 
118  @Override
119  protected void removeNotify() {
120  super.removeNotify();
121  setKeys(new ArrayList<Content>());
122  }
123 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.