Autopsy  4.9.1
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;
25 import org.sleuthkit.datamodel.BlackboardArtifact;
26 import org.sleuthkit.datamodel.BlackboardAttribute;
27 import org.sleuthkit.datamodel.SleuthkitCase;
28 import org.sleuthkit.datamodel.TskCoreException;
29 import org.sleuthkit.datamodel.TskDataException;
30 
37 public final class Blackboard implements Closeable {
38 
39  private SleuthkitCase caseDb;
40 
47  Blackboard(SleuthkitCase casedb) {
48  this.caseDb = casedb;
49  }
50 
58  public synchronized void indexArtifact(BlackboardArtifact artifact) throws BlackboardException {
59  if (null == caseDb) {
60  throw new BlackboardException("Blackboard has been closed");
61  }
62  KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class);
63  if (null == searchService) {
64  throw new BlackboardException("Keyword search service not found");
65  }
66  try {
67  searchService.index(artifact);
68  } catch (TskCoreException ex) {
69  throw new BlackboardException("Error indexing artifact", ex);
70  }
71  }
72 
85  public synchronized BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName) throws BlackboardException {
86  if (null == caseDb) {
87  throw new BlackboardException("Blackboard has been closed");
88  }
89  try {
90  return caseDb.addBlackboardArtifactType(typeName, displayName);
91  } catch (TskDataException typeExistsEx) {
92  try {
93  return caseDb.getArtifactType(typeName);
94  } catch (TskCoreException ex) {
95  throw new BlackboardException("Failed to get or add artifact type", ex);
96  }
97  } catch (TskCoreException ex) {
98  throw new BlackboardException("Failed to get or add artifact type", ex);
99  }
100  }
101 
115  public synchronized BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName) throws BlackboardException {
116  if (null == caseDb) {
117  throw new BlackboardException("Blackboard has been closed");
118  }
119  try {
120  return caseDb.addArtifactAttributeType(typeName, valueType, displayName);
121  } catch (TskDataException typeExistsEx) {
122  try {
123  return caseDb.getAttributeType(typeName);
124  } catch (TskCoreException ex) {
125  throw new BlackboardException("Failed to get or add attribute type", ex);
126  }
127  } catch (TskCoreException ex) {
128  throw new BlackboardException("Failed to get or add attribute type", ex);
129  }
130  }
131 
137  @Override
138  public synchronized void close() throws IOException {
139  caseDb = null;
140  }
141 
145  public static final class BlackboardException extends Exception {
146 
147  private static final long serialVersionUID = 1L;
148 
154  public BlackboardException(String message) {
155  super(message);
156  }
157 
165  public BlackboardException(String message, Throwable cause) {
166  super(message, cause);
167  }
168  }
169 }
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:85
synchronized void indexArtifact(BlackboardArtifact artifact)
Definition: Blackboard.java:58

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.