Revert AUT-2158 changes

This commit is contained in:
Richard Cordovano 2016-05-27 15:13:59 -04:00
parent 02233f5ce2
commit 0ebfb0d7da
5 changed files with 220 additions and 64 deletions

View File

@ -282,7 +282,6 @@ public class Case implements SleuthkitCase.ErrorObserver {
/**
* Constructor for the Case class
*/
@SuppressWarnings("deprecation")
private Case(CaseMetadata caseMetadata, SleuthkitCase db) {
this.caseMetadata = caseMetadata;
this.db = db;
@ -836,7 +835,6 @@ public class Case implements SleuthkitCase.ErrorObserver {
/**
* Closes this case. This methods close the xml and clear all the fields.
*/
@SuppressWarnings("deprecation")
public void closeCase() throws CaseActionException {
changeCase(null);
try {

View File

@ -25,17 +25,30 @@ import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskDataException;
/**
* Represents the blackboard, a place where artifacts and their attributes are
* posted.
* A representation of the blackboard, a place where artifacts and their
* attributes are posted.
*
* NOTE: This API of this class is under development.
*/
public final class Blackboard implements Closeable {
private SleuthkitCase caseDb;
/**
* Constructs a representation of the blackboard, a place where artifacts
* and their attributes are posted.
*
* @param casedb The case database.
*/
Blackboard(SleuthkitCase casedb) {
this.caseDb = casedb;
}
/**
* Indexes the text associated with the an artifact.
*
@ -44,6 +57,9 @@ public final class Blackboard implements Closeable {
* @throws BlackboardException If there is a problem indexing the artifact.
*/
public void indexArtifact(BlackboardArtifact artifact) throws BlackboardException {
if (null == caseDb) {
throw new BlackboardException("Blackboard has been closed");
}
KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class);
if (null == searchService) {
throw new BlackboardException("Keyword search service not found");
@ -68,6 +84,9 @@ public final class Blackboard implements Closeable {
* adding the artifact type.
*/
public BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName) throws BlackboardException {
if (null == caseDb) {
throw new BlackboardException("Blackboard has been closed");
}
try {
return Case.getCurrentCase().getSleuthkitCase().addBlackboardArtifactType(typeName, displayName);
} catch (TskDataException typeExistsEx) {
@ -95,6 +114,9 @@ public final class Blackboard implements Closeable {
* adding the attribute type.
*/
public BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName) throws BlackboardException {
if (null == caseDb) {
throw new BlackboardException("Blackboard has been closed");
}
try {
return Case.getCurrentCase().getSleuthkitCase().addArtifactAttributeType(typeName, valueType, displayName);
} catch (TskDataException typeExistsEx) {
@ -112,13 +134,13 @@ public final class Blackboard implements Closeable {
* Closes the blackboard.
*
* @throws IOException If there is a problem closing the blackboard.
* @deprecated blackboard clients should not close the blackboard.
*/
@Override
@Deprecated
public void close() throws IOException {
public synchronized void close() throws IOException {
caseDb = null;
}
/**
* A blackboard exception.
*/

View File

@ -25,9 +25,9 @@ package org.sleuthkit.autopsy.casemodule.services;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.datamodel.VirtualDirectoryNode;
import org.sleuthkit.autopsy.ingest.IngestServices;
import org.sleuthkit.autopsy.ingest.ModuleContentEvent;
@ -43,6 +43,7 @@ import org.sleuthkit.datamodel.VirtualDirectory;
import org.sleuthkit.datamodel.CarvedFileContainer;
import org.sleuthkit.datamodel.LocalFilesDataSource;
import org.sleuthkit.datamodel.TskDataException;
import org.apache.commons.lang3.StringUtils;
/**
* A manager that provides methods for retrieving files from the current case
@ -51,13 +52,65 @@ import org.sleuthkit.datamodel.TskDataException;
*/
public class FileManager implements Closeable {
private SleuthkitCase caseDb;
/**
* Constructs a manager that provides methods for retrieving files from the
* current case and for adding local files, carved files, and derived files
* to the current case.
*
* @param caseDb The case database.
*/
FileManager() {
public FileManager(SleuthkitCase caseDb) {
this.caseDb = caseDb;
}
/**
* Finds all files with types that match one of a collection of MIME types.
*
* @param mimeTypes The MIME types.
*
* @return The files.
*
* @throws TskCoreException If there is a problem querying the case
* database.
*/
public synchronized List<AbstractFile> findFilesByMimeType(Collection<String> mimeTypes) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.findAllFilesWhere(createFileTypeInCondition(mimeTypes));
}
/**
* Finds all files in a given data source (image, local/logical files set,
* etc.) with types that match one of a collection of MIME types.
*
* @param dataSource The data source.
* @param mimeTypes The MIME types.
*
* @return The files.
*
* @throws TskCoreException If there is a problem querying the case
* database.
*/
public synchronized List<AbstractFile> findFilesByMimeType(Content dataSource, Collection<String> mimeTypes) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.findAllFilesWhere("data_source_obj_id = " + dataSource.getId() + " AND " + createFileTypeInCondition(mimeTypes));
}
/**
* Converts a list of MIME types into an SQL "mime_type IN" condition.
*
* @param mimeTypes The MIIME types.
*
* @return The condition string.
*/
private static String createFileTypeInCondition(Collection<String> mimeTypes) {
String types = StringUtils.join(mimeTypes, "',");
return "mime_type IN ('" + types + "')";
}
/**
@ -72,9 +125,12 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(String fileName) throws TskCoreException {
public synchronized List<AbstractFile> findFiles(String fileName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
List<AbstractFile> result = new ArrayList<>();
List<Content> dataSources = Case.getCurrentCase().getSleuthkitCase().getRootObjects();
List<Content> dataSources = caseDb.getRootObjects();
for (Content dataSource : dataSources) {
result.addAll(findFiles(dataSource, fileName));
}
@ -95,9 +151,12 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(String fileName, String parentName) throws TskCoreException {
public synchronized List<AbstractFile> findFiles(String fileName, String parentName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
List<AbstractFile> result = new ArrayList<>();
List<Content> dataSources = Case.getCurrentCase().getSleuthkitCase().getRootObjects();
List<Content> dataSources = caseDb.getRootObjects();
for (Content dataSource : dataSources) {
result.addAll(findFiles(dataSource, fileName, parentName));
}
@ -118,9 +177,12 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(String fileName, AbstractFile parent) throws TskCoreException {
public synchronized List<AbstractFile> findFiles(String fileName, AbstractFile parent) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
List<AbstractFile> result = new ArrayList<>();
List<Content> dataSources = Case.getCurrentCase().getSleuthkitCase().getRootObjects();
List<Content> dataSources = caseDb.getRootObjects();
for (Content dataSource : dataSources) {
result.addAll(findFiles(dataSource, fileName, parent));
}
@ -141,8 +203,11 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(Content dataSource, String fileName) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().findFiles(dataSource, fileName);
public synchronized List<AbstractFile> findFiles(Content dataSource, String fileName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.findFiles(dataSource, fileName);
}
/**
@ -161,8 +226,11 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(Content dataSource, String fileName, String parentName) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().findFiles(dataSource, fileName, parentName);
public synchronized List<AbstractFile> findFiles(Content dataSource, String fileName, String parentName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.findFiles(dataSource, fileName, parentName);
}
/**
@ -181,7 +249,10 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> findFiles(Content dataSource, String fileName, AbstractFile parent) throws TskCoreException {
public synchronized List<AbstractFile> findFiles(Content dataSource, String fileName, AbstractFile parent) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return findFiles(dataSource, fileName, parent.getName());
}
@ -210,8 +281,11 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
public List<AbstractFile> openFiles(Content dataSource, String filePath) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().openFiles(dataSource, filePath);
public synchronized List<AbstractFile> openFiles(Content dataSource, String filePath) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.openFiles(dataSource, filePath);
}
/**
@ -242,15 +316,17 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem adding the file to the
* case database.
*/
public DerivedFile addDerivedFile(String fileName,
public synchronized DerivedFile addDerivedFile(String fileName,
String localPath,
long size,
long ctime, long crtime, long atime, long mtime,
boolean isFile,
AbstractFile parentFile,
String rederiveDetails, String toolName, String toolVersion, String otherDetails) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().addDerivedFile(fileName, localPath, size,
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.addDerivedFile(fileName, localPath, size,
ctime, crtime, atime, mtime,
isFile, parentFile, rederiveDetails, toolName, toolVersion, otherDetails);
}
@ -272,7 +348,10 @@ public class FileManager implements Closeable {
* case database.
*/
public synchronized LayoutFile addCarvedFile(String fileName, long fileSize, long parentObjId, List<TskFileRange> layout) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().addCarvedFile(fileName, fileSize, parentObjId, layout);
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.addCarvedFile(fileName, fileSize, parentObjId, layout);
}
/**
@ -287,8 +366,11 @@ public class FileManager implements Closeable {
* @throws TskCoreException if there is a problem adding the files to the
* case database.
*/
public List<LayoutFile> addCarvedFiles(List<CarvedFileContainer> filesToAdd) throws TskCoreException {
return Case.getCurrentCase().getSleuthkitCase().addCarvedFiles(filesToAdd);
public synchronized List<LayoutFile> addCarvedFiles(List<CarvedFileContainer> filesToAdd) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
return caseDb.addCarvedFiles(filesToAdd);
}
/**
@ -334,19 +416,21 @@ public class FileManager implements Closeable {
* directory that does not exist or cannot be read.
*/
public synchronized LocalFilesDataSource addLocalFilesDataSource(String deviceId, String rootVirtualDirectoryName, String timeZone, List<String> localFilePaths, FileAddProgressUpdater progressUpdater) throws TskCoreException, TskDataException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
List<java.io.File> localFiles = getFilesAndDirectories(localFilePaths);
CaseDbTransaction trans = null;
try {
String rootDirectoryName = rootVirtualDirectoryName;
if (rootDirectoryName.isEmpty()) {
rootDirectoryName = generateFilesDataSourceName();
rootDirectoryName = generateFilesDataSourceName(caseDb);
}
/*
* Add the root virtual directory and its local/logical file
* children to the case database.
*/
SleuthkitCase caseDb = Case.getCurrentCase().getSleuthkitCase();
trans = caseDb.beginTransaction();
LocalFilesDataSource dataSource = caseDb.addLocalFilesDataSource(deviceId, rootDirectoryName, timeZone, trans);
VirtualDirectory rootDirectory = dataSource.getRootDirectory();
@ -391,10 +475,10 @@ public class FileManager implements Closeable {
* @throws TskCoreException If there is a problem querying the case
* database.
*/
private synchronized String generateFilesDataSourceName() throws TskCoreException {
private static synchronized String generateFilesDataSourceName(SleuthkitCase caseDb) throws TskCoreException {
int localFileDataSourcesCounter = 0;
try {
List<VirtualDirectory> localFileDataSources = Case.getCurrentCase().getSleuthkitCase().getVirtualDirectoryRoots();
List<VirtualDirectory> localFileDataSources = caseDb.getVirtualDirectoryRoots();
for (VirtualDirectory vd : localFileDataSources) {
if (vd.getName().startsWith(VirtualDirectoryNode.LOGICAL_FILE_SET_PREFIX)) {
++localFileDataSourcesCounter;
@ -455,7 +539,7 @@ public class FileManager implements Closeable {
/*
* Add the directory as a virtual directory.
*/
VirtualDirectory virtualDirectory = Case.getCurrentCase().getSleuthkitCase().addVirtualDirectory(parentDirectory.getId(), localFile.getName(), trans);
VirtualDirectory virtualDirectory = caseDb.addVirtualDirectory(parentDirectory.getId(), localFile.getName(), trans);
progressUpdater.fileAdded(virtualDirectory);
/*
@ -470,7 +554,7 @@ public class FileManager implements Closeable {
return virtualDirectory;
} else {
return Case.getCurrentCase().getSleuthkitCase().addLocalFile(localFile.getName(), localFile.getAbsolutePath(), localFile.length(),
return caseDb.addLocalFile(localFile.getName(), localFile.getAbsolutePath(), localFile.length(),
0, 0, 0, 0,
localFile.isFile(), parentDirectory, trans);
}
@ -495,7 +579,10 @@ public class FileManager implements Closeable {
* @deprecated Use addLocalFilesDataSource instead.
*/
@Deprecated
public VirtualDirectory addLocalFilesDirs(List<String> localFilePaths, FileAddProgressUpdater progressUpdater) throws TskCoreException {
public synchronized VirtualDirectory addLocalFilesDirs(List<String> localFilePaths, FileAddProgressUpdater progressUpdater) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("File manager has been closed");
}
try {
return addLocalFilesDataSource("", "", "", localFilePaths, progressUpdater).getRootDirectory();
} catch (TskDataException ex) {
@ -503,29 +590,14 @@ public class FileManager implements Closeable {
}
}
/**
* Constructs a manager that provides methods for retrieving files from the
* current case and for adding local files, carved files, and derived files
* to the current case.
*
* @param caseDb The case database.
*
* @deprecated Use Case.getCurrentCase().getServices().getFileManager()
* instead.
*/
@Deprecated
public FileManager(SleuthkitCase caseDb) {
}
/**
* Closes the file manager.
*
* @throws IOException If there is a problem closing the file manager.
* @deprecated File manager clients should not close the file manager.
*/
@Override
@Deprecated
public void close() throws IOException {
public synchronized void close() throws IOException {
caseDb = null;
}
}

View File

@ -46,23 +46,18 @@ public class Services implements Closeable {
* manager, keyword search, blackboard).
*
* @param caseDb The case database for the current case.
*
* @deprecated Use Case.getCurrentCase().getServices() instead.
*
* TODO (AUT-2158): Prevent public construction of the Services class.
*/
@Deprecated
public Services(SleuthkitCase caseDb) {
fileManager = new FileManager();
fileManager = new FileManager(caseDb);
services.add(fileManager);
tagsManager = new TagsManager();
tagsManager = new TagsManager(caseDb);
services.add(tagsManager);
keywordSearchService = Lookup.getDefault().lookup(KeywordSearchService.class);
services.add(keywordSearchService);
blackboard = new Blackboard();
blackboard = new Blackboard(caseDb);
services.add(blackboard);
}
@ -106,11 +101,8 @@ public class Services implements Closeable {
* Closes the services for the current case.
*
* @throws IOException if there is a problem closing the services.
* @deprecated Services clients other than the case should not close the
* services.
*/
@Override
@Deprecated
public void close() throws IOException {
for (Closeable service : services) {
service.close();

View File

@ -32,6 +32,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardArtifactTag;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.ContentTag;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TagName;
import org.sleuthkit.datamodel.TskCoreException;
@ -44,6 +45,7 @@ public class TagsManager implements Closeable {
private static final Logger logger = Logger.getLogger(TagsManager.class.getName());
private static final String TAGS_SETTINGS_NAME = "Tags"; //NON-NLS
private static final String TAG_NAMES_SETTING_KEY = "TagNames"; //NON-NLS
private SleuthkitCase caseDb;
private final HashMap<String, TagName> uniqueTagNames = new HashMap<>();
private boolean tagNamesLoaded = false;
@ -51,8 +53,11 @@ public class TagsManager implements Closeable {
* Constructs a per case Autopsy service that manages the creation,
* updating, and deletion of tags applied to content and blackboard
* artifacts by users.
*
* @param caseDb The case database.
*/
TagsManager() {
TagsManager(SleuthkitCase caseDb) {
this.caseDb = caseDb;
}
/**
@ -65,6 +70,9 @@ public class TagsManager implements Closeable {
* database.
*/
public synchronized List<TagName> getAllTagNames() throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getAllTagNames();
}
@ -79,6 +87,9 @@ public class TagsManager implements Closeable {
* database.
*/
public synchronized List<TagName> getTagNamesInUse() throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getTagNamesInUse();
}
@ -109,6 +120,9 @@ public class TagsManager implements Closeable {
* to the case database.
*/
public TagName addTagName(String displayName) throws TagNameAlreadyExistsException, TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
return addTagName(displayName, "", TagName.HTML_COLOR.NONE);
}
@ -127,6 +141,9 @@ public class TagsManager implements Closeable {
* to the case database.
*/
public TagName addTagName(String displayName, String description) throws TagNameAlreadyExistsException, TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
return addTagName(displayName, description, TagName.HTML_COLOR.NONE);
}
@ -146,6 +163,9 @@ public class TagsManager implements Closeable {
* to the case database.
*/
public synchronized TagName addTagName(String displayName, String description, TagName.HTML_COLOR color) throws TagNameAlreadyExistsException, TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
if (uniqueTagNames.containsKey(displayName)) {
throw new TagNameAlreadyExistsException();
@ -177,6 +197,9 @@ public class TagsManager implements Closeable {
* database.
*/
public ContentTag addContentTag(Content content, TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
return addContentTag(content, tagName, "", -1, -1);
}
@ -193,6 +216,9 @@ public class TagsManager implements Closeable {
* database.
*/
public ContentTag addContentTag(Content content, TagName tagName, String comment) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
return addContentTag(content, tagName, comment, -1, -1);
}
@ -213,6 +239,9 @@ public class TagsManager implements Closeable {
* the case database.
*/
public ContentTag addContentTag(Content content, TagName tagName, String comment, long beginByteOffset, long endByteOffset) throws IllegalArgumentException, TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
ContentTag tag;
synchronized (this) {
lazyLoadExistingTagNames();
@ -260,6 +289,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public void deleteContentTag(ContentTag tag) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
synchronized (this) {
lazyLoadExistingTagNames();
Case.getCurrentCase().getSleuthkitCase().deleteContentTag(tag);
@ -281,6 +313,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<ContentTag> getAllContentTags() throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getAllContentTags();
}
@ -296,6 +331,9 @@ public class TagsManager implements Closeable {
* the case database.
*/
public synchronized long getContentTagsCountByTagName(TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getContentTagsCountByTagName(tagName);
}
@ -311,6 +349,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized ContentTag getContentTagByTagID(long tagID) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getContentTagByID(tagID);
}
@ -327,6 +368,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<ContentTag> getContentTagsByTagName(TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getContentTagsByTagName(tagName);
}
@ -343,6 +387,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<ContentTag> getContentTagsByContent(Content content) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getContentTagsByContent(content);
}
@ -360,6 +407,9 @@ public class TagsManager implements Closeable {
* database.
*/
public BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
return addBlackboardArtifactTag(artifact, tagName, "");
}
@ -377,6 +427,9 @@ public class TagsManager implements Closeable {
* database.
*/
public BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
BlackboardArtifactTag tag;
synchronized (this) {
lazyLoadExistingTagNames();
@ -403,6 +456,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
synchronized (this) {
lazyLoadExistingTagNames();
Case.getCurrentCase().getSleuthkitCase().deleteBlackboardArtifactTag(tag);
@ -424,6 +480,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<BlackboardArtifactTag> getAllBlackboardArtifactTags() throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getAllBlackboardArtifactTags();
}
@ -440,6 +499,9 @@ public class TagsManager implements Closeable {
* the case database.
*/
public synchronized long getBlackboardArtifactTagsCountByTagName(TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTagsCountByTagName(tagName);
}
@ -455,6 +517,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized BlackboardArtifactTag getBlackboardArtifactTagByTagID(long tagID) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTagByID(tagID);
}
@ -471,6 +536,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByTagName(TagName tagName) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTagsByTagName(tagName);
}
@ -487,6 +555,9 @@ public class TagsManager implements Closeable {
* case database.
*/
public synchronized List<BlackboardArtifactTag> getBlackboardArtifactTagsByArtifact(BlackboardArtifact artifact) throws TskCoreException {
if (null == caseDb) {
throw new TskCoreException("Tags manager has been closed");
}
lazyLoadExistingTagNames();
return Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTagsByArtifact(artifact);
}
@ -502,6 +573,7 @@ public class TagsManager implements Closeable {
@Deprecated
public synchronized void close() throws IOException {
saveTagNamesToTagsSettings();
caseDb = null;
}
/**