Autopsy  4.6.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
BlackboardPostEvent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.ingest.events;
20 
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.logging.Level;
26 import java.util.stream.Collectors;
27 import javax.annotation.concurrent.Immutable;
34 import org.sleuthkit.datamodel.BlackboardArtifact;
35 import org.sleuthkit.datamodel.TskCoreException;
36 
41 public final class BlackboardPostEvent extends AutopsyEvent implements Serializable {
42 
43  private static final long serialVersionUID = 1L;
44  private static final Logger logger = Logger.getLogger(BlackboardPostEvent.class.getName());
45  private transient ModuleDataEvent eventData;
46 
62  super(
64  new SerializableEventData(eventData.getModuleName(), eventData.getBlackboardArtifactType(), eventData.getArtifacts() != null
65  ? eventData.getArtifacts()
66  .stream()
67  .map(BlackboardArtifact::getArtifactID)
68  .collect(Collectors.toList()) : Collections.emptyList()),
69  null
70  );
71  this.eventData = eventData;
72  }
73 
79  @Override
80  public Object getOldValue() {
90  if (null != eventData) {
91  return eventData;
92  }
93  try {
94  SerializableEventData data = (SerializableEventData) super.getOldValue();
95  Collection<BlackboardArtifact> artifacts = new ArrayList<>();
96  for (Long id : data.artifactIds) {
97  artifacts.add(Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(id));
98  }
99  eventData = new ModuleDataEvent(data.moduleName, data.artifactTypeId, !artifacts.isEmpty() ? artifacts : null);
100  return eventData;
101  } catch (NoCurrentCaseException | TskCoreException ex) {
102  logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS
103  return null;
104  }
105  }
106 
110  @Immutable
111  private static final class SerializableEventData implements Serializable {
112 
113  private static final long serialVersionUID = 1L;
114  private final String moduleName;
115  private BlackboardArtifact.Type artifactTypeId;
116  private Collection<Long> artifactIds;
117 
118  private SerializableEventData(String moduleName, BlackboardArtifact.Type artifactTypeId, Collection<Long> artifactIds) {
119  this.moduleName = moduleName;
121  this.artifactIds = new ArrayList<>(artifactIds);
122  }
123 
124  }
125 
126 }
Collection< BlackboardArtifact > getArtifacts()
BlackboardArtifact.Type getBlackboardArtifactType()
static final long serialVersionUID
BlackboardArtifact.Type artifactTypeId
transient ModuleDataEvent eventData
Object getOldValue()
final String moduleName
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
SerializableEventData(String moduleName, BlackboardArtifact.Type artifactTypeId, Collection< Long > artifactIds)
Collection< Long > artifactIds
static final Logger logger
BlackboardPostEvent(ModuleDataEvent eventData)

Copyright © 2012-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.