Autopsy  4.7.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Blackboard.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2015-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.casemodule.services;
20 
21 import java.io.Closeable;
22 import java.io.IOException;
23 import org.openide.util.Lookup;
26 import org.sleuthkit.datamodel.BlackboardArtifact;
27 import org.sleuthkit.datamodel.BlackboardAttribute;
28 import org.sleuthkit.datamodel.SleuthkitCase;
29 import org.sleuthkit.datamodel.TskCoreException;
30 import org.sleuthkit.datamodel.TskDataException;
31 
38 public final class Blackboard implements Closeable {
39 
40  private SleuthkitCase caseDb;
41 
48  Blackboard(SleuthkitCase casedb) {
49  this.caseDb = casedb;
50  }
51 
59  public synchronized void indexArtifact(BlackboardArtifact artifact) throws BlackboardException {
60  if (null == caseDb) {
61  throw new BlackboardException("Blackboard has been closed");
62  }
63  KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class);
64  if (null == searchService) {
65  throw new BlackboardException("Keyword search service not found");
66  }
67  try {
68  searchService.index(artifact);
69  } catch (TskCoreException ex) {
70  throw new BlackboardException("Error indexing artifact", ex);
71  }
72  }
73 
86  public synchronized BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName) throws BlackboardException {
87  if (null == caseDb) {
88  throw new BlackboardException("Blackboard has been closed");
89  }
90  try {
91  return caseDb.addBlackboardArtifactType(typeName, displayName);
92  } catch (TskDataException typeExistsEx) {
93  try {
94  return caseDb.getArtifactType(typeName);
95  } catch (TskCoreException ex) {
96  throw new BlackboardException("Failed to get or add artifact type", ex);
97  }
98  } catch (TskCoreException ex) {
99  throw new BlackboardException("Failed to get or add artifact type", ex);
100  }
101  }
102 
116  public synchronized BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName) throws BlackboardException {
117  if (null == caseDb) {
118  throw new BlackboardException("Blackboard has been closed");
119  }
120  try {
121  return caseDb.addArtifactAttributeType(typeName, valueType, displayName);
122  } catch (TskDataException typeExistsEx) {
123  try {
124  return caseDb.getAttributeType(typeName);
125  } catch (TskCoreException ex) {
126  throw new BlackboardException("Failed to get or add attribute type", ex);
127  }
128  } catch (TskCoreException ex) {
129  throw new BlackboardException("Failed to get or add attribute type", ex);
130  }
131  }
132 
138  @Override
139  public synchronized void close() throws IOException {
140  caseDb = null;
141  }
142 
143 
147  public static final class BlackboardException extends Exception {
148 
149  private static final long serialVersionUID = 1L;
150 
156  public BlackboardException(String message) {
157  super(message);
158  }
159 
167  public BlackboardException(String message, Throwable cause) {
168  super(message, cause);
169  }
170  }
171 }
synchronized BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName)
synchronized BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName)
Definition: Blackboard.java:86
synchronized void indexArtifact(BlackboardArtifact artifact)
Definition: Blackboard.java:59

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