Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
TimeLineModule.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.timeline;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.logging.Level;
24 import javafx.application.Platform;
25 import javax.swing.SwingUtilities;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
38 public class TimeLineModule {
39 
40  private static final Logger logger = Logger.getLogger(TimeLineModule.class.getName());
41 
42  private static final Object controllerLock = new Object();
43  private static volatile TimeLineController controller;
44 
48  private TimeLineModule() {
49  }
50 
61  public static TimeLineController getController() throws TskCoreException {
62  synchronized (controllerLock) {
63  if (controller == null) {
64  throw new TskCoreException("Timeline controller not initialized");
65  }
66  return controller;
67  }
68  }
69 
74  static void onStart() {
75  Platform.setImplicitExit(false);
76  logger.info("Setting up TimeLine listeners"); //NON-NLS
77 
78  IngestManager.getInstance().addIngestModuleEventListener(new IngestModuleEventListener());
79  Case.addPropertyChangeListener(new CaseEventListener());
80  }
81 
85  static private class CaseEventListener implements PropertyChangeListener {
86 
87  @Override
88  public void propertyChange(PropertyChangeEvent evt) {
89  if (Case.Events.valueOf(evt.getPropertyName()).equals(CURRENT_CASE)) {
90  if (evt.getNewValue() == null) {
91  /*
92  * Current case is closing, shut down the timeline top
93  * component and set the pre case singleton controller
94  * reference to null.
95  */
96  synchronized (controllerLock) {
97  if (controller != null) {
98  controller.shutDownTimeLineListeners();
99  SwingUtilities.invokeLater(controller::shutDownTimeLineGui);
100  }
101  controller = null;
102  }
103  } else {
104  // Case is opening - create the controller now
105  synchronized (controllerLock) {
106  try {
107  controller = new TimeLineController(Case.getCurrentCaseThrows());
108  } catch (TskCoreException | NoCurrentCaseException ex) {
109  logger.log(Level.SEVERE, "Error creating Timeline controller", ex);
110  }
111  }
112  }
113  } else {
114  try {
115  getController().handleCaseEvent(evt);
116  } catch (TskCoreException ex) {
117  // The call to getController() will only fail due to case closing, so do
118  // not record the error.
119  }
120  }
121  }
122  }
123 
127  static private class IngestModuleEventListener implements PropertyChangeListener {
128 
129  @Override
130  public void propertyChange(PropertyChangeEvent evt) {
131  try {
132  getController().handleIngestModuleEvent(evt);
133  } catch (TskCoreException ex) {
134  // The call to getController() will only fail due to case closing, so do
135  // not record the error.
136  }
137  }
138  }
139 }
static synchronized IngestManager getInstance()
static volatile TimeLineController controller
static void addPropertyChangeListener(PropertyChangeListener listener)
Definition: Case.java:674
void addIngestModuleEventListener(final PropertyChangeListener listener)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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