Merge remote-tracking branch 'upstream/develop' into 3575_PhotoRecCorruptedFilesSetting

This commit is contained in:
U-BASIS\dgrove 2018-03-07 17:46:05 -05:00
commit 33ea11b79e
84 changed files with 754 additions and 434 deletions

View File

@ -107,9 +107,15 @@ class AddImageTask implements Runnable {
*/
@Override
public void run() {
Case currentCase;
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
progressMonitor.setIndeterminate(true);
progressMonitor.setProgress(0);
Case currentCase = Case.getCurrentCase();
String imageWriterPath = "";
if (imageWriterSettings != null) {
imageWriterPath = imageWriterSettings.getPath();

View File

@ -583,6 +583,8 @@ public class Case {
}
/**
* Deprecated. Use getOpenCase() instead.
*
* Gets the current case, if there is one, at the time of the call.
*
* @return The current case.

View File

@ -66,7 +66,7 @@ final class CaseDeleteAction extends CallableSystemAction {
"# {0} - exception message", "Case.deleteCaseFailureMessageBox.message=Error deleting case: {0}",})
public void actionPerformed(ActionEvent e) {
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
String caseName = currentCase.getName();
String caseDirectory = currentCase.getCaseDirectory();
@ -110,7 +110,7 @@ final class CaseDeleteAction extends CallableSystemAction {
}
}.execute();
}
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Case delete action called with no current case", ex);
}
}

View File

@ -31,6 +31,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileFilter;
import org.apache.commons.lang3.StringUtils;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import static org.sleuthkit.autopsy.casemodule.Bundle.*;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
@ -306,7 +307,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
*
* @return true if a proper image has been selected, false otherwise
*/
@NbBundle.Messages("ImageFilePanel.pathValidation.dataSourceOnCDriveError=Warning: Path to multi-user data source is on \"C:\" drive")
@NbBundle.Messages({"ImageFilePanel.pathValidation.dataSourceOnCDriveError=Warning: Path to multi-user data source is on \"C:\" drive",
"ImageFilePanel.pathValidation.getOpenCase.Error=Warning: Exception while getting open case."
})
public boolean validatePanel() {
pathErrorLabel.setVisible(false);
String path = getContentPaths();
@ -315,10 +318,15 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
}
// Display warning if there is one (but don't disable "next" button)
if (false == PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) {
try {
if (false == PathValidator.isValid(path, Case.getOpenCase().getCaseType())) {
pathErrorLabel.setVisible(true);
pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_dataSourceOnCDriveError());
}
} catch (NoCurrentCaseException ex) {
pathErrorLabel.setVisible(true);
pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_getOpenCase_Error());
}
return new File(path).isFile()
|| DriveUtils.isPhysicalDrive(path)

View File

@ -31,6 +31,7 @@ import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
import org.apache.commons.io.FilenameUtils;
import org.openide.modules.InstalledFileLocator;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.ServiceProvider;

View File

@ -275,10 +275,12 @@ final class LocalFilesPanel extends javax.swing.JPanel {
*
* @param paths Absolute paths to the selected data source
*/
@NbBundle.Messages("LocalFilesPanel.pathValidation.error=WARNING: Exception while gettting opon case.")
private void warnIfPathIsInvalid(final List<String> pathsList) {
errorLabel.setVisible(false);
final Case.CaseType currentCaseType = Case.getCurrentCase().getCaseType();
try {
final Case.CaseType currentCaseType = Case.getOpenCase().getCaseType();
for (String currentPath : pathsList) {
if (!PathValidator.isValid(currentPath, currentCaseType)) {
@ -287,6 +289,10 @@ final class LocalFilesPanel extends javax.swing.JPanel {
return;
}
}
} catch (NoCurrentCaseException ex) {
errorLabel.setVisible(true);
errorLabel.setText(Bundle.LocalFilesPanel_pathValidation_error());
}
}
/**

View File

@ -32,6 +32,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.PathValidator;
@ -178,7 +179,8 @@ final class LogicalEvidenceFilePanel extends javax.swing.JPanel implements Docum
*/
@Messages({
"LogicalEvidenceFilePanel.validatePanel.nonL01Error.text=Only files with the .l01 file extension are supported here.",
"LogicalEvidenceFilePanel.pathValidation.dataSourceOnCDriveError=Warning: Path to multi-user data source is on \"C:\" drive"
"LogicalEvidenceFilePanel.pathValidation.dataSourceOnCDriveError=Warning: Path to multi-user data source is on \"C:\" drive",
"LogicalEvidenceFilePanel.pathValidation.getOpenCase.Error=Warning: Exception while getting open case."
})
boolean validatePanel() {
errorLabel.setVisible(false);
@ -188,11 +190,17 @@ final class LogicalEvidenceFilePanel extends javax.swing.JPanel implements Docum
return false;
}
// display warning if there is one (but don't disable "next" button)
if (!PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) {
try {
if (!PathValidator.isValid(path, Case.getOpenCase().getCaseType())) {
errorLabel.setVisible(true);
errorLabel.setText(Bundle.LogicalEvidenceFilePanel_pathValidation_dataSourceOnCDriveError());
return false;
}
} catch (NoCurrentCaseException ex) {
errorLabel.setVisible(true);
errorLabel.setText(Bundle.LogicalEvidenceFilePanel_pathValidation_getOpenCase_Error());
return false;
}
//check the extension incase the path was manually entered
if (!LocalFilesDSProcessor.getLogicalEvidenceFilter().accept(new File(path))) {
errorLabel.setVisible(true);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -62,12 +62,19 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
OptionalCasePropertiesPanel(boolean editCurrentCase) {
initComponents();
if (editCurrentCase) {
caseDisplayNameTextField.setText(Case.getCurrentCase().getDisplayName());
caseNumberTextField.setText(Case.getCurrentCase().getNumber());
examinerTextField.setText(Case.getCurrentCase().getExaminer());
tfExaminerEmailText.setText(Case.getCurrentCase().getExaminerEmail());
tfExaminerPhoneText.setText(Case.getCurrentCase().getExaminerPhone());
taNotesText.setText(Case.getCurrentCase().getCaseNotes());
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
caseDisplayNameTextField.setText(openCase.getDisplayName());
caseNumberTextField.setText(openCase.getNumber());
examinerTextField.setText(openCase.getExaminer());
tfExaminerEmailText.setText(openCase.getExaminerEmail());
tfExaminerPhoneText.setText(openCase.getExaminerPhone());
taNotesText.setText(openCase.getCaseNotes());
setUpCaseDetailsFields();
setUpOrganizationData();
} else {
@ -86,15 +93,18 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
private void setUpOrganizationData() {
if (EamDb.isEnabled()) {
Case currentCase = Case.getCurrentCase();
if (currentCase != null) {
try {
Case currentCase = Case.getOpenCase();
if (currentCase != null) {
EamDb dbManager = EamDb.getInstance();
selectedOrg = dbManager.getCase(currentCase).getOrg();
}
} catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Unable to get Organization associated with the case from Central Repo", ex);
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
}
}
if (selectedOrg != null) {
setCurrentlySelectedOrganization(selectedOrg.getName());
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.casemodule.events;
import java.io.Serializable;
import javax.annotation.concurrent.Immutable;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.ContentTag;
import org.sleuthkit.datamodel.TskCoreException;
@ -41,10 +42,10 @@ public class ContentTagAddedEvent extends TagAddedEvent<ContentTag> implements S
*
* @return ContentTag that was added
*
* @throws IllegalStateException
* @throws NoCurrentCaseException
* @throws TskCoreException
*/
ContentTag getTagByID() throws IllegalStateException, TskCoreException {
return Case.getCurrentCase().getServices().getTagsManager().getContentTagByTagID(getTagID());
ContentTag getTagByID() throws NoCurrentCaseException, TskCoreException {
return Case.getOpenCase().getServices().getTagsManager().getContentTagByTagID(getTagID());
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.UUID;
import java.util.logging.Level;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.datamodel.Content;
@ -78,9 +79,9 @@ public final class DataSourceAddedEvent extends AutopsyEvent implements Serializ
}
try {
long id = (Long) super.getNewValue();
dataSource = Case.getCurrentCase().getSleuthkitCase().getContentById(id);
dataSource = Case.getOpenCase().getSleuthkitCase().getContentById(id);
return dataSource;
} catch (IllegalStateException | TskCoreException ex) {
} catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS
return null;
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.casemodule.events;
import java.io.Serializable;
import java.util.logging.Level;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.datamodel.Tag;
@ -84,7 +85,7 @@ abstract class TagAddedEvent<T extends Tag> extends AutopsyEvent implements Seri
try {
tag = getTagByID();
return tag;
} catch (IllegalStateException | TskCoreException ex) {
} catch (NoCurrentCaseException | TskCoreException ex) {
Logger.getLogger(TagAddedEvent.class.getName()).log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS
return null;
}
@ -98,8 +99,8 @@ abstract class TagAddedEvent<T extends Tag> extends AutopsyEvent implements Seri
*
* @return the Tag based on the saved tag id
*
* @throws IllegalStateException
* @throws NoCurrentCaseException
* @throws TskCoreException
*/
abstract T getTagByID() throws IllegalStateException, TskCoreException;
abstract T getTagByID() throws NoCurrentCaseException, TskCoreException;
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -29,6 +29,7 @@ import java.util.Set;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardArtifactTag;
@ -98,11 +99,11 @@ public class TagsManager implements Closeable {
tagDisplayNames.add(tagType.getDisplayName());
});
try {
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
for (TagName tagName : tagsManager.getAllTagNames()) {
tagDisplayNames.add(tagName.getDisplayName());
}
} catch (IllegalStateException ignored) {
} catch (NoCurrentCaseException ignored) {
/*
* No current case, nothing more to add to the set.
*/
@ -339,8 +340,8 @@ public class TagsManager implements Closeable {
ContentTag tag;
tag = caseDb.addContentTag(content, tagName, comment, beginByteOffset, endByteOffset);
try {
Case.getCurrentCase().notifyContentTagAdded(tag);
} catch (IllegalStateException ex) {
Case.getOpenCase().notifyContentTagAdded(tag);
} catch (NoCurrentCaseException ex) {
throw new TskCoreException("Added a tag to a closed case", ex);
}
return tag;
@ -357,8 +358,8 @@ public class TagsManager implements Closeable {
public void deleteContentTag(ContentTag tag) throws TskCoreException {
caseDb.deleteContentTag(tag);
try {
Case.getCurrentCase().notifyContentTagDeleted(tag);
} catch (IllegalStateException ex) {
Case.getOpenCase().notifyContentTagDeleted(tag);
} catch (NoCurrentCaseException ex) {
throw new TskCoreException("Deleted a tag from a closed case", ex);
}
}
@ -469,8 +470,8 @@ public class TagsManager implements Closeable {
public BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException {
BlackboardArtifactTag tag = caseDb.addBlackboardArtifactTag(artifact, tagName, comment);
try {
Case.getCurrentCase().notifyBlackBoardArtifactTagAdded(tag);
} catch (IllegalStateException ex) {
Case.getOpenCase().notifyBlackBoardArtifactTagAdded(tag);
} catch (NoCurrentCaseException ex) {
throw new TskCoreException("Added a tag to a closed case", ex);
}
return tag;
@ -487,8 +488,8 @@ public class TagsManager implements Closeable {
public void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException {
caseDb.deleteBlackboardArtifactTag(tag);
try {
Case.getCurrentCase().notifyBlackBoardArtifactTagDeleted(tag);
} catch (IllegalStateException ex) {
Case.getOpenCase().notifyBlackBoardArtifactTagDeleted(tag);
} catch (NoCurrentCaseException ex) {
throw new TskCoreException("Deleted a tag from a closed case", ex);
}
}

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2015-2017 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.centralrepository.datamodel;
import java.io.Serializable;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.datamodel.TskDataException;
@ -73,8 +74,8 @@ public class CorrelationDataSource implements Serializable {
public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException {
Case curCase;
try {
curCase = Case.getCurrentCase();
} catch (IllegalStateException ex) {
curCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
throw new EamDbException("Autopsy case is closed");
}
String deviceId;

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2015-2017 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -23,6 +23,7 @@ import java.util.List;
import java.util.logging.Level;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardArtifact;
@ -89,7 +90,7 @@ public class EamArtifactUtil {
// if they asked for it, add the instance details associated with this occurance.
if (!eamArtifacts.isEmpty() && addInstanceDetails) {
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
AbstractFile bbSourceFile = currentCase.getSleuthkitCase().getAbstractFileById(bbArtifact.getObjectID());
if (null == bbSourceFile) {
//@@@ Log this
@ -97,9 +98,9 @@ public class EamArtifactUtil {
}
// make an instance for the BB source file
CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCase());
CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getOpenCase());
if (null == correlationCase) {
correlationCase = EamDb.getInstance().newCase(Case.getCurrentCase());
correlationCase = EamDb.getInstance().newCase(Case.getOpenCase());
}
CorrelationAttributeInstance eamInstance = new CorrelationAttributeInstance(
correlationCase,
@ -116,7 +117,7 @@ public class EamArtifactUtil {
} catch (TskCoreException | EamDbException ex) {
LOGGER.log(Level.SEVERE, "Error creating artifact instance.", ex); // NON-NLS
return eamArtifacts;
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Case is closed.", ex); // NON-NLS
return eamArtifacts;
}
@ -145,7 +146,7 @@ public class EamArtifactUtil {
// Get the associated artifact
BlackboardAttribute attribute = bbArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
if (attribute != null) {
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
BlackboardArtifact associatedArtifact = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
return EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(correlationType, associatedArtifact);
}
@ -203,6 +204,9 @@ public class EamArtifactUtil {
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, "Error getting attribute while getting type from BlackboardArtifact.", ex); // NON-NLS
return null;
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
return null;
}
if (null != value) {
@ -250,9 +254,9 @@ public class EamArtifactUtil {
try {
CorrelationAttribute.Type filesType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID);
eamArtifact = new CorrelationAttribute(filesType, af.getMd5Hash());
CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCase());
CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getOpenCase());
if (null == correlationCase) {
correlationCase = EamDb.getInstance().newCase(Case.getCurrentCase());
correlationCase = EamDb.getInstance().newCase(Case.getOpenCase());
}
CorrelationAttributeInstance cei = new CorrelationAttributeInstance(
correlationCase,
@ -263,7 +267,7 @@ public class EamArtifactUtil {
);
eamArtifact.addInstance(cei);
return eamArtifact;
} catch (TskCoreException | EamDbException ex) {
} catch (TskCoreException | EamDbException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Error making correlation attribute.", ex);
return null;
}

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2015-2017 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -28,6 +28,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
@ -162,8 +163,8 @@ final class CaseEventListener implements PropertyChangeListener {
try {
// Get the remaining tags on the content object
Content content = Case.getCurrentCase().getSleuthkitCase().getContentById(contentID);
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
Content content = Case.getOpenCase().getSleuthkitCase().getContentById(contentID);
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
List<ContentTag> tags = tagsManager.getContentTagsByContent(content);
if (tags.stream()
@ -185,7 +186,7 @@ final class CaseEventListener implements PropertyChangeListener {
// There's still at least one bad tag, so leave the known status as is
return;
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Failed to find content", ex);
return;
}
@ -241,6 +242,13 @@ final class CaseEventListener implements PropertyChangeListener {
return;
}
} else { //BLACKBOARD_ARTIFACT_TAG_DELETED
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
// For deleted tags, we want to set the file status to UNKNOWN if:
// - The tag that was just removed is notable in central repo
// - There are no remaining tags that are notable
@ -256,9 +264,9 @@ final class CaseEventListener implements PropertyChangeListener {
try {
// Get the remaining tags on the artifact
content = Case.getCurrentCase().getSleuthkitCase().getContentById(contentID);
bbArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(artifactID);
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
content = openCase.getSleuthkitCase().getContentById(contentID);
bbArtifact = openCase.getSleuthkitCase().getBlackboardArtifact(artifactID);
TagsManager tagsManager = openCase.getServices().getTagsManager();
List<BlackboardArtifactTag> tags = tagsManager.getBlackboardArtifactTagsByArtifact(bbArtifact);
if (tags.stream()
@ -319,10 +327,10 @@ final class CaseEventListener implements PropertyChangeListener {
* that are tagged with the given tag name.
*/
try {
TagName tagName = Case.getCurrentCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(modifiedTagName);
TagName tagName = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(modifiedTagName);
//First update the artifacts
//Get all BlackboardArtifactTags with this tag name
List<BlackboardArtifactTag> artifactTags = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTagsByTagName(tagName);
List<BlackboardArtifactTag> artifactTags = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifactTagsByTagName(tagName);
for (BlackboardArtifactTag bbTag : artifactTags) {
//start with assumption that none of the other tags applied to this Correlation Attribute will prevent it's status from being changed
boolean hasTagWithConflictingKnownStatus = false;
@ -338,7 +346,7 @@ final class CaseEventListener implements PropertyChangeListener {
}
//Get the BlackboardArtifact which this BlackboardArtifactTag has been applied to.
BlackboardArtifact bbArtifact = bbTag.getArtifact();
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
List<BlackboardArtifactTag> tags = tagsManager.getBlackboardArtifactTagsByArtifact(bbArtifact);
//get all tags which are on this blackboard artifact
for (BlackboardArtifactTag t : tags) {
@ -366,7 +374,7 @@ final class CaseEventListener implements PropertyChangeListener {
}
// Next update the files
List<ContentTag> fileTags = Case.getCurrentCase().getSleuthkitCase().getContentTagsByTagName(tagName);
List<ContentTag> fileTags = Case.getOpenCase().getSleuthkitCase().getContentTagsByTagName(tagName);
//Get all ContentTags with this tag name
for (ContentTag contentTag : fileTags) {
//start with assumption that none of the other tags applied to this ContentTag will prevent it's status from being changed
@ -376,7 +384,7 @@ final class CaseEventListener implements PropertyChangeListener {
// the status of the file in the central repository
if (tagName.getKnownStatus() == TskData.FileKnown.UNKNOWN) {
Content content = contentTag.getContent();
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
List<ContentTag> tags = tagsManager.getContentTagsByContent(content);
//get all tags which are on this file
for (ContentTag t : tags) {
@ -405,6 +413,8 @@ final class CaseEventListener implements PropertyChangeListener {
LOGGER.log(Level.SEVERE, "Cannot update known status in central repository for tag: " + modifiedTagName, ex); //NON-NLS
} catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Cannot get central repository for tag: " + modifiedTagName, ex); //NON-NLS
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
}
} //TAG_STATUS_CHANGED
}
@ -424,15 +434,22 @@ final class CaseEventListener implements PropertyChangeListener {
if (!EamDb.isEnabled()) {
return;
}
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
final DataSourceAddedEvent dataSourceAddedEvent = (DataSourceAddedEvent) event;
Content newDataSource = dataSourceAddedEvent.getDataSource();
try {
String deviceId = Case.getCurrentCase().getSleuthkitCase().getDataSource(newDataSource.getId()).getDeviceId();
CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCase());
String deviceId = openCase.getSleuthkitCase().getDataSource(newDataSource.getId()).getDeviceId();
CorrelationCase correlationCase = dbManager.getCase(openCase);
if (null == correlationCase) {
correlationCase = dbManager.newCase(Case.getCurrentCase());
correlationCase = dbManager.newCase(openCase);
}
if (null == dbManager.getDataSource(correlationCase, deviceId)) {
dbManager.newDataSource(CorrelationDataSource.fromTSKDataSource(correlationCase, newDataSource));

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2015-2017 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
@ -144,9 +145,9 @@ public class IngestEventsListener {
tifArtifact.addAttributes(attributes);
try {
// index the artifact for keyword search
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard();
blackboard.indexArtifact(tifArtifact);
} catch (Blackboard.BlackboardException ex) {
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Unable to index blackboard artifact " + tifArtifact.getArtifactID(), ex); //NON-NLS
}

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -79,7 +80,12 @@ class IngestModule implements FileIngestModule {
return ProcessResult.OK;
}
blackboard = Case.getCurrentCase().getServices().getBlackboard();
try {
blackboard = Case.getOpenCase().getServices().getBlackboard();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return ProcessResult.ERROR;
}
if (!EamArtifactUtil.isValidCentralRepoFile(af)) {
return ProcessResult.OK;
@ -190,8 +196,16 @@ class IngestModule implements FileIngestModule {
}
return;
}
Case autopsyCase;
try {
autopsyCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
throw new IngestModuleException("Exception while getting open case.", ex);
}
// Don't allow sqlite central repo databases to be used for multi user cases
if ((Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE)
if ((autopsyCase.getCaseType() == Case.CaseType.MULTI_USER_CASE)
&& (EamDbPlatformEnum.getSelectedPlatform() == EamDbPlatformEnum.SQLITE)) {
LOGGER.log(Level.SEVERE, "Cannot run correlation engine on a multi-user case with a SQLite central repository.");
throw new IngestModuleException("Cannot run on a multi-user case with a SQLite central repository."); // NON-NLS
@ -212,7 +226,7 @@ class IngestModule implements FileIngestModule {
LOGGER.log(Level.SEVERE, "Error getting correlation type FILES in ingest module start up.", ex); // NON-NLS
throw new IngestModuleException("Error getting correlation type FILES in ingest module start up.", ex); // NON-NLS
}
Case autopsyCase = Case.getCurrentCase();
try {
eamCase = centralRepoDb.getCase(autopsyCase);
} catch (EamDbException ex) {

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2017 Basis Technology Corp.
* Copyright 2017-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -30,6 +30,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.datamodel.NodeProperty;
import org.sleuthkit.datamodel.Account;
import org.sleuthkit.datamodel.AccountDeviceInstance;
@ -76,13 +77,13 @@ class AccountsRootChildren extends ChildFactory<AccountDeviceInstanceKey> {
private String getDataSourceName(AccountDeviceInstance accountDeviceInstance) {
try {
final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
final SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase();
for (DataSource dataSource : sleuthkitCase.getDataSources()) {
if (dataSource.getDeviceId().equals(accountDeviceInstance.getDeviceId())) {
return sleuthkitCase.getContentById(dataSource.getId()).getName();
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error getting datasource name, falling back on device ID.", ex);
}
return accountDeviceInstance.getDeviceId();

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2017 Basis Technology Corp.
* Copyright 2017-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -36,6 +36,7 @@ import org.openide.nodes.Children;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import static org.sleuthkit.autopsy.casemodule.Case.Events.CURRENT_CASE;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
@ -198,7 +199,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
//TODO: something like this commented code could be used to show only
//the account types that are found:
//final CommunicationsManager communicationsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
//final CommunicationsManager communicationsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager();
//List<Account.Type> accountTypesInUse = communicationsManager.getAccountTypesInUse();
//accountTypesInUSe.forEach(...)
Account.Type.PREDEFINED_ACCOUNT_TYPES.forEach(type -> {
@ -229,7 +230,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
*/
private void updateDeviceFilter() {
try {
final SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
final SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase();
for (DataSource dataSource : sleuthkitCase.getDataSources()) {
String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName();
@ -242,7 +243,7 @@ final public class FiltersPanel extends javax.swing.JPanel {
});
};
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex);
} catch (TskCoreException tskCoreException) {
logger.log(Level.SEVERE, "There was a error loading the datasources for the case.", tskCoreException);
@ -500,10 +501,12 @@ final public class FiltersPanel extends javax.swing.JPanel {
ImmutableSet.of(CALL_LOG, MESSAGE)));
try {
final CommunicationsManager commsManager = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager();
final CommunicationsManager commsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager();
em.setRootContext(new AbstractNode(Children.create(new AccountsRootChildren(commsManager, commsFilter), true)));
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "There was an error getting the CommunicationsManager for the current case.", ex);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
}
needsRefresh = false;

View File

@ -51,6 +51,7 @@ import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.TskCoreException;
import org.xml.sax.SAXException;
@ -186,8 +187,21 @@ public class PListViewer extends javax.swing.JPanel implements FileTypeViewer, E
*/
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
JOptionPane.showMessageDialog(this,
"Failed to export plist file.",
Bundle.PListViewer_ExportFailed_message(),
JOptionPane.ERROR_MESSAGE);
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(Case.getCurrentCase().getExportDirectory()));
fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
fileChooser.setFileFilter(new FileNameExtensionFilter("XML file", "xml"));
final int returnVal = fileChooser.showSaveDialog(this);

View File

@ -42,6 +42,7 @@ import javax.swing.JComboBox;
import javax.swing.SwingWorker;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.FileManager;
import org.sleuthkit.autopsy.casemodule.services.Services;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -324,7 +325,7 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
try {
// Copy the file to temp folder
tmpDBPathName = Case.getCurrentCase().getTempDirectory() + File.separator + sqliteFile.getName();
tmpDBPathName = Case.getOpenCase().getTempDirectory() + File.separator + sqliteFile.getName();
tmpDBFile = new File(tmpDBPathName);
ContentUtils.writeToFile(sqliteFile, tmpDBFile);
@ -338,6 +339,8 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
// Read all table names and schema
return getTables();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to copy DB file.", ex); //NON-NLS
} catch (SQLException ex) {
@ -380,8 +383,14 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
* @return true if the meta file is found and copied successfully, false otherwise
*/
private boolean findAndCopySQLiteMetaFile(AbstractFile sqliteFile, String metaFileName ) {
SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return false;
}
SleuthkitCase sleuthkitCase = openCase.getSleuthkitCase();
Services services = new Services(sleuthkitCase);
FileManager fileManager = services.getFileManager();
@ -395,7 +404,7 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer {
if (metaFiles != null) {
for (AbstractFile metaFile: metaFiles) {
String tmpMetafilePathName = Case.getCurrentCase().getTempDirectory() + File.separator + metaFile.getName();
String tmpMetafilePathName = openCase.getTempDirectory() + File.separator + metaFile.getName();
File tmpMetafile = new File(tmpMetafilePathName);
try {

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -33,6 +33,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.WeakListeners;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -263,8 +264,8 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
protected void addTagProperty(Sheet.Set ss) {
List<ContentTag> tags = new ArrayList<>();
try {
tags.addAll(Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(content));
} catch (TskCoreException ex) {
tags.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(content));
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to get tags for content " + content.getName(), ex);
}
ss.put(new NodeProperty<>("Tags", AbstractAbstractFileNode_tagsProperty_displayName(),

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.openide.util.lookup.Lookups;
import org.openide.util.Lookup;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
import org.sleuthkit.datamodel.Content;
@ -119,12 +120,12 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
+ " AND type = " + TskData.ObjectType.ABSTRACTFILE.getObjectType() + ") AS OBJECT_IDS"; //NON-NLS;
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(query)) {
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getOpenCase().getSleuthkitCase().executeQuery(query)) {
ResultSet resultSet = dbQuery.getResultSet();
if(resultSet.next()){
return (0 < resultSet.getInt("count"));
}
} catch (TskCoreException | SQLException ex) {
} catch (TskCoreException | SQLException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error checking if the node has children, for content: " + c, ex); //NON-NLS
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -42,6 +42,7 @@ import org.openide.util.NbBundle;
import org.openide.util.WeakListeners;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
@ -260,7 +261,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
try {
for (BlackboardAttribute attribute : artifact.getAttributes()) {
if (attribute.getAttributeType().getTypeID() == ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
BlackboardArtifact associatedArtifact = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
if (associatedArtifact != null) {
if (artifact.getArtifactTypeID() == ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()) {
artifact.getDisplayName();
@ -270,7 +271,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
}
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
// Do nothing since the display name will be set to the file name.
}
}
@ -327,7 +328,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
try {
BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
if (attribute != null) {
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
BlackboardArtifact associatedArtifact = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
ss.put(new NodeProperty<>(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.name"),
NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.displayName"),
NO_DESCR,
@ -337,7 +338,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
NO_DESCR,
associatedArtifact.getShortDescription()));
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
// Do nothing since the display name will be set to the file name.
}
}
@ -449,9 +450,9 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
// add properties for tags
List<Tag> tags = new ArrayList<>();
try {
tags.addAll(Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact));
tags.addAll(Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(associated));
} catch (TskCoreException ex) {
tags.addAll(Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact));
tags.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(associated));
} catch (TskCoreException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Failed to get tags for artifact " + artifact.getDisplayName(), ex);
}
ss.put(new NodeProperty<>("Tags", NbBundle.getMessage(AbstractAbstractFileNode.class, "BlackboardArtifactNode.createSheet.tags.displayName"),

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -39,6 +39,7 @@ import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
import static org.sleuthkit.autopsy.datamodel.Bundle.*;
@ -206,11 +207,11 @@ public class DeletedContent implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
// new file was added
// @@@ COULD CHECK If the new file is deleted before notifying...
update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -225,9 +226,9 @@ public class DeletedContent implements AutopsyVisitableItem {
* received for a case that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2012-2017 Basis Technology Corp.
* Copyright 2012-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -39,6 +39,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
@ -240,7 +241,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -251,7 +252,7 @@ public class EmailExtracted implements AutopsyVisitableItem {
if (null != eventData && eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG.getTypeID()) {
emailResults.update();
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -265,9 +266,9 @@ public class EmailExtracted implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
emailResults.update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -34,6 +34,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
@ -210,7 +211,7 @@ public class ExtractedContent implements AutopsyVisitableItem {
* may be received for a case that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Due to some unresolved issues with how cases are closed,
* it is possible for the event to have a null oldValue if
@ -220,7 +221,7 @@ public class ExtractedContent implements AutopsyVisitableItem {
if (null != event && !(this.doNotShow.contains(event.getBlackboardArtifactType()))) {
refresh(true);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -233,9 +234,9 @@ public class ExtractedContent implements AutopsyVisitableItem {
* may be received for a case that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -401,7 +402,7 @@ public class ExtractedContent implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -412,7 +413,7 @@ public class ExtractedContent implements AutopsyVisitableItem {
if (null != event && event.getBlackboardArtifactType().equals(type)) {
refresh(true);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -426,9 +427,9 @@ public class ExtractedContent implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-2017 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -36,6 +36,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
@ -201,9 +202,9 @@ public class FileSize implements AutopsyVisitableItem {
try {
// new file was added
// @@@ could check the size here and only fire off updates if we know the file meets the min size criteria
Case.getCurrentCase();
Case.getOpenCase();
update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -218,9 +219,9 @@ public class FileSize implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -37,6 +37,7 @@ import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.datamodel.FileTypes.FileTypesKey;
@ -93,10 +94,10 @@ public final class FileTypesByExtension implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
typesRoot.updateShowCounts();
update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -41,6 +41,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import static org.sleuthkit.autopsy.core.UserPreferences.hideKnownFilesInViewsTree;
import static org.sleuthkit.autopsy.core.UserPreferences.hideSlackFilesInViewsTree;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -163,10 +164,10 @@ public final class FileTypesByMimeType extends Observable implements AutopsyVisi
* already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
typesRoot.updateShowCounts();
populateHashMap();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -33,6 +33,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.FileSearchAction;
@ -170,7 +171,7 @@ public class ImageNode extends AbstractContentNode<Image> {
Bundle.ImageNode_createSheet_timezone_desc(),
this.content.getTimeZone()));
try (CaseDbQuery query = Case.getCurrentCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
try (CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
ResultSet deviceIdSet = query.getResultSet();
if (deviceIdSet.next()) {
ss.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(),
@ -178,7 +179,7 @@ public class ImageNode extends AbstractContentNode<Image> {
Bundle.ImageNode_createSheet_deviceId_desc(),
deviceIdSet.getString("device_id")));
}
} catch (SQLException | TskCoreException ex) {
} catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to get device id for the following image: " + this.content.getId(), ex);
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -43,6 +43,7 @@ import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import static org.sleuthkit.autopsy.datamodel.Bundle.*;
import org.sleuthkit.autopsy.ingest.IngestManager;
@ -411,7 +412,7 @@ public class KeywordHits implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -422,7 +423,7 @@ public class KeywordHits implements AutopsyVisitableItem {
if (null != eventData && eventData.getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()) {
keywordResults.update();
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -434,9 +435,9 @@ public class KeywordHits implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
keywordResults.update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())

View File

@ -40,6 +40,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.directorytree.ExternalViewerAction;
@ -114,9 +115,9 @@ public final class Reports implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
ReportNodeFactory.this.refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -128,8 +129,8 @@ public final class Reports implements AutopsyVisitableItem {
@Override
protected boolean createKeys(List<Report> keys) {
try {
keys.addAll(Case.getCurrentCase().getAllReports());
} catch (TskCoreException ex) {
keys.addAll(Case.getOpenCase().getAllReports());
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(Reports.ReportNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get reports", ex); //NON-NLS
}
return true;
@ -265,8 +266,8 @@ public final class Reports implements AutopsyVisitableItem {
NbBundle.getMessage(Reports.class, "DeleteReportAction.actionPerformed.showConfirmDialog.title"),
JOptionPane.YES_NO_OPTION)) {
try {
Case.getCurrentCase().deleteReports(selectedReportsCollection);
} catch (TskCoreException | IllegalStateException ex) {
Case.getOpenCase().deleteReports(selectedReportsCollection);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(DeleteReportAction.class.getName()).log(Level.SEVERE, "Error deleting reports", ex); // NON-NLS
MessageNotifyUtil.Message.error(Bundle.DeleteReportAction_showConfirmDialog_errorMsg());
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -34,6 +34,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
@ -141,10 +142,10 @@ public class Tags implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
tagResults.update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -158,10 +159,10 @@ public class Tags implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
tagResults.update();
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
/**
* Case is closed, do nothing.
*/
@ -195,10 +196,10 @@ public class Tags implements AutopsyVisitableItem {
@Override
protected boolean createKeys(List<TagName> keys) {
try {
List<TagName> tagNamesInUse = Case.getCurrentCase().getServices().getTagsManager().getTagNamesInUse();
List<TagName> tagNamesInUse = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse();
Collections.sort(tagNamesInUse);
keys.addAll(tagNamesInUse);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagNameNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
return true;
@ -242,10 +243,10 @@ public class Tags implements AutopsyVisitableItem {
private void updateDisplayName() {
long tagsCount = 0;
try {
TagsManager tm = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tm = Case.getOpenCase().getServices().getTagsManager();
tagsCount = tm.getContentTagsCountByTagName(tagName);
tagsCount += tm.getBlackboardArtifactTagsCountByTagName(tagName);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagNameNode.class.getName()).log(Level.SEVERE, "Failed to get tags count for " + tagName.getDisplayName() + " tag name", ex); //NON-NLS
}
setDisplayName(tagName.getDisplayName() + " \u200E(\u200E" + tagsCount + ")\u200E");
@ -347,8 +348,8 @@ public class Tags implements AutopsyVisitableItem {
private void updateDisplayName() {
long tagsCount = 0;
try {
tagsCount = Case.getCurrentCase().getServices().getTagsManager().getContentTagsCountByTagName(tagName);
} catch (TskCoreException ex) {
tagsCount = Case.getOpenCase().getServices().getTagsManager().getContentTagsCountByTagName(tagName);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(ContentTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get content tags count for " + tagName.getDisplayName() + " tag name", ex); //NON-NLS
}
super.setDisplayName(CONTENT_DISPLAY_NAME + " (" + tagsCount + ")");
@ -402,8 +403,8 @@ public class Tags implements AutopsyVisitableItem {
protected boolean createKeys(List<ContentTag> keys) {
// Use the content tags bearing the specified tag name as the keys.
try {
keys.addAll(Case.getCurrentCase().getServices().getTagsManager().getContentTagsByTagName(tagName));
} catch (TskCoreException ex) {
keys.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByTagName(tagName));
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(ContentTagNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
return true;
@ -446,8 +447,8 @@ public class Tags implements AutopsyVisitableItem {
private void updateDisplayName() {
long tagsCount = 0;
try {
tagsCount = Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsCountByTagName(tagName);
} catch (TskCoreException ex) {
tagsCount = Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsCountByTagName(tagName);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(BlackboardArtifactTagTypeNode.class.getName()).log(Level.SEVERE, "Failed to get blackboard artifact tags count for " + tagName.getDisplayName() + " tag name", ex); //NON-NLS
}
super.setDisplayName(ARTIFACT_DISPLAY_NAME + " (" + tagsCount + ")");
@ -501,8 +502,8 @@ public class Tags implements AutopsyVisitableItem {
protected boolean createKeys(List<BlackboardArtifactTag> keys) {
try {
// Use the blackboard artifact tags bearing the specified tag name as the keys.
keys.addAll(Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsByTagName(tagName));
} catch (TskCoreException ex) {
keys.addAll(Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByTagName(tagName));
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(BlackboardArtifactTagNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
return true;

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException;
@ -105,7 +106,7 @@ public class VirtualDirectoryNode extends SpecialDirectoryNode {
Bundle.VirtualDirectoryNode_createSheet_size_displayName(),
Bundle.VirtualDirectoryNode_createSheet_size_desc(),
this.content.getSize()));
try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCase().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) {
try (SleuthkitCase.CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) {
ResultSet timeZoneSet = query.getResultSet();
if (timeZoneSet.next()) {
ss.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_timezone_name(),
@ -113,10 +114,10 @@ public class VirtualDirectoryNode extends SpecialDirectoryNode {
Bundle.VirtualDirectoryNode_createSheet_timezone_desc(),
timeZoneSet.getString("time_zone")));
}
} catch (SQLException | TskCoreException ex) {
} catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to get time zone for the following image: " + this.content.getId(), ex);
}
try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
try (SleuthkitCase.CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) {
ResultSet deviceIdSet = query.getResultSet();
if (deviceIdSet.next()) {
ss.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_deviceId_name(),
@ -124,7 +125,7 @@ public class VirtualDirectoryNode extends SpecialDirectoryNode {
Bundle.VirtualDirectoryNode_createSheet_deviceId_desc(),
deviceIdSet.getString("device_id")));
}
} catch (SQLException | TskCoreException ex) {
} catch (SQLException | TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to get device id for the following image: " + this.content.getId(), ex);
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -59,6 +59,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponents.DataResultTopComponent;
import org.sleuthkit.autopsy.datamodel.AutopsyItemVisitor;
import org.sleuthkit.autopsy.datamodel.AutopsyVisitableItem;
@ -240,7 +241,7 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -252,7 +253,7 @@ final public class Accounts implements AutopsyVisitableItem {
&& eventData.getBlackboardArtifactType().getTypeID() == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
reviewStatusBus.post(eventData);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -264,9 +265,9 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
@ -368,7 +369,7 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -380,7 +381,7 @@ final public class Accounts implements AutopsyVisitableItem {
&& eventData.getBlackboardArtifactType().getTypeID() == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
reviewStatusBus.post(eventData);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -392,10 +393,10 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
@ -517,7 +518,7 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -529,7 +530,7 @@ final public class Accounts implements AutopsyVisitableItem {
&& eventData.getBlackboardArtifactType().getTypeID() == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
reviewStatusBus.post(eventData);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -541,10 +542,10 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
@ -651,7 +652,7 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -663,7 +664,7 @@ final public class Accounts implements AutopsyVisitableItem {
&& eventData.getBlackboardArtifactType().getTypeID() == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
reviewStatusBus.post(eventData);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -675,10 +676,10 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {
@ -862,7 +863,7 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
/**
* Even with the check above, it is still possible that
* the case will be closed in a different thread before
@ -874,7 +875,7 @@ final public class Accounts implements AutopsyVisitableItem {
&& eventData.getBlackboardArtifactType().getTypeID() == ARTIFACT_TYPE.TSK_ACCOUNT.getTypeID()) {
reviewStatusBus.post(eventData);
}
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString())
@ -886,10 +887,10 @@ final public class Accounts implements AutopsyVisitableItem {
* that is already closed.
*/
try {
Case.getCurrentCase();
Case.getOpenCase();
refresh(true);
} catch (IllegalStateException notUsed) {
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
}
} else if (eventType.equals(Case.Events.CURRENT_CASE.toString())) {

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2014 Basis Technology Corp.
* Copyright 2014-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -299,7 +299,7 @@ public class PerformancePanel extends javax.swing.JDialog {
Case curCase;
try {
curCase = Case.getCurrentCase();
curCase = Case.getOpenCase();
} catch (Exception e) {
setImgLabel(NbBundle.getMessage(this.getClass(), "PerformancePanel.label.caseNotOpen.text"));
setStatusMsg("");
@ -380,7 +380,7 @@ public class PerformancePanel extends javax.swing.JDialog {
Case curCase;
try {
curCase = Case.getCurrentCase();
curCase = Case.getOpenCase();
} catch (Exception e) {
setFileReadLabel(
NbBundle.getMessage(this.getClass(), "PerformancePanel.label.caseNotOpen.text"));
@ -472,7 +472,7 @@ public class PerformancePanel extends javax.swing.JDialog {
Case curCase;
try {
curCase = Case.getCurrentCase();
curCase = Case.getOpenCase();
} catch (Exception e) {
setDbLabel(NbBundle.getMessage(this.getClass(), "PerformancePanel.label.caseNotOpen.text"));
return;

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -23,6 +23,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.TskCoreException;
@ -48,7 +49,7 @@ class ViewSourceArtifactAction extends AbstractAction {
try {
for (BlackboardAttribute attribute : artifact.getAttributes()) {
if (attribute.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
BlackboardArtifact associatedArtifact = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong());
if (associatedArtifact != null) {
dirTree.viewArtifact(associatedArtifact);
break;
@ -56,7 +57,7 @@ class ViewSourceArtifactAction extends AbstractAction {
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Unable to perform view artifact on an associated artifact of " + artifact.getDisplayName(), ex); //NON-NLS
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import java.util.logging.Level;
import org.netbeans.api.progress.ProgressHandle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.Image;
@ -78,12 +79,12 @@ class ImageWriter implements PropertyChangeListener{
this.settings = settings;
doUI = RuntimeProperties.runningWithGUI();
// We save the reference to the sleuthkit case here in case getCurrentCase() is set to
// We save the reference to the sleuthkit case here in case getOpenCase() is set to
// null before Image Writer finishes. The user can still elect to wait for image writer
// (in ImageWriterService.closeCaseResources) even though the case is closing.
try{
caseDb = Case.getCurrentCase().getSleuthkitCase();
} catch (IllegalStateException ex){
caseDb = Case.getOpenCase().getSleuthkitCase();
} catch (NoCurrentCaseException ex){
logger.log(Level.SEVERE, "Unable to load case. Image writer will be cancelled.");
this.isCancelled = true;
}
@ -151,10 +152,10 @@ class ImageWriter implements PropertyChangeListener{
Image image;
try{
image = Case.getCurrentCase().getSleuthkitCase().getImageById(dataSourceId);
image = Case.getOpenCase().getSleuthkitCase().getImageById(dataSourceId);
imageHandle = image.getImageHandle();
} catch (IllegalStateException ex){
// This exception means that getCurrentCase() failed because no case was open.
} catch (NoCurrentCaseException ex){
// This exception means that getOpenCase() failed because no case was open.
// This can happen when the user closes the case while ingest is ongoing - canceling
// ingest fires off the DataSourceAnalysisCompletedEvent while the case is in the
// process of closing.

View File

@ -43,6 +43,7 @@ import javax.swing.table.TableColumn;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.IngestJobInfoPanel;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog;
import org.sleuthkit.autopsy.modules.interestingitems.FilesSet;
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetDefsPanel;
@ -97,9 +98,9 @@ public final class IngestJobSettingsPanel extends javax.swing.JPanel {
this.settings = settings;
this.dataSources.addAll(dataSources);
try {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase();
ingestJobs.addAll(skCase.getIngestJobs());
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "No open case", ex);
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Failed to load ingest job information", ex);

View File

@ -50,6 +50,7 @@ import org.openide.util.Cancellable;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.RuntimeProperties;
import org.sleuthkit.autopsy.core.ServicesMonitor;
import org.sleuthkit.autopsy.core.UserPreferences;
@ -190,10 +191,10 @@ public class IngestManager {
* only necessary for multi-user cases.
*/
try {
if (Case.getCurrentCase().getCaseType() != Case.CaseType.MULTI_USER_CASE) {
if (Case.getOpenCase().getCaseType() != Case.CaseType.MULTI_USER_CASE) {
return;
}
} catch (IllegalStateException noCaseOpenException) {
} catch (NoCurrentCaseException noCaseOpenException) {
return;
}
@ -251,13 +252,13 @@ public class IngestManager {
caseIsOpen = true;
clearIngestMessageBox();
try {
Case openedCase = Case.getCurrentCase();
Case openedCase = Case.getOpenCase();
String channelPrefix = openedCase.getName();
if (Case.CaseType.MULTI_USER_CASE == openedCase.getCaseType()) {
jobEventPublisher.openRemoteEventChannel(String.format(INGEST_JOB_EVENT_CHANNEL_NAME, channelPrefix));
moduleEventPublisher.openRemoteEventChannel(String.format(INGEST_MODULE_EVENT_CHANNEL_NAME, channelPrefix));
}
} catch (IllegalStateException | AutopsyEventException ex) {
} catch (NoCurrentCaseException | AutopsyEventException ex) {
logger.log(Level.SEVERE, "Failed to open remote events channel", ex); //NON-NLS
MessageNotifyUtil.Notify.error(NbBundle.getMessage(IngestManager.class, "IngestManager.OpenEventChannel.Fail.Title"),
NbBundle.getMessage(IngestManager.class, "IngestManager.OpenEventChannel.Fail.ErrMsg"));
@ -347,8 +348,13 @@ public class IngestManager {
})
private IngestJobStartResult startIngestJob(IngestJob job) {
List<IngestModuleError> errors = null;
if (caseIsOpen) {
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
return new IngestJobStartResult(null, new IngestManagerException("Exception while getting open case.", ex), Collections.<IngestModuleError>emptyList()); //NON-NLS
}
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
try {
if (!servicesMonitor.getServiceStatus(ServicesMonitor.Service.REMOTE_CASE_DATABASE.toString()).equals(ServicesMonitor.ServiceStatus.UP.toString())) {
if (RuntimeProperties.runningWithGUI()) {
@ -402,7 +408,6 @@ public class IngestManager {
}
return new IngestJobStartResult(null, new IngestManagerException("Errors occurred while starting ingest"), errors); //NON-NLS
}
}
return new IngestJobStartResult(job, null, errors);
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -26,6 +26,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import javax.annotation.concurrent.Immutable;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.autopsy.ingest.IngestManager;
@ -93,11 +94,11 @@ public final class BlackboardPostEvent extends AutopsyEvent implements Serializa
SerializableEventData data = (SerializableEventData) super.getOldValue();
Collection<BlackboardArtifact> artifacts = new ArrayList<>();
for (Long id : data.artifactIds) {
artifacts.add(Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(id));
artifacts.add(Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(id));
}
eventData = new ModuleDataEvent(data.moduleName, data.artifactTypeId, !artifacts.isEmpty() ? artifacts : null);
return eventData;
} catch (IllegalStateException | TskCoreException ex) {
} catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS
return null;
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -27,6 +27,7 @@ import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
import org.sleuthkit.autopsy.corecomponents.DataContentTopComponent;
@ -51,9 +52,9 @@ class DataContentDynamicMenu extends JMenuItem implements DynamicMenuContent {
defaultItem.addActionListener(new OpenTopComponentAction(contentWin));
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
defaultItem.setEnabled(currentCase.hasData());
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
defaultItem.setEnabled(false); // disable the menu when no case is opened
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -25,6 +25,7 @@ import org.openide.awt.DynamicMenuContent;
import org.openide.util.Lookup;
import org.openide.windows.TopComponent;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataExplorer;
/**
@ -54,9 +55,9 @@ class DataExplorerDynamicMenu extends JMenuItem implements DynamicMenuContent {
item.addActionListener(new OpenTopComponentAction(explorerWin));
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
item.setEnabled(currentCase.hasData());
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
item.setEnabled(false); // disable the menu when no case is opened
}

View File

@ -24,6 +24,7 @@ import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.autopsy.directorytree.HashSearchProvider;
import org.sleuthkit.datamodel.AbstractFile;
@ -118,8 +119,12 @@ public class HashDbSearchAction extends CallableSystemAction implements HashSear
* performAction.
*/
@Override
@NbBundle.Messages ({
"HashDbSearchAction.noOpenCase.errMsg=No open case available."
})
public void performAction() {
// Make sure at least 1 file has an md5 hash
try {
if (file != null && HashDbSearcher.countFilesMd5Hashed() > 0) {
doSearch();
} else {
@ -129,6 +134,12 @@ public class HashDbSearchAction extends CallableSystemAction implements HashSear
NbBundle.getMessage(this.getClass(), "HashDbSearchAction.dlgMsg.title"),
JOptionPane.ERROR_MESSAGE);
}
} catch (NoCurrentCaseException ex) {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
Bundle.HashDbSearchAction_noOpenCase_errMsg(),
NbBundle.getMessage(this.getClass(), "HashDbSearchAction.dlgMsg.title"),
JOptionPane.ERROR_MESSAGE);
}
}
private void doSearch() {

View File

@ -32,6 +32,7 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.ingest.IngestManager;
/**
@ -292,10 +293,14 @@ class HashDbSearchPanel extends javax.swing.JPanel implements ActionListener {
* Search through all tsk_files to find ones with the same hashes as the
* hashes given.
*/
@NbBundle.Messages ({
"HashDbSearchPanel.noOpenCase.errMsg=No open case available."
})
boolean search() {
// Check if any hashed have been entered
if (hashTable.getRowCount() != 0) {
// Make sure at least 1 file has an md5 hash
try {
if (HashDbSearcher.countFilesMd5Hashed() > 0) {
return doSearch();
} else {
@ -306,6 +311,13 @@ class HashDbSearchPanel extends javax.swing.JPanel implements ActionListener {
JOptionPane.ERROR_MESSAGE);
return false;
}
} catch (NoCurrentCaseException ex) {
JOptionPane.showMessageDialog(this,
Bundle.HashDbSearchPanel_noOpenCase_errMsg(),
NbBundle.getMessage(this.getClass(), "HashDbSearchPanel.dlgMsg.title"),
JOptionPane.ERROR_MESSAGE);
return false;
}
} else {
errorField.setText(NbBundle.getMessage(this.getClass(), "HashDbSearchPanel.errorText.noHashesAddedMsg"));
errorField.setVisible(true);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -22,9 +22,12 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.swing.SwingWorker;
import org.netbeans.api.progress.ProgressHandle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.FsContent;
import org.sleuthkit.datamodel.SleuthkitCase;
@ -34,7 +37,7 @@ import org.sleuthkit.datamodel.SleuthkitCase;
* the same content.
*/
class HashDbSearcher {
private static final Logger logger = Logger.getLogger(HashDbSearcher.class.getName());
/**
* Given a string hash value, find all files with that hash.
*
@ -42,8 +45,8 @@ class HashDbSearcher {
*
* @return a List of all FsContent with the given hash
*/
static List<AbstractFile> findFilesByMd5(String md5Hash) {
final Case currentCase = Case.getCurrentCase();
static List<AbstractFile> findFilesByMd5(String md5Hash) throws NoCurrentCaseException {
final Case currentCase = Case.getOpenCase();
final SleuthkitCase skCase = currentCase.getSleuthkitCase();
return skCase.findFilesByMd5(md5Hash);
}
@ -56,7 +59,7 @@ class HashDbSearcher {
*
* @return a Map of md5 hashes mapped to the list of files hit
*/
static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash) {
static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash) throws NoCurrentCaseException {
Map<String, List<AbstractFile>> map = new LinkedHashMap<String, List<AbstractFile>>();
for (String md5 : md5Hash) {
List<AbstractFile> files = findFilesByMd5(md5);
@ -69,7 +72,7 @@ class HashDbSearcher {
// Same as above, but with a given ProgressHandle to accumulate and StringWorker to check if cancelled
static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash, ProgressHandle progress, SwingWorker<Object, Void> worker) {
static Map<String, List<AbstractFile>> findFilesBymd5(List<String> md5Hash, ProgressHandle progress, SwingWorker<Object, Void> worker) throws NoCurrentCaseException {
Map<String, List<AbstractFile>> map = new LinkedHashMap<String, List<AbstractFile>>();
if (!worker.isCancelled()) {
progress.switchToDeterminate(md5Hash.size());
@ -101,11 +104,16 @@ class HashDbSearcher {
*/
static List<AbstractFile> findFiles(FsContent file) {
String md5;
try {
if ((md5 = file.getMd5Hash()) != null) {
return findFilesByMd5(md5);
} else {
return Collections.<AbstractFile>emptyList();
}
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
return Collections.<AbstractFile>emptyList();
}
}
/**
@ -114,8 +122,8 @@ class HashDbSearcher {
*
* @return true if the search feature is ready.
*/
static boolean allFilesMd5Hashed() {
final Case currentCase = Case.getCurrentCase();
static boolean allFilesMd5Hashed() throws NoCurrentCaseException {
final Case currentCase = Case.getOpenCase();
final SleuthkitCase skCase = currentCase.getSleuthkitCase();
return skCase.allFilesMd5Hashed();
}
@ -125,8 +133,8 @@ class HashDbSearcher {
*
* @return the number of files with an MD5
*/
static int countFilesMd5Hashed() {
final Case currentCase = Case.getCurrentCase();
static int countFilesMd5Hashed() throws NoCurrentCaseException {
final Case currentCase = Case.getOpenCase();
final SleuthkitCase skCase = currentCase.getSleuthkitCase();
return skCase.countFilesMd5Hashed();
}

View File

@ -29,6 +29,7 @@ import java.util.List;
import java.util.logging.Level;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -62,10 +63,17 @@ final class CallLogAnalyzer {
* @param context The ingest job context.
*/
public void findCallLogs(IngestJobContext context) {
blackboard = Case.getCurrentCase().getServices().getBlackboard();
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
blackboard = openCase.getServices().getBlackboard();
List<AbstractFile> absFiles;
try {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase skCase = openCase.getSleuthkitCase();
absFiles = skCase.findAllFilesWhere("name ='contacts2.db' OR name ='contacts.db'"); //NON-NLS //get exact file names
if (absFiles.isEmpty()) {
return;
@ -107,7 +115,13 @@ final class CallLogAnalyzer {
logger.log(Level.SEVERE, "Error opening database", e); //NON-NLS
}
Case currentCase = Case.getCurrentCase();
Case currentCase;
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
SleuthkitCase skCase = currentCase.getSleuthkitCase();
try {
AbstractFile file = skCase.getAbstractFileById(fileId);

View File

@ -30,6 +30,7 @@ import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -65,9 +66,16 @@ class TextMessageAnalyzer {
* @param context The ingest job context.
*/
void findTexts(IngestJobContext context) {
blackboard = Case.getCurrentCase().getServices().getBlackboard();
Case openCase;
try {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
blackboard = openCase.getServices().getBlackboard();
try {
SleuthkitCase skCase = openCase.getSleuthkitCase();
absFiles = skCase.findAllFilesWhere("name ='mmssms.db'"); //NON-NLS //get exact file name
if (absFiles.isEmpty()) {
return;

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -30,6 +30,7 @@ import java.util.ArrayList;
import org.mitre.cybox.objects.AccountObjectType;
import org.mitre.cybox.objects.UserAccountObjectType;
import org.mitre.cybox.objects.WindowsUserAccount;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
/**
*
@ -104,7 +105,7 @@ class EvalAccountObj extends EvaluatableObject {
try {
List<BlackboardArtifact> finalHits = new ArrayList<BlackboardArtifact>();
Case case1 = Case.getCurrentCase();
Case case1 = Case.getOpenCase();
SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
List<BlackboardArtifact> artList
= sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_ACCOUNT);
@ -150,7 +151,7 @@ class EvalAccountObj extends EvaluatableObject {
// Didn't find any matches
return new ObservableResult(id, "AccountObject: No matches found for " + searchString, //NON-NLS
spacing, ObservableResult.ObservableState.FALSE, null);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
return new ObservableResult(id, "AccountObject: Exception during evaluation: " + ex.getLocalizedMessage(), //NON-NLS
spacing, ObservableResult.ObservableState.INDETERMINATE, null);
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.logging.Level;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -49,20 +50,28 @@ class StixArtifactData {
}
public StixArtifactData(long a_objId, String a_observableId, String a_objType) {
Case case1 = Case.getCurrentCase();
SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
try {
Case case1 = Case.getOpenCase();
SleuthkitCase sleuthkitCase = case1.getSleuthkitCase();
file = sleuthkitCase.getAbstractFileById(a_objId);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
file = null;
}
observableId = a_observableId;
objType = a_objType;
}
@Messages({"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search."})
@Messages({"StixArtifactData.indexError.message=Failed to index STIX interesting file hit artifact for keyword search.",
"StixArtifactData.noOpenCase.errMsg=No open case available."})
public void createArtifact(String a_title) throws TskCoreException {
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
Blackboard blackboard;
try {
blackboard = Case.getOpenCase().getServices().getBlackboard();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
MessageNotifyUtil.Notify.error(Bundle.StixArtifactData_noOpenCase_errMsg(), ex.getLocalizedMessage());
return;
}
String setName;
if (a_title != null) {

View File

@ -35,6 +35,7 @@ import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.GeneralFilter;
import org.sleuthkit.autopsy.casemodule.ImageDSProcessor;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -73,13 +74,14 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
private final HashMap<String, String> imageFolderToOutputFolder = new HashMap<>();
private int folderId = 0;
@Messages({"# {0} - data source name", "deviceIdQueryErrMsg=Data source {0} missing Device ID"})
@Messages({"# {0} - data source name", "deviceIdQueryErrMsg=Data source {0} missing Device ID",
"VMExtractorIngestModule.noOpenCase.errMsg=No open case available."})
@Override
public void startUp(IngestJobContext context) throws IngestModuleException {
this.context = context;
long dataSourceObjId = context.getDataSource().getId();
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
SleuthkitCase caseDb = currentCase.getSleuthkitCase();
DataSource dataSource = caseDb.getDataSource(dataSourceObjId);
parentDeviceId = dataSource.getDeviceId();
@ -88,13 +90,15 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
String timeStamp = dateFormat.format(Calendar.getInstance().getTime());
String ingestJobOutputDirName = context.getDataSource().getName() + "_" + context.getDataSource().getId() + "_" + timeStamp;
ingestJobOutputDirName = ingestJobOutputDirName.replace(':', '_');
ingestJobOutputDir = Paths.get(Case.getCurrentCase().getModuleDirectory(), VMExtractorIngestModuleFactory.getModuleName(), ingestJobOutputDirName);
ingestJobOutputDir = Paths.get(currentCase.getModuleDirectory(), VMExtractorIngestModuleFactory.getModuleName(), ingestJobOutputDirName);
// create module output folder to write extracted virtual machine files to
Files.createDirectories(ingestJobOutputDir);
} catch (IOException | SecurityException | UnsupportedOperationException ex) {
throw new IngestModule.IngestModuleException(Bundle.VMExtractorIngestModule_cannotCreateOutputDir_message(ex.getLocalizedMessage()), ex);
} catch (TskDataException | TskCoreException ex) {
throw new IngestModule.IngestModuleException(Bundle.deviceIdQueryErrMsg(context.getDataSource().getName()), ex);
} catch (NoCurrentCaseException ex) {
throw new IngestModule.IngestModuleException(Bundle.VMExtractorIngestModule_noOpenCase_errMsg(), ex);
}
}
@ -117,6 +121,9 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error querying case database", ex); //NON-NLS
return ProcessResult.ERROR;
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return ProcessResult.ERROR;
}
if (vmFiles.isEmpty()) {
@ -198,6 +205,10 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
logger.log(Level.SEVERE, "Failed to ingest virtual machine file " + file + " in folder " + folder, ex); //NON-NLS
MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.msgNotify.failedIngestVM.title.txt"),
NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.msgNotify.failedIngestVM.msg.txt", file));
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
MessageNotifyUtil.Notify.error(NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.msgNotify.failedIngestVM.title.txt"),
Bundle.VMExtractorIngestModule_noOpenCase_errMsg());
}
}
// Update progress bar
@ -219,11 +230,11 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
* @throws TskCoreException if there is a problem querying the case
* database.
*/
private static List<AbstractFile> findVirtualMachineFiles(Content dataSource) throws TskCoreException {
private static List<AbstractFile> findVirtualMachineFiles(Content dataSource) throws TskCoreException, NoCurrentCaseException {
List<AbstractFile> vmFiles = new ArrayList<>();
for (String vmExtension : GeneralFilter.VIRTUAL_MACHINE_EXTS) {
String searchString = "%" + vmExtension; // want a search string that looks like this "%.vmdk"
vmFiles.addAll(Case.getCurrentCase().getServices().getFileManager().findFiles(dataSource, searchString));
vmFiles.addAll(Case.getOpenCase().getServices().getFileManager().findFiles(dataSource, searchString));
}
return vmFiles;
}
@ -258,13 +269,13 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
*
* @param vmFile A virtual machine file.
*/
private void ingestVirtualMachineImage(Path vmFile) throws InterruptedException, IOException {
private void ingestVirtualMachineImage(Path vmFile) throws InterruptedException, IOException, NoCurrentCaseException {
/*
* Try to add the virtual machine file to the case as a data source.
*/
UUID taskId = UUID.randomUUID();
Case.getCurrentCase().notifyAddingDataSource(taskId);
Case.getOpenCase().notifyAddingDataSource(taskId);
ImageDSProcessor dataSourceProcessor = new ImageDSProcessor();
AddDataSourceCallback dspCallback = new AddDataSourceCallback(vmFile);
synchronized (this) {
@ -280,7 +291,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
* ingest context.
*/
if (!dspCallback.vmDataSources.isEmpty()) {
Case.getCurrentCase().notifyDataSourceAdded(dspCallback.vmDataSources.get(0), taskId);
Case.getOpenCase().notifyDataSourceAdded(dspCallback.vmDataSources.get(0), taskId);
List<Content> dataSourceContent = new ArrayList<>(dspCallback.vmDataSources);
IngestJobSettings ingestJobSettings = new IngestJobSettings(context.getExecutionContext());
for (String warning : ingestJobSettings.getWarnings()) {
@ -291,7 +302,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.addedVirtualMachineImage.message", vmFile.toString())));
IngestManager.getInstance().queueIngestJob(dataSourceContent, ingestJobSettings);
} else {
Case.getCurrentCase().notifyFailedAddingDataSource(taskId);
Case.getOpenCase().notifyFailedAddingDataSource(taskId);
}
}

View File

@ -36,6 +36,7 @@ import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.TskCoreException;
@ -74,7 +75,7 @@ public class ArtifactSelectionDialog extends javax.swing.JDialog {
BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getLabel(),
BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getDisplayName())); // output is too unstructured for table review
artifactTypes = Case.getCurrentCase().getSleuthkitCase().getArtifactTypesInUse();
artifactTypes = Case.getOpenCase().getSleuthkitCase().getArtifactTypesInUse();
artifactTypes.removeAll(doNotReport);
Collections.sort(artifactTypes, new Comparator<BlackboardArtifact.Type>() {
@Override
@ -89,6 +90,8 @@ public class ArtifactSelectionDialog extends javax.swing.JDialog {
}
} catch (TskCoreException ex) {
Logger.getLogger(ArtifactSelectionDialog.class.getName()).log(Level.SEVERE, "Error getting list of artifacts in use: {0}", ex.getLocalizedMessage()); //NON-NLS
} catch (NoCurrentCaseException ex) {
Logger.getLogger(ArtifactSelectionDialog.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex.getLocalizedMessage()); //NON-NLS
}
}

View File

@ -31,6 +31,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
@ -71,13 +72,15 @@ class FileReportText implements FileReportModule {
if (out != null) {
try {
out.close();
Case.getCurrentCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
Case.getOpenCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
"FileReportText.getName.text"), "");
} catch (IOException ex) {
logger.log(Level.WARNING, "Could not close output writer when ending report.", ex); //NON-NLS
} catch (TskCoreException ex) {
String errorMessage = String.format("Error adding %s to case as a report", reportPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
}
}
}

View File

@ -31,6 +31,7 @@ import javax.swing.JPanel;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestManager;
import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus;
@ -73,11 +74,17 @@ class ReportBodyFile implements GeneralReportModule {
@SuppressWarnings("deprecation")
public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) {
// Start the progress bar and setup the report
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
return;
}
progressPanel.setIndeterminate(false);
progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportBodyFile.progress.querying"));
reportPath = baseReportDir + getRelativeFilePath(); //NON-NLS
currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase();
// Run query to get all files
@ -154,14 +161,14 @@ class ReportBodyFile implements GeneralReportModule {
if (out != null) {
out.flush();
out.close();
Case.getCurrentCase().addReport(reportPath,
Case.getOpenCase().addReport(reportPath,
NbBundle.getMessage(this.getClass(),
"ReportBodyFile.generateReport.srcModuleName.text"), "");
}
} catch (IOException ex) {
logger.log(Level.WARNING, "Could not flush and close the BufferedWriter.", ex); //NON-NLS
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
String errorMessage = String.format("Error adding %s to case as a report", reportPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
}

View File

@ -27,6 +27,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.TskCoreException;
@ -112,13 +113,15 @@ class ReportExcel implements TableReportModule {
try {
out = new FileOutputStream(reportPath);
wb.write(out);
Case.getCurrentCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
Case.getOpenCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
"ReportExcel.endReport.srcModuleName.text"), "");
} catch (IOException ex) {
logger.log(Level.SEVERE, "Failed to write Excel report.", ex); //NON-NLS
} catch (TskCoreException ex) {
String errorMessage = String.format("Error adding %s to case as a report", reportPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
} finally {
if (out != null) {
try {
@ -300,6 +303,13 @@ class ReportExcel implements TableReportModule {
}
private void writeSummaryWorksheet() {
Case currentCase;
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
sheet = wb.createSheet(NbBundle.getMessage(this.getClass(), "ReportExcel.sheetName.text"));
rowIndex = 0;
@ -311,8 +321,6 @@ class ReportExcel implements TableReportModule {
sheet.createRow(rowIndex);
++rowIndex;
Case currentCase = Case.getCurrentCase();
row = sheet.createRow(rowIndex);
row.setRowStyle(setStyle);
row.createCell(0).setCellValue(NbBundle.getMessage(this.getClass(), "ReportExcel.cellVal.caseName"));

View File

@ -41,6 +41,7 @@ import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.report.ReportProgressPanel.ReportStatus;
@ -54,8 +55,6 @@ class ReportGenerator {
private static final Logger logger = Logger.getLogger(ReportGenerator.class.getName());
private Case currentCase = Case.getCurrentCase();
/**
* Progress reportGenerationPanel that can be used to check for cancellation.
*/
@ -229,10 +228,10 @@ class ReportGenerator {
private List<AbstractFile> getFiles() {
List<AbstractFile> absFiles;
try {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase();
absFiles = skCase.findAllFilesWhere("meta_type != " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue()); //NON-NLS
return absFiles;
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
MessageNotifyUtil.Notify.show(
NbBundle.getMessage(this.getClass(), "ReportGenerator.errors.reportErrorTitle"),
NbBundle.getMessage(this.getClass(), "ReportGenerator.errors.reportErrorText") + ex.getLocalizedMessage(),
@ -252,7 +251,12 @@ class ReportGenerator {
}
private static String createReportDirectory(ReportModule module) throws IOException {
Case currentCase = Case.getCurrentCase();
Case currentCase;
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
throw new IOException("Exception while getting open case.", ex);
}
// Create the root reports directory path of the form: <CASE DIRECTORY>/Reports/<Case fileName> <Timestamp>/
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
Date date = new Date();

View File

@ -49,6 +49,7 @@ import javax.imageio.ImageIO;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Services;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.coreutils.EscapeUtil;
@ -102,8 +103,8 @@ class ReportHTML implements TableReportModule {
}
// Refesh the member variables
private void refresh() {
currentCase = Case.getCurrentCase();
private void refresh() throws NoCurrentCaseException {
currentCase = Case.getOpenCase();
skCase = currentCase.getSleuthkitCase();
dataTypes = new TreeMap<>();
@ -327,7 +328,12 @@ class ReportHTML implements TableReportModule {
@Override
public void startReport(String baseReportDir) {
// Refresh the HTML report
try {
refresh();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case."); //NON-NLS
return;
}
// Setup the path for the HTML report
this.path = baseReportDir; //NON-NLS
this.subPath = this.path + HTML_SUBDIR + File.separator;
@ -882,6 +888,13 @@ class ReportHTML implements TableReportModule {
private void writeIndex() {
Writer indexOut = null;
String indexFilePath = path + "report.html"; //NON-NLS
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
try {
indexOut = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(indexFilePath), "UTF-8")); //NON-NLS
StringBuilder index = new StringBuilder();
@ -909,7 +922,7 @@ class ReportHTML implements TableReportModule {
index.append("</frameset>\n"); //NON-NLS
index.append("</html>"); //NON-NLS
indexOut.write(index.toString());
Case.getCurrentCase().addReport(indexFilePath, NbBundle.getMessage(this.getClass(),
openCase.addReport(indexFilePath, NbBundle.getMessage(this.getClass(),
"ReportHTML.writeIndex.srcModuleName.text"), "");
} catch (IOException ex) {
logger.log(Level.SEVERE, "Error creating Writer for report.html: {0}", ex); //NON-NLS

View File

@ -43,6 +43,7 @@ import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.jdom2.CDATA;
import org.openide.filesystems.FileUtil;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.ReadContentInputStream.ReadContentInputStreamException;
/**
@ -99,14 +100,18 @@ class ReportKML implements GeneralReportModule {
*/
@Override
public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) {
try {
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return;
}
// Start the progress bar and setup the report
progressPanel.setIndeterminate(true);
progressPanel.start();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.querying"));
String kmlFileFullPath = baseReportDir + REPORT_KML; //NON-NLS
currentCase = Case.getCurrentCase();
skCase = currentCase.getSleuthkitCase();
progressPanel.updateStatusLabel(NbBundle.getMessage(this.getClass(), "ReportKML.progress.loading"));
@ -382,7 +387,7 @@ class ReportKML implements GeneralReportModule {
if (result == ReportProgressPanel.ReportStatus.ERROR) {
prependedStatus = "Incomplete ";
}
Case.getCurrentCase().addReport(kmlFileFullPath,
Case.getOpenCase().addReport(kmlFileFullPath,
NbBundle.getMessage(this.getClass(), "ReportKML.genReport.srcModuleName.text"),
prependedStatus + NbBundle.getMessage(this.getClass(), "ReportKML.genReport.reportName"));
} catch (IOException ex) {
@ -392,6 +397,9 @@ class ReportKML implements GeneralReportModule {
String errorMessage = String.format("Error adding %s to case as a report", kmlFileFullPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
result = ReportProgressPanel.ReportStatus.ERROR;
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
result = ReportProgressPanel.ReportStatus.ERROR;
}
progressPanel.complete(result);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-2014 Basis Technology Corp.
* Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -41,6 +41,7 @@ import javax.swing.event.ListDataListener;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.BlackboardArtifact;
@ -97,8 +98,8 @@ final class ReportVisualPanel2 extends JPanel {
private void initTags() {
List<TagName> tagNamesInUse;
try {
tagNamesInUse = Case.getCurrentCase().getServices().getTagsManager().getTagNamesInUse();
} catch (TskCoreException ex) {
tagNamesInUse = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse();
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(ReportVisualPanel2.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
return;
}
@ -136,6 +137,7 @@ final class ReportVisualPanel2 extends JPanel {
private void initArtifactTypes() {
try {
Case openCase = Case.getOpenCase();
ArrayList<BlackboardArtifact.Type> doNotReport = new ArrayList<>();
doNotReport.add(new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getTypeID(),
BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getLabel(),
@ -144,7 +146,7 @@ final class ReportVisualPanel2 extends JPanel {
BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getLabel(),
BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getDisplayName())); // output is too unstructured for table review
artifacts = Case.getCurrentCase().getSleuthkitCase().getArtifactTypesInUse();
artifacts = openCase.getSleuthkitCase().getArtifactTypesInUse();
artifacts.removeAll(doNotReport);
@ -152,7 +154,7 @@ final class ReportVisualPanel2 extends JPanel {
for (BlackboardArtifact.Type type : artifacts) {
artifactStates.put(type, Boolean.TRUE);
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(ReportVisualPanel2.class.getName()).log(Level.SEVERE, "Error getting list of artifacts in use: " + ex.getLocalizedMessage(), ex); //NON-NLS
}
}

View File

@ -39,6 +39,7 @@ import java.util.TreeSet;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.coreutils.ImageUtils;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -181,11 +182,11 @@ class TableReportGenerator {
String accountDisplayname = accountTypeStr;
if (accountTypeStr != null) {
try {
Account.Type acctType = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager().getAccountType(accountTypeStr);
Account.Type acctType = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().getAccountType(accountTypeStr);
if (acctType != null) {
accountDisplayname = acctType.getDisplayName();
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Unable to get display name for account type " + accountTypeStr, ex);
}
}
@ -267,8 +268,8 @@ class TableReportGenerator {
// Get the content tags.
List<ContentTag> tags;
try {
tags = Case.getCurrentCase().getServices().getTagsManager().getAllContentTags();
} catch (TskCoreException ex) {
tags = Case.getOpenCase().getServices().getTagsManager().getAllContentTags();
} catch (TskCoreException | NoCurrentCaseException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetContentTags"));
logger.log(Level.SEVERE, "failed to get content tags", ex); //NON-NLS
return;
@ -360,8 +361,8 @@ class TableReportGenerator {
List<BlackboardArtifactTag> tags;
try {
tags = Case.getCurrentCase().getServices().getTagsManager().getAllBlackboardArtifactTags();
} catch (TskCoreException ex) {
tags = Case.getOpenCase().getServices().getTagsManager().getAllBlackboardArtifactTags();
} catch (TskCoreException | NoCurrentCaseException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetBBArtifactTags"));
logger.log(Level.SEVERE, "failed to get blackboard artifact tags", ex); //NON-NLS
return;
@ -452,8 +453,8 @@ class TableReportGenerator {
private void checkIfTagHasImage(BlackboardArtifactTag artifactTag) {
AbstractFile file;
try {
file = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(artifactTag.getArtifact().getObjectID());
} catch (TskCoreException ex) {
file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(artifactTag.getArtifact().getObjectID());
} catch (TskCoreException | NoCurrentCaseException ex) {
errorList.add(
NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.errGetContentFromBBArtifact"));
logger.log(Level.WARNING, "Error while getting content from a blackboard artifact to report on.", ex); //NON-NLS
@ -520,6 +521,7 @@ class TableReportGenerator {
* @param tableModule module to report on
*/
@SuppressWarnings("deprecation")
@NbBundle.Messages ({"ReportGenerator.errList.noOpenCase=No open case available."})
private void writeKeywordHits(TableReportModule tableModule, String comment, HashSet<String> tagNamesFilter) {
// Query for keyword lists-only so that we can tell modules what lists
@ -528,7 +530,15 @@ class TableReportGenerator {
// so that we only report the lists that we will later provide with real
// hits. If no keyord hits are tagged, then we make the page for nothing.
String orderByClause;
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
errorList.add(Bundle.ReportGenerator_errList_noOpenCase());
logger.log(Level.SEVERE, "Exception while getting open case: ", ex); //NON-NLS
return;
}
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
orderByClause = "ORDER BY convert_to(att.value_text, 'SQL_ASCII') ASC NULLS FIRST"; //NON-NLS
} else {
orderByClause = "ORDER BY list ASC"; //NON-NLS
@ -546,7 +556,7 @@ class TableReportGenerator {
+ //NON-NLS
"GROUP BY list " + orderByClause; //NON-NLS
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(keywordListQuery)) {
try (SleuthkitCase.CaseDbQuery dbQuery = openCase.getSleuthkitCase().executeQuery(keywordListQuery)) {
ResultSet listsRs = dbQuery.getResultSet();
List<String> lists = new ArrayList<>();
while (listsRs.next()) {
@ -569,7 +579,7 @@ class TableReportGenerator {
return;
}
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
orderByClause = "ORDER BY convert_to(att3.value_text, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
+ "convert_to(att1.value_text, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
+ "convert_to(f.parent_path, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
@ -602,7 +612,7 @@ class TableReportGenerator {
+ //NON-NLS
orderByClause; //NON-NLS
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(keywordsQuery)) {
try (SleuthkitCase.CaseDbQuery dbQuery = openCase.getSleuthkitCase().executeQuery(keywordsQuery)) {
ResultSet resultSet = dbQuery.getResultSet();
String currentKeyword = "";
@ -627,9 +637,9 @@ class TableReportGenerator {
String uniquePath = "";
try {
AbstractFile f = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId);
AbstractFile f = openCase.getSleuthkitCase().getAbstractFileById(objId);
if (f != null) {
uniquePath = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId).getUniquePath();
uniquePath = openCase.getSleuthkitCase().getAbstractFileById(objId).getUniquePath();
}
} catch (TskCoreException ex) {
errorList.add(
@ -685,7 +695,15 @@ class TableReportGenerator {
@SuppressWarnings("deprecation")
private void writeHashsetHits(TableReportModule tableModule, String comment, HashSet<String> tagNamesFilter) {
String orderByClause;
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
errorList.add(Bundle.ReportGenerator_errList_noOpenCase());
logger.log(Level.SEVERE, "Exception while getting open case: ", ex); //NON-NLS
return;
}
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
orderByClause = "ORDER BY convert_to(att.value_text, 'SQL_ASCII') ASC NULLS FIRST"; //NON-NLS
} else {
orderByClause = "ORDER BY att.value_text ASC"; //NON-NLS
@ -703,7 +721,7 @@ class TableReportGenerator {
+ //NON-NLS
"GROUP BY list " + orderByClause; //NON-NLS
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(hashsetsQuery)) {
try (SleuthkitCase.CaseDbQuery dbQuery = openCase.getSleuthkitCase().executeQuery(hashsetsQuery)) {
// Query for hashsets
ResultSet listsRs = dbQuery.getResultSet();
List<String> lists = new ArrayList<>();
@ -722,7 +740,7 @@ class TableReportGenerator {
return;
}
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
orderByClause = "ORDER BY convert_to(att.value_text, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
+ "convert_to(f.parent_path, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
+ "convert_to(f.name, 'SQL_ASCII') ASC NULLS FIRST, " //NON-NLS
@ -745,7 +763,7 @@ class TableReportGenerator {
+ //NON-NLS
orderByClause; //NON-NLS
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(hashsetHitsQuery)) {
try (SleuthkitCase.CaseDbQuery dbQuery = openCase.getSleuthkitCase().executeQuery(hashsetHitsQuery)) {
// Query for hashset hits
ResultSet resultSet = dbQuery.getResultSet();
String currentSet = "";
@ -768,9 +786,9 @@ class TableReportGenerator {
String uniquePath = "";
try {
AbstractFile f = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId);
AbstractFile f = openCase.getSleuthkitCase().getAbstractFileById(objId);
if (f != null) {
uniquePath = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(objId).getUniquePath();
uniquePath = openCase.getSleuthkitCase().getAbstractFileById(objId).getUniquePath();
}
} catch (TskCoreException ex) {
errorList.add(
@ -834,9 +852,9 @@ class TableReportGenerator {
this.attributes = attrs;
this.tags = tags;
try {
this.content = Case.getCurrentCase().getSleuthkitCase().getContentById(artifact.getObjectID());
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Could not get content from database");
this.content = Case.getOpenCase().getSleuthkitCase().getContentById(artifact.getObjectID());
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Could not get content from database", ex);
}
}
@ -972,12 +990,12 @@ class TableReportGenerator {
HashSet<String> allTags = getTags();
try {
List<ContentTag> contentTags = Case.getCurrentCase().getServices().getTagsManager().getContentTagsByContent(content);
List<ContentTag> contentTags = Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(content);
for (ContentTag ct : contentTags) {
String notableString = ct.getName().getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : "";
allTags.add(ct.getName().getDisplayName() + notableString);
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetContentTags"));
logger.log(Level.SEVERE, "Failed to get content tags", ex); //NON-NLS
}
@ -1008,8 +1026,8 @@ class TableReportGenerator {
private List<ArtifactData> getFilteredArtifacts(BlackboardArtifact.Type type, HashSet<String> tagNamesFilter) {
List<ArtifactData> artifacts = new ArrayList<>();
try {
for (BlackboardArtifact artifact : Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifacts(type.getTypeID())) {
List<BlackboardArtifactTag> tags = Case.getCurrentCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact);
for (BlackboardArtifact artifact : Case.getOpenCase().getSleuthkitCase().getBlackboardArtifacts(type.getTypeID())) {
List<BlackboardArtifactTag> tags = Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact);
HashSet<String> uniqueTagNames = new HashSet<>();
for (BlackboardArtifactTag tag : tags) {
String notableString = tag.getName().getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : "";
@ -1019,13 +1037,13 @@ class TableReportGenerator {
continue;
}
try {
artifacts.add(new ArtifactData(artifact, Case.getCurrentCase().getSleuthkitCase().getBlackboardAttributes(artifact), uniqueTagNames));
artifacts.add(new ArtifactData(artifact, Case.getOpenCase().getSleuthkitCase().getBlackboardAttributes(artifact), uniqueTagNames));
} catch (TskCoreException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetBBAttribs"));
logger.log(Level.SEVERE, "Failed to get Blackboard Attributes when generating report.", ex); //NON-NLS
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
errorList.add(NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.failedGetBBArtifacts"));
logger.log(Level.SEVERE, "Failed to get Blackboard Artifacts when generating report.", ex); //NON-NLS
}
@ -1609,12 +1627,12 @@ class TableReportGenerator {
+ //NON-NLS
"WHERE tn.tag_name_id = bat.tag_name_id AND bat.artifact_id = " + artifactId; //NON-NLS
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCase().getSleuthkitCase().executeQuery(query)) {
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getOpenCase().getSleuthkitCase().executeQuery(query)) {
ResultSet tagNameRows = dbQuery.getResultSet();
while (tagNameRows.next()) {
uniqueTagNames.add(tagNameRows.getString("display_name")); //NON-NLS
}
} catch (TskCoreException | SQLException ex) {
} catch (TskCoreException | SQLException | NoCurrentCaseException ex) {
throw new TskCoreException("Error getting tag names for artifact: ", ex);
}

View File

@ -27,6 +27,7 @@ import javax.swing.JPanel;
import org.openide.util.lookup.ServiceProvider;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb;
import org.sleuthkit.autopsy.report.GeneralReportModule;
@ -66,6 +67,14 @@ public class AddTaggedHashesToHashDb implements GeneralReportModule {
@Override
public void generateReport(String reportPath, ReportProgressPanel progressPanel) {
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
Logger.getLogger(AddTaggedHashesToHashDb.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex);
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "No open Case", "Exception while getting open case.", JOptionPane.ERROR_MESSAGE);
return;
}
progressPanel.setIndeterminate(true);
progressPanel.start();
progressPanel.updateStatusLabel("Adding hashes...");
@ -74,7 +83,7 @@ public class AddTaggedHashesToHashDb implements GeneralReportModule {
if (hashSet != null) {
progressPanel.updateStatusLabel("Adding hashes to " + hashSet.getHashSetName() + " hash set...");
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager = openCase.getServices().getTagsManager();
List<TagName> tagNames = configPanel.getSelectedTagNames();
ArrayList<String> failedExports = new ArrayList<>();
for (TagName tagName : tagNames) {
@ -91,7 +100,7 @@ public class AddTaggedHashesToHashDb implements GeneralReportModule {
if (content instanceof AbstractFile) {
if (null != ((AbstractFile) content).getMd5Hash()) {
try {
hashSet.addHashes(tag.getContent(), Case.getCurrentCase().getDisplayName());
hashSet.addHashes(tag.getContent(), openCase.getDisplayName());
} catch (TskCoreException ex) {
Logger.getLogger(AddTaggedHashesToHashDb.class.getName()).log(Level.SEVERE, "Error adding hash for obj_id = " + tag.getContent().getId() + " to hash set " + hashSet.getHashSetName(), ex);
failedExports.add(tag.getContent().getName());

View File

@ -34,6 +34,7 @@ import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb;
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
@ -67,10 +68,13 @@ class AddTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel {
private void populateTagNameComponents() {
// Get the tag names in use for the current case.
try {
tagNames = Case.getCurrentCase().getServices().getTagsManager().getTagNamesInUse();
tagNames = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse();
} catch (TskCoreException ex) {
Logger.getLogger(AddTaggedHashesToHashDbConfigPanel.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex);
JOptionPane.showMessageDialog(this, "Error getting tag names for case.", "Tag Names Not Found", JOptionPane.ERROR_MESSAGE);
} catch (NoCurrentCaseException ex) {
Logger.getLogger(AddTaggedHashesToHashDbConfigPanel.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex);
JOptionPane.showMessageDialog(this, "Error getting tag names for case.", "Exception while getting open case.", JOptionPane.ERROR_MESSAGE);
}
// Mark the tag names as unselected. Note that tagNameSelections is a

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.DatatypeConverter;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute;
@ -63,8 +64,8 @@ final class CustomArtifactType {
*
* @throws BlackboardException If there is an error adding any of the types.
*/
static void addToCaseDatabase() throws Blackboard.BlackboardException {
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
static void addToCaseDatabase() throws Blackboard.BlackboardException, NoCurrentCaseException {
Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard();
artifactType = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAME, ARTIFACT_DISPLAY_NAME);
intAttrType = blackboard.getOrAddAttributeType(INT_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER, INT_ATTR_DISPLAY_NAME);
doubleAttrType = blackboard.getOrAddAttributeType(DOUBLE_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE, DOUBLE_ATTR_DISPLAY_NAME);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.test;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleAdapter;
@ -53,7 +54,7 @@ public class CustomArtifactsCreatorDataSourceIngestModule extends DataSourceInge
public void startUp(IngestJobContext context) throws IngestModuleException {
try {
CustomArtifactType.addToCaseDatabase();
} catch (Blackboard.BlackboardException ex) {
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.CustomArtifactsCreatorDataSourceIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.test;
import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.FileIngestModuleAdapter;
@ -52,7 +53,7 @@ final class CustomArtifactsCreatorFileIngestModule extends FileIngestModuleAdapt
public void startUp(IngestJobContext context) throws IngestModuleException {
try {
CustomArtifactType.addToCaseDatabase();
} catch (Blackboard.BlackboardException ex) {
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.CustomArtifactsCreatorFileIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -25,6 +25,7 @@ import java.util.logging.Level;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.FileIngestModuleAdapter;
@ -53,10 +54,10 @@ final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapt
@Override
public void startUp(IngestJobContext context) throws IngestModuleException {
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
try {
Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard();
artifactType = blackboard.getOrAddArtifactType(INT_ARTIFACT_TYPE_NAME, INT_ARTIFACT_DISPLAY_NAME);
} catch (Blackboard.BlackboardException ex) {
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.InterestingArtifactCreatorIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
}
}
@ -76,7 +77,7 @@ final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapt
* type.
*/
int randomArtIndex = (int) (Math.random() * 3);
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard();
BlackboardArtifact.Type artifactTypeBase = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAMES[randomArtIndex], ARTIFACT_DISPLAY_NAMES[randomArtIndex]);
BlackboardArtifact artifactBase = file.newArtifact(artifactTypeBase.getTypeID());
Collection<BlackboardAttribute> baseAttributes = new ArrayList<>();
@ -123,7 +124,7 @@ final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapt
attributes.add(att3);
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT, MODULE_NAME, artifactBase.getArtifactID()));
artifact.addAttributes(attributes);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, String.format("Failed to process file (obj_id = %d)", file.getId()), ex);
return ProcessResult.ERROR;
} catch (Blackboard.BlackboardException ex) {

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2014-2017 Basis Technology Corp.
* Copyright 2014-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -33,6 +33,7 @@ import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.Installer;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -80,7 +81,7 @@ public final class OpenTimelineAction extends CallableSystemAction {
@Override
public boolean isEnabled() {
/**
* We used to also check if Case.getCurrentCase().hasData() was true. We
* We used to also check if Case.getOpenCase().hasData() was true. We
* disabled that check because if it is executed while a data source is
* being added, it blocks the edt. We still do that in ImageGallery.
*/
@ -111,7 +112,7 @@ public final class OpenTimelineAction extends CallableSystemAction {
"OpenTimeLineAction.msgdlg.text=Could not create timeline, there are no data sources."})
synchronized private void showTimeline(AbstractFile file, BlackboardArtifact artifact) {
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
if (currentCase.hasData() == false) {
MessageNotifyUtil.Message.info(Bundle.OpenTimeLineAction_msgdlg_text());
logger.log(Level.INFO, "Could not create timeline, there are no data sources.");// NON-NLS
@ -131,7 +132,7 @@ public final class OpenTimelineAction extends CallableSystemAction {
MessageNotifyUtil.Message.error(Bundle.OpenTimelineAction_settingsErrorMessage());
logger.log(Level.SEVERE, "Failed to initialize per case timeline settings.", iOException);
}
} catch (IllegalStateException e) {
} catch (NoCurrentCaseException e) {
//there is no case... Do nothing.
}
}
@ -212,8 +213,8 @@ public final class OpenTimelineAction extends CallableSystemAction {
private boolean tooManyFiles() {
try {
return FILE_LIMIT < Case.getCurrentCase().getSleuthkitCase().countFilesWhere("1 = 1");
} catch (IllegalStateException ex) {
return FILE_LIMIT < Case.getOpenCase().getSleuthkitCase().countFilesWhere("1 = 1");
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Can not open timeline with no case open.", ex);
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error counting files in the DB.", ex);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2014-2016 Basis Technology Corp.
* Copyright 2014-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -67,6 +67,7 @@ import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import static org.sleuthkit.autopsy.casemodule.Case.Events.CURRENT_CASE;
import static org.sleuthkit.autopsy.casemodule.Case.Events.DATA_SOURCE_ADDED;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.BlackBoardArtifactTagDeletedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
@ -949,8 +950,8 @@ public class TimeLineController {
* already closed.
*/
try {
Case.getCurrentCase();
} catch (IllegalStateException notUsed) {
Case.getOpenCase();
} catch (NoCurrentCaseException notUsed) {
// Case is closed, do nothing.
return;
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -51,6 +51,7 @@ import org.openide.windows.RetainLocation;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.actions.AddBookmarkTagAction;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponents.DataContentPanel;
import org.sleuthkit.autopsy.corecomponents.DataResultPanel;
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
@ -132,7 +133,7 @@ public final class TimeLineTopComponent extends TopComponent implements Explorer
contentViewerPanel.setNode(null);
}
});
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
//Since the case is closed, the user probably doesn't care about this, just log it as a precaution.
LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); // NON-NLS
} catch (TskCoreException ex) {

View File

@ -47,6 +47,7 @@ import org.controlsfx.validation.Validator;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.timeline.PromptDialogManager;
@ -152,8 +153,8 @@ public class SaveSnapshotAsReport extends Action {
try {
//add main file as report to case
Case.getCurrentCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName);
} catch (TskCoreException ex) {
Case.getOpenCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName);
} catch (TskCoreException | NoCurrentCaseException ex) {
LOGGER.log(Level.WARNING, "Failed to add " + reportMainFilePath.toString() + " to case as a report", ex); //NON_NLS
new Alert(Alert.AlertType.ERROR, Bundle.SaveSnapShotAsReport_FailedToAddReport()).show();
return;

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -33,6 +33,7 @@ import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.datamodel.DataModelActionsFactory;
@ -215,14 +216,14 @@ public class EventNode extends DisplayableItemNode {
* @return An EventNode with the file (and artifact) backing this event in
* its lookup.
*/
public static EventNode createEventNode(final Long eventID, FilteredEventsModel eventsModel) throws TskCoreException, IllegalStateException {
public static EventNode createEventNode(final Long eventID, FilteredEventsModel eventsModel) throws TskCoreException, NoCurrentCaseException {
/*
* Look up the event by id and creata an EventNode with the appropriate
* data in the lookup.
*/
final SingleEvent eventById = eventsModel.getEventById(eventID);
SleuthkitCase sleuthkitCase = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase();
AbstractFile file = sleuthkitCase.getAbstractFileById(eventById.getFileID());
if (eventById.getArtifactID().isPresent()) {

View File

@ -29,6 +29,7 @@ import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
@ -130,7 +131,7 @@ public class EventRootNode extends DisplayableItemNode {
} else {
try {
return EventNode.createEventNode(eventID, filteredEvents);
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
//Since the case is closed, the user probably doesn't care about this, just log it as a precaution.
LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); // NON-NLS
return null;

View File

@ -78,6 +78,7 @@ import org.controlsfx.control.action.ActionUtils;
import org.openide.awt.Actions;
import org.openide.util.NbBundle;
import org.openide.util.actions.Presenter;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ThreadConfined;
@ -668,7 +669,7 @@ class ListTimeline extends BorderPane {
//show new context menu.
new ContextMenu(menuItems.toArray(new MenuItem[menuItems.size()]))
.show(this, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
//Since the case is closed, the user probably doesn't care about this, just log it as a precaution.
LOGGER.log(Level.SEVERE, "There was no case open to lookup the Sleuthkit object backing a SingleEvent.", ex); //NON-NLS
} catch (TskCoreException ex) {

View File

@ -41,6 +41,7 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.datamodel.TskData;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
/**
*
@ -2343,9 +2344,9 @@ public class CentralRepoDatamodelTest extends TestCase {
// Test creating a case from an Autopsy case
// The case may already be in the database - the result is the same either way
try {
caseB = EamDb.getInstance().newCase(Case.getCurrentCase());
caseB = EamDb.getInstance().newCase(Case.getOpenCase());
assertTrue("Failed to create correlation case from Autopsy case", caseB != null);
} catch (EamDbException ex) {
} catch (EamDbException | NoCurrentCaseException ex) {
Exceptions.printStackTrace(ex);
Assert.fail(ex);
return;
@ -2412,9 +2413,9 @@ public class CentralRepoDatamodelTest extends TestCase {
// Test getting a case from an Autopsy case
try {
CorrelationCase tempCase = EamDb.getInstance().getCase(Case.getCurrentCase());
CorrelationCase tempCase = EamDb.getInstance().getCase(Case.getOpenCase());
assertTrue("getCase returned null for current Autopsy case", tempCase != null);
} catch (EamDbException ex) {
} catch (EamDbException | NoCurrentCaseException ex) {
Exceptions.printStackTrace(ex);
Assert.fail(ex);
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2016 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
import org.apache.commons.io.IOUtils;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.datamodel.ContentUtils;
import org.sleuthkit.datamodel.AbstractFile;
@ -57,9 +58,9 @@ class ArtifactTextExtractor implements TextExtractor<BlackboardArtifact> {
Case currentCase;
try {
currentCase = Case.getCurrentCase();
} catch (IllegalStateException ignore) {
// thorown by Case.getCurrentCase() if currentCase is null
currentCase = Case.getOpenCase();
} catch (NoCurrentCaseException ignore) {
// thorown by Case.getOpenCase() if currentCase is null
return null;
}

View File

@ -31,6 +31,7 @@ import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.keywordsearch.KeywordSearchResultFactory.AdHocQueryResult;
@ -176,7 +177,7 @@ public class ExtractedContentViewer implements DataContentViewer {
if (rawArtifactText != null) {
sources.add(rawArtifactText);
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error creating RawText for " + file, ex); //NON-NLS
}
@ -206,7 +207,7 @@ public class ExtractedContentViewer implements DataContentViewer {
}
static private IndexedText getRawArtifactText(BlackboardArtifact artifact) throws TskCoreException {
static private IndexedText getRawArtifactText(BlackboardArtifact artifact) throws TskCoreException, NoCurrentCaseException {
IndexedText rawArtifactText = null;
if (null != artifact) {
/*
@ -219,7 +220,7 @@ public class ExtractedContentViewer implements DataContentViewer {
BlackboardAttribute attribute = artifact.getAttribute(TSK_ASSOCIATED_ARTIFACT_TYPE);
if (attribute != null) {
long artifactId = attribute.getValueLong();
BlackboardArtifact associatedArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(artifactId);
BlackboardArtifact associatedArtifact = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(artifactId);
rawArtifactText = new RawText(associatedArtifact, associatedArtifact.getArtifactID());
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -24,6 +24,7 @@ import java.util.Comparator;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException;
@ -116,7 +117,12 @@ class KeywordHit implements Comparable<KeywordHit> {
long getContentID() throws TskCoreException {
if (isArtifactHit()) {
// If the hit was in an artifact, look up the source content for the artifact.
SleuthkitCase caseDb = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase caseDb;
try {
caseDb = Case.getOpenCase().getSleuthkitCase();
} catch (NoCurrentCaseException ex) {
throw new TskCoreException("Exception while getting open case.", ex);
}
try (SleuthkitCase.CaseDbQuery executeQuery =
caseDb.executeQuery(GET_CONTENT_ID_FROM_ARTIFACT_ID + this.solrObjectId);
ResultSet resultSet = executeQuery.getResultSet();) {

View File

@ -27,6 +27,7 @@ import java.util.logging.Level;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -144,7 +145,8 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
@Messages({
"KeywordSearchIngestModule.startupMessage.failedToGetIndexSchema=Failed to get schema version for text index.",
"# {0} - Solr version number", "KeywordSearchIngestModule.startupException.indexSolrVersionNotSupported=Adding text no longer supported for Solr version {0} of the text index.",
"# {0} - schema version number", "KeywordSearchIngestModule.startupException.indexSchemaNotSupported=Adding text no longer supported for schema version {0} of the text index."
"# {0} - schema version number", "KeywordSearchIngestModule.startupException.indexSchemaNotSupported=Adding text no longer supported for schema version {0} of the text index.",
"KeywordSearchIngestModule.noOpenCase.errMsg=No open case available."
})
@Override
public void startUp(IngestJobContext context) throws IngestModuleException {
@ -180,11 +182,17 @@ public final class KeywordSearchIngestModule implements FileIngestModule {
// increment the module reference count
// if first instance of this module for this job then check the server and existence of keywords
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
throw new IngestModuleException(Bundle.KeywordSearchIngestModule_noOpenCase_errMsg(), ex);
}
if (refCounter.incrementAndGet(jobId) == 1) {
if (Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) {
if (openCase.getCaseType() == Case.CaseType.MULTI_USER_CASE) {
// for multi-user cases need to verify connection to remore SOLR server
KeywordSearchService kwsService = new SolrSearchService();
Server.IndexingServerProperties properties = Server.getMultiUserServerProperties(Case.getCurrentCase().getCaseDirectory());
Server.IndexingServerProperties properties = Server.getMultiUserServerProperties(openCase.getCaseDirectory());
int port;
try {
port = Integer.parseInt(properties.getPort());

View File

@ -39,6 +39,7 @@ import org.openide.nodes.Node;
import org.openide.util.NbBundle;
import org.openide.util.lookup.Lookups;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode;
@ -147,8 +148,8 @@ class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
}
SleuthkitCase tskCase;
try {
tskCase = Case.getCurrentCase().getSleuthkitCase();
} catch (IllegalStateException ex) {
tskCase = Case.getOpenCase().getSleuthkitCase();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "There was no case open.", ex); //NON-NLS
return false;
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -32,6 +32,7 @@ import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.aggregate.ProgressContributor;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.EscapeUtil;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.ingest.IngestMessage;
@ -212,9 +213,9 @@ class QueryResults {
*/
Content content = null;
try {
SleuthkitCase tskCase = Case.getCurrentCase().getSleuthkitCase();
SleuthkitCase tskCase = Case.getOpenCase().getSleuthkitCase();
content = tskCase.getContentById(hit.getContentID());
} catch (TskCoreException | IllegalStateException tskCoreException) {
} catch (TskCoreException | NoCurrentCaseException tskCoreException) {
logger.log(Level.SEVERE, "Failed to get text source object for ", tskCoreException); //NON-NLS
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -39,6 +39,7 @@ import org.apache.solr.common.params.CursorMarkParams;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.datamodel.CreditCards;
@ -590,11 +591,11 @@ final class RegexQuery implements KeywordSearchQuery {
* Create an account instance.
*/
try {
AccountFileInstance ccAccountInstance = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString() , MODULE_NAME, content);
AccountFileInstance ccAccountInstance = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString() , MODULE_NAME, content);
ccAccountInstance.addAttributes(attributes);
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Error creating CCN account instance", ex); //NON-NLS
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 Basis Technology Corp.
* Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -34,6 +34,7 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.TermsResponse.Term;
import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.Version;
import org.sleuthkit.autopsy.datamodel.CreditCards;
@ -494,10 +495,9 @@ final class TermsComponentQuery implements KeywordSearchQuery {
* Create an account.
*/
try {
AccountFileInstance ccAccountInstance = Case.getCurrentCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString(), MODULE_NAME, content);
AccountFileInstance ccAccountInstance = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString(), MODULE_NAME, content);
ccAccountInstance.addAttributes(attributes);
//newArtifact = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifact(ccAccountInstance.getArtifactId());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Error creating CCN account instance", ex); //NON-NLS
}

View File

@ -114,7 +114,8 @@
<!-- Disabled. Could enforce in future, but not top priority right now.
<rule ref="rulesets/java/design.xml/UseLocaleWithCaseConversions"/> -->
<rule ref="rulesets/java/design.xml/AvoidProtectedFieldInFinalClass"/>
<rule ref="rulesets/java/design.xml/AvoidSynchronizedAtMethodLevel"/>
<!-- Disabled. Could enforce in future, but not top priority right now.
<rule ref="rulesets/java/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
<rule ref="rulesets/java/design.xml/UseNotifyAllInsteadOfNotify"/>
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod"/>
<rule ref="rulesets/java/design.xml/SimplifyConditional"/>