@@ -0,0 +1,3089 @@
+/*%0A * Autopsy Forensic Browser%0A * %0A * Copyright 2012 Basis Technology Corp.%0A * Contact: carrier %3Cat%3E sleuthkit %3Cdot%3E org%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *     http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.sleuthkit.autopsy.datamodel;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.logging.Level;%0Aimport org.sleuthkit.autopsy.coreutils.Logger;%0Aimport org.sleuthkit.datamodel.Content;%0Aimport org.sleuthkit.datamodel.ContentVisitor;%0Aimport org.sleuthkit.datamodel.Directory;%0Aimport org.sleuthkit.datamodel.FileSystem;%0Aimport org.sleuthkit.datamodel.LayoutDirectory;%0Aimport org.sleuthkit.datamodel.TskException;%0Aimport org.sleuthkit.datamodel.VolumeSystem;%0A%0A%0A/**%0A * Returns all the children Ids of a Content object, descending the hierarchy%0A * past subclasses that aren't part of the exposed hierarchy (VolumeSystem,%0A * FileSystem, and root Directories)%0A */%0Apublic class ContentIdHierarchyVisitor extends ContentVisitor.Default%3CList%3C? extends Long%3E%3E %7B%0A    private static final Logger logger = Logger.getLogger(ContentHierarchyVisitor.class.getName());%0A    private static final ContentIdHierarchyVisitor INSTANCE = new ContentIdHierarchyVisitor();%0A    %0A    private ContentIdHierarchyVisitor() %7B%7D%0A%0A    /**%0A     * Get the child Content objects according the the exposed hierarchy.%0A     * @param parent%0A     * @return %0A     */%0A    public static List%3CLong%3E getChildren(Content parent) %7B%0A        List%3CLong%3E keys = new ArrayList%3CLong%3E();%0A%0A        List%3CContent%3E children;%0A%0A        try %7B%0A            children = parent.getChildren();%0A        %7D catch (TskException ex) %7B%0A            logger.log(Level.WARNING, %22Error getting Content children.%22, ex);%0A            children = Collections.emptyList();%0A        %7D%0A%0A        for (Content c : children) %7B%0A            keys.addAll(c.accept(INSTANCE));%0A        %7D%0A%0A        return keys;%0A    %7D%0A%0A    @Override%0A    protected List%3CLong%3E defaultVisit(Content c) %7B%0A        return Collections.singletonList(c.getId());%0A    %7D%0A%0A    @Override%0A    public List%3CLong%3E visit(VolumeSystem vs) %7B%0A        return getChildren(vs);%0A    %7D%0A%0A    @Override%0A    public List%3CLong%3E visit(FileSystem fs) %7B%0A        return getChildren(fs);%0A    %7D%0A%0A    @Override%0A    public List%3C? extends Long%3E visit(Directory dir) %7B%0A        if (dir.isRoot()) %7B%0A            return getChildren(dir);%0A        %7D else %7B%0A            return Collections.singletonList(dir.getId());%0A        %7D%0A    %7D%0A    %0A    @Override%0A    public List%3C? extends Long%3E visit(LayoutDirectory ldir) %7B%0A        //return getChildren(ldir);%0A        return Collections.singletonList(ldir.getId());%0A    %7D%0A%7D

add a visitor to get IDs of of children content hierarchy