Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataSourceGroupingNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 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.datamodel;
20 
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.Optional;
24 import java.util.logging.Level;
25 import org.openide.util.lookup.Lookups;
29 import org.sleuthkit.datamodel.DataSource;
30 import org.sleuthkit.datamodel.Image;
31 import org.sleuthkit.datamodel.LocalFilesDataSource;
32 
37 class DataSourceGroupingNode extends DisplayableItemNode {
38 
39  private static final Logger logger = Logger.getLogger(DataSourceGroupingNode.class.getName());
40 
46  DataSourceGroupingNode(DataSource dataSource) {
47 
48  super(Optional.ofNullable(createDSGroupingNodeChildren(dataSource))
49  .orElse(new RootContentChildren(Arrays.asList(Collections.EMPTY_LIST))),
50  Lookups.singleton(dataSource));
51 
52  if (dataSource instanceof Image) {
53  Image image = (Image) dataSource;
54 
55  super.setName(image.getName());
56  super.setDisplayName(image.getName());
57  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/image.png");
58  } else if (dataSource instanceof LocalFilesDataSource) {
59  LocalFilesDataSource localFilesDataSource = (LocalFilesDataSource) dataSource;
60 
61  super.setName(localFilesDataSource.getName());
62  super.setDisplayName(localFilesDataSource.getName());
63  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png");
64  }
65 
66  }
67 
68  @Override
69  public boolean isLeafTypeNode() {
70  return false;
71  }
72 
73  private static RootContentChildren createDSGroupingNodeChildren(DataSource dataSource) {
74 
75  long dsObjId = dataSource.getId();
76  try {
77  return new RootContentChildren(Arrays.asList(
78  new DataSources(dsObjId),
79  new Views(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
80  new DataArtifacts(dsObjId),
81  new AnalysisResults(dsObjId),
82  new OsAccounts(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
83  new Tags(dsObjId)
84  ));
85 
86  } catch (NoCurrentCaseException ex) {
87  logger.log(Level.SEVERE, "Error getting open case.", ex); //NON-NLS
88  return null;
89  }
90  }
91 
92  @Override
93  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
94  return visitor.visit(this);
95  }
96 
97  @Override
98  public String getItemType() {
99  return getClass().getName();
100  }
101 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.