Merge pull request #3513 from zhhl/2229-Part21UsegetOpenCaseInsteadOfgetCurrentCase

2229 Part 21 use getOpenCase() instead of getCurrentCase()
This commit is contained in:
Richard Cordovano 2018-03-09 17:44:59 -05:00 committed by GitHub
commit 24a9675330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 26 deletions

View File

@ -75,12 +75,12 @@ public final class IngestJobInfoPanel extends javax.swing.JPanel {
} }
private void refresh() { private void refresh() {
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
try { try {
SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase();
List<IngestJobInfo> ingestJobs = skCase.getIngestJobs(); List<IngestJobInfo> ingestJobs = skCase.getIngestJobs();
this.ingestJobs = ingestJobs; this.ingestJobs = ingestJobs;
this.repaint(); this.repaint();
} catch (TskCoreException ex) { } catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to load ingest jobs.", ex); logger.log(Level.SEVERE, "Failed to load ingest jobs.", ex);
JOptionPane.showMessageDialog(this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, Bundle.IngestJobInfoPanel_loadIngestJob_error_text(), Bundle.IngestJobInfoPanel_loadIngestJob_error_title(), JOptionPane.ERROR_MESSAGE);
} }
@ -114,11 +114,11 @@ public final class IngestJobInfoPanel extends javax.swing.JPanel {
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
IngestJobInfo currIngestJob = ingestJobs.get(rowIndex); IngestJobInfo currIngestJob = ingestJobs.get(rowIndex);
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
if (columnIndex == 0) { if (columnIndex == 0) {
try { try {
SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase();
return skCase.getContentById(currIngestJob.getObjectId()).getName(); return skCase.getContentById(currIngestJob.getObjectId()).getName();
} catch (TskCoreException ex) { } catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Failed to get content from db", ex); logger.log(Level.SEVERE, "Failed to get content from db", ex);
return ""; return "";
} }

View File

@ -543,7 +543,8 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
@Messages({ @Messages({
"OptionalCasePropertiesPanel.errorDialog.emptyCaseNameMessage=No case name entered.", "OptionalCasePropertiesPanel.errorDialog.emptyCaseNameMessage=No case name entered.",
"OptionalCasePropertiesPanel.errorDialog.invalidCaseNameMessage=Case names cannot include the following symbols: \\, /, :, *, ?, \", <, >, |" "OptionalCasePropertiesPanel.errorDialog.invalidCaseNameMessage=Case names cannot include the following symbols: \\, /, :, *, ?, \", <, >, |",
"OptionalCasePropertiesPanel.errorDialog.noOpenCase.errMsg=Exception while getting open case."
}) })
void saveUpdatedCaseDetails() { void saveUpdatedCaseDetails() {
if (caseDisplayNameTextField.getText().trim().isEmpty()) { if (caseDisplayNameTextField.getText().trim().isEmpty()) {
@ -554,14 +555,19 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_invalidCaseNameMessage()); MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_invalidCaseNameMessage());
return; return;
} }
updateCaseDetails(); try {
updateCaseDetails();
} catch (NoCurrentCaseException ex) {
MessageNotifyUtil.Message.error(Bundle.OptionalCasePropertiesPanel_errorDialog_noOpenCase_errMsg());
return;
}
updateCorrelationCase(); updateCorrelationCase();
} }
private void updateCaseDetails() { private void updateCaseDetails() throws NoCurrentCaseException {
if (caseDisplayNameTextField.isVisible()) { if (caseDisplayNameTextField.isVisible()) {
try { try {
Case.getCurrentCase().updateCaseDetails(new CaseDetails( Case.getOpenCase().updateCaseDetails(new CaseDetails(
caseDisplayNameTextField.getText(), caseNumberTextField.getText(), caseDisplayNameTextField.getText(), caseNumberTextField.getText(),
examinerTextField.getText(), tfExaminerPhoneText.getText(), examinerTextField.getText(), tfExaminerPhoneText.getText(),
tfExaminerEmailText.getText(), taNotesText.getText())); tfExaminerEmailText.getText(), taNotesText.getText()));
@ -580,7 +586,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
if (EamDb.isEnabled()) { if (EamDb.isEnabled()) {
try { try {
EamDb dbManager = EamDb.getInstance(); EamDb dbManager = EamDb.getInstance();
CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCase()); CorrelationCase correlationCase = dbManager.getCase(Case.getOpenCase());
if (caseDisplayNameTextField.isVisible()) { if (caseDisplayNameTextField.isVisible()) {
correlationCase.setDisplayName(caseDisplayNameTextField.getText()); correlationCase.setDisplayName(caseDisplayNameTextField.getText());
} }
@ -592,7 +598,9 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel {
correlationCase.setNotes(taNotesText.getText()); correlationCase.setNotes(taNotesText.getText());
dbManager.updateCase(correlationCase); dbManager.updateCase(correlationCase);
} catch (EamDbException ex) { } catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Error connecting to central repository database", ex); // NON-NLS LOGGER.log(Level.SEVERE, "Error connecting to central repository database", ex); // NON-NLS
} catch (NoCurrentCaseException ex) {
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
} finally { } finally {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2016 Basis Technology Corp. * Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -28,6 +28,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.PathValidator; import org.sleuthkit.autopsy.coreutils.PathValidator;
@ -296,12 +297,18 @@ final class RawDSInputPanel extends JPanel implements DocumentListener {
* *
* @param path Absolute path to the selected data source * @param path Absolute path to the selected data source
*/ */
@Messages({"RawDSInputPanel.error.text=Path to multi-user data source is on \"C:\" drive"}) @Messages({"RawDSInputPanel.error.text=Path to multi-user data source is on \"C:\" drive",
"RawDSInputPanel.noOpenCase.errMsg=Exception while getting open case."})
private void warnIfPathIsInvalid(String path) { private void warnIfPathIsInvalid(String path) {
if (!PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { try {
if (!PathValidator.isValid(path, Case.getOpenCase().getCaseType())) {
errorLabel.setVisible(true); errorLabel.setVisible(true);
errorLabel.setText(Bundle.RawDSInputPanel_error_text()); errorLabel.setText(Bundle.RawDSInputPanel_error_text());
} }
} catch (NoCurrentCaseException ex) {
errorLabel.setVisible(true);
errorLabel.setText(Bundle.RawDSInputPanel_noOpenCase_errMsg());
}
} }
void storeSettings() { void storeSettings() {

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2017 Basis Technology Corp. * Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -43,6 +43,7 @@ import javax.swing.border.EmptyBorder;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
/** /**
* Filters file date properties (modified/created/etc.. times) * Filters file date properties (modified/created/etc.. times)
@ -140,7 +141,7 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
try { try {
// get the latest case // get the latest case
Case currentCase = Case.getCurrentCase(); // get the most updated case Case currentCase = Case.getOpenCase(); // get the most updated case
Set<TimeZone> caseTimeZones = currentCase.getTimeZones(); Set<TimeZone> caseTimeZones = currentCase.getTimeZones();
Iterator<TimeZone> iterator = caseTimeZones.iterator(); Iterator<TimeZone> iterator = caseTimeZones.iterator();
@ -167,7 +168,7 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
String item = String.format("(GMT%+d:%02d) %s", hour, minutes, id); //NON-NLS String item = String.format("(GMT%+d:%02d) %s", hour, minutes, id); //NON-NLS
timeZones.add(item); timeZones.add(item);
} }
} catch (IllegalStateException ex) { } catch (NoCurrentCaseException ex) {
// No current case. // No current case.
} }
@ -281,9 +282,9 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
* that is already closed. * that is already closed.
*/ */
try { try {
Case.getCurrentCase(); Case.getOpenCase();
SwingUtilities.invokeLater(DateSearchFilter.this::updateTimeZoneList); SwingUtilities.invokeLater(DateSearchFilter.this::updateTimeZoneList);
} catch (IllegalStateException notUsed) { } catch (NoCurrentCaseException notUsed) {
/** /**
* Case is closed, do nothing. * Case is closed, do nothing.
*/ */

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2015 Basis Technology Corp. * Copyright 2011-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -40,6 +40,7 @@ import java.util.logging.Level;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.casemodule.services.Blackboard; import org.sleuthkit.autopsy.casemodule.services.Blackboard;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
@ -102,8 +103,12 @@ public final class ExifParserFileIngestModule implements FileIngestModule {
@Override @Override
public ProcessResult process(AbstractFile content) { public ProcessResult process(AbstractFile content) {
blackboard = Case.getCurrentCase().getServices().getBlackboard(); try {
blackboard = Case.getOpenCase().getServices().getBlackboard();
} catch (NoCurrentCaseException ex) {
logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS
return ProcessResult.ERROR;
}
//skip unalloc //skip unalloc
if ((content.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS) if ((content.getType().equals(TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS)
|| (content.getType().equals(TSK_DB_FILES_TYPE_ENUM.SLACK)))) { || (content.getType().equals(TSK_DB_FILES_TYPE_ENUM.SLACK)))) {

View File

@ -39,6 +39,7 @@ import java.util.logging.Level;
import org.openide.modules.InstalledFileLocator; import org.openide.modules.InstalledFileLocator;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.ExecUtil; import org.sleuthkit.autopsy.coreutils.ExecUtil;
import org.sleuthkit.autopsy.coreutils.FileUtil; import org.sleuthkit.autopsy.coreutils.FileUtil;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
@ -409,7 +410,12 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule {
* @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException * @throws org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException
*/ */
synchronized Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException { synchronized Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException {
Path path = Paths.get(Case.getCurrentCase().getModuleDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); Path path;
try {
path = Paths.get(Case.getOpenCase().getModuleDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName());
} catch (NoCurrentCaseException ex) {
throw new IngestModule.IngestModuleException(Bundle.cannotCreateOutputDir_message(ex.getLocalizedMessage()), ex);
}
try { try {
Files.createDirectory(path); Files.createDirectory(path);
if (UNCPathUtilities.isUNC(path)) { if (UNCPathUtilities.isUNC(path)) {

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2013 Basis Technology Corp. * Copyright 2013-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -35,6 +35,7 @@ import java.util.regex.Matcher;
import org.mitre.cybox.objects.WindowsRegistryKey; import org.mitre.cybox.objects.WindowsRegistryKey;
import org.mitre.cybox.common_2.ConditionTypeEnum; import org.mitre.cybox.common_2.ConditionTypeEnum;
import com.williballenthin.rejistry.*; import com.williballenthin.rejistry.*;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
/** /**
* *
@ -345,7 +346,12 @@ class EvalRegistryObj extends EvaluatableObject {
List<RegistryFileInfo> regFilesLocal = new ArrayList<RegistryFileInfo>(); List<RegistryFileInfo> regFilesLocal = new ArrayList<RegistryFileInfo>();
// Make the temp directory // Make the temp directory
String tmpDir = Case.getCurrentCase().getTempDirectory() + File.separator + "STIX"; //NON-NLS String tmpDir;
try {
tmpDir = Case.getOpenCase().getTempDirectory() + File.separator + "STIX"; //NON-NLS
} catch (NoCurrentCaseException ex) {
throw new TskCoreException(ex.getLocalizedMessage());
}
File dir = new File(tmpDir); File dir = new File(tmpDir);
if (dir.exists() == false) { if (dir.exists() == false) {
dir.mkdirs(); dir.mkdirs();
@ -377,9 +383,15 @@ class EvalRegistryObj extends EvaluatableObject {
*/ */
private static List<AbstractFile> findRegistryFiles() throws TskCoreException { private static List<AbstractFile> findRegistryFiles() throws TskCoreException {
List<AbstractFile> registryFiles = new ArrayList<AbstractFile>(); List<AbstractFile> registryFiles = new ArrayList<AbstractFile>();
org.sleuthkit.autopsy.casemodule.services.FileManager fileManager = Case.getCurrentCase().getServices().getFileManager(); Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
throw new TskCoreException(ex.getLocalizedMessage());
}
org.sleuthkit.autopsy.casemodule.services.FileManager fileManager = openCase.getServices().getFileManager();
for (Content ds : Case.getCurrentCase().getDataSources()) { for (Content ds : openCase.getDataSources()) {
// find the user-specific ntuser-dat files // find the user-specific ntuser-dat files
registryFiles.addAll(fileManager.findFiles(ds, "ntuser.dat")); //NON-NLS registryFiles.addAll(fileManager.findFiles(ds, "ntuser.dat")); //NON-NLS