Merge remote-tracking branch 'upstream/develop' into 3537_CorrelationEngineSettingsPanel

This commit is contained in:
U-BASIS\dgrove 2018-03-06 17:34:02 -05:00
commit 010ebfc476
24 changed files with 205 additions and 80 deletions

View File

@ -27,6 +27,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
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.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.TagName;
@ -83,8 +84,8 @@ public class AddBlackboardArtifactTagAction extends AddTagAction {
new Thread(() -> {
for (BlackboardArtifact artifact : selectedArtifacts) {
try {
Case.getCurrentCase().getServices().getTagsManager().addBlackboardArtifactTag(artifact, tagName, comment);
} catch (TskCoreException ex) {
Case.getOpenCase().getServices().getTagsManager().addBlackboardArtifactTag(artifact, tagName, comment);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(AddBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error tagging result", ex); //NON-NLS
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),

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");
@ -30,6 +30,7 @@ import javax.swing.KeyStroke;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
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.TagName;
@ -44,7 +45,7 @@ public class AddBookmarkTagAction extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
try {
Map<String, TagName> tagNamesMap = Case.getCurrentCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap();
Map<String, TagName> tagNamesMap = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap();
TagName bookmarkTagName = tagNamesMap.get(BOOKMARK);
/*
@ -60,7 +61,7 @@ public class AddBookmarkTagAction extends AbstractAction {
AddContentTagAction.getInstance().addTag(bookmarkTagName, NO_COMMENT);
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(AddBookmarkTagAction.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
}

View File

@ -27,6 +27,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
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.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content;
@ -139,8 +140,8 @@ public class AddContentTagAction extends AddTagAction {
}
}
Case.getCurrentCase().getServices().getTagsManager().addContentTag(file, tagName, comment);
} catch (TskCoreException ex) {
Case.getOpenCase().getServices().getTagsManager().addContentTag(file, tagName, comment);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(AddContentTagAction.class.getName()).log(Level.SEVERE, "Error tagging result", ex); //NON-NLS
AbstractFile fileCopy = file;
SwingUtilities.invokeLater(() -> {

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,9 +26,9 @@ import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.Presenter;
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.TagName;
@ -91,11 +91,11 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
super(getActionDisplayName());
// Get the current set of tag names.
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
Map<String, TagName> tagNamesMap = null;
try {
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
@ -168,18 +168,26 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
* @param comment comment for the content or artifact tag
*/
private void getAndAddTag(String tagDisplayName, TagName tagName, String comment) {
Case openCase;
try {
openCase = Case.getOpenCase();
} catch (NoCurrentCaseException ex) {
Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
return;
}
if (tagName == null) {
try {
tagName = Case.getCurrentCase().getServices().getTagsManager().addTagName(tagDisplayName);
tagName = openCase.getServices().getTagsManager().addTagName(tagDisplayName);
} catch (TagsManager.TagNameAlreadyExistsException ex) {
try {
tagName = Case.getCurrentCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(tagDisplayName);
tagName = openCase.getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(tagDisplayName);
} catch (TskCoreException ex1) {
Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, tagDisplayName + " already exists in database but an error occurred in retrieving it.", ex1); //NON-NLS
}
}
} catch (TskCoreException ex) {
Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, "Error adding " + tagDisplayName + " tag name", ex); //NON-NLS
}
}
}
addTag(tagName, comment);
}

View File

@ -28,6 +28,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
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.datamodel.BlackboardArtifactTag;
import org.sleuthkit.datamodel.TskCoreException;
@ -72,8 +73,8 @@ public class DeleteBlackboardArtifactTagAction extends AbstractAction {
new Thread(() -> {
for (BlackboardArtifactTag tag : selectedTags) {
try {
Case.getCurrentCase().getServices().getTagsManager().deleteBlackboardArtifactTag(tag);
} catch (TskCoreException ex) {
Case.getOpenCase().getServices().getTagsManager().deleteBlackboardArtifactTag(tag);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(DeleteBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),

View File

@ -28,6 +28,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
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.datamodel.ContentTag;
import org.sleuthkit.datamodel.TskCoreException;
@ -71,8 +72,8 @@ public class DeleteContentTagAction extends AbstractAction {
new Thread(() -> {
for (ContentTag tag : selectedTags) {
try {
Case.getCurrentCase().getServices().getTagsManager().deleteContentTag(tag);
} catch (TskCoreException ex) {
Case.getOpenCase().getServices().getTagsManager().deleteContentTag(tag);
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(DeleteContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),

View File

@ -36,6 +36,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.Presenter;
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;
@ -95,7 +96,16 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem
@Override
protected Void doInBackground() throws Exception {
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager;
try {
tagsManager = Case.getOpenCase().getServices().getTagsManager();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error untagging artifact. No open case found.", ex); //NON-NLS
Platform.runLater(()
-> new Alert(Alert.AlertType.ERROR, Bundle.DeleteFileBlackboardArtifactTagAction_deleteTag_alert(artifactId)).show()
);
return null;
}
try {
logger.log(Level.INFO, "Removing tag {0} from {1}", new Object[]{tagName.getDisplayName(), artifactTag.getContent().getName()}); //NON-NLS
@ -142,13 +152,13 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem
BlackboardArtifact artifact
= selectedBlackboardArtifactsList.iterator().next();
// Get the current set of tag names.
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
Map<String, TagName> tagNamesMap = null;
try {
// Get the current set of tag names.
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
@ -158,7 +168,7 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem
if (null != tagNamesMap && !tagNamesMap.isEmpty()) {
try {
List<BlackboardArtifactTag> existingTagsList
= Case.getCurrentCase().getServices().getTagsManager()
= Case.getOpenCase().getServices().getTagsManager()
.getBlackboardArtifactTagsByArtifact(artifact);
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
@ -176,7 +186,7 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem
}
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagMenu.class.getName())
.log(Level.SEVERE, "Error retrieving tags for TagMenu", ex); //NON-NLS
}

View File

@ -36,6 +36,7 @@ import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.Presenter;
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.AbstractFile;
@ -95,7 +96,16 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen
@Override
protected Void doInBackground() throws Exception {
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
TagsManager tagsManager;
try {
tagsManager = Case.getOpenCase().getServices().getTagsManager();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error untagging file. No open case found.", ex); //NON-NLS
Platform.runLater(() ->
new Alert(Alert.AlertType.ERROR, Bundle.DeleteFileContentTagAction_deleteTag_alert(fileId)).show()
);
return null;
}
try {
logger.log(Level.INFO, "Removing tag {0} from {1}", new Object[]{tagName.getDisplayName(), contentTag.getContent().getName()}); //NON-NLS
@ -139,13 +149,13 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen
if(!selectedAbstractFilesList.isEmpty()) {
AbstractFile file = selectedAbstractFilesList.iterator().next();
// Get the current set of tag names.
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
Map<String, TagName> tagNamesMap = null;
try {
// Get the current set of tag names.
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
@ -155,7 +165,7 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen
if (null != tagNamesMap && !tagNamesMap.isEmpty()) {
try {
List<ContentTag> existingTagsList =
Case.getCurrentCase().getServices().getTagsManager()
Case.getOpenCase().getServices().getTagsManager()
.getContentTagsByContent(file);
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
@ -173,7 +183,7 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen
}
}
}
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(TagMenu.class.getName())
.log(Level.SEVERE, "Error retrieving tags for TagMenu", 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");
@ -36,6 +36,7 @@ import javax.swing.KeyStroke;
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.TagName;
@ -137,11 +138,11 @@ public class GetTagNameAndCommentDialog extends JDialog {
// tag name DTOs to be enable to return the one the user selects.
// Tag name DTOs may be null (user tag names that have not been used do
// not exist in the database).
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
try {
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
tagNamesSet.addAll(tagsManager.getAllTagNames());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(GetTagNameAndCommentDialog.class
.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}

View File

@ -39,6 +39,7 @@ import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
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.TagName;
@ -108,10 +109,10 @@ public class GetTagNameDialog extends JDialog {
// Get the current set of tag names and hash them for a speedy lookup in
// case the user chooses an existing tag name from the tag names table.
TagsManager tagsManager = Case.getCurrentCase().getServices().getTagsManager();
try {
TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager();
tagNamesMap.putAll(tagsManager.getDisplayNamesToTagNamesMap());
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(GetTagNameDialog.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
}
@ -347,9 +348,9 @@ public class GetTagNameDialog extends JDialog {
if (tagName == null) {
try {
tagName = Case.getCurrentCase().getServices().getTagsManager().addTagName(tagDisplayName, userTagDescription, TagName.HTML_COLOR.NONE, status);
tagName = Case.getOpenCase().getServices().getTagsManager().addTagName(tagDisplayName, userTagDescription, TagName.HTML_COLOR.NONE, status);
dispose();
} catch (TskCoreException ex) {
} catch (TskCoreException | NoCurrentCaseException ex) {
Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, "Error adding " + tagDisplayName + " tag name", ex); //NON-NLS
JOptionPane.showMessageDialog(this,
NbBundle.getMessage(this.getClass(),
@ -360,8 +361,8 @@ public class GetTagNameDialog extends JDialog {
tagName = null;
} catch (TagsManager.TagNameAlreadyExistsException ex) {
try {
tagName = Case.getCurrentCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(tagDisplayName);
} catch (TskCoreException ex1) {
tagName = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(tagDisplayName);
} catch (TskCoreException | NoCurrentCaseException ex1) {
Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, tagDisplayName + " exists in database but an error occurred in retrieving it.", ex1); //NON-NLS
JOptionPane.showMessageDialog(this,
NbBundle.getMessage(this.getClass(),

View File

@ -32,6 +32,7 @@ import org.openide.awt.ActionRegistration;
import org.openide.modules.Places;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
@ -57,9 +58,9 @@ public final class OpenLogFolderAction implements ActionListener {
/*
* Open the log directory for the case.
*/
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
logDir = new File(currentCase.getLogDirectoryPath());
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
/*
* There is no open case, open the application level log
* directory.

View File

@ -33,6 +33,7 @@ import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
import org.sleuthkit.autopsy.coreutils.Logger;
/**
@ -56,7 +57,7 @@ public final class OpenOutputFolderAction extends CallableSystemAction {
public void performAction() {
File outputDir;
try {
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
outputDir = new File(currentCase.getOutputDirectory());
if (outputDir.exists()) {
try {
@ -72,7 +73,7 @@ public final class OpenOutputFolderAction extends CallableSystemAction {
NbBundle.getMessage(this.getClass(), "OpenOutputFolder.error1", outputDir.getAbsolutePath()), NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
}
} catch (IllegalStateException ex) {
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "OpenOutputFolderAction enabled with no current case", ex); //NON-NLS
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), NbBundle.getMessage(this.getClass(), "OpenOutputFolder.noCaseOpen"));
}

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");
@ -58,10 +58,15 @@ final class AddImageWizardSelectDspVisual extends JPanel {
initComponents();
selectedDsp = lastDspUsed;
//if the last selected DSP was the Local Disk DSP and it would be disabled then we want to select a different DSP
if ((Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && selectedDsp.equals(LocalDiskDSProcessor.getType())) {
selectedDsp = ImageDSProcessor.getType();
try {
if ((Case.getOpenCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && selectedDsp.equals(LocalDiskDSProcessor.getType())) {
selectedDsp = ImageDSProcessor.getType();
}
createDataSourceProcessorButtons();
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex);
}
createDataSourceProcessorButtons();
//add actionlistner to listen for change
}
@ -96,7 +101,7 @@ final class AddImageWizardSelectDspVisual extends JPanel {
* Create the a button for each DataSourceProcessor that should exist as an
* option.
*/
private void createDataSourceProcessorButtons() {
private void createDataSourceProcessorButtons() throws NoCurrentCaseException {
//Listener for button selection
ActionListener cbActionListener = new ActionListener() {
@Override
@ -126,7 +131,7 @@ final class AddImageWizardSelectDspVisual extends JPanel {
//Add the button
JToggleButton dspButton = createDspButton(dspType);
dspButton.addActionListener(cbActionListener);
if ((Case.getCurrentCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && dspType.equals(LocalDiskDSProcessor.getType())){
if ((Case.getOpenCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && dspType.equals(LocalDiskDSProcessor.getType())){
dspButton.setEnabled(false); //disable the button for local disk DSP when this is a multi user case
dspButton.setSelected(false);
shouldAddMultiUserWarning = true;

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-2016 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");
@ -87,10 +87,10 @@ class AddLocalFilesTask implements Runnable {
List<String> errors = new ArrayList<>();
try {
progress.setIndeterminate(true);
FileManager fileManager = Case.getCurrentCase().getServices().getFileManager();
FileManager fileManager = Case.getOpenCase().getServices().getFileManager();
LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName, "", localFilePaths, new ProgressUpdater());
newDataSources.add(newDataSource);
} catch (TskDataException | TskCoreException ex) {
} catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
errors.add(ex.getMessage());
LOGGER.log(Level.SEVERE, String.format("Failed to add datasource: %s", ex.getMessage()), ex);
} finally {

View File

@ -588,19 +588,35 @@ public class Case {
* @return The current case.
*
* @throws IllegalStateException if there is no current case.
*/
*
* @deprecated. Use getOpenCase() instead.
*/
@Deprecated
public static Case getCurrentCase() {
/*
* Throwing an unchecked exception is a bad idea here.
*
* TODO (JIRA-2229): Case.getCurrentCase() method throws unchecked
* IllegalStateException; change to throw checked exception or return
* null
*/
if (null != currentCase) {
return currentCase;
try {
return getOpenCase();
} catch (NoCurrentCaseException ex) {
throw new IllegalStateException(NbBundle.getMessage(Case.class, "Case.getCurCase.exception.noneOpen"), ex);
}
}
/**
* Gets the current open case, if there is one, at the time of the call.
*
* @return The open case.
*
* @throws NoCurrentCaseException if there is no open case.
*/
public static Case getOpenCase() throws NoCurrentCaseException {
Case openCase = currentCase;
if (openCase == null) {
throw new NoCurrentCaseException(NbBundle.getMessage(Case.class, "Case.getCurCase.exception.noneOpen"));
} else {
throw new IllegalStateException(NbBundle.getMessage(Case.class, "Case.getCurCase.exception.noneOpen"));
return openCase;
}
}

View File

@ -264,7 +264,7 @@ public class ImageDSProcessor implements DataSourceProcessor, AutoIngestDataSour
try {
// verify that the image has a file system that TSK can process
Case currentCase = Case.getCurrentCase();
Case currentCase = Case.getOpenCase();
if (!DataSourceUtils.imageHasFileSystem(dataSourcePath)) {
// image does not have a file system that TSK can process
return 0;

View File

@ -42,6 +42,10 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
import org.sleuthkit.autopsy.imagewriter.ImageWriterSettings;
@NbBundle.Messages({"LocalDiskPanel.refreshTablebutton.text=Refresh Local Disks",
"LocalDiskPanel.listener.getOpenCase.errTitle=No open case available",
"LocalDiskPanel.listener.getOpenCase.errMsg=LocalDiskPanel listener couldn't get the open case."
})
/**
* ImageTypePanel for adding a local disk or partition such as PhysicalDrive0 or
* C:.
@ -74,9 +78,14 @@ final class LocalDiskPanel extends JPanel {
public void valueChanged(ListSelectionEvent e) {
if (diskTable.getSelectedRow() >= 0 && diskTable.getSelectedRow() < disks.size()) {
enableNext = true;
setPotentialImageWriterPath(disks.get(diskTable.getSelectedRow()));
try {
setPotentialImageWriterPath(disks.get(diskTable.getSelectedRow()));
firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true);
} catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", e); //NON-NLS
MessageNotifyUtil.Notify.show(Bundle.LocalDiskPanel_listener_getOpenCase_errTitle(),
Bundle.LocalDiskPanel_listener_getOpenCase_errMsg(),
MessageNotifyUtil.MessageType.ERROR);
} catch (Exception ex) {
logger.log(Level.SEVERE, "LocalDiskPanel listener threw exception", e); //NON-NLS
MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "LocalDiskPanel.moduleErr"),
@ -400,11 +409,11 @@ final class LocalDiskPanel extends JPanel {
return noFatOrphansCheckbox.isSelected();
}
private static String getDefaultImageWriterFolder() {
return Paths.get(Case.getCurrentCase().getModuleDirectory(), "Image Writer").toString();
private static String getDefaultImageWriterFolder() throws NoCurrentCaseException {
return Paths.get(Case.getOpenCase().getModuleDirectory(), "Image Writer").toString();
}
private void setPotentialImageWriterPath(LocalDisk disk) {
private void setPotentialImageWriterPath(LocalDisk disk) throws NoCurrentCaseException {
File subDirectory = Paths.get(getDefaultImageWriterFolder()).toFile();
if (!subDirectory.exists()) {

View File

@ -166,6 +166,9 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
errors.add(ex.getMessage());
callback.done(DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS, errors, new ArrayList<>());
return;
} catch (NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Exception while getting open case.", ex);
return;
}
}
}
@ -184,7 +187,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
* @throws
* org.sleuthkit.autopsy.casemodule.LocalFilesDSProcessor.L01Exception
*/
private List<String> extractLogicalEvidenceFileContents(final List<String> logicalEvidenceFilePaths) throws L01Exception {
private List<String> extractLogicalEvidenceFileContents(final List<String> logicalEvidenceFilePaths) throws L01Exception, NoCurrentCaseException {
final List<String> extractedPaths = new ArrayList<>();
Path ewfexportPath;
ewfexportPath = locateEwfexportExecutable();
@ -195,7 +198,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
command.add("-f");
command.add("files");
command.add("-t");
File l01Dir = new File(Case.getCurrentCase().getModuleDirectory(), L01_EXTRACTION_DIR); //WJS-TODO change to getOpenCase() when that method exists
File l01Dir = new File(Case.getOpenCase().getModuleDirectory(), L01_EXTRACTION_DIR); //WJS-TODO change to getOpenCase() when that method exists
if (!l01Dir.exists()) {
l01Dir.mkdirs();
}
@ -354,6 +357,9 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat
logger.log(Level.WARNING, "File extension was .l01 but contents of logical evidence file were unable to be extracted", ex);
//contents of l01 could not be extracted don't add data source or run ingest
return 0;
} catch (NoCurrentCaseException ex) {
logger.log(Level.WARNING, "Exception while getting open case.", ex);
return 0;
}
}
}

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");
@ -91,9 +91,9 @@ final class NewCaseWizardAction extends CallableSystemAction {
if (EamDb.isEnabled()) { //if the eam is enabled we need to save the case organization information now
EamDb dbManager = EamDb.getInstance();
if (dbManager != null) {
CorrelationCase cRCase = dbManager.getCase(Case.getCurrentCase());
CorrelationCase cRCase = dbManager.getCase(Case.getOpenCase());
if (cRCase == null) {
cRCase = dbManager.newCase(Case.getCurrentCase());
cRCase = dbManager.newCase(Case.getOpenCase());
}
if (!organizationName.isEmpty()) {
for (EamOrganization org : dbManager.getOrganizations()) {

View File

@ -0,0 +1,47 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.casemodule;
/**
*
* Exception thrown when no current case is available
*/
public class NoCurrentCaseException extends Exception {
private static final long serialVersionUID = 1L;
/**
* Constructs an exception with the specified message.
*
* @param message The exception message.
*/
public NoCurrentCaseException(String message) {
super(message);
}
/**
* Constructs an exception with the specified message and cause.
*
* @param message The exception message.
* @param cause The exception cause.
*/
public NoCurrentCaseException(String message, Throwable cause) {
super(message, cause);
}
}

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");
@ -374,8 +374,8 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu {
int i = 0;
String currentCaseName = null;
try {
currentCaseName = Case.getCurrentCase().getDisplayName();
} catch (IllegalStateException ex) {
currentCaseName = Case.getOpenCase().getDisplayName();
} catch (NoCurrentCaseException ex) {
// in case there is no current case.
}
@ -407,8 +407,8 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu {
String[] casePaths = new String[LENGTH];
String currentCasePath = null;
try {
currentCasePath = Case.getCurrentCase().getMetadata().getFilePath().toString();
} catch (IllegalStateException ex) {
currentCasePath = Case.getOpenCase().getMetadata().getFilePath().toString();
} catch (NoCurrentCaseException ex) {
/*
* There may be no current case.
*/

View File

@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.stream.Collectors;
import javax.swing.Action;
import org.apache.commons.lang3.StringUtils;
import org.openide.nodes.Sheet;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
@ -421,7 +422,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
ss.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_artifactMD5_name(),
Bundle.BlackboardArtifactNode_createSheet_artifactMD5_displayName(),
"",
file != null ? file.getMd5Hash() : ""));
file != null ? StringUtils.defaultString(file.getMd5Hash()) : ""));
}
} else {
String dataSourceStr = "";

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import javax.swing.Action;
import org.apache.commons.lang3.StringUtils;
import org.openide.nodes.Children;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
@ -114,7 +115,7 @@ class ContentTagNode extends DisplayableItemNode {
properties.put(new NodeProperty<>(Bundle.ContentTagNode_createSheet_artifactMD5_name(),
Bundle.ContentTagNode_createSheet_artifactMD5_displayName(),
"",
file != null ? file.getMd5Hash() : ""));
file != null ? StringUtils.defaultString(file.getMd5Hash()) : ""));
return propertySheet;
}

View File

@ -178,7 +178,10 @@
<rule ref="rulesets/java/imports.xml/ImportFromSamePackage"/>
<rule ref="rulesets/java/imports.xml/DuplicateImports"/>
<rule ref="rulesets/java/imports.xml/DontImportJavaLang"/>
<rule ref="rulesets/java/imports.xml/UnnecessaryFullyQualifiedName"/>
<!-- Disabled because flagging use of Bundle for bundle messages
is not desirable since this qualification helps with code completion
while inappropriate use of full qualification is otherwise very rare
<rule ref="rulesets/java/imports.xml/UnnecessaryFullyQualifiedName"/>-->
<!-- Disabled because it generated a lot of errors for non-Beans
<rule ref="rulesets/java/javabeans.xml/BeanMembersShouldSerialize"/>-->
<rule ref="rulesets/java/javabeans.xml/MissingSerialVersionUID"/>