Autopsy  4.20.0
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 import org.sleuthkit.datamodel.SleuthkitCase;
33 
38 class DataSourceGroupingNode extends DisplayableItemNode {
39 
40  private static final Logger logger = Logger.getLogger(DataSourceGroupingNode.class.getName());
41 
47  DataSourceGroupingNode(DataSource dataSource) {
48 
49  super(Optional.ofNullable(createDSGroupingNodeChildren(dataSource))
50  .orElse(new RootContentChildren(Arrays.asList(Collections.EMPTY_LIST))),
51  Lookups.singleton(dataSource));
52 
53  if (dataSource instanceof Image) {
54  Image image = (Image) dataSource;
55 
56  super.setName(image.getName());
57  super.setDisplayName(image.getName());
58  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/image.png");
59  } else if (dataSource instanceof LocalFilesDataSource) {
60  LocalFilesDataSource localFilesDataSource = (LocalFilesDataSource) dataSource;
61 
62  super.setName(localFilesDataSource.getName());
63  super.setDisplayName(localFilesDataSource.getName());
64  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png");
65  }
66 
67  }
68 
69  @Override
70  public boolean isLeafTypeNode() {
71  return false;
72  }
73 
74  private static RootContentChildren createDSGroupingNodeChildren(DataSource dataSource) {
75 
76  long dsObjId = dataSource.getId();
77  try {
78  SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
79  return new RootContentChildren(Arrays.asList(
80  new DataSources(dsObjId),
81  new Views(skCase, dsObjId),
82  new DataArtifacts(dsObjId),
83  new AnalysisResults(dsObjId),
84  new OsAccounts(skCase, dsObjId),
85  new Tags(dsObjId),
86  new ScoreContent(skCase, dsObjId)
87  ));
88 
89  } catch (NoCurrentCaseException ex) {
90  logger.log(Level.SEVERE, "Error getting open case.", ex); //NON-NLS
91  return null;
92  }
93  }
94 
95  @Override
96  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
97  return visitor.visit(this);
98  }
99 
100  @Override
101  public String getItemType() {
102  return getClass().getName();
103  }
104 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.