Autopsy  4.17.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 
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  return new RootContentChildren(Arrays.asList(
79  new DataSources(dsObjId),
80  new Views(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
81  new Results(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
82  new Tags(dsObjId) )
83 
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: Tue Jan 19 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.