Autopsy  4.18.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
TskDataModelChangeEvent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.casemodule.events;
20 
21 import java.util.Collections;
22 import java.util.List;
23 import java.util.logging.Level;
28 import org.sleuthkit.datamodel.SleuthkitCase;
29 import org.sleuthkit.datamodel.TskCoreException;
30 
37 public abstract class TskDataModelChangeEvent<T> extends AutopsyEvent {
38 
39  private static final long serialVersionUID = 1L;
40  private static final Logger logger = Logger.getLogger(TskDataModelChangeEvent.class.getName());
41  private final List<Long> dataModelObjectIds;
42  private transient List<T> dataModelObjects;
43 
56  protected TskDataModelChangeEvent(String eventName, List<Long> dataModelObjectIds, List<T> dataModelObjects) {
57  super(eventName, null, null);
58  this.dataModelObjectIds = dataModelObjectIds;
59  this.dataModelObjects = dataModelObjects;
60  if (eventName == null) {
61  throw new IllegalArgumentException("eventName is null");
62  }
63  if (dataModelObjectIds == null) {
64  throw new IllegalArgumentException("dataModelObjectIds is null");
65  }
66  if (dataModelObjects == null) {
67  throw new IllegalArgumentException("dataModelObjects is null");
68  }
69  }
70 
78  public final List<Long> getDataModelObjectIds() {
79  return Collections.unmodifiableList(dataModelObjectIds);
80  }
81 
88  @Override
89  public List<T> getNewValue() {
90  /*
91  * If this event came from another host collaborating on a multi-user
92  * case, the transient list of Sleuth Kit Data Model objects will be
93  * null and will need to be reconstructed on the current host.
94  */
95  if (dataModelObjects == null) {
96  try {
97  Case currentCase = Case.getCurrentCaseThrows();
98  SleuthkitCase caseDb = currentCase.getSleuthkitCase();
99  dataModelObjects = getDataModelObjects(caseDb, dataModelObjectIds);
100  } catch (NoCurrentCaseException | TskCoreException ex) {
101  logger.log(Level.SEVERE, String.format("Error geting TSK Data Model objects for %s event (%s)", getPropertyName(), getSourceType()), ex);
102  return Collections.emptyList();
103  }
104  }
105  return Collections.unmodifiableList(dataModelObjects);
106  }
107 
122  abstract protected List<T> getDataModelObjects(SleuthkitCase caseDb, List<Long> ids) throws TskCoreException;
123 
124 }
TskDataModelChangeEvent(String eventName, List< Long > dataModelObjectIds, List< T > dataModelObjects)
abstract List< T > getDataModelObjects(SleuthkitCase caseDb, List< Long > ids)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2021 Basis Technology. Generated on: Wed Jun 2 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.