Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AutopsyTreeChildFactory.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.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.EnumSet;
26 import java.util.List;
27 import java.util.Objects;
28 import java.util.logging.Level;
29 import org.openide.nodes.ChildFactory;
30 import org.openide.nodes.Node;
36 import org.sleuthkit.datamodel.DataSource;
37 import org.sleuthkit.datamodel.SleuthkitCase;
38 import org.sleuthkit.datamodel.SleuthkitVisitableItem;
39 import org.sleuthkit.datamodel.TskCoreException;
40 
41 
46 public final class AutopsyTreeChildFactory extends ChildFactory.Detachable<Object> {
47 
48  private static final Logger logger = Logger.getLogger(AutopsyTreeChildFactory.class.getName());
49 
53  private final PropertyChangeListener pcl = new PropertyChangeListener() {
54  @Override
55  public void propertyChange(PropertyChangeEvent evt) {
56  String eventType = evt.getPropertyName();
57  if (eventType.equals(Case.Events.DATA_SOURCE_ADDED.toString()) &&
58  Objects.equals(CasePreferences.getGroupItemsInTreeByDataSource(), true)) {
60  }
61  }
62  };
63 
64  @Override
65  protected void addNotify() {
66  super.addNotify();
68  }
69 
70  @Override
71  protected void removeNotify() {
72  super.removeNotify();
74  }
75 
82  @Override
83  protected boolean createKeys(List<Object> list) {
84 
85  try {
86  SleuthkitCase tskCase = Case.getCurrentCaseThrows().getSleuthkitCase();
87 
88  if (Objects.equals(CasePreferences.getGroupItemsInTreeByDataSource(), true)) {
89  List<DataSource> dataSources = tskCase.getDataSources();
90  List<DataSourceGrouping> keys = new ArrayList<>();
91  dataSources.forEach((datasource) -> {
92  keys.add(new DataSourceGrouping(datasource));
93  });
94  list.addAll(keys);
95 
96  list.add(new Reports());
97  } else {
98  List<AutopsyVisitableItem> keys = new ArrayList<>(Arrays.asList(
99  new DataSources(),
100  new Views(tskCase),
101  new Results(tskCase),
102  new Tags(),
103  new Reports()));
104 
105  list.addAll(keys);
106  }
107 
108  } catch (TskCoreException tskCoreException) {
109  logger.log(Level.SEVERE, "Error getting datas sources list from the database.", tskCoreException);
110  } catch (NoCurrentCaseException ex) {
111  logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
112  }
113  return true;
114  }
115 
123  @Override
124  protected Node createNodeForKey(Object key) {
125 
126  if (key instanceof SleuthkitVisitableItem) {
127  return ((SleuthkitVisitableItem) key).accept(new RootContentChildren.CreateSleuthkitNodeVisitor());
128  } else if (key instanceof AutopsyVisitableItem) {
129  return ((AutopsyVisitableItem) key).accept(new RootContentChildren.CreateAutopsyNodeVisitor());
130  }
131  else {
132  logger.log(Level.SEVERE, "Unknown key type ", key.getClass().getName());
133  return null;
134  }
135  }
136 
140  public void refreshChildren() {
141  refresh(true);
142  }
143 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:429
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
Definition: Case.java:474

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.