Autopsy  4.9.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;
28 import org.sleuthkit.datamodel.DataSource;
29 import org.sleuthkit.datamodel.Image;
30 import org.sleuthkit.datamodel.LocalFilesDataSource;
31 
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 
51  if (dataSource instanceof Image) {
52  Image image = (Image) dataSource;
53 
54  super.setName(image.getName());
55  super.setDisplayName(image.getName());
56  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/image.png");
57  } else if (dataSource instanceof LocalFilesDataSource) {
58  LocalFilesDataSource localFilesDataSource = (LocalFilesDataSource) dataSource;
59 
60  super.setName(localFilesDataSource.getName());
61  super.setDisplayName(localFilesDataSource.getName());
62  this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png");
63  }
64 
65  }
66 
67  @Override
68  public boolean isLeafTypeNode() {
69  return false;
70  }
71 
72  private static RootContentChildren createDSGroupingNodeChildren(DataSource dataSource) {
73 
74  long dsObjId = dataSource.getId();
75  try {
76  return new RootContentChildren(Arrays.asList(
77  new DataSources(dsObjId),
78  new Views(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
79  new Results(Case.getCurrentCaseThrows().getSleuthkitCase(), dsObjId),
80  new Tags(dsObjId) )
81 
82  );
83 
84  } catch (NoCurrentCaseException ex) {
85  logger.log(Level.SEVERE, "Error getting open case.", ex); //NON-NLS
86  return null;
87  }
88  }
89 
90  @Override
91  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
92  return visitor.visit(this);
93  }
94 
95  @Override
96  public String getItemType() {
97  return getClass().getName();
98  }
99 }

Copyright © 2012-2018 Basis Technology. Generated on: Tue Dec 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.