diff --git a/Core/manifest.mf b/Core/manifest.mf index 260c73c542..67d3366e22 100644 --- a/Core/manifest.mf +++ b/Core/manifest.mf @@ -2,7 +2,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.sleuthkit.autopsy.core/10 OpenIDE-Module-Localizing-Bundle: org/sleuthkit/autopsy/core/Bundle.properties OpenIDE-Module-Layer: org/sleuthkit/autopsy/core/layer.xml -OpenIDE-Module-Implementation-Version: 22 +OpenIDE-Module-Implementation-Version: 23 OpenIDE-Module-Requires: org.openide.windows.WindowManager AutoUpdate-Show-In-Client: true AutoUpdate-Essential-Module: true diff --git a/Core/nbproject/project.properties b/Core/nbproject/project.properties index 0e683d15fd..7ae5484bc9 100644 --- a/Core/nbproject/project.properties +++ b/Core/nbproject/project.properties @@ -19,6 +19,9 @@ file.reference.sevenzipjbinding.jar=release/modules/ext/sevenzipjbinding.jar file.reference.sqlite-jdbc-3.8.11.jar=release/modules/ext/sqlite-jdbc-3.8.11.jar file.reference.StixLib.jar=release/modules/ext/StixLib.jar file.reference.sleuthkit-postgresql-4.6.1.jar=release/modules/ext/sleuthkit-postgresql-4.6.1.jar +file.reference.bcprov-jdk15on-1.54.jar=release/modules/ext/bcprov-jdk15on-1.54.jar +file.reference.jackcess-2.1.8.jar=release/modules/ext/jackcess-2.1.8.jar +file.reference.jackcess-encrypt-2.1.2.jar=release/modules/ext/jackcess-encrypt-2.1.2.jar file.reference.jempbox-1.8.13.jar=release/modules/ext/jempbox-1.8.13.jar file.reference.javax.ws.rs-api-2.0.1.jar=release/modules/ext/javax.ws.rs-api-2.0.1.jar file.reference.cxf-core-3.0.16.jar=release/modules/ext/cxf-core-3.0.16.jar @@ -44,5 +47,5 @@ nbm.homepage=http://www.sleuthkit.org/ nbm.module.author=Brian Carrier nbm.needs.restart=true source.reference.curator-recipes-2.8.0.jar=release/modules/ext/curator-recipes-2.8.0-sources.jar -spec.version.base=10.10 +spec.version.base=10.11 diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index 26676f0054..ac3ec60d44 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -411,6 +411,18 @@ ext/curator-client-2.8.0.jar release/modules/ext/curator-client-2.8.0.jar + + ext/bcprov-jdk15on-1.54.jar + release/modules/ext/bcprov-jdk15on-1.54.jar + + + ext/jackcess-2.1.8.jar + release/modules/ext/jackcess-2.1.8.jar + + + ext/jackcess-encrypt-2.1.2.jar + release/modules/ext/jackcess-encrypt-2.1.2.jar + ext/jempbox-1.8.13.jar release/modules/ext/jempbox-1.8.13.jar diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddBlackboardArtifactTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddBlackboardArtifactTagAction.java index 47bd201ec1..7ad185ac8e 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/AddBlackboardArtifactTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddBlackboardArtifactTagAction.java @@ -84,7 +84,7 @@ public class AddBlackboardArtifactTagAction extends AddTagAction { new Thread(() -> { for (BlackboardArtifact artifact : selectedArtifacts) { try { - Case.getOpenCase().getServices().getTagsManager().addBlackboardArtifactTag(artifact, tagName, comment); + Case.getCurrentCaseThrows().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(() -> { diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddBookmarkTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddBookmarkTagAction.java index 9e99922775..d6090b2ace 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/AddBookmarkTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddBookmarkTagAction.java @@ -45,7 +45,7 @@ public class AddBookmarkTagAction extends AbstractAction { @Override public void actionPerformed(ActionEvent e) { try { - Map tagNamesMap = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap(); + Map tagNamesMap = Case.getCurrentCaseThrows().getServices().getTagsManager().getDisplayNamesToTagNamesMap(); TagName bookmarkTagName = tagNamesMap.get(BOOKMARK); /* diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java index dad777585f..602789735d 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddContentTagAction.java @@ -140,7 +140,7 @@ public class AddContentTagAction extends AddTagAction { } } - Case.getOpenCase().getServices().getTagsManager().addContentTag(file, tagName, comment); + Case.getCurrentCaseThrows().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; diff --git a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java index 12e23bdb30..7d0212b51c 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/AddTagAction.java @@ -93,7 +93,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { // Get the current set of tag names. Map tagNamesMap = null; try { - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap()); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS @@ -170,7 +170,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup { private void getAndAddTag(String tagDisplayName, TagName tagName, String comment) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/actions/DeleteBlackboardArtifactTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/DeleteBlackboardArtifactTagAction.java index 28aa03bed8..18ae9ac7e5 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/DeleteBlackboardArtifactTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/DeleteBlackboardArtifactTagAction.java @@ -73,7 +73,7 @@ public class DeleteBlackboardArtifactTagAction extends AbstractAction { new Thread(() -> { for (BlackboardArtifactTag tag : selectedTags) { try { - Case.getOpenCase().getServices().getTagsManager().deleteBlackboardArtifactTag(tag); + Case.getCurrentCaseThrows().getServices().getTagsManager().deleteBlackboardArtifactTag(tag); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(DeleteBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS SwingUtilities.invokeLater(() -> { diff --git a/Core/src/org/sleuthkit/autopsy/actions/DeleteContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/DeleteContentTagAction.java index 065a023c2f..07cce02bfc 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/DeleteContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/DeleteContentTagAction.java @@ -72,7 +72,7 @@ public class DeleteContentTagAction extends AbstractAction { new Thread(() -> { for (ContentTag tag : selectedTags) { try { - Case.getOpenCase().getServices().getTagsManager().deleteContentTag(tag); + Case.getCurrentCaseThrows().getServices().getTagsManager().deleteContentTag(tag); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(DeleteContentTagAction.class.getName()).log(Level.SEVERE, "Error deleting tag", ex); //NON-NLS SwingUtilities.invokeLater(() -> { diff --git a/Core/src/org/sleuthkit/autopsy/actions/DeleteFileBlackboardArtifactTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/DeleteFileBlackboardArtifactTagAction.java index ce99fb1ec4..008cb419ff 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/DeleteFileBlackboardArtifactTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/DeleteFileBlackboardArtifactTagAction.java @@ -98,7 +98,7 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem protected Void doInBackground() throws Exception { TagsManager tagsManager; try { - tagsManager = Case.getOpenCase().getServices().getTagsManager(); + tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Error untagging artifact. No open case found.", ex); //NON-NLS Platform.runLater(() @@ -155,7 +155,7 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem Map tagNamesMap = null; try { // Get the current set of tag names. - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap()); } catch (TskCoreException | NoCurrentCaseException ex) { @@ -168,7 +168,7 @@ public class DeleteFileBlackboardArtifactTagAction extends AbstractAction implem if (null != tagNamesMap && !tagNamesMap.isEmpty()) { try { List existingTagsList - = Case.getOpenCase().getServices().getTagsManager() + = Case.getCurrentCaseThrows().getServices().getTagsManager() .getBlackboardArtifactTagsByArtifact(artifact); for (Map.Entry entry : tagNamesMap.entrySet()) { diff --git a/Core/src/org/sleuthkit/autopsy/actions/DeleteFileContentTagAction.java b/Core/src/org/sleuthkit/autopsy/actions/DeleteFileContentTagAction.java index abc316b33f..f336cd888f 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/DeleteFileContentTagAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/DeleteFileContentTagAction.java @@ -98,7 +98,7 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen protected Void doInBackground() throws Exception { TagsManager tagsManager; try { - tagsManager = Case.getOpenCase().getServices().getTagsManager(); + tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Error untagging file. No open case found.", ex); //NON-NLS Platform.runLater(() -> @@ -152,7 +152,7 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen Map tagNamesMap = null; try { // Get the current set of tag names. - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagNamesMap = new TreeMap<>(tagsManager.getDisplayNamesToTagNamesMap()); } catch (TskCoreException | NoCurrentCaseException ex) { @@ -165,7 +165,7 @@ public class DeleteFileContentTagAction extends AbstractAction implements Presen if (null != tagNamesMap && !tagNamesMap.isEmpty()) { try { List existingTagsList = - Case.getOpenCase().getServices().getTagsManager() + Case.getCurrentCaseThrows().getServices().getTagsManager() .getContentTagsByContent(file); for (Map.Entry entry : tagNamesMap.entrySet()) { diff --git a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameAndCommentDialog.java b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameAndCommentDialog.java index f295a613a5..51665012cd 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameAndCommentDialog.java +++ b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameAndCommentDialog.java @@ -139,7 +139,7 @@ public class GetTagNameAndCommentDialog extends JDialog { // Tag name DTOs may be null (user tag names that have not been used do // not exist in the database). try { - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagNamesSet.addAll(tagsManager.getAllTagNames()); } catch (TskCoreException | NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java index 4bdbf0bd29..21785f2003 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java +++ b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java @@ -110,7 +110,7 @@ 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. try { - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagNamesMap.putAll(tagsManager.getDisplayNamesToTagNamesMap()); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(GetTagNameDialog.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS @@ -348,7 +348,7 @@ public class GetTagNameDialog extends JDialog { if (tagName == null) { try { - tagName = Case.getOpenCase().getServices().getTagsManager().addTagName(tagDisplayName, userTagDescription, TagName.HTML_COLOR.NONE, status); + tagName = Case.getCurrentCaseThrows().getServices().getTagsManager().addTagName(tagDisplayName, userTagDescription, TagName.HTML_COLOR.NONE, status); dispose(); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(AddTagAction.class.getName()).log(Level.SEVERE, "Error adding " + tagDisplayName + " tag name", ex); //NON-NLS @@ -361,7 +361,7 @@ public class GetTagNameDialog extends JDialog { tagName = null; } catch (TagsManager.TagNameAlreadyExistsException ex) { try { - tagName = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(tagDisplayName); + tagName = Case.getCurrentCaseThrows().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, diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java index 021ecd6278..fb178c797d 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenLogFolderAction.java @@ -58,7 +58,7 @@ public final class OpenLogFolderAction implements ActionListener { /* * Open the log directory for the case. */ - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); logDir = new File(currentCase.getLogDirectoryPath()); } catch (NoCurrentCaseException ex) { /* diff --git a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java index c79a559b2d..29b8d67960 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java +++ b/Core/src/org/sleuthkit/autopsy/actions/OpenOutputFolderAction.java @@ -57,7 +57,7 @@ public final class OpenOutputFolderAction extends CallableSystemAction { public void performAction() { File outputDir; try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); outputDir = new File(currentCase.getOutputDirectory()); if (outputDir.exists()) { try { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java index 21a7bca103..cbcb06c936 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java @@ -109,7 +109,7 @@ class AddImageTask implements Runnable { public void run() { Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); return; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index 23a963bf6a..6c6097717e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -345,7 +345,7 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { new Thread(() -> { try { - Case.getOpenCase().notifyAddingDataSource(dataSourceId); + Case.getCurrentCaseThrows().notifyAddingDataSource(dataSourceId); } catch (NoCurrentCaseException ex) { Logger.getLogger(AddImageWizardAddingProgressVisual.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS } @@ -417,9 +417,9 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { new Thread(() -> { try { if (!contents.isEmpty()) { - Case.getOpenCase().notifyDataSourceAdded(contents.get(0), dataSourceId); + Case.getCurrentCaseThrows().notifyDataSourceAdded(contents.get(0), dataSourceId); } else { - Case.getOpenCase().notifyFailedAddingDataSource(dataSourceId); + Case.getCurrentCaseThrows().notifyFailedAddingDataSource(dataSourceId); } } catch (NoCurrentCaseException ex) { Logger.getLogger(AddImageWizardAddingProgressVisual.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardSelectDspVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardSelectDspVisual.java index e01773a79c..43bfed1caa 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardSelectDspVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardSelectDspVisual.java @@ -59,7 +59,7 @@ final class AddImageWizardSelectDspVisual extends JPanel { 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 try { - if ((Case.getOpenCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && selectedDsp.equals(LocalDiskDSProcessor.getType())) { + if ((Case.getCurrentCaseThrows().getCaseType() == Case.CaseType.MULTI_USER_CASE) && selectedDsp.equals(LocalDiskDSProcessor.getType())) { selectedDsp = ImageDSProcessor.getType(); } createDataSourceProcessorButtons(); @@ -131,7 +131,7 @@ final class AddImageWizardSelectDspVisual extends JPanel { //Add the button JToggleButton dspButton = createDspButton(dspType); dspButton.addActionListener(cbActionListener); - if ((Case.getOpenCase().getCaseType() == Case.CaseType.MULTI_USER_CASE) && dspType.equals(LocalDiskDSProcessor.getType())){ + if ((Case.getCurrentCaseThrows().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; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddLocalFilesTask.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddLocalFilesTask.java index e7e3702600..feae1ddb6b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddLocalFilesTask.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddLocalFilesTask.java @@ -87,7 +87,7 @@ class AddLocalFilesTask implements Runnable { List errors = new ArrayList<>(); try { progress.setIndeterminate(true); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName, "", localFilePaths, new ProgressUpdater()); newDataSources.add(newDataSource); } catch (TskDataException | TskCoreException | NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index ffea4e9d5d..44bf52503f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -584,37 +584,41 @@ public class Case { } /** - * Deprecated. Use getOpenCase() instead. - * - * Gets the current case, if there is one, at the time of the call. + * Gets the current case. This method should only be called by clients that + * can be sure a case is currently open. Some examples of suitable clients + * are data source processors, ingest modules, and report modules. * * @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. - * - */ try { - return getOpenCase(); + return getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { + /* + * Throw a runtime exception, since this is a programming error. + */ 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. + * Gets the current case, if there is one, or throws an exception if there + * is no current case. This method should only be called by methods known to + * run in threads where it is possible that another thread has closed the + * current case. The exception provides some protection from the + * consequences of the race condition between the calling thread and a case + * closing thread, but it is not fool-proof. Background threads calling this + * method should put all operations in an exception firewall with a try and + * catch-all block to handle the possibility of bad timing. * - * @return The open case. + * TODO (JIRA-3825): Introduce a reference counting scheme for this get case + * method. * - * @throws NoCurrentCaseException if there is no open case. + * @return The current case. + * + * @throws NoCurrentCaseException if there is no current case. */ - public static Case getOpenCase() throws NoCurrentCaseException { + public static Case getCurrentCaseThrows() throws NoCurrentCaseException { Case openCase = currentCase; if (openCase == null) { throw new NoCurrentCaseException(NbBundle.getMessage(Case.class, "Case.getCurCase.exception.noneOpen")); @@ -1568,7 +1572,7 @@ public class Case { String normalizedLocalPath; try { if (localPath.toLowerCase().contains("http:")) { - normalizedLocalPath = localPath; + normalizedLocalPath = localPath; } else { normalizedLocalPath = Paths.get(localPath).normalize().toString(); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseDeleteAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseDeleteAction.java index 2b333e2bdc..a389aca979 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseDeleteAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseDeleteAction.java @@ -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.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); String caseName = currentCase.getName(); String caseDirectory = currentCase.getCaseDirectory(); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java index 76c280f6b2..b8542552c4 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CaseInformationPanel.java @@ -54,7 +54,7 @@ class CaseInformationPanel extends javax.swing.JPanel { }) private void customizeComponents() { try { - propertiesPanel = new CasePropertiesPanel(Case.getOpenCase()); + propertiesPanel = new CasePropertiesPanel(Case.getCurrentCaseThrows()); } catch (NoCurrentCaseException ex) { Logger.getLogger(CaseInformationPanel.class.getName()).log(Level.INFO, "Exception while getting open case.", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CasePropertiesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/CasePropertiesPanel.java index c020e7b033..cc3c682830 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CasePropertiesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CasePropertiesPanel.java @@ -50,7 +50,7 @@ final class CasePropertiesPanel extends javax.swing.JPanel { void updateCaseInfo() { try { - theCase = Case.getOpenCase(); + theCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); return; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java index be7905e010..2db469e371 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java @@ -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.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); if (!DataSourceUtils.imageHasFileSystem(dataSourcePath)) { // image does not have a file system that TSK can process return 0; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 6fa73b7ff7..56d5e67839 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -319,7 +319,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { // Display warning if there is one (but don't disable "next" button) try { - if (false == PathValidator.isValid(path, Case.getOpenCase().getCaseType())) { + if (false == PathValidator.isValid(path, Case.getCurrentCaseThrows().getCaseType())) { pathErrorLabel.setVisible(true); pathErrorLabel.setText(Bundle.ImageFilePanel_pathValidation_dataSourceOnCDriveError()); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/IngestJobInfoPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/IngestJobInfoPanel.java index e0b1ec8f01..9bce28753f 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/IngestJobInfoPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/IngestJobInfoPanel.java @@ -75,7 +75,7 @@ public final class IngestJobInfoPanel extends javax.swing.JPanel { private void refresh() { try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); List ingestJobs = skCase.getIngestJobs(); this.ingestJobs = ingestJobs; this.repaint(); @@ -115,7 +115,7 @@ public final class IngestJobInfoPanel extends javax.swing.JPanel { IngestJobInfo currIngestJob = ingestJobs.get(rowIndex); if (columnIndex == 0) { try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); return skCase.getContentById(currIngestJob.getObjectId()).getName(); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Failed to get content from db", ex); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java index b22f858b63..fc702076a0 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskPanel.java @@ -382,7 +382,7 @@ final class LocalDiskPanel extends JPanel { } private static String getDefaultImageWriterFolder() throws NoCurrentCaseException { - return Paths.get(Case.getOpenCase().getModuleDirectory(), "Image Writer").toString(); + return Paths.get(Case.getCurrentCaseThrows().getModuleDirectory(), "Image Writer").toString(); } private void setPotentialImageWriterPath(LocalDisk disk) throws NoCurrentCaseException { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java index f98e8264ac..c7fa2c3de3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java @@ -197,7 +197,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor, AutoIngestDat command.add("-f"); command.add("files"); command.add("-t"); - File l01Dir = new File(Case.getOpenCase().getModuleDirectory(), L01_EXTRACTION_DIR); //WJS-TODO change to getOpenCase() when that method exists + File l01Dir = new File(Case.getCurrentCaseThrows().getModuleDirectory(), L01_EXTRACTION_DIR); //WJS-TODO change to getOpenCase() when that method exists if (!l01Dir.exists()) { l01Dir.mkdirs(); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java index ecfafd7844..3ab4088094 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesPanel.java @@ -283,7 +283,7 @@ final class LocalFilesPanel extends javax.swing.JPanel { errorLabel.setVisible(false); try { - final Case.CaseType currentCaseType = Case.getOpenCase().getCaseType(); + final Case.CaseType currentCaseType = Case.getCurrentCaseThrows().getCaseType(); for (String currentPath : pathsList) { if (!PathValidator.isValid(currentPath, currentCaseType)) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LogicalEvidenceFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/LogicalEvidenceFilePanel.java index 4e70d4b248..d38106a0ab 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LogicalEvidenceFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LogicalEvidenceFilePanel.java @@ -191,7 +191,7 @@ final class LogicalEvidenceFilePanel extends javax.swing.JPanel implements Docum } // display warning if there is one (but don't disable "next" button) try { - if (!PathValidator.isValid(path, Case.getOpenCase().getCaseType())) { + if (!PathValidator.isValid(path, Case.getCurrentCaseThrows().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(Bundle.LogicalEvidenceFilePanel_pathValidation_dataSourceOnCDriveError()); return false; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java index 2f806bcecc..2b85a74333 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/NewCaseWizardAction.java @@ -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.getOpenCase()); + CorrelationCase cRCase = dbManager.getCase(Case.getCurrentCaseThrows()); if (cRCase == null) { - cRCase = dbManager.newCase(Case.getOpenCase()); + cRCase = dbManager.newCase(Case.getCurrentCaseThrows()); } if (!organizationName.isEmpty()) { for (EamOrganization org : dbManager.getOrganizations()) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java index 0dae889f5b..4625727d94 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/OptionalCasePropertiesPanel.java @@ -64,7 +64,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { if (editCurrentCase) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); return; @@ -94,7 +94,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { private void setUpOrganizationData() { if (EamDb.isEnabled()) { try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); if (currentCase != null) { EamDb dbManager = EamDb.getInstance(); selectedOrg = dbManager.getCase(currentCase).getOrg(); @@ -567,7 +567,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { private void updateCaseDetails() throws NoCurrentCaseException { if (caseDisplayNameTextField.isVisible()) { try { - Case.getOpenCase().updateCaseDetails(new CaseDetails( + Case.getCurrentCaseThrows().updateCaseDetails(new CaseDetails( caseDisplayNameTextField.getText(), caseNumberTextField.getText(), examinerTextField.getText(), tfExaminerPhoneText.getText(), tfExaminerEmailText.getText(), taNotesText.getText())); @@ -586,7 +586,7 @@ final class OptionalCasePropertiesPanel extends javax.swing.JPanel { if (EamDb.isEnabled()) { try { EamDb dbManager = EamDb.getInstance(); - CorrelationCase correlationCase = dbManager.getCase(Case.getOpenCase()); + CorrelationCase correlationCase = dbManager.getCase(Case.getCurrentCaseThrows()); if (caseDisplayNameTextField.isVisible()) { correlationCase.setDisplayName(caseDisplayNameTextField.getText()); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java b/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java index 6aeb3338d4..ccf592ca67 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java @@ -374,7 +374,7 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu { int i = 0; String currentCaseName = null; try { - currentCaseName = Case.getOpenCase().getDisplayName(); + currentCaseName = Case.getCurrentCaseThrows().getDisplayName(); } catch (NoCurrentCaseException ex) { // in case there is no current case. } @@ -407,7 +407,7 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu { String[] casePaths = new String[LENGTH]; String currentCasePath = null; try { - currentCasePath = Case.getOpenCase().getMetadata().getFilePath().toString(); + currentCasePath = Case.getCurrentCaseThrows().getMetadata().getFilePath().toString(); } catch (NoCurrentCaseException ex) { /* * There may be no current case. diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/BlackBoardArtifactTagAddedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/BlackBoardArtifactTagAddedEvent.java index ad08e643fd..8c2a2d6dfa 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/BlackBoardArtifactTagAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/BlackBoardArtifactTagAddedEvent.java @@ -47,6 +47,6 @@ public class BlackBoardArtifactTagAddedEvent extends TagAddedEvent implements S * @throws TskCoreException */ ContentTag getTagByID() throws NoCurrentCaseException, TskCoreException { - return Case.getOpenCase().getServices().getTagsManager().getContentTagByTagID(getTagID()); + return Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagByTagID(getTagID()); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java index dcf575a5dc..84a99ee8b2 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/DataSourceAddedEvent.java @@ -79,7 +79,7 @@ public final class DataSourceAddedEvent extends AutopsyEvent implements Serializ } try { long id = (Long) super.getNewValue(); - dataSource = Case.getOpenCase().getSleuthkitCase().getContentById(id); + dataSource = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(id); return dataSource; } catch (NoCurrentCaseException | TskCoreException ex) { logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/events/ReportAddedEvent.java b/Core/src/org/sleuthkit/autopsy/casemodule/events/ReportAddedEvent.java index 2fe152d32e..7f35c625c5 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/events/ReportAddedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/events/ReportAddedEvent.java @@ -70,7 +70,7 @@ public final class ReportAddedEvent extends AutopsyEvent implements Serializable } try { long id = (Long) super.getNewValue(); - List reports = Case.getOpenCase().getSleuthkitCase().getAllReports(); + List reports = Case.getCurrentCaseThrows().getSleuthkitCase().getAllReports(); for (Report thisReport : reports) { if (thisReport.getId() == id) { report = thisReport; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index 70b10b0f0e..58b4f41d6e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -1,14 +1,14 @@ /* - * Sleuth Kit Data Model + * Autopsy Forensic Browser * - * Copyright 2011-2016 Basis Technology Corp. + * Copyright 2015-2018 Basis Technology Corp. * Contact: carrier sleuthkit 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 + * 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, @@ -65,7 +65,7 @@ public final class Blackboard implements Closeable { throw new BlackboardException("Keyword search service not found"); } try { - searchService.indexArtifact(artifact); + searchService.index(artifact); } catch (TskCoreException ex) { throw new BlackboardException("Error indexing artifact", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java index 5c978f6378..fb02e7d2d4 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagNameDefinition.java @@ -297,7 +297,7 @@ final class TagNameDefinition implements Comparable { } setting.append(tagName.toSettingsFormat()); try { - SleuthkitCase caseDb = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase caseDb = Case.getCurrentCaseThrows().getSleuthkitCase(); tagName.saveToCase(caseDb); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagOptionsPanel.java index 5073f4110b..419a92e8c9 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagOptionsPanel.java @@ -425,7 +425,7 @@ final class TagOptionsPanel extends javax.swing.JPanel implements OptionsPanel { for (String modifiedTagDisplayName : updatedStatusTags) { //if user closes their case after options have been changed but before application of them is complete don't notify try { - Case.getOpenCase().notifyTagDefinitionChanged(modifiedTagDisplayName); + Case.getCurrentCaseThrows().notifyTagDefinitionChanged(modifiedTagDisplayName); } catch (NoCurrentCaseException ex) { Logger.getLogger(TagOptionsPanel.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java index b38165ef5c..f113a622fe 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java @@ -99,7 +99,7 @@ public class TagsManager implements Closeable { tagDisplayNames.add(tagType.getDisplayName()); }); try { - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); for (TagName tagName : tagsManager.getAllTagNames()) { tagDisplayNames.add(tagName.getDisplayName()); } @@ -340,7 +340,7 @@ public class TagsManager implements Closeable { ContentTag tag; tag = caseDb.addContentTag(content, tagName, comment, beginByteOffset, endByteOffset); try { - Case.getOpenCase().notifyContentTagAdded(tag); + Case.getCurrentCaseThrows().notifyContentTagAdded(tag); } catch (NoCurrentCaseException ex) { throw new TskCoreException("Added a tag to a closed case", ex); } @@ -358,7 +358,7 @@ public class TagsManager implements Closeable { public void deleteContentTag(ContentTag tag) throws TskCoreException { caseDb.deleteContentTag(tag); try { - Case.getOpenCase().notifyContentTagDeleted(tag); + Case.getCurrentCaseThrows().notifyContentTagDeleted(tag); } catch (NoCurrentCaseException ex) { throw new TskCoreException("Deleted a tag from a closed case", ex); } @@ -470,7 +470,7 @@ 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.getOpenCase().notifyBlackBoardArtifactTagAdded(tag); + Case.getCurrentCaseThrows().notifyBlackBoardArtifactTagAdded(tag); } catch (NoCurrentCaseException ex) { throw new TskCoreException("Added a tag to a closed case", ex); } @@ -488,7 +488,7 @@ public class TagsManager implements Closeable { public void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException { caseDb.deleteBlackboardArtifactTag(tag); try { - Case.getOpenCase().notifyBlackBoardArtifactTagDeleted(tag); + Case.getCurrentCaseThrows().notifyBlackBoardArtifactTagDeleted(tag); } catch (NoCurrentCaseException ex) { throw new TskCoreException("Deleted a tag from a closed case", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java index c16d16d70c..2a86e7c279 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/DataContentViewerOtherCases.java @@ -169,7 +169,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D private void showCaseDetails(int selectedRowViewIdx) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, Bundle.DataContentViewerOtherCases_noOpenCase_errMsg(), @@ -225,7 +225,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D if (0 != otherCasesTable.getSelectedRowCount()) { Calendar now = Calendar.getInstance(); String fileName = String.format("%1$tY%1$tm%1$te%1$tI%1$tM%1$tS_other_data_sources.csv", now); - CSVFileChooser.setCurrentDirectory(new File(Case.getOpenCase().getExportDirectory())); + CSVFileChooser.setCurrentDirectory(new File(Case.getCurrentCaseThrows().getExportDirectory())); CSVFileChooser.setSelectedFile(new File(fileName)); CSVFileChooser.setFileFilter(new FileNameExtensionFilter("csv file", "csv")); @@ -434,7 +434,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D private Collection getCorrelatedInstances(CorrelationAttribute corAttr, String dataSourceName, String deviceId) { // @@@ Check exception try { - String caseUUID = Case.getOpenCase().getName(); + String caseUUID = Case.getCurrentCaseThrows().getName(); EamDb dbManager = EamDb.getInstance(); Collection artifactInstances = dbManager.getArtifactInstancesByTypeValue(corAttr.getCorrelationType(), corAttr.getCorrelationValue()).stream() .filter(artifactInstance -> !artifactInstance.getCorrelationCase().getCaseUUID().equals(caseUUID) @@ -491,7 +491,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D if (af != null) { Content dataSource = af.getDataSource(); dataSourceName = dataSource.getName(); - deviceId = Case.getOpenCase().getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId(); + deviceId = Case.getCurrentCaseThrows().getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId(); } } catch (TskException | NoCurrentCaseException ex) { // do nothing. diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java index cba529954e..864bf50923 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationDataSource.java @@ -74,7 +74,7 @@ public class CorrelationDataSource implements Serializable { public static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource) throws EamDbException { Case curCase; try { - curCase = Case.getOpenCase(); + curCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { throw new EamDbException("Autopsy case is closed"); } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java index 43812eeebf..69cad2abef 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/EamArtifactUtil.java @@ -90,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.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); AbstractFile bbSourceFile = currentCase.getSleuthkitCase().getAbstractFileById(bbArtifact.getObjectID()); if (null == bbSourceFile) { //@@@ Log this @@ -98,9 +98,9 @@ public class EamArtifactUtil { } // make an instance for the BB source file - CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getOpenCase()); + CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); if (null == correlationCase) { - correlationCase = EamDb.getInstance().newCase(Case.getOpenCase()); + correlationCase = EamDb.getInstance().newCase(Case.getCurrentCaseThrows()); } CorrelationAttributeInstance eamInstance = new CorrelationAttributeInstance( correlationCase, @@ -146,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.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); + BlackboardArtifact associatedArtifact = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); return EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(correlationType, associatedArtifact); } @@ -254,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.getOpenCase()); + CorrelationCase correlationCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); if (null == correlationCase) { - correlationCase = EamDb.getInstance().newCase(Case.getOpenCase()); + correlationCase = EamDb.getInstance().newCase(Case.getCurrentCaseThrows()); } CorrelationAttributeInstance cei = new CorrelationAttributeInstance( correlationCase, diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java index da11671a08..570f5bca06 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java @@ -163,8 +163,8 @@ final class CaseEventListener implements PropertyChangeListener { try { // Get the remaining tags on the content object - Content content = Case.getOpenCase().getSleuthkitCase().getContentById(contentID); - TagsManager tagsManager = Case.getOpenCase().getServices().getTagsManager(); + Content content = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(contentID); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); List tags = tagsManager.getContentTagsByContent(content); if (tags.stream() @@ -244,7 +244,7 @@ final class CaseEventListener implements PropertyChangeListener { } else { //BLACKBOARD_ARTIFACT_TAG_DELETED Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); return; @@ -327,10 +327,10 @@ final class CaseEventListener implements PropertyChangeListener { * that are tagged with the given tag name. */ try { - TagName tagName = Case.getOpenCase().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(modifiedTagName); + TagName tagName = Case.getCurrentCaseThrows().getServices().getTagsManager().getDisplayNamesToTagNamesMap().get(modifiedTagName); //First update the artifacts //Get all BlackboardArtifactTags with this tag name - List artifactTags = Case.getOpenCase().getSleuthkitCase().getBlackboardArtifactTagsByTagName(tagName); + List artifactTags = Case.getCurrentCaseThrows().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; @@ -346,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.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); List tags = tagsManager.getBlackboardArtifactTagsByArtifact(bbArtifact); //get all tags which are on this blackboard artifact for (BlackboardArtifactTag t : tags) { @@ -374,7 +374,7 @@ final class CaseEventListener implements PropertyChangeListener { } // Next update the files - List fileTags = Case.getOpenCase().getSleuthkitCase().getContentTagsByTagName(tagName); + List fileTags = Case.getCurrentCaseThrows().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 @@ -384,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.getOpenCase().getServices().getTagsManager(); + TagsManager tagsManager = Case.getCurrentCaseThrows().getServices().getTagsManager(); List tags = tagsManager.getContentTagsByContent(content); //get all tags which are on this file for (ContentTag t : tags) { @@ -436,7 +436,7 @@ final class CaseEventListener implements PropertyChangeListener { } Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); return; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java index 508798f02b..46ebe75541 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/IngestEventsListener.java @@ -163,7 +163,7 @@ public class IngestEventsListener { tifArtifact.addAttributes(attributes); try { // index the artifact for keyword search - Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard(); + Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); blackboard.indexArtifact(tifArtifact); } catch (Blackboard.BlackboardException | NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Unable to index blackboard artifact " + tifArtifact.getArtifactID(), ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java index 991da1ad58..96486a8f5b 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/ingestmodule/IngestModule.java @@ -94,7 +94,7 @@ final class IngestModule implements FileIngestModule { } try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); return ProcessResult.ERROR; @@ -233,7 +233,7 @@ final class IngestModule implements FileIngestModule { } Case autopsyCase; try { - autopsyCase = Case.getOpenCase(); + autopsyCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); throw new IngestModuleException("Exception while getting open case.", ex); diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetadataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetadataBuilder.java index 8abab90380..2d279179ee 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetadataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetadataBuilder.java @@ -170,7 +170,7 @@ abstract class CommonFilesMetadataBuilder { Map commonFiles = new HashMap<>(); - SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase sleuthkitCase = Case.getCurrentCaseThrows().getSleuthkitCase(); String selectStatement = this.buildSqlSelectStatement(); try ( @@ -225,7 +225,7 @@ abstract class CommonFilesMetadataBuilder { StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size()); if (!mimeTypesToFilterOn.isEmpty()) { for (String mimeType : mimeTypesToFilterOn) { - mimeTypeFilter.append('"').append(mimeType).append("\","); + mimeTypeFilter.append("'").append(mimeType).append("',"); } mimeTypeString = mimeTypeFilter.toString().substring(0, mimeTypeFilter.length() - 1); mimeTypeString = String.format(filterByMimeTypesWhereClause, new Object[]{mimeTypeString}); diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java index 6b8fada124..ad278a4cb5 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java @@ -166,7 +166,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel { Map dataSouceMap = new HashMap<>(); - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); SleuthkitCase tskDb = currentCase.getSleuthkitCase(); loadLogicalSources(tskDb, dataSouceMap); diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceKey.java b/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceKey.java index 244838d8ef..2262e6af61 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceKey.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountDeviceInstanceKey.java @@ -104,7 +104,7 @@ final class AccountDeviceInstanceKey { private static String getDataSourceName(AccountDeviceInstance accountDeviceInstance) { try { - SleuthkitCase db = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase db = Case.getCurrentCaseThrows().getSleuthkitCase(); for (DataSource dataSource : db.getDataSources()) { if (dataSource.getDeviceId().equals(accountDeviceInstance.getDeviceId())) { return db.getContentById(dataSource.getId()).getName(); diff --git a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java index 534da9d557..a0417855fe 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java +++ b/Core/src/org/sleuthkit/autopsy/communications/AccountsBrowser.java @@ -121,7 +121,7 @@ public final class AccountsBrowser extends JPanel implements ExplorerManager.Pro @Subscribe public void handleFilterEvent(CVTEvents.FilterChangeEvent filterChangeEvent) { try { - final CommunicationsManager commsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager(); + final CommunicationsManager commsManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager(); accountsTableEM.setRootContext(new AbstractNode(Children.create(new AccountDeviceInstanceNodeFactory(commsManager, filterChangeEvent.getNewFilter()), true))); } catch (TskCoreException ex) { logger.log(Level.SEVERE, "There was an error getting the CommunicationsManager for the current case.", ex); diff --git a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java index c3d69ed28d..6cd46fbab4 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java @@ -209,7 +209,7 @@ final public class FiltersPanel extends JPanel { //TODO: something like this commented code could be used to show only //the account types that are found: - //final CommunicationsManager communicationsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager(); + //final CommunicationsManager communicationsManager = Case.getCurrentOpenCase().getSleuthkitCase().getCommunicationsManager(); //List accountTypesInUse = communicationsManager.getAccountTypesInUse(); //accountTypesInUSe.forEach(...) Account.Type.PREDEFINED_ACCOUNT_TYPES.forEach(type -> { @@ -240,7 +240,7 @@ final public class FiltersPanel extends JPanel { */ private void updateDeviceFilter(boolean initialState) { try { - final SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase(); + final SleuthkitCase sleuthkitCase = Case.getCurrentCaseThrows().getSleuthkitCase(); for (DataSource dataSource : sleuthkitCase.getDataSources()) { String dsName = sleuthkitCase.getContentById(dataSource.getId()).getName(); diff --git a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java index f3f77fbef4..8d0743b272 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/VisualizationPanel.java @@ -295,7 +295,7 @@ final public class VisualizationPanel extends JPanel implements Lookup.Provider windowAncestor = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this); try { - commsManager = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager(); + commsManager = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager(); } catch (TskCoreException ex) { logger.log(Level.SEVERE, "Error getting CommunicationsManager for the current case.", ex); } catch (NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/EpochTimeCellRenderer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/EpochTimeCellRenderer.java index 723c1ef0f3..7f618c0754 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/EpochTimeCellRenderer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/EpochTimeCellRenderer.java @@ -33,7 +33,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; * Custom Cell renderer to display a SQLite column cell as readable Epoch date/time * */ -public class EpochTimeCellRenderer extends DefaultTableCellRenderer { +class EpochTimeCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; private static final Logger LOGGER = Logger.getLogger(FileViewer.class.getName()); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/FXVideoPanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/FXVideoPanel.java index ef6acc1fd4..cc5e2008b5 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/FXVideoPanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/FXVideoPanel.java @@ -139,7 +139,7 @@ public class FXVideoPanel extends MediaViewVideoPanel { final File tempFile; try { - tempFile = VideoUtils.getTempVideoFile(currentFile); + tempFile = VideoUtils.getVideoFileInTempDir(currentFile); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/FileTypeViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/FileTypeViewer.java similarity index 77% rename from Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/FileTypeViewer.java rename to Core/src/org/sleuthkit/autopsy/contentviewers/FileTypeViewer.java index b3ae7210a2..a2096dd2d9 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/FileTypeViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/FileTypeViewer.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.sleuthkit.autopsy.corecomponentinterfaces; +package org.sleuthkit.autopsy.contentviewers; import java.awt.Component; import java.util.List; @@ -26,7 +26,7 @@ import org.sleuthkit.datamodel.AbstractFile; * Defines an interface for application specific content viewer * */ -public interface FileTypeViewer { +interface FileTypeViewer { /** * Returns list of MIME types supported by this viewer @@ -45,6 +45,11 @@ public interface FileTypeViewer { /** * Clears the data in the panel + * + * IMPORTANT IF MAKING THIS PUBLIC: I (RC) am not sure that this method + * belongs in this interface. If we are not going to use setFile(null) as a + * reset method as in DataContentViewer and DataResultViewer, then this is + * fine. Otherwise, it is ambiguous. */ void resetComponent(); } diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/FileViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/FileViewer.java index 98cee5bc59..53be8ddbcd 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/FileViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/FileViewer.java @@ -31,7 +31,6 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.datamodel.AbstractFile; -import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer; /** * Generic Application content viewer diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/GstVideoPanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/GstVideoPanel.java index c686471a41..5ebd894517 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/GstVideoPanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/GstVideoPanel.java @@ -198,7 +198,7 @@ public class GstVideoPanel extends MediaViewVideoPanel { java.io.File ioFile; try { - ioFile = VideoUtils.getTempVideoFile(file); + ioFile = VideoUtils.getVideoFileInTempDir(file); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS infoLabel.setText(Bundle.GstVideoPanel_noOpenCase_errMsg()); @@ -552,7 +552,7 @@ public class GstVideoPanel extends MediaViewVideoPanel { } else if (state.equals(State.READY)) { final File tempVideoFile; try { - tempVideoFile = VideoUtils.getTempVideoFile(currentFile); + tempVideoFile = VideoUtils.getVideoFileInTempDir(currentFile); } catch (NoCurrentCaseException ex) { logger.log(Level.WARNING, "Exception while getting open case."); //NON-NLS infoLabel.setText(MEDIA_PLAYER_ERROR_STRING); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaFileViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaFileViewer.java index 1d9695712b..92da0733d8 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaFileViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaFileViewer.java @@ -24,14 +24,13 @@ import java.awt.Dimension; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; -import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; /** * Media content viewer for videos, sounds and images. */ -public class MediaFileViewer extends javax.swing.JPanel implements FileTypeViewer { +class MediaFileViewer extends javax.swing.JPanel implements FileTypeViewer { private static final Logger LOGGER = Logger.getLogger(MediaFileViewer.class.getName()); private AbstractFile lastFile; diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java index b6505544ba..b04473990c 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2017 Basis Technology Corp. + * Copyright 2011-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,6 @@ import org.controlsfx.control.MaskerPane; import org.openide.util.NbBundle; import org.python.google.common.collect.Lists; import org.sleuthkit.autopsy.casemodule.Case; -//import org.sleuthkit.autopsy.corecomponents.Bundle; import org.sleuthkit.autopsy.coreutils.ImageUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.FileNode; @@ -61,7 +60,7 @@ import org.sleuthkit.datamodel.AbstractFile; @NbBundle.Messages({"MediaViewImagePanel.externalViewerButton.text=Open in External Viewer", "MediaViewImagePanel.errorLabel.text=Could not load file into Media View.", "MediaViewImagePanel.errorLabel.OOMText=Could not load file into Media View: insufficent memory."}) -public class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPanel { +class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPanel { private static final Image EXTERNAL = new Image(MediaViewImagePanel.class.getResource("/org/sleuthkit/autopsy/images/external.png").toExternalForm()); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewVideoPanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewVideoPanel.java index 8848164683..0a203a0909 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewVideoPanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewVideoPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ import org.sleuthkit.datamodel.AbstractFile; * Video viewer part of the Media View layered pane. Uses different engines * depending on platform. */ -public abstract class MediaViewVideoPanel extends JPanel implements FrameCapture, MediaFileViewer.MediaViewPanel { +abstract class MediaViewVideoPanel extends JPanel implements FrameCapture, MediaFileViewer.MediaViewPanel { private static final Set AUDIO_EXTENSIONS = new TreeSet<>(Arrays.asList(".mp3", ".wav", ".wma")); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java index 8726cfedb6..62b9996f22 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MessageContentViewer.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2017-18 Basis Technology Corp. + * Copyright 2017-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/PListRowFactory.java b/Core/src/org/sleuthkit/autopsy/contentviewers/PListRowFactory.java index 75b2970ecb..f0bc0a95bc 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/PListRowFactory.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/PListRowFactory.java @@ -33,7 +33,8 @@ import org.sleuthkit.autopsy.datamodel.NodeProperty; /** * Factory class to create nodes for Plist table view */ -public class PListRowFactory extends ChildFactory { + +class PListRowFactory extends ChildFactory { private final List rows; diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/PListViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/PListViewer.java index f3d630eaf3..6478114314 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/PListViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/PListViewer.java @@ -58,13 +58,12 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.TskCoreException; import org.xml.sax.SAXException; -import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer; /** * PListViewer - a file viewer for binary plist files. * */ -public class PListViewer extends javax.swing.JPanel implements FileTypeViewer, ExplorerManager.Provider { +class PListViewer extends javax.swing.JPanel implements FileTypeViewer, ExplorerManager.Provider { private static final long serialVersionUID = 1L; private static final String[] MIMETYPES = new String[]{"application/x-bplist"}; @@ -192,7 +191,7 @@ public class PListViewer extends javax.swing.JPanel implements FileTypeViewer, E Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { JOptionPane.showMessageDialog(this, "Failed to export plist file.", diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteTableRowFactory.java b/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteTableRowFactory.java index 02a08f7037..afaf3ae398 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteTableRowFactory.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteTableRowFactory.java @@ -34,7 +34,8 @@ import org.sleuthkit.autopsy.datamodel.NodeProperty; /** * Factory class to generate nodes for SQLite table rows */ -public class SQLiteTableRowFactory extends ChildFactory { + +class SQLiteTableRowFactory extends ChildFactory { private final List> rows; private final List colActions; diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteViewer.java b/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteViewer.java index 4a4ee95a90..250b74f36a 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteViewer.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/SQLiteViewer.java @@ -50,13 +50,12 @@ import org.sleuthkit.autopsy.datamodel.ContentUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; -import org.sleuthkit.autopsy.corecomponentinterfaces.FileTypeViewer; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; /** * A file content viewer for SQLite database files. */ -public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer { +class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer { private static final long serialVersionUID = 1L; public static final String[] SUPPORTED_MIMETYPES = new String[]{"application/x-sqlite3"}; @@ -320,7 +319,7 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer { // Copy the file to temp folder String tmpDBPathName; try { - tmpDBPathName = Case.getOpenCase().getTempDirectory() + File.separator + sqliteDbFile.getName(); + tmpDBPathName = Case.getCurrentCaseThrows().getTempDirectory() + File.separator + sqliteDbFile.getName(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Current case has been closed", ex); //NON-NLS MessageNotifyUtil.Message.error(Bundle.SQLiteViewer_errorMessage_noCurrentCase()); @@ -373,7 +372,7 @@ public class SQLiteViewer extends javax.swing.JPanel implements FileTypeViewer { * @param metaFileName name of meta file to look for */ private void findAndCopySQLiteMetaFile(AbstractFile sqliteFile, String metaFileName) throws NoCurrentCaseException, TskCoreException, IOException { - Case openCase = Case.getOpenCase(); + Case openCase = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = openCase.getSleuthkitCase(); Services services = new Services(sleuthkitCase); FileManager fileManager = services.getFileManager(); diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties index c2a9d9845f..bae8218148 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Bundle.properties @@ -26,7 +26,7 @@ LBL_Description=
Autopsy™ is a digital forensics platform based on The Sleuth Kit™ and other tools.
Copyright © 2003-2018.
URL_ON_IMG=http://www.sleuthkit.org/ -URL_ON_HELP=http://sleuthkit.org/autopsy/docs/user-docs/4.6.0/ +URL_ON_HELP=http://sleuthkit.org/autopsy/docs/user-docs/4.7.0/ FILE_FOR_LOCAL_HELP=file:/// INDEX_FOR_LOCAL_HELP=/docs/index.html LBL_Close=Close diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java index abe3876ae2..6331d67023 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentTopComponent.java @@ -184,7 +184,7 @@ public final class DataContentTopComponent extends TopComponent implements DataC */ Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return true; } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java index 02bf1f4907..eea1a61f6e 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultPanel.java @@ -496,7 +496,28 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C } /** - * Closes this reult view panel. Intended to be called by the parent top + * Indicates whether or not this panel can be closed at the time of the + * call. + * + * @return True or false. + */ + public boolean canClose() { + /* + * If this is the "main" panel, only allow it to be closed when no case + * is open or no there are no data sources in the current case. + */ + Case openCase; + try { + openCase = Case.getCurrentCaseThrows(); + } catch (NoCurrentCaseException ex) { + return true; + } + return (!this.isMain) || openCase.hasData() == false; + } + + /** + * Closes down the component. Intended to be called by the parent top +>>>>>>> custom-release-may-2018 * component when it is closed. */ void close() { @@ -548,7 +569,7 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C * single node. */ Node[] selectedNodes = explorerManager.getSelectedNodes(); - if (1 == selectedNodes.length) { + if (selectedNodes.length == 1) { contentView.setNode(selectedNodes[0]); } else { contentView.setNode(null); diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java index c6b0037a85..dc88be9fee 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataResultTopComponent.java @@ -375,7 +375,7 @@ public final class DataResultTopComponent extends TopComponent implements DataRe public boolean canClose() { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException unused) { return true; } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java index 9394234e4d..5bcd68a03b 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java @@ -121,7 +121,7 @@ public class Installer extends ModuleInstall { }); } - public static void setUIFont (javax.swing.plaf.FontUIResource f){ + private static void setUIFont (javax.swing.plaf.FontUIResource f){ java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java index 2e517db0bb..11e92836ac 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ImageUtils.java @@ -132,8 +132,7 @@ public class ImageUtils { } catch (UnsatisfiedLinkError e) { openCVLoadedTemp = false; LOGGER.log(Level.SEVERE, "OpenCV Native code library failed to load", e); //NON-NLS - //TODO: show warning bubble - + MessageNotifyUtil.Notify.show("Open CV", "OpenCV native library failed to load, see log for more details", MessageNotifyUtil.MessageType.WARNING); } OPEN_CV_LOADED = openCVLoadedTemp; @@ -385,7 +384,7 @@ public class ImageUtils { private static File getCachedThumbnailLocation(long fileID) { return cacheFileMap.computeIfAbsent(fileID, id -> { try { - String cacheDirectory = Case.getOpenCase().getCacheDirectory(); + String cacheDirectory = Case.getCurrentCaseThrows().getCacheDirectory(); return Paths.get(cacheDirectory, "thumbnails", fileID + ".png").toFile(); //NON-NLS } catch (NoCurrentCaseException e) { LOGGER.log(Level.WARNING, "Could not get cached thumbnail location. No case is open."); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java b/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java index 59d16ac5f3..1ff258dade 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/VideoUtils.java @@ -45,8 +45,8 @@ import org.sleuthkit.datamodel.AbstractFile; */ public class VideoUtils { - private static final List SUPPORTED_VIDEO_EXTENSIONS = - Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg", //NON-NLS + private static final List SUPPORTED_VIDEO_EXTENSIONS + = Arrays.asList("mov", "m4v", "flv", "mp4", "3gp", "avi", "mpg", //NON-NLS "mpeg", "asf", "divx", "rm", "moov", "wmv", "vob", "dat", //NON-NLS "m1v", "m2v", "m4v", "mkv", "mpe", "yop", "vqa", "xmv", //NON-NLS "mve", "wtv", "webm", "vivo", "vc1", "seq", "thp", "san", //NON-NLS @@ -91,8 +91,17 @@ public class VideoUtils { private VideoUtils() { } - public static File getTempVideoFile(AbstractFile file) throws NoCurrentCaseException { - return Paths.get(Case.getOpenCase().getTempDirectory(), "videos", file.getId() + "." + file.getNameExtension()).toFile(); //NON-NLS + /** + * Gets a File object in the temp directory of the current case for the + * given AbstractFile object. + * + * @param file The AbstractFile object + * + * @return The File object + * + */ + public static File getVideoFileInTempDir(AbstractFile file) throws NoCurrentCaseException { + return Paths.get(Case.getCurrentCaseThrows().getTempDirectory(), "videos", file.getId() + "." + file.getNameExtension()).toFile(); //NON-NLS } public static boolean isVideoThumbnailSupported(AbstractFile file) { @@ -104,7 +113,7 @@ public class VideoUtils { static BufferedImage generateVideoThumbnail(AbstractFile file, int iconSize) { java.io.File tempFile; try { - tempFile = getTempVideoFile(file); + tempFile = getVideoFileInTempDir(file); } catch (NoCurrentCaseException ex) { LOGGER.log(Level.WARNING, "Exception while getting open case.", ex); //NON-NLS return null; @@ -189,4 +198,25 @@ public class VideoUtils { } return bufferedImage == null ? null : ScalrWrapper.resizeFast(bufferedImage, iconSize); } + + /** + * Gets a File object in the temp directory of the current case for the + * given AbstractFile object. + * + * @param file The AbstractFile object + * + * @return The File object + * + * @deprecated Call getVideoFileInTempDir instead. + */ + @Deprecated + public static File getTempVideoFile(AbstractFile file) { + try { + return getVideoFileInTempDir(file); + } catch (NoCurrentCaseException ex) { + // Mimic the old behavior. + throw new IllegalStateException(ex); + } + } + } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java index 02252ec483..3f1ca56e47 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java @@ -264,7 +264,7 @@ public abstract class AbstractAbstractFileNode extends A protected void addTagProperty(Sheet.Set sheetSet) { List tags = new ArrayList<>(); try { - tags.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(content)); + tags.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagsByContent(content)); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Failed to get tags for content " + content.getName(), ex); } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java index 8750d57f30..b4c34e5da7 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java @@ -120,7 +120,7 @@ public abstract class AbstractContentNode extends ContentNode + " AND type = " + TskData.ObjectType.ABSTRACTFILE.getObjectType() + ") AS OBJECT_IDS"; //NON-NLS; - try (SleuthkitCase.CaseDbQuery dbQuery = Case.getOpenCase().getSleuthkitCase().executeQuery(query)) { + try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery(query)) { ResultSet resultSet = dbQuery.getResultSet(); if(resultSet.next()){ return (0 < resultSet.getInt("count")); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index 2fdf4c23cb..ab64cead5e 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -266,7 +266,7 @@ public class BlackboardArtifactNode extends AbstractContentNode(NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.name"), NbBundle.getMessage(BlackboardArtifactNode.class, "BlackboardArtifactNode.createSheet.artifactType.displayName"), NO_DESCR, @@ -461,7 +461,7 @@ public class BlackboardArtifactNode extends AbstractContentNode tags = new ArrayList<>(); try { - tags.addAll(Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact)); - tags.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(associated)); + tags.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact)); + tags.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagsByContent(associated)); } catch (TskCoreException | NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Failed to get tags for artifact " + artifact.getDisplayName(), ex); } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java index 57c0dea74f..6e8374252d 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DataSourcesNode.java @@ -103,7 +103,7 @@ public class DataSourcesNode extends DisplayableItemNode { private void reloadKeys() { try { - currentKeys = Case.getOpenCase().getDataSources(); + currentKeys = Case.getCurrentCaseThrows().getDataSources(); setKeys(currentKeys); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Error getting data sources: {0}", ex.getMessage()); // NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DeletedContent.java b/Core/src/org/sleuthkit/autopsy/datamodel/DeletedContent.java index 9638de6335..812eaa065b 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DeletedContent.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DeletedContent.java @@ -207,7 +207,7 @@ public class DeletedContent implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); // new file was added // @@@ COULD CHECK If the new file is deleted before notifying... update(); @@ -226,7 +226,7 @@ public class DeletedContent implements AutopsyVisitableItem { * received for a case that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); update(); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/EmailExtracted.java b/Core/src/org/sleuthkit/autopsy/datamodel/EmailExtracted.java index 563ae144b5..409c3165e8 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/EmailExtracted.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/EmailExtracted.java @@ -241,7 +241,7 @@ public class EmailExtracted implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -266,7 +266,7 @@ public class EmailExtracted implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); emailResults.update(); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ExtractedContent.java b/Core/src/org/sleuthkit/autopsy/datamodel/ExtractedContent.java index f6b25ad2ba..304073c9b6 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ExtractedContent.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ExtractedContent.java @@ -211,7 +211,7 @@ public class ExtractedContent implements AutopsyVisitableItem { * may be received for a case that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Due to some unresolved issues with how cases are closed, * it is possible for the event to have a null oldValue if @@ -234,7 +234,7 @@ public class ExtractedContent implements AutopsyVisitableItem { * may be received for a case that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { /** @@ -402,7 +402,7 @@ public class ExtractedContent implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -427,7 +427,7 @@ public class ExtractedContent implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileSize.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileSize.java index a6b6d676c2..4bf994fb0c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileSize.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileSize.java @@ -202,7 +202,7 @@ 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.getOpenCase(); + Case.getCurrentCaseThrows(); update(); } catch (NoCurrentCaseException notUsed) { /** @@ -219,7 +219,7 @@ public class FileSize implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); update(); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java index d881161084..2d04fe9733 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByExtension.java @@ -94,7 +94,7 @@ public final class FileTypesByExtension implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); typesRoot.updateShowCounts(); update(); } catch (NoCurrentCaseException notUsed) { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByMimeType.java b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByMimeType.java index e0b589546a..e41477d96e 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByMimeType.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/FileTypesByMimeType.java @@ -164,7 +164,7 @@ public final class FileTypesByMimeType extends Observable implements AutopsyVisi * already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); typesRoot.updateShowCounts(); populateHashMap(); } catch (NoCurrentCaseException notUsed) { diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java b/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java index c8f9e0041c..a720409489 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/HashsetHits.java @@ -209,7 +209,7 @@ public class HashsetHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Due to some unresolved issues with how cases are * closed, it is possible for the event to have a null @@ -233,7 +233,7 @@ public class HashsetHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); hashsetResults.update(); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java index 6cb9a72f6c..d11d7c64b2 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java @@ -171,7 +171,7 @@ public class ImageNode extends AbstractContentNode { Bundle.ImageNode_createSheet_timezone_desc(), this.content.getTimeZone())); - try (CaseDbQuery query = Case.getOpenCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) { + try (CaseDbQuery query = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) { ResultSet deviceIdSet = query.getResultSet(); if (deviceIdSet.next()) { sheetSet.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(), diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/InterestingHits.java b/Core/src/org/sleuthkit/autopsy/datamodel/InterestingHits.java index 9df6a8a591..7c3249f990 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/InterestingHits.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/InterestingHits.java @@ -200,7 +200,7 @@ public class InterestingHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -226,7 +226,7 @@ public class InterestingHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); interestingResults.update(); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/KeywordHits.java b/Core/src/org/sleuthkit/autopsy/datamodel/KeywordHits.java index ec3d28d2b1..c35d9bdda0 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/KeywordHits.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/KeywordHits.java @@ -412,7 +412,7 @@ public class KeywordHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -435,7 +435,7 @@ public class KeywordHits implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); keywordResults.update(); } catch (NoCurrentCaseException notUsed) { // Case is closed, do nothing. diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Md5Node.java b/Core/src/org/sleuthkit/autopsy/datamodel/Md5Node.java index fcfcfba4bf..96de7eba36 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Md5Node.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Md5Node.java @@ -139,7 +139,7 @@ public class Md5Node extends DisplayableItemNode { @Override protected Node createNodeForKey(FileInstanceMetadata file) { try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); SleuthkitCase tskDb = currentCase.getSleuthkitCase(); AbstractFile abstractFile = tskDb.findAllFilesWhere(String.format("obj_id in (%s)", file.getObjectId())).get(0); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Reports.java b/Core/src/org/sleuthkit/autopsy/datamodel/Reports.java index bda7a9cf08..b2f7667150 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Reports.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Reports.java @@ -115,7 +115,7 @@ public final class Reports implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); ReportNodeFactory.this.refresh(true); } catch (NoCurrentCaseException notUsed) { /** @@ -129,7 +129,7 @@ public final class Reports implements AutopsyVisitableItem { @Override protected boolean createKeys(List keys) { try { - keys.addAll(Case.getOpenCase().getAllReports()); + keys.addAll(Case.getCurrentCaseThrows().getAllReports()); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(Reports.ReportNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get reports", ex); //NON-NLS } @@ -266,7 +266,7 @@ public final class Reports implements AutopsyVisitableItem { NbBundle.getMessage(Reports.class, "DeleteReportAction.actionPerformed.showConfirmDialog.title"), JOptionPane.YES_NO_OPTION)) { try { - Case.getOpenCase().deleteReports(selectedReportsCollection); + Case.getCurrentCaseThrows().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()); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java b/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java index 59450abf33..9a01fa608f 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/Tags.java @@ -142,7 +142,7 @@ public class Tags implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); tagResults.update(); } catch (NoCurrentCaseException notUsed) { @@ -159,7 +159,7 @@ public class Tags implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); tagResults.update(); } catch (NoCurrentCaseException notUsed) { @@ -196,7 +196,7 @@ public class Tags implements AutopsyVisitableItem { @Override protected boolean createKeys(List keys) { try { - List tagNamesInUse = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse(); + List tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse(); Collections.sort(tagNamesInUse); keys.addAll(tagNamesInUse); } catch (TskCoreException | NoCurrentCaseException ex) { @@ -243,7 +243,7 @@ public class Tags implements AutopsyVisitableItem { private void updateDisplayName() { long tagsCount = 0; try { - TagsManager tm = Case.getOpenCase().getServices().getTagsManager(); + TagsManager tm = Case.getCurrentCaseThrows().getServices().getTagsManager(); tagsCount = tm.getContentTagsCountByTagName(tagName); tagsCount += tm.getBlackboardArtifactTagsCountByTagName(tagName); } catch (TskCoreException | NoCurrentCaseException ex) { @@ -348,7 +348,7 @@ public class Tags implements AutopsyVisitableItem { private void updateDisplayName() { long tagsCount = 0; try { - tagsCount = Case.getOpenCase().getServices().getTagsManager().getContentTagsCountByTagName(tagName); + tagsCount = Case.getCurrentCaseThrows().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 } @@ -403,7 +403,7 @@ public class Tags implements AutopsyVisitableItem { protected boolean createKeys(List keys) { // Use the content tags bearing the specified tag name as the keys. try { - keys.addAll(Case.getOpenCase().getServices().getTagsManager().getContentTagsByTagName(tagName)); + keys.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagsByTagName(tagName)); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(ContentTagNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS } @@ -447,7 +447,7 @@ public class Tags implements AutopsyVisitableItem { private void updateDisplayName() { long tagsCount = 0; try { - tagsCount = Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsCountByTagName(tagName); + tagsCount = Case.getCurrentCaseThrows().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 } @@ -502,7 +502,7 @@ public class Tags implements AutopsyVisitableItem { protected boolean createKeys(List keys) { try { // Use the blackboard artifact tags bearing the specified tag name as the keys. - keys.addAll(Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByTagName(tagName)); + keys.addAll(Case.getCurrentCaseThrows().getServices().getTagsManager().getBlackboardArtifactTagsByTagName(tagName)); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(BlackboardArtifactTagNodeFactory.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java index cf0be2a67d..9a7e3eae8e 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java @@ -106,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.getOpenCase().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) { + try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery("SELECT time_zone FROM data_source_info WHERE obj_id = " + this.content.getId())) { ResultSet timeZoneSet = query.getResultSet(); if (timeZoneSet.next()) { sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_timezone_name(), @@ -117,7 +117,7 @@ public class VirtualDirectoryNode extends SpecialDirectoryNode { } 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.getOpenCase().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) { + try (SleuthkitCase.CaseDbQuery query = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery("SELECT device_id FROM data_source_info WHERE obj_id = " + this.content.getId());) { ResultSet deviceIdSet = query.getResultSet(); if (deviceIdSet.next()) { sheetSet.put(new NodeProperty<>(Bundle.VirtualDirectoryNode_createSheet_deviceId_name(), diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/accounts/Accounts.java b/Core/src/org/sleuthkit/autopsy/datamodel/accounts/Accounts.java index 254a25b7c5..8301928528 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/accounts/Accounts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/accounts/Accounts.java @@ -238,7 +238,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -262,7 +262,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { // Case is closed, do nothing. @@ -364,7 +364,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -388,7 +388,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { @@ -515,7 +515,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -539,7 +539,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { @@ -651,7 +651,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -675,7 +675,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { @@ -864,7 +864,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); /** * Even with the check above, it is still possible that * the case will be closed in a different thread before @@ -888,7 +888,7 @@ final public class Accounts implements AutopsyVisitableItem { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); refresh(true); } catch (NoCurrentCaseException notUsed) { //NOPMD empy catch clause diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/AddRawImageTask.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/AddRawImageTask.java index a65e32c8a6..f8ff559afd 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/AddRawImageTask.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/AddRawImageTask.java @@ -127,7 +127,7 @@ final class AddRawImageTask implements Runnable { private void addImageToCase(List dataSources, List errorMessages) { SleuthkitCase caseDatabase; try { - caseDatabase = Case.getOpenCase().getSleuthkitCase(); + caseDatabase = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex) { errorMessages.add(Bundle.AddRawImageTask_noOpenCase_errMsg()); logger.log(Level.SEVERE, Bundle.AddRawImageTask_noOpenCase_errMsg(), ex); diff --git a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/RawDSInputPanel.java b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/RawDSInputPanel.java index a8572a4664..baf9b15223 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourceprocessors/RawDSInputPanel.java +++ b/Core/src/org/sleuthkit/autopsy/datasourceprocessors/RawDSInputPanel.java @@ -301,7 +301,7 @@ final class RawDSInputPanel extends JPanel implements DocumentListener { "RawDSInputPanel.noOpenCase.errMsg=Exception while getting open case."}) private void warnIfPathIsInvalid(String path) { try { - if (!PathValidator.isValid(path, Case.getOpenCase().getCaseType())) { + if (!PathValidator.isValid(path, Case.getCurrentCaseThrows().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(Bundle.RawDSInputPanel_error_text()); } diff --git a/Core/src/org/sleuthkit/autopsy/diagnostics/PerformancePanel.java b/Core/src/org/sleuthkit/autopsy/diagnostics/PerformancePanel.java index 1525958390..d50f31e383 100644 --- a/Core/src/org/sleuthkit/autopsy/diagnostics/PerformancePanel.java +++ b/Core/src/org/sleuthkit/autopsy/diagnostics/PerformancePanel.java @@ -299,7 +299,7 @@ public class PerformancePanel extends javax.swing.JDialog { Case curCase; try { - curCase = Case.getOpenCase(); + curCase = Case.getCurrentCaseThrows(); } 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.getOpenCase(); + curCase = Case.getCurrentCaseThrows(); } 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.getOpenCase(); + curCase = Case.getCurrentCaseThrows(); } catch (Exception e) { setDbLabel(NbBundle.getMessage(this.getClass(), "PerformancePanel.label.caseNotOpen.text")); return; diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index 3069b7fb5d..0fd19c98a1 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -364,7 +364,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Case currentCase = null; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { // No open case. } @@ -526,7 +526,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat * sources. */ try { - Case openCase = Case.getOpenCase(); + Case openCase = Case.getCurrentCaseThrows(); return openCase.hasData() == false; } catch (NoCurrentCaseException ex) { return true; @@ -619,7 +619,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat * already closed. */ try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); // We only need to trigger openCoreWindows() when the // first data source is added. if (currentCase.getDataSources().size() == 1) { diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java index 991b554c63..3451b073a3 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java @@ -89,7 +89,7 @@ public class ExternalViewerAction extends AbstractAction { // Get the temp folder path of the case Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.WARNING, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java index 28a8bac071..2f45e44331 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractAction.java @@ -101,7 +101,7 @@ public final class ExtractAction extends AbstractAction { private void extractFile(ActionEvent e, AbstractFile selectedFile) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { JOptionPane.showMessageDialog((Component) e.getSource(), Bundle.ExtractAction_noOpenCase_errMsg()); logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS @@ -127,7 +127,7 @@ public final class ExtractAction extends AbstractAction { private void extractFiles(ActionEvent e, Collection selectedFiles) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { JOptionPane.showMessageDialog((Component) e.getSource(), Bundle.ExtractAction_noOpenCase_errMsg()); logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java index 893bd94da4..b0729d24c6 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java @@ -121,7 +121,7 @@ final class ExtractUnallocAction extends AbstractAction { } Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { MessageNotifyUtil.Message.info(Bundle.ExtractAction_noOpenCase_errMsg()); return; @@ -611,7 +611,7 @@ final class ExtractUnallocAction extends AbstractAction { this.imageId = img.getId(); this.imageName = img.getName(); this.fileName = this.imageName + "-Unalloc-" + this.imageId + "-" + 0 + ".dat"; //NON-NLS - this.fileInstance = new File(Case.getOpenCase().getExportDirectory() + File.separator + this.fileName); + this.fileInstance = new File(Case.getCurrentCaseThrows().getExportDirectory() + File.separator + this.fileName); this.sizeInBytes = calcSizeInBytes(); } @@ -633,7 +633,7 @@ final class ExtractUnallocAction extends AbstractAction { this.imageId = 0; } this.fileName = this.imageName + "-Unalloc-" + this.imageId + "-" + volumeId + ".dat"; //NON-NLS - this.fileInstance = new File(Case.getOpenCase().getExportDirectory() + File.separator + this.fileName); + this.fileInstance = new File(Case.getCurrentCaseThrows().getExportDirectory() + File.separator + this.fileName); this.layoutFiles = getUnallocFiles(volume); Collections.sort(layoutFiles, new SortObjId()); this.sizeInBytes = calcSizeInBytes(); diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ViewSourceArtifactAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ViewSourceArtifactAction.java index 494908285b..bc7c10b3c3 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ViewSourceArtifactAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ViewSourceArtifactAction.java @@ -49,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.getOpenCase().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); + BlackboardArtifact associatedArtifact = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboardArtifact(attribute.getValueLong()); if (associatedArtifact != null) { dirTree.viewArtifact(associatedArtifact); break; diff --git a/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java b/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java index 8605d33c13..9a1bd96cc7 100644 --- a/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java @@ -77,7 +77,7 @@ class SampleDataSourceIngestModule implements DataSourceIngestModule { try { // Get count of files with .doc extension. - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); List docFiles = fileManager.findFiles(dataSource, "%.doc"); long fileCount = 0; diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/DateSearchFilter.java b/Core/src/org/sleuthkit/autopsy/filesearch/DateSearchFilter.java index 661e08a542..048ccd5f79 100644 --- a/Core/src/org/sleuthkit/autopsy/filesearch/DateSearchFilter.java +++ b/Core/src/org/sleuthkit/autopsy/filesearch/DateSearchFilter.java @@ -141,7 +141,7 @@ class DateSearchFilter extends AbstractFileSearchFilter { try { // get the latest case - Case currentCase = Case.getOpenCase(); // get the most updated case + Case currentCase = Case.getCurrentCaseThrows(); // get the most updated case Set caseTimeZones = currentCase.getTimeZones(); Iterator iterator = caseTimeZones.iterator(); @@ -282,7 +282,7 @@ class DateSearchFilter extends AbstractFileSearchFilter { * that is already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); SwingUtilities.invokeLater(DateSearchFilter.this::updateTimeZoneList); } catch (NoCurrentCaseException notUsed) { /** diff --git a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java index 626449f26e..231dda4c50 100644 --- a/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filesearch/FileSearchPanel.java @@ -154,7 +154,7 @@ class FileSearchPanel extends javax.swing.JPanel { String pathText = NbBundle.getMessage(this.getClass(), "FileSearchPanel.search.results.pathText"); // try to get the number of matches first - Case currentCase = Case.getOpenCase(); // get the most updated case + Case currentCase = Case.getCurrentCaseThrows(); // get the most updated case long totalMatches = 0; List contentList = null; try { diff --git a/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java b/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java index 2186dc3be1..2c455c1743 100644 --- a/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/healthmonitor/EnterpriseHealthMonitor.java @@ -338,7 +338,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener { */ private void performDatabaseQuery() throws HealthMonitorException { try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); TimingMetric metric = EnterpriseHealthMonitor.getTimingMetric("Database: getImages query"); List images = skCase.getImages(); diff --git a/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java b/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java index b7d064aa44..71404c76e7 100644 --- a/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java +++ b/Core/src/org/sleuthkit/autopsy/imagewriter/ImageWriter.java @@ -83,7 +83,7 @@ class ImageWriter implements PropertyChangeListener{ // 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.getOpenCase().getSleuthkitCase(); + caseDb = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex){ logger.log(Level.SEVERE, "Unable to load case. Image writer will be cancelled."); this.isCancelled = true; @@ -152,7 +152,7 @@ class ImageWriter implements PropertyChangeListener{ Image image; try{ - image = Case.getOpenCase().getSleuthkitCase().getImageById(dataSourceId); + image = Case.getCurrentCaseThrows().getSleuthkitCase().getImageById(dataSourceId); imageHandle = image.getImageHandle(); } catch (NoCurrentCaseException ex){ // This exception means that getOpenCase() failed because no case was open. diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java index fe9535916e..c59b3f20bf 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestJob.java @@ -277,7 +277,7 @@ final class DataSourceIngestJob { Thread.currentThread().interrupt(); } try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); this.addIngestModules(firstStageDataSourceModuleTemplates, IngestModuleType.DATA_SOURCE_LEVEL, skCase); this.addIngestModules(fileIngestModuleTemplates, IngestModuleType.FILE_LEVEL, skCase); this.addIngestModules(secondStageDataSourceModuleTemplates, IngestModuleType.DATA_SOURCE_LEVEL, skCase); @@ -415,7 +415,7 @@ final class DataSourceIngestJob { List errors = startUpIngestPipelines(); if (errors.isEmpty()) { try { - this.ingestJob = Case.getOpenCase().getSleuthkitCase().addIngestJob(dataSource, NetworkUtils.getLocalHostName(), ingestModules, new Date(this.createTime), new Date(0), IngestJobStatusType.STARTED, ""); + this.ingestJob = Case.getCurrentCaseThrows().getSleuthkitCase().addIngestJob(dataSource, NetworkUtils.getLocalHostName(), ingestModules, new Date(this.createTime), new Date(0), IngestJobStatusType.STARTED, ""); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Failed to add ingest job to database.", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/GetFilesCountVisitor.java b/Core/src/org/sleuthkit/autopsy/ingest/GetFilesCountVisitor.java index 94b9b2a93b..8796009f2a 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/GetFilesCountVisitor.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/GetFilesCountVisitor.java @@ -47,7 +47,7 @@ final class GetFilesCountVisitor extends ContentVisitor.Default { //case of a real fs, query all files for it SleuthkitCase sc; try { - sc = Case.getOpenCase().getSleuthkitCase(); + sc = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return 0L; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettingsPanel.java index d03616d6f0..88fb0b347e 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettingsPanel.java @@ -98,7 +98,7 @@ public final class IngestJobSettingsPanel extends javax.swing.JPanel { this.settings = settings; this.dataSources.addAll(dataSources); try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); ingestJobs.addAll(skCase.getIngestJobs()); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "No open case", ex); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 6511a6693e..28a7c44474 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -191,7 +191,7 @@ public class IngestManager { * only necessary for multi-user cases. */ try { - if (Case.getOpenCase().getCaseType() != Case.CaseType.MULTI_USER_CASE) { + if (Case.getCurrentCaseThrows().getCaseType() != Case.CaseType.MULTI_USER_CASE) { return; } } catch (NoCurrentCaseException noCaseOpenException) { @@ -252,7 +252,7 @@ public class IngestManager { caseIsOpen = true; clearIngestMessageBox(); try { - Case openedCase = Case.getOpenCase(); + Case openedCase = Case.getCurrentCaseThrows(); String channelPrefix = openedCase.getName(); if (Case.CaseType.MULTI_USER_CASE == openedCase.getCaseType()) { jobEventPublisher.openRemoteEventChannel(String.format(INGEST_JOB_EVENT_CHANNEL_NAME, channelPrefix)); @@ -369,7 +369,7 @@ public class IngestManager { List errors = null; Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return new IngestJobStartResult(null, new IngestManagerException("Exception while getting open case.", ex), Collections.emptyList()); //NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestMessageDetailsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestMessageDetailsPanel.java index 52698415d3..17645ccb68 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestMessageDetailsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestMessageDetailsPanel.java @@ -248,7 +248,7 @@ class IngestMessageDetailsPanel extends javax.swing.JPanel { long objId = artifact.getObjectID(); AbstractFile file = null; try { - file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(objId); + file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(objId); } catch (TskException | NoCurrentCaseException ex) { } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestMonitor.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestMonitor.java index 764fc694ef..071c6bb489 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestMonitor.java @@ -150,11 +150,11 @@ public final class IngestMonitor { */ private void findRootDirectoryForCurrentCase() { try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); findRootDirectoryForCurrentCase(currentCase); } catch (NoCurrentCaseException unused) { /* - * Case.getOpenCase() throws NoCurrentCaseException when there + * Case.getCurrentOpenCase() throws NoCurrentCaseException when there * is no case. */ root = new File(File.separator); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestServices.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestServices.java index f70c9b0813..01e86823c5 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestServices.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestServices.java @@ -1,15 +1,15 @@ /* * Autopsy Forensic Browser - * - * Copyright 2011-2014 Basis Technology Corp. + * + * Copyright 2012-2018 Basis Technology Corp. * Contact: carrier sleuthkit 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. @@ -26,20 +26,25 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.datamodel.SleuthkitCase; /** - * Singleton class that provides services for ingest modules. These exist to - * make it easier to write modules. Use the getDefault() method to get the - * singleton instance. + * Ingest services provides convenience methods for ingest modules to use during + * to access the Autopsy case, the case database, fire events, etc. */ public final class IngestServices { private static IngestServices instance = null; - private final IngestManager manager = IngestManager.getInstance(); + /** + * Constructs an ingest services object that provides convenience methods + * for ingest modules to use to access the Autopsy case, the case database, + * fire events, etc. + */ private IngestServices() { } /** - * Get the ingest services. + * Gets the ingest services singleton that provides convenience methods for + * ingest modules to use to access the Autopsy case, the case database, fire + * events, * * @return The ingest services singleton. */ @@ -51,123 +56,150 @@ public final class IngestServices { } /** - * Get the current Autopsy case. + * Gets the current open Autopsy case. + * + * @return The current open case. * - * @return The current case. * @throws NoCurrentCaseException if there is no open case. */ - public Case getOpenCase() throws NoCurrentCaseException { - return Case.getOpenCase(); + public Case getCase() throws NoCurrentCaseException { + return Case.getCurrentCaseThrows(); } /** - * Get the current SleuthKit case. The SleuthKit case is the case database. + * Gets the case database of the current open Autopsy case. * * @return The current case database. + * * @throws NoCurrentCaseException if there is no open case. */ - public SleuthkitCase getCurrentSleuthkitCaseDb() throws NoCurrentCaseException { - return Case.getOpenCase().getSleuthkitCase(); + public SleuthkitCase getCaseDatabase() throws NoCurrentCaseException { + return Case.getCurrentCaseThrows().getSleuthkitCase(); } /** - * Get a logger that incorporates the display name of an ingest module in + * Gets a logger that incorporates the display name of an ingest module in * messages written to the Autopsy log files. * * @param moduleDisplayName The display name of the ingest module. * - * @return The custom logger for the ingest module. + * @return A logger for the ingest module. */ public Logger getLogger(String moduleDisplayName) { return Logger.getLogger(moduleDisplayName); } /** - * Post message to the ingest messages in box. + * Posts a message to the ingest messages in box. * * @param message An ingest message */ public void postMessage(final IngestMessage message) { - manager.postIngestMessage(message); + IngestManager.getInstance().postIngestMessage(message); } /** - * Fire module data event to notify registered module data event listeners - * that there is new data of a given type from a module. + * Fires an event to notify registered listeners that a new artifact has + * been posted to the blackboard. * - * @param moduleDataEvent module data event, encapsulating blackboard - * artifact data + * @param moduleDataEvent A module data event, i.e., an event that + * encapsulates artifact data. */ public void fireModuleDataEvent(ModuleDataEvent moduleDataEvent) { IngestManager.getInstance().fireIngestModuleDataEvent(moduleDataEvent); } /** - * Fire module content event to notify registered module content event - * listeners that there is new content (from ZIP file contents, carving, - * etc.) + * Fires an event to notify registered listeners that there is new content + * (e.g., files extracted from an archive file, carved files, etc.) * - * @param moduleContentEvent module content event, encapsulating content - * changed + * @param moduleContentEvent A module content event, i.e., an event that + * encapsulates new content data. */ public void fireModuleContentEvent(ModuleContentEvent moduleContentEvent) { IngestManager.getInstance().fireIngestModuleContentEvent(moduleContentEvent); } /** - * Get free disk space of a drive where ingest data are written to That - * drive is being monitored by IngestMonitor thread when ingest is running. + * Gets the free disk space of the drive where data is written during + * ingest. Can be used by ingest modules to determine if there is enough + * disk space before writing data is attmepted. * - * @return amount of disk space, -1 if unknown + * @return Amount of free disk space, in bytes, or -1 if unknown. */ public long getFreeDiskSpace() { - return manager.getFreeDiskSpace(); + return IngestManager.getInstance().getFreeDiskSpace(); } /** - * Gets a specific name/value configuration setting for a module + * Gets a global configuration setting for an ingest module. * - * @param moduleName moduleName identifier unique to that module - * @param settingName setting name to retrieve + * @param moduleName A unique identifier for the module. + * @param settingName The name of the setting. * - * @return setting value for the module / setting name, or null if not found + * @return setting The value of the setting, or null if not found. */ public String getConfigSetting(String moduleName, String settingName) { return ModuleSettings.getConfigSetting(moduleName, settingName); } /** - * Sets a specific name/value configuration setting for a module + * Sets a global configuration setting for an ingest module. * - * @param moduleName moduleName identifier unique to that module - * @param settingName setting name to set - * @param settingVal setting value to set + * @param moduleName A unique identifier for the module. + * @param settingName The name of the setting. + * @param setting The value of the setting. */ - public void setConfigSetting(String moduleName, String settingName, String settingVal) { - ModuleSettings.setConfigSetting(moduleName, settingName, settingVal); + public void setConfigSetting(String moduleName, String settingName, String setting) { + ModuleSettings.setConfigSetting(moduleName, settingName, setting); } /** - * Gets all name/value configuration settings for a module + * Gets all of the global configuration settings for an ingest module. * - * @param moduleName moduleName identifier unique to that module + * @param moduleName A unique identifier for the module. * - * @return settings for the module / setting name + * @return A mapping of setting names to setting values. */ public Map getConfigSettings(String moduleName) { return ModuleSettings.getConfigSettings(moduleName); } /** - * Sets all name/value configuration setting for a module. Names not in the - * list will have settings preserved. + * Sets all of the global configuration settings for an ingest module. + * + * @param moduleName A unique identifier for the module. * * @param moduleName moduleName identifier unique to that module - * @param settings settings to set and replace old settings, keeping - * settings not specified in the map. + * @param settings A mapping of setting names to setting values. * */ public void setConfigSettings(String moduleName, Map settings) { ModuleSettings.setConfigSettings(moduleName, settings); } + + /** + * Gets the current SleuthKit case. The SleuthKit case is the case database. + * + * @return The current case database. + * + * @deprecated Use getCaseDatabase instead. + */ + @Deprecated + public SleuthkitCase getCurrentSleuthkitCaseDb() { + return Case.getCurrentCase().getSleuthkitCase(); + } + + /** + * Get the current open case. + * + * @return The current case. + * + * @deprecated Use getCase instead. + */ + @Deprecated + public Case getCurrentCase() { + return Case.getCurrentCase(); + } + } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestAction.java b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestAction.java index 72bc963fe7..d18faeee7b 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestAction.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestAction.java @@ -84,7 +84,7 @@ public final class RunIngestAction extends CallableSystemAction implements Prese @Override public boolean isEnabled() { try { - Case openCase = Case.getOpenCase(); + Case openCase = Case.getCurrentCaseThrows(); return openCase.hasData(); } catch (NoCurrentCaseException ex) { return false; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestSubMenu.java b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestSubMenu.java index d58c57da72..c03abd577b 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestSubMenu.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestSubMenu.java @@ -49,7 +49,7 @@ final class RunIngestSubMenu extends JMenuItem implements DynamicMenuContent { List dataSources = new ArrayList<>(); try { - dataSources = Case.getOpenCase().getDataSources(); + dataSources = Case.getCurrentCaseThrows().getDataSources(); } catch (IllegalStateException ex) { // No open Cases, create a disabled empty menu return getEmpty(); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/BlackboardPostEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/BlackboardPostEvent.java index 9e05d538de..7d57b420ab 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/events/BlackboardPostEvent.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/BlackboardPostEvent.java @@ -94,7 +94,7 @@ public final class BlackboardPostEvent extends AutopsyEvent implements Serializa SerializableEventData data = (SerializableEventData) super.getOldValue(); Collection artifacts = new ArrayList<>(); for (Long id : data.artifactIds) { - artifacts.add(Case.getOpenCase().getSleuthkitCase().getBlackboardArtifact(id)); + artifacts.add(Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboardArtifact(id)); } eventData = new ModuleDataEvent(data.moduleName, data.artifactTypeId, !artifacts.isEmpty() ? artifacts : null); return eventData; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/ContentChangedEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/ContentChangedEvent.java index d22cefb5ac..fbb842d9d2 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/events/ContentChangedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/ContentChangedEvent.java @@ -86,7 +86,7 @@ public final class ContentChangedEvent extends AutopsyEvent implements Serializa } try { SerializableEventData data = (SerializableEventData) super.getOldValue(); - Content content = Case.getOpenCase().getSleuthkitCase().getContentById(data.contentId); + Content content = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(data.contentId); eventData = new ModuleContentEvent(data.moduleName, content); return eventData; } catch (NoCurrentCaseException | TskCoreException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java index 100db13067..fb7d2f2f56 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/DataSourceAnalysisEvent.java @@ -97,7 +97,7 @@ public abstract class DataSourceAnalysisEvent extends AutopsyEvent implements Se } try { long id = (Long) super.getNewValue(); - dataSource = Case.getOpenCase().getSleuthkitCase().getContentById(id); + dataSource = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(id); return dataSource; } catch (NoCurrentCaseException | TskCoreException ex) { logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/ingest/events/FileAnalyzedEvent.java b/Core/src/org/sleuthkit/autopsy/ingest/events/FileAnalyzedEvent.java index 6845fcf391..42488c69de 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/events/FileAnalyzedEvent.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/events/FileAnalyzedEvent.java @@ -77,7 +77,7 @@ public final class FileAnalyzedEvent extends AutopsyEvent implements Serializabl } try { long id = (Long) super.getOldValue(); - file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(id); + file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(id); return file; } catch (NoCurrentCaseException | TskCoreException ex) { logger.log(Level.SEVERE, "Error doing lazy load for remote event", ex); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/menuactions/DataContentDynamicMenu.java b/Core/src/org/sleuthkit/autopsy/menuactions/DataContentDynamicMenu.java index a677f8042a..b025cebf79 100644 --- a/Core/src/org/sleuthkit/autopsy/menuactions/DataContentDynamicMenu.java +++ b/Core/src/org/sleuthkit/autopsy/menuactions/DataContentDynamicMenu.java @@ -52,7 +52,7 @@ class DataContentDynamicMenu extends JMenuItem implements DynamicMenuContent { defaultItem.addActionListener(new OpenTopComponentAction(contentWin)); try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); defaultItem.setEnabled(currentCase.hasData()); } catch (NoCurrentCaseException ex) { defaultItem.setEnabled(false); // disable the menu when no case is opened diff --git a/Core/src/org/sleuthkit/autopsy/menuactions/DataExplorerDynamicMenu.java b/Core/src/org/sleuthkit/autopsy/menuactions/DataExplorerDynamicMenu.java index 38377d0f28..8dac009bf0 100644 --- a/Core/src/org/sleuthkit/autopsy/menuactions/DataExplorerDynamicMenu.java +++ b/Core/src/org/sleuthkit/autopsy/menuactions/DataExplorerDynamicMenu.java @@ -55,7 +55,7 @@ class DataExplorerDynamicMenu extends JMenuItem implements DynamicMenuContent { item.addActionListener(new OpenTopComponentAction(explorerWin)); try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); item.setEnabled(currentCase.hasData()); } catch (NoCurrentCaseException ex) { item.setEnabled(false); // disable the menu when no case is opened diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/EmbeddedFileExtractorIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/EmbeddedFileExtractorIngestModule.java index 331b6d8830..5e67e9da8b 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/EmbeddedFileExtractorIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/EmbeddedFileExtractorIngestModule.java @@ -67,7 +67,7 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda * is used to write the extracted (derived) files to local storage. */ try { - final Case currentCase = Case.getOpenCase(); + final Case currentCase = Case.getCurrentCaseThrows(); moduleDirRelative = Paths.get(currentCase.getModuleOutputDirectoryRelativePath(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); moduleDirAbsolute = Paths.get(currentCase.getModuleDirectory(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); } catch (NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/ExtractArchiveWithPasswordAction.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/ExtractArchiveWithPasswordAction.java index bae9570ab5..722f211951 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/ExtractArchiveWithPasswordAction.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/ExtractArchiveWithPasswordAction.java @@ -111,8 +111,8 @@ public class ExtractArchiveWithPasswordAction extends AbstractAction { protected Boolean doInBackground() { boolean done = false; try { - String moduleDirRelative = Paths.get(Case.getOpenCase().getModuleOutputDirectoryRelativePath(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); - String moduleDirAbsolute = Paths.get(Case.getOpenCase().getModuleDirectory(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); + String moduleDirRelative = Paths.get(Case.getCurrentCaseThrows().getModuleOutputDirectoryRelativePath(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); + String moduleDirAbsolute = Paths.get(Case.getCurrentCaseThrows().getModuleDirectory(), EmbeddedFileExtractorModuleFactory.getModuleName()).toString(); /* * Construct a file type detector. */ diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/MSOfficeEmbeddedContentExtractor.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/MSOfficeEmbeddedContentExtractor.java index 23e33dc180..b123197f0a 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/MSOfficeEmbeddedContentExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/MSOfficeEmbeddedContentExtractor.java @@ -118,7 +118,7 @@ class MSOfficeEmbeddedContentExtractor { MSOfficeEmbeddedContentExtractor(IngestJobContext context, FileTypeDetector fileTypeDetector, String moduleDirRelative, String moduleDirAbsolute) throws NoCurrentCaseException { - this.fileManager = Case.getOpenCase().getServices().getFileManager(); + this.fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); this.services = IngestServices.getInstance(); this.context = context; this.fileTypeDetector = fileTypeDetector; diff --git a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java index 15d933115f..d09c170110 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/modules/embeddedfileextractor/SevenZipExtractor.java @@ -284,7 +284,7 @@ class SevenZipExtractor { //check if already has derived files, skip //check if local unpacked dir exists if (archiveFile.hasChildren() && new File(moduleDirAbsolute, EmbeddedFileExtractorIngestModule.getUniqueName(archiveFile)).exists()) { - return Case.getOpenCase().getServices().getFileManager().findFilesByParentPath(getRootArchiveId(archiveFile), archiveFilePath); + return Case.getCurrentCaseThrows().getServices().getFileManager().findFilesByParentPath(getRootArchiveId(archiveFile), archiveFilePath); } return new ArrayList<>(); } @@ -494,7 +494,7 @@ class SevenZipExtractor { final long archiveId = archiveFile.getId(); SevenZipExtractor.ArchiveDepthCountTree.Archive parentAr = null; try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS unpackSuccessful = false; @@ -997,7 +997,7 @@ class SevenZipExtractor { * files for the entire hierarchy */ void updateOrAddFileToCaseRec(HashMap statusMap, String archiveFilePath) throws TskCoreException, NoCurrentCaseException { - final FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + final FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); for (UnpackedNode child : rootNode.children) { updateOrAddFileToCaseRec(child, fileManager, statusMap, archiveFilePath); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionDataSourceIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionDataSourceIngestModule.java index a269b2bdd2..2d288532e2 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionDataSourceIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionDataSourceIngestModule.java @@ -64,12 +64,8 @@ final class EncryptionDetectionDataSourceIngestModule implements DataSourceInges @Override public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException { - try { - validateSettings(); - blackboard = Case.getOpenCase().getServices().getBlackboard(); - } catch (NoCurrentCaseException ex) { - throw new IngestModule.IngestModuleException("Exception while getting open case.", ex); - } + validateSettings(); + blackboard = Case.getCurrentCase().getServices().getBlackboard(); } @Override diff --git a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java index d075dec1e8..fa7961db8b 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java @@ -18,6 +18,13 @@ */ package org.sleuthkit.autopsy.modules.encryptiondetection; +import com.healthmarketscience.jackcess.CryptCodecProvider; +import com.healthmarketscience.jackcess.Database; +import com.healthmarketscience.jackcess.DatabaseBuilder; +import com.healthmarketscience.jackcess.InvalidCredentialsException; +import com.healthmarketscience.jackcess.impl.CodecProvider; +import com.healthmarketscience.jackcess.impl.UnsupportedCodecException; +import com.healthmarketscience.jackcess.util.MemFileChannel; import java.io.IOException; import java.util.Collections; import java.util.logging.Level; @@ -57,6 +64,14 @@ import org.xml.sax.SAXException; final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter { private static final int FILE_SIZE_MODULUS = 512; + + private static final String MIME_TYPE_OOXML_PROTECTED = "application/x-ooxml-protected"; + private static final String MIME_TYPE_MSWORD = "application/msword"; + private static final String MIME_TYPE_MSEXCEL = "application/vnd.ms-excel"; + private static final String MIME_TYPE_MSPOWERPOINT = "application/vnd.ms-powerpoint"; + private static final String MIME_TYPE_MSACCESS = "application/x-msaccess"; + private static final String MIME_TYPE_PDF = "application/pdf"; + private final IngestServices services = IngestServices.getInstance(); private final Logger logger = services.getLogger(EncryptionDetectionModuleFactory.getModuleName()); private FileTypeDetector fileTypeDetector; @@ -86,7 +101,7 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter public void startUp(IngestJobContext context) throws IngestModule.IngestModuleException { try { validateSettings(); - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); fileTypeDetector = new FileTypeDetector(); } catch (FileTypeDetector.FileTypeDetectorInitException ex) { throw new IngestModule.IngestModuleException("Failed to create file type detector", ex); @@ -126,7 +141,7 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter } } } - } catch (ReadContentInputStreamException | SAXException | TikaException ex) { + } catch (ReadContentInputStreamException | SAXException | TikaException | UnsupportedCodecException ex) { logger.log(Level.WARNING, String.format("Unable to read file '%s'", file.getParentPath() + file.getName()), ex); return IngestModule.ProcessResult.ERROR; } catch (IOException ex) { @@ -212,13 +227,16 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter * file with Tika. * @throws TikaException If there was an issue parsing the * file with Tika. + * @throws UnsupportedCodecException If an Access database could not + * be opened by Jackcess due to + * unsupported encoding. */ - private boolean isFilePasswordProtected(AbstractFile file) throws ReadContentInputStreamException, IOException, SAXException, TikaException { + private boolean isFilePasswordProtected(AbstractFile file) throws ReadContentInputStreamException, IOException, SAXException, TikaException, UnsupportedCodecException { boolean passwordProtected = false; switch (file.getMIMEType()) { - case "application/x-ooxml-protected": + case MIME_TYPE_OOXML_PROTECTED: /* * Office Open XML files that are password protected can be * determined so simply by checking the MIME type. @@ -226,10 +244,10 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter passwordProtected = true; break; - case "application/msword": - case "application/vnd.ms-excel": - case "application/vnd.ms-powerpoint": - case "application/pdf": + case MIME_TYPE_MSWORD: + case MIME_TYPE_MSEXCEL: + case MIME_TYPE_MSPOWERPOINT: + case MIME_TYPE_PDF: { /* * A file of one of these types will be determined to be * password protected or not by attempting to parse it via Tika. @@ -258,6 +276,51 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter bin.close(); } } + break; + } + + case MIME_TYPE_MSACCESS: { + /* + * Access databases are determined to be password protected + * using Jackcess. If the database can be opened, the password + * is read from it to see if it's null. If the database can not + * be opened due to an InvalidCredentialException being thrown, + * it is automatically determined to be password protected. + */ + InputStream in = null; + BufferedInputStream bin = null; + + try { + in = new ReadContentInputStream(file); + bin = new BufferedInputStream(in); + MemFileChannel memFileChannel = MemFileChannel.newChannel(bin); + CodecProvider codecProvider = new CryptCodecProvider(); + DatabaseBuilder databaseBuilder = new DatabaseBuilder(); + databaseBuilder.setChannel(memFileChannel); + databaseBuilder.setCodecProvider(codecProvider); + Database accessDatabase = databaseBuilder.open(); + /* + * No exception has been thrown at this point, so the file + * is either a JET database, or an unprotected ACE database. + * Read the password from the database to see if it exists. + */ + if (accessDatabase.getDatabasePassword() != null) { + passwordProtected = true; + } + } catch (InvalidCredentialsException ex) { + /* + * The ACE database is determined to be password protected. + */ + passwordProtected = true; + } finally { + if (in != null) { + in.close(); + } + if (bin != null) { + bin.close(); + } + } + } } return passwordProtected; diff --git a/Core/src/org/sleuthkit/autopsy/modules/exif/ExifParserFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/exif/ExifParserFileIngestModule.java index f6fc2292ae..b0894cbdd9 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/exif/ExifParserFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/exif/ExifParserFileIngestModule.java @@ -104,7 +104,7 @@ public final class ExifParserFileIngestModule implements FileIngestModule { @Override public ProcessResult process(AbstractFile content) { try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS return ProcessResult.ERROR; diff --git a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchIngestModule.java index 1d33730e20..6f2281c45d 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchIngestModule.java @@ -110,7 +110,7 @@ public class FileExtMismatchIngestModule implements FileIngestModule { @Messages({"FileExtMismatchIngestModule.indexError.message=Failed to index file extension mismatch artifact for keyword search."}) public ProcessResult process(AbstractFile abstractFile) { try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.WARNING, "Exception while getting open case.", ex); //NON-NLS return ProcessResult.ERROR; diff --git a/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdIngestModule.java index f9cb21434c..e342f06bbf 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdIngestModule.java @@ -156,7 +156,7 @@ public class FileTypeIdIngestModule implements FileIngestModule { attributes.add(ruleNameAttribute); artifact.addAttributes(attributes); try { - Case.getOpenCase().getServices().getBlackboard().indexArtifact(artifact); + Case.getCurrentCaseThrows().getServices().getBlackboard().indexArtifact(artifact); } catch (Blackboard.BlackboardException ex) { logger.log(Level.SEVERE, String.format("Unable to index TSK_INTERESTING_FILE_HIT blackboard artifact %d (file obj_id=%d)", artifact.getArtifactID(), file.getId()), ex); //NON-NLS } catch (NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbIngestModule.java index ea93d10434..d907a131e9 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbIngestModule.java @@ -92,7 +92,7 @@ public class HashDbIngestModule implements FileIngestModule { HashDbIngestModule(HashLookupModuleSettings settings) throws NoCurrentCaseException { this.settings = settings; - skCase = Case.getOpenCase().getSleuthkitCase(); + skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); } @Override @@ -149,7 +149,7 @@ public class HashDbIngestModule implements FileIngestModule { @Override public ProcessResult process(AbstractFile file) { try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return ProcessResult.ERROR; diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearcher.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearcher.java index 213400925f..91d1d08e36 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDbSearcher.java @@ -46,7 +46,7 @@ class HashDbSearcher { * @return a List of all FsContent with the given hash */ static List findFilesByMd5(String md5Hash) throws NoCurrentCaseException { - final Case currentCase = Case.getOpenCase(); + final Case currentCase = Case.getCurrentCaseThrows(); final SleuthkitCase skCase = currentCase.getSleuthkitCase(); return skCase.findFilesByMd5(md5Hash); } @@ -123,7 +123,7 @@ class HashDbSearcher { * @return true if the search feature is ready. */ static boolean allFilesMd5Hashed() throws NoCurrentCaseException { - final Case currentCase = Case.getOpenCase(); + final Case currentCase = Case.getCurrentCaseThrows(); final SleuthkitCase skCase = currentCase.getSleuthkitCase(); return skCase.allFilesMd5Hashed(); } @@ -134,7 +134,7 @@ class HashDbSearcher { * @return the number of files with an MD5 */ static int countFilesMd5Hashed() throws NoCurrentCaseException { - final Case currentCase = Case.getOpenCase(); + final Case currentCase = Case.getCurrentCaseThrows(); final SleuthkitCase skCase = currentCase.getSleuthkitCase(); return skCase.countFilesMd5Hashed(); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/iOS/CallLogAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/iOS/CallLogAnalyzer.java index 976f8aefac..ec8c84dc0b 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/iOS/CallLogAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/iOS/CallLogAnalyzer.java @@ -65,7 +65,7 @@ final class CallLogAnalyzer { public void findCallLogs(IngestJobContext context) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; @@ -80,7 +80,7 @@ final class CallLogAnalyzer { } for (AbstractFile file : absFiles) { try { - jFile = new java.io.File(Case.getOpenCase().getTempDirectory(), file.getName().replaceAll("[<>%|\"/:*\\\\]", "")); + jFile = new java.io.File(Case.getCurrentCaseThrows().getTempDirectory(), file.getName().replaceAll("[<>%|\"/:*\\\\]", "")); dbPath = jFile.toString(); //path of file as string fileId = file.getId(); ContentUtils.writeToFile(file, jFile, context::dataSourceIngestIsCancelled); @@ -117,7 +117,7 @@ final class CallLogAnalyzer { Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/modules/iOS/ContactAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/iOS/ContactAnalyzer.java index 9346b10acb..1adb60d4dd 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/iOS/ContactAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/iOS/ContactAnalyzer.java @@ -71,7 +71,7 @@ final class ContactAnalyzer { public void findContacts(IngestJobContext context) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; @@ -116,7 +116,7 @@ final class ContactAnalyzer { } Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/modules/iOS/TextMessageAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/iOS/TextMessageAnalyzer.java index dd3cc14d5b..c6288f0933 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/iOS/TextMessageAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/iOS/TextMessageAnalyzer.java @@ -68,7 +68,7 @@ class TextMessageAnalyzer { void findTexts(IngestJobContext context) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; @@ -82,7 +82,7 @@ class TextMessageAnalyzer { } for (AbstractFile file : absFiles) { try { - jFile = new java.io.File(Case.getOpenCase().getTempDirectory(), file.getName().replaceAll("[<>%|\"/:*\\\\]", "")); + jFile = new java.io.File(Case.getCurrentCaseThrows().getTempDirectory(), file.getName().replaceAll("[<>%|\"/:*\\\\]", "")); dbPath = jFile.toString(); //path of file as string fileId = file.getId(); ContentUtils.writeToFile(file, jFile, context::dataSourceIngestIsCancelled); @@ -112,7 +112,7 @@ class TextMessageAnalyzer { } Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java index 8ae1db3dc5..88eea65dda 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesIdentifierIngestModule.java @@ -107,7 +107,7 @@ final class FilesIdentifierIngestModule implements FileIngestModule { @Messages({"FilesIdentifierIngestModule.indexError.message=Failed to index interesting file hit artifact for keyword search."}) public ProcessResult process(AbstractFile file) { try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return ProcessResult.ERROR; diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java index 446da55940..e98e15a331 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverFileIngestModule.java @@ -427,7 +427,7 @@ final class PhotoRecCarverFileIngestModule implements FileIngestModule { synchronized Path createModuleOutputDirectoryForCase() throws IngestModule.IngestModuleException { Path path; try { - path = Paths.get(Case.getOpenCase().getModuleDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); + path = Paths.get(Case.getCurrentCaseThrows().getModuleDirectory(), PhotoRecCarverIngestModuleFactory.getModuleName()); } catch (NoCurrentCaseException ex) { throw new IngestModule.IngestModuleException(Bundle.cannotCreateOutputDir_message(ex.getLocalizedMessage()), ex); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverOutputParser.java b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverOutputParser.java index 6c1975f5a8..967a3c41ab 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverOutputParser.java +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/PhotoRecCarverOutputParser.java @@ -100,7 +100,7 @@ class PhotoRecCarverOutputParser { NodeList fileRanges; Element entry; Path filePath; - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); // create and initialize the list to put into the database List carvedFiles = new ArrayList<>(); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAccountObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAccountObj.java index 5174e479eb..35bfd82eff 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAccountObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAccountObj.java @@ -105,7 +105,7 @@ class EvalAccountObj extends EvaluatableObject { try { List finalHits = new ArrayList(); - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); List artList = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_OS_ACCOUNT); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAddressObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAddressObj.java index 4141ba874f..b37f9dd304 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAddressObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalAddressObj.java @@ -57,7 +57,7 @@ class EvalAddressObj extends EvaluatableObject { Case case1; try { - case1 = Case.getOpenCase(); + case1 = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return new ObservableResult(id, "Exception while getting open case.", //NON-NLS spacing, ObservableResult.ObservableState.FALSE, null); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalDomainObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalDomainObj.java index d06c5a19e0..e57ac8e067 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalDomainObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalDomainObj.java @@ -55,7 +55,7 @@ class EvalDomainObj extends EvaluatableObject { Case case1; try { - case1 = Case.getOpenCase(); + case1 = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return new ObservableResult(id, "Exception while getting open case.", //NON-NLS spacing, ObservableResult.ObservableState.FALSE, null); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalFileObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalFileObj.java index e99f34fe06..c5b3bae881 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalFileObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalFileObj.java @@ -62,7 +62,7 @@ class EvalFileObj extends EvaluatableObject { Case case1; try { - case1 = Case.getOpenCase(); + case1 = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return new ObservableResult(id, "Exception while getting open case.", //NON-NLS spacing, ObservableResult.ObservableState.FALSE, null); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalNetworkShareObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalNetworkShareObj.java index 7c1379e75f..7e6fa7c7b1 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalNetworkShareObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalNetworkShareObj.java @@ -89,7 +89,7 @@ class EvalNetworkShareObj extends EvaluatableObject { try { List finalHits = new ArrayList(); - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); List artList = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_REMOTE_DRIVE); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalRegistryObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalRegistryObj.java index 6040ea66e5..b5a4662ec6 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalRegistryObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalRegistryObj.java @@ -348,7 +348,7 @@ class EvalRegistryObj extends EvaluatableObject { // Make the temp directory String tmpDir; try { - tmpDir = Case.getOpenCase().getTempDirectory() + File.separator + "STIX"; //NON-NLS + tmpDir = Case.getCurrentCaseThrows().getTempDirectory() + File.separator + "STIX"; //NON-NLS } catch (NoCurrentCaseException ex) { throw new TskCoreException(ex.getLocalizedMessage()); } @@ -385,7 +385,7 @@ class EvalRegistryObj extends EvaluatableObject { List registryFiles = new ArrayList(); Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { throw new TskCoreException(ex.getLocalizedMessage()); } diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalSystemObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalSystemObj.java index bcfc5bc88e..73a7b1449f 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalSystemObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalSystemObj.java @@ -136,7 +136,7 @@ class EvalSystemObj extends EvaluatableObject { setUnsupportedFieldWarnings(); try { - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); List osInfoList = OSUtility.getOSInfo(sleuthkitCase); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURIObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURIObj.java index 123468041d..0c0ddb6971 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURIObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURIObj.java @@ -56,7 +56,7 @@ class EvalURIObj extends EvaluatableObject { Case case1; try { - case1 = Case.getOpenCase(); + case1 = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return new ObservableResult(id, "Exception while getting open case: " + ex.getLocalizedMessage(), //NON-NLS spacing, ObservableResult.ObservableState.FALSE, null); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURLHistoryObj.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURLHistoryObj.java index 5cfa2adcec..5cf0b28213 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURLHistoryObj.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvalURLHistoryObj.java @@ -139,7 +139,7 @@ class EvalURLHistoryObj extends EvaluatableObject { } try { - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); List artList = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY); @@ -232,7 +232,7 @@ class EvalURLHistoryObj extends EvaluatableObject { // It doesn't seem too useful, but we can just search for the browser name // if there aren't any URL entries try { - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); List artList = sleuthkitCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY); diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/EvaluatableObject.java b/Core/src/org/sleuthkit/autopsy/modules/stix/EvaluatableObject.java index 5c3a4cc75a..1fd7a7bed1 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/EvaluatableObject.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/EvaluatableObject.java @@ -101,7 +101,7 @@ abstract class EvaluatableObject { List hits = null; try { - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); String[] parts = item.getValue().toString().split("##comma##"); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java b/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java index 3f295b5cd7..5daf23c217 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/STIXReportModule.java @@ -186,7 +186,7 @@ public class STIXReportModule implements GeneralReportModule { // Set the progress bar to done. If any errors occurred along the way, modify // the "complete" message to indicate this. - Case.getOpenCase().addReport(reportPath, Bundle.STIXReportModule_srcModuleName_text(), ""); + Case.getCurrentCaseThrows().addReport(reportPath, Bundle.STIXReportModule_srcModuleName_text(), ""); if (hadErrors) { progressPanel.complete(ReportStatus.ERROR); progressPanel.updateStatusLabel( diff --git a/Core/src/org/sleuthkit/autopsy/modules/stix/StixArtifactData.java b/Core/src/org/sleuthkit/autopsy/modules/stix/StixArtifactData.java index cf4c4a3aea..6b0622f630 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/stix/StixArtifactData.java +++ b/Core/src/org/sleuthkit/autopsy/modules/stix/StixArtifactData.java @@ -51,7 +51,7 @@ class StixArtifactData { public StixArtifactData(long a_objId, String a_observableId, String a_objType) { try { - Case case1 = Case.getOpenCase(); + Case case1 = Case.getCurrentCaseThrows(); SleuthkitCase sleuthkitCase = case1.getSleuthkitCase(); file = sleuthkitCase.getAbstractFileById(a_objId); } catch (TskCoreException | NoCurrentCaseException ex) { @@ -66,7 +66,7 @@ class StixArtifactData { public void createArtifact(String a_title) throws TskCoreException { Blackboard blackboard; try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().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()); diff --git a/Core/src/org/sleuthkit/autopsy/modules/vmextractor/VMExtractorIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/vmextractor/VMExtractorIngestModule.java index a6d22b4d6b..843b07a3d6 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/vmextractor/VMExtractorIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/vmextractor/VMExtractorIngestModule.java @@ -81,7 +81,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter { this.context = context; long dataSourceObjId = context.getDataSource().getId(); try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); SleuthkitCase caseDb = currentCase.getSleuthkitCase(); DataSource dataSource = caseDb.getDataSource(dataSourceObjId); parentDeviceId = dataSource.getDeviceId(); @@ -234,7 +234,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter { List 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.getOpenCase().getServices().getFileManager().findFiles(dataSource, searchString)); + vmFiles.addAll(Case.getCurrentCaseThrows().getServices().getFileManager().findFiles(dataSource, searchString)); } return vmFiles; } @@ -275,7 +275,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter { * Try to add the virtual machine file to the case as a data source. */ UUID taskId = UUID.randomUUID(); - Case.getOpenCase().notifyAddingDataSource(taskId); + Case.getCurrentCaseThrows().notifyAddingDataSource(taskId); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); AddDataSourceCallback dspCallback = new AddDataSourceCallback(vmFile); synchronized (this) { @@ -291,7 +291,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter { * ingest context. */ if (!dspCallback.vmDataSources.isEmpty()) { - Case.getOpenCase().notifyDataSourceAdded(dspCallback.vmDataSources.get(0), taskId); + Case.getCurrentCaseThrows().notifyDataSourceAdded(dspCallback.vmDataSources.get(0), taskId); List dataSourceContent = new ArrayList<>(dspCallback.vmDataSources); IngestJobSettings ingestJobSettings = new IngestJobSettings(context.getExecutionContext()); for (String warning : ingestJobSettings.getWarnings()) { @@ -302,7 +302,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter { NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.addedVirtualMachineImage.message", vmFile.toString()))); IngestManager.getInstance().queueIngestJob(dataSourceContent, ingestJobSettings); } else { - Case.getOpenCase().notifyFailedAddingDataSource(taskId); + Case.getCurrentCaseThrows().notifyFailedAddingDataSource(taskId); } } diff --git a/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java b/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java index 300a810def..50e9715a16 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java +++ b/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java @@ -75,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.getOpenCase().getSleuthkitCase().getArtifactTypesInUse(); + artifactTypes = Case.getCurrentCaseThrows().getSleuthkitCase().getArtifactTypesInUse(); artifactTypes.removeAll(doNotReport); Collections.sort(artifactTypes, new Comparator() { @Override diff --git a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java index 71cccf96ed..f96bad446b 100644 --- a/Core/src/org/sleuthkit/autopsy/report/FileReportText.java +++ b/Core/src/org/sleuthkit/autopsy/report/FileReportText.java @@ -72,7 +72,7 @@ class FileReportText implements FileReportModule { if (out != null) { try { out.close(); - Case.getOpenCase().addReport(reportPath, NbBundle.getMessage(this.getClass(), + Case.getCurrentCaseThrows().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 diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java b/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java index 3a601fdd7f..4695418117 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportBodyFile.java @@ -75,7 +75,7 @@ class ReportBodyFile implements GeneralReportModule { public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { // Start the progress bar and setup the report try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); return; @@ -161,7 +161,7 @@ class ReportBodyFile implements GeneralReportModule { if (out != null) { out.flush(); out.close(); - Case.getOpenCase().addReport(reportPath, + Case.getCurrentCaseThrows().addReport(reportPath, NbBundle.getMessage(this.getClass(), "ReportBodyFile.generateReport.srcModuleName.text"), ""); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java b/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java index b28ac5ade2..3dcc416ef3 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportExcel.java @@ -113,7 +113,7 @@ class ReportExcel implements TableReportModule { try { out = new FileOutputStream(reportPath); wb.write(out); - Case.getOpenCase().addReport(reportPath, NbBundle.getMessage(this.getClass(), + Case.getCurrentCaseThrows().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 @@ -305,7 +305,7 @@ class ReportExcel implements TableReportModule { private void writeSummaryWorksheet() { Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java index 127f537df4..aecfe0661a 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java @@ -228,7 +228,7 @@ class ReportGenerator { private List getFiles() { List absFiles; try { - SleuthkitCase skCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); absFiles = skCase.findAllFilesWhere("meta_type != " + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue()); //NON-NLS return absFiles; } catch (TskCoreException | NoCurrentCaseException ex) { @@ -253,7 +253,7 @@ class ReportGenerator { private static String createReportDirectory(ReportModule module) throws IOException { Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { throw new IOException("Exception while getting open case.", ex); } diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java index fdc0457b1c..2f0cb5f770 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -104,7 +104,7 @@ class ReportHTML implements TableReportModule { // Refesh the member variables private void refresh() throws NoCurrentCaseException { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); skCase = currentCase.getSleuthkitCase(); dataTypes = new TreeMap<>(); @@ -890,7 +890,7 @@ class ReportHTML implements TableReportModule { String indexFilePath = path + "report.html"; //NON-NLS Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportKML.java b/Core/src/org/sleuthkit/autopsy/report/ReportKML.java index c5c57eccb8..3a092efc83 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportKML.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportKML.java @@ -101,7 +101,7 @@ class ReportKML implements GeneralReportModule { @Override public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; @@ -387,7 +387,7 @@ class ReportKML implements GeneralReportModule { if (result == ReportProgressPanel.ReportStatus.ERROR) { prependedStatus = "Incomplete "; } - Case.getOpenCase().addReport(kmlFileFullPath, + Case.getCurrentCaseThrows().addReport(kmlFileFullPath, NbBundle.getMessage(this.getClass(), "ReportKML.genReport.srcModuleName.text"), prependedStatus + NbBundle.getMessage(this.getClass(), "ReportKML.genReport.reportName")); } catch (IOException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java index 5790a34de4..98160874c9 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java @@ -98,7 +98,7 @@ final class ReportVisualPanel2 extends JPanel { private void initTags() { List tagNamesInUse; try { - tagNamesInUse = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse(); + tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse(); } catch (TskCoreException | NoCurrentCaseException ex) { Logger.getLogger(ReportVisualPanel2.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS return; @@ -137,7 +137,7 @@ final class ReportVisualPanel2 extends JPanel { private void initArtifactTypes() { try { - Case openCase = Case.getOpenCase(); + Case openCase = Case.getCurrentCaseThrows(); ArrayList doNotReport = new ArrayList<>(); doNotReport.add(new BlackboardArtifact.Type(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getTypeID(), BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO.getLabel(), diff --git a/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java index 673d5fa3d4..9d5d41c836 100644 --- a/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java @@ -182,7 +182,7 @@ class TableReportGenerator { String accountDisplayname = accountTypeStr; if (accountTypeStr != null) { try { - Account.Type acctType = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().getAccountType(accountTypeStr); + Account.Type acctType = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager().getAccountType(accountTypeStr); if (acctType != null) { accountDisplayname = acctType.getDisplayName(); } @@ -268,7 +268,7 @@ class TableReportGenerator { // Get the content tags. List tags; try { - tags = Case.getOpenCase().getServices().getTagsManager().getAllContentTags(); + tags = Case.getCurrentCaseThrows().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 @@ -361,7 +361,7 @@ class TableReportGenerator { List tags; try { - tags = Case.getOpenCase().getServices().getTagsManager().getAllBlackboardArtifactTags(); + tags = Case.getCurrentCaseThrows().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 @@ -453,7 +453,7 @@ class TableReportGenerator { private void checkIfTagHasImage(BlackboardArtifactTag artifactTag) { AbstractFile file; try { - file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(artifactTag.getArtifact().getObjectID()); + file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(artifactTag.getArtifact().getObjectID()); } catch (TskCoreException | NoCurrentCaseException ex) { errorList.add( NbBundle.getMessage(this.getClass(), "ReportGenerator.errList.errGetContentFromBBArtifact")); @@ -532,7 +532,7 @@ class TableReportGenerator { String orderByClause; Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { errorList.add(Bundle.ReportGenerator_errList_noOpenCase()); logger.log(Level.SEVERE, "Exception while getting open case: ", ex); //NON-NLS @@ -697,7 +697,7 @@ class TableReportGenerator { String orderByClause; Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { errorList.add(Bundle.ReportGenerator_errList_noOpenCase()); logger.log(Level.SEVERE, "Exception while getting open case: ", ex); //NON-NLS @@ -852,7 +852,7 @@ class TableReportGenerator { this.attributes = attrs; this.tags = tags; try { - this.content = Case.getOpenCase().getSleuthkitCase().getContentById(artifact.getObjectID()); + this.content = Case.getCurrentCaseThrows().getSleuthkitCase().getContentById(artifact.getObjectID()); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Could not get content from database", ex); } @@ -990,7 +990,7 @@ class TableReportGenerator { HashSet allTags = getTags(); try { - List contentTags = Case.getOpenCase().getServices().getTagsManager().getContentTagsByContent(content); + List contentTags = Case.getCurrentCaseThrows().getServices().getTagsManager().getContentTagsByContent(content); for (ContentTag ct : contentTags) { String notableString = ct.getName().getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : ""; allTags.add(ct.getName().getDisplayName() + notableString); @@ -1026,8 +1026,8 @@ class TableReportGenerator { private List getFilteredArtifacts(BlackboardArtifact.Type type, HashSet tagNamesFilter) { List artifacts = new ArrayList<>(); try { - for (BlackboardArtifact artifact : Case.getOpenCase().getSleuthkitCase().getBlackboardArtifacts(type.getTypeID())) { - List tags = Case.getOpenCase().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact); + for (BlackboardArtifact artifact : Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboardArtifacts(type.getTypeID())) { + List tags = Case.getCurrentCaseThrows().getServices().getTagsManager().getBlackboardArtifactTagsByArtifact(artifact); HashSet uniqueTagNames = new HashSet<>(); for (BlackboardArtifactTag tag : tags) { String notableString = tag.getName().getKnownStatus() == TskData.FileKnown.BAD ? TagsManager.getNotableTagLabel() : ""; @@ -1037,7 +1037,7 @@ class TableReportGenerator { continue; } try { - artifacts.add(new ArtifactData(artifact, Case.getOpenCase().getSleuthkitCase().getBlackboardAttributes(artifact), uniqueTagNames)); + artifacts.add(new ArtifactData(artifact, Case.getCurrentCaseThrows().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 @@ -1627,7 +1627,7 @@ 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.getOpenCase().getSleuthkitCase().executeQuery(query)) { + try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery(query)) { ResultSet tagNameRows = dbQuery.getResultSet(); while (tagNameRows.next()) { uniqueTagNames.add(tagNameRows.getString("display_name")); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDb.java b/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDb.java index f64a14306f..eb8b8a289f 100644 --- a/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDb.java +++ b/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDb.java @@ -69,7 +69,7 @@ public class AddTaggedHashesToHashDb implements GeneralReportModule { public void generateReport(String reportPath, ReportProgressPanel progressPanel) { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } 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); diff --git a/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDbConfigPanel.java b/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDbConfigPanel.java index 44e0f93d75..06484468a4 100644 --- a/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDbConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/taggedhashes/AddTaggedHashesToHashDbConfigPanel.java @@ -68,7 +68,7 @@ class AddTaggedHashesToHashDbConfigPanel extends javax.swing.JPanel { private void populateTagNameComponents() { // Get the tag names in use for the current case. try { - tagNames = Case.getOpenCase().getServices().getTagsManager().getTagNamesInUse(); + tagNames = Case.getCurrentCaseThrows().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); diff --git a/Core/src/org/sleuthkit/autopsy/test/CustomArtifactType.java b/Core/src/org/sleuthkit/autopsy/test/CustomArtifactType.java index adb366878c..032f7da506 100644 --- a/Core/src/org/sleuthkit/autopsy/test/CustomArtifactType.java +++ b/Core/src/org/sleuthkit/autopsy/test/CustomArtifactType.java @@ -65,7 +65,7 @@ final class CustomArtifactType { * @throws BlackboardException If there is an error adding any of the types. */ static void addToCaseDatabase() throws Blackboard.BlackboardException, NoCurrentCaseException { - Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard(); + Blackboard blackboard = Case.getCurrentCaseThrows().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); diff --git a/Core/src/org/sleuthkit/autopsy/test/InterestingArtifactCreatorIngestModule.java b/Core/src/org/sleuthkit/autopsy/test/InterestingArtifactCreatorIngestModule.java index f56d4cb043..f3232ceb86 100644 --- a/Core/src/org/sleuthkit/autopsy/test/InterestingArtifactCreatorIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/test/InterestingArtifactCreatorIngestModule.java @@ -55,7 +55,7 @@ final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapt @Override public void startUp(IngestJobContext context) throws IngestModuleException { try { - Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard(); + Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); artifactType = blackboard.getOrAddArtifactType(INT_ARTIFACT_TYPE_NAME, INT_ARTIFACT_DISPLAY_NAME); } catch (Blackboard.BlackboardException | NoCurrentCaseException ex) { throw new IngestModuleException(Bundle.InterestingArtifactCreatorIngestModule_exceptionMessage_errorCreatingCustomType(), ex); @@ -77,7 +77,7 @@ final class InterestingArtifactCreatorIngestModule extends FileIngestModuleAdapt * type. */ int randomArtIndex = (int) (Math.random() * 3); - Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard(); + Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); BlackboardArtifact.Type artifactTypeBase = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAMES[randomArtIndex], ARTIFACT_DISPLAY_NAMES[randomArtIndex]); BlackboardArtifact artifactBase = file.newArtifact(artifactTypeBase.getTypeID()); Collection baseAttributes = new ArrayList<>(); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/OpenTimelineAction.java b/Core/src/org/sleuthkit/autopsy/timeline/OpenTimelineAction.java index c6e995c195..362853db3b 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/OpenTimelineAction.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/OpenTimelineAction.java @@ -81,7 +81,7 @@ public final class OpenTimelineAction extends CallableSystemAction { @Override public boolean isEnabled() { /** - * We used to also check if Case.getOpenCase().hasData() was true. We + * We used to also check if Case.getCurrentOpenCase().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. */ @@ -112,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.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); 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 @@ -213,7 +213,7 @@ public final class OpenTimelineAction extends CallableSystemAction { private boolean tooManyFiles() { try { - return FILE_LIMIT < Case.getOpenCase().getSleuthkitCase().countFilesWhere("1 = 1"); + return FILE_LIMIT < Case.getCurrentCaseThrows().getSleuthkitCase().countFilesWhere("1 = 1"); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Can not open timeline with no case open.", ex); } catch (TskCoreException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java index b382814f0d..c1cd61e427 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/TimeLineController.java @@ -950,7 +950,7 @@ public class TimeLineController { * already closed. */ try { - Case.getOpenCase(); + Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException notUsed) { // Case is closed, do nothing. return; diff --git a/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshotAsReport.java b/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshotAsReport.java index e0b3a3e333..b7fe2de313 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshotAsReport.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/actions/SaveSnapshotAsReport.java @@ -153,7 +153,7 @@ public class SaveSnapshotAsReport extends Action { try { //add main file as report to case - Case.getOpenCase().addReport(reportMainFilePath.toString(), Bundle.Timeline_ModuleName(), reportName); + Case.getCurrentCaseThrows().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(); diff --git a/Core/src/org/sleuthkit/autopsy/timeline/explorernodes/EventNode.java b/Core/src/org/sleuthkit/autopsy/timeline/explorernodes/EventNode.java index c501e703d6..a4f9f0106a 100644 --- a/Core/src/org/sleuthkit/autopsy/timeline/explorernodes/EventNode.java +++ b/Core/src/org/sleuthkit/autopsy/timeline/explorernodes/EventNode.java @@ -223,7 +223,7 @@ public class EventNode extends DisplayableItemNode { */ final SingleEvent eventById = eventsModel.getEventById(eventID); - SleuthkitCase sleuthkitCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase sleuthkitCase = Case.getCurrentCaseThrows().getSleuthkitCase(); AbstractFile file = sleuthkitCase.getAbstractFileById(eventById.getFileID()); if (eventById.getArtifactID().isPresent()) { diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java index 105f13146a..99dbd9204d 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepoDatamodelTest.java @@ -2344,7 +2344,7 @@ 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.getOpenCase()); + caseB = EamDb.getInstance().newCase(Case.getCurrentCaseThrows()); assertTrue("Failed to create correlation case from Autopsy case", caseB != null); } catch (EamDbException | NoCurrentCaseException ex) { Exceptions.printStackTrace(ex); @@ -2413,7 +2413,7 @@ public class CentralRepoDatamodelTest extends TestCase { // Test getting a case from an Autopsy case try { - CorrelationCase tempCase = EamDb.getInstance().getCase(Case.getOpenCase()); + CorrelationCase tempCase = EamDb.getInstance().getCase(Case.getCurrentCaseThrows()); assertTrue("getCase returned null for current Autopsy case", tempCase != null); } catch (EamDbException | NoCurrentCaseException ex) { Exceptions.printStackTrace(ex); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java index 70415d3c7e..810c682798 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/ingest/IngestFileFiltersTest.java @@ -31,7 +31,6 @@ import org.openide.util.Exceptions; import org.python.icu.impl.Assert; import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; import org.sleuthkit.autopsy.casemodule.LocalFilesDSProcessor; -import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.casemodule.services.FileManager; import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; import org.sleuthkit.autopsy.modules.embeddedfileextractor.EmbeddedFileExtractorModuleFactory; @@ -74,7 +73,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testBasicDir() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testBasicDir"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testBasicDir"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -84,12 +83,12 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet dirFilter = new FilesSet("Filter", "Filter to find all files in dir1.", false, true, rule); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, dirFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = openCase.getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List results = fileManager.findFiles("file.jpg", "dir1"); String mimeType = results.get(0).getMIMEType(); assertEquals("image/jpeg", mimeType); @@ -108,7 +107,7 @@ public class IngestFileFiltersTest extends NbTestCase { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -117,7 +116,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testExtAndDirWithOneRule() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testExtAndDirWithOneRule"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testExtAndDirWithOneRule"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -127,12 +126,12 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all jpg files in dir1.", false, true, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, filesExtDirsFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List results = fileManager.findFiles("%%"); assertEquals(62, results.size()); for (AbstractFile file : results) { @@ -145,7 +144,7 @@ public class IngestFileFiltersTest extends NbTestCase { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -153,7 +152,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testExtAndDirWithTwoRules() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testExtAndDirWithTwoRules"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testExtAndDirWithTwoRules"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -164,12 +163,12 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet filesExtDirsFilter = new FilesSet("Filter", "Filter to find all files in dir1 and all files with jpg extention.", false, true, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, filesExtDirsFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List results = fileManager.findFiles("%%"); assertEquals(62, results.size()); for (AbstractFile file : results) { @@ -190,7 +189,7 @@ public class IngestFileFiltersTest extends NbTestCase { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -198,7 +197,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testFullFileNameRule() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testFullFileNameRule"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testFullFileNameRule"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -208,12 +207,12 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet fullNameFilter = new FilesSet("Filter", "Filter to find file.docx.", false, true, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, fullNameFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List results = fileManager.findFiles("%%"); assertEquals(62, results.size()); for (AbstractFile file : results) { @@ -226,7 +225,7 @@ public class IngestFileFiltersTest extends NbTestCase { assertTrue(errMsg, file.getMIMEType() == null); } } - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -234,7 +233,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testCarvingWithExtRuleAndUnallocSpace() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testCarvingWithExtRuleAndUnallocSpace"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testCarvingWithExtRuleAndUnallocSpace"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -246,13 +245,13 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, false, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new PhotoRecCarverIngestModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, extensionFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); List results = fileManager.findFiles("%%"); assertEquals(70, results.size()); int carvedJpgGifFiles = 0; @@ -275,7 +274,7 @@ public class IngestFileFiltersTest extends NbTestCase { //Make sure we have carved jpg/gif files assertEquals(2, carvedJpgGifFiles); - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -283,7 +282,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testCarvingNoUnallocatedSpace() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testCarvingNoUnallocatedSpace"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testCarvingNoUnallocatedSpace"); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); @@ -295,13 +294,13 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet extensionFilter = new FilesSet("Filter", "Filter to files with .jpg and .gif extension.", false, true, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new PhotoRecCarverIngestModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates, extensionFilter); try { - List errs = IngestJobRunner.runIngestJob(openCase.getDataSources(), ingestJobSettings); + List errs = IngestJobRunner.runIngestJob(currentCase.getDataSources(), ingestJobSettings); //Ingest fails because Carving wants unallocated space assertEquals(1, errs.size()); assertEquals("PhotoRec Carver", errs.get(0).getModuleDisplayName()); @@ -309,7 +308,7 @@ public class IngestFileFiltersTest extends NbTestCase { Exceptions.printStackTrace(ex); Assert.fail(ex); } - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } @@ -317,7 +316,7 @@ public class IngestFileFiltersTest extends NbTestCase { public void testEmbeddedModule() { Path casePath = Paths.get(System.getProperty("java.io.tmpdir"), "testEmbeddedModule"); - CaseUtils.createCase(casePath); + CaseUtils.createCase(casePath, "testEmbeddedModule"); LocalFilesDSProcessor dataSourceProcessor = new LocalFilesDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, ZIPFILE_PATH); @@ -330,13 +329,13 @@ public class IngestFileFiltersTest extends NbTestCase { FilesSet embeddedFilter = new FilesSet("Filter", "Filter to files with .jpg extension.", false, false, rules); try { - Case openCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCase(); ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new FileTypeIdModuleFactory())); templates.add(IngestUtils.getIngestModuleTemplate(new EmbeddedFileExtractorModuleFactory())); IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestFileFiltersTest.class.getCanonicalName(), IngestJobSettings.IngestType.FILES_ONLY, templates, embeddedFilter); - IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + IngestUtils.runIngestJob(currentCase.getDataSources(), ingestJobSettings); + FileManager fileManager = currentCase.getServices().getFileManager(); //get all .jpg files in zip file List results = fileManager.findFiles("%%"); assertEquals(39, results.size()); @@ -356,7 +355,7 @@ public class IngestFileFiltersTest extends NbTestCase { } //Make sure 10 jpg files and 1 zip file have been typed assertEquals(11, numTypeJpgFiles); - } catch (NoCurrentCaseException | TskCoreException ex) { + } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java index 4b11fe37fc..b1963c3fd0 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java @@ -18,39 +18,28 @@ */ package org.sleuthkit.autopsy.modules.encryptiondetection; -import java.io.File; -import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import static junit.framework.Assert.assertFalse; import org.netbeans.junit.NbModuleSuite; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.casemodule.CaseActionException; -import org.sleuthkit.autopsy.casemodule.CaseDetails; import junit.framework.Test; -import org.apache.commons.io.FileUtils; import org.netbeans.junit.NbTestCase; import org.openide.util.Exceptions; import org.python.icu.impl.Assert; import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; -import org.sleuthkit.autopsy.casemodule.services.Blackboard; import org.sleuthkit.autopsy.casemodule.services.FileManager; -import org.sleuthkit.autopsy.datasourceprocessors.AutoIngestDataSourceProcessor; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; -import org.sleuthkit.autopsy.ingest.IngestModuleError; import org.sleuthkit.autopsy.ingest.IngestModuleFactory; import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; -import org.sleuthkit.autopsy.testutils.DataSourceProcessorRunner; -import org.sleuthkit.autopsy.testutils.DataSourceProcessorRunner.ProcessorCallback; -import org.sleuthkit.autopsy.testutils.IngestJobRunner; +import org.sleuthkit.autopsy.testutils.CaseUtils; +import org.sleuthkit.autopsy.testutils.IngestUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; -import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; @@ -58,7 +47,6 @@ public class EncryptionDetectionTest extends NbTestCase { private static final String CASE_NAME = "EncryptionDetectionTest"; private static final Path CASE_DIRECTORY_PATH = Paths.get(System.getProperty("java.io.tmpdir"), CASE_NAME); - private static final File CASE_DIR = new File(CASE_DIRECTORY_PATH.toString()); private final Path IMAGE_PATH = Paths.get(this.getDataDir().toString(), "password_detection_test.img"); public static Test suite() { @@ -74,51 +62,14 @@ public class EncryptionDetectionTest extends NbTestCase { @Override public void setUp() { - // Delete the test directory, if it exists - if (CASE_DIRECTORY_PATH.toFile().exists()) { - try { - FileUtils.deleteDirectory(CASE_DIRECTORY_PATH.toFile()); - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); - } - } - assertFalse(String.format("Unable to delete existing test directory '%s'.", CASE_DIRECTORY_PATH.toString()), CASE_DIRECTORY_PATH.toFile().exists()); - - // Create the test directory - CASE_DIRECTORY_PATH.toFile().mkdirs(); - assertTrue(String.format("Unable to create test directory '%s'.", CASE_DIRECTORY_PATH.toString()), CASE_DIRECTORY_PATH.toFile().exists()); - - try { - Case.createAsCurrentCase(Case.CaseType.SINGLE_USER_CASE, CASE_DIRECTORY_PATH.toString(), new CaseDetails(CASE_NAME)); - } catch (CaseActionException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); - } - assertTrue(CASE_DIR.exists()); + CaseUtils.createCase(CASE_DIRECTORY_PATH, CASE_NAME); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); - try { - ProcessorCallback callBack = DataSourceProcessorRunner.runDataSourceProcessor(dataSourceProcessor, IMAGE_PATH); - List dataSourceContentList = callBack.getDataSourceContent(); - String errorMessage = String.format("The data source processor callback should produce 1 data source Content object, but the actual count was %d.", dataSourceContentList.size()); - assertEquals(errorMessage, 1, dataSourceContentList.size()); - List callbackErrorMessageList = callBack.getErrorMessages(); - errorMessage = String.format("The data source processor callback produced %d error messages.", callbackErrorMessageList.size()); - assertEquals(errorMessage, 0, callbackErrorMessageList.size()); - } catch (AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException | InterruptedException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); - - } + IngestUtils.addDataSource(dataSourceProcessor, IMAGE_PATH); } @Override public void tearDown() { - try { - Case.closeCurrentCase(); - } catch (CaseActionException ex) { - Exceptions.printStackTrace(ex); - } + CaseUtils.closeCase(); } /** @@ -127,43 +78,78 @@ public class EncryptionDetectionTest extends NbTestCase { public void testPasswordProtection() { try { Case openCase = Case.getOpenCase(); - runIngestJob(openCase.getDataSources(), new EncryptionDetectionModuleFactory()); + + /* + * Create ingest job settings. + */ + IngestModuleFactory ingestModuleFactory = new EncryptionDetectionModuleFactory(); + IngestModuleIngestJobSettings settings = ingestModuleFactory.getDefaultIngestJobSettings(); + IngestModuleTemplate template = new IngestModuleTemplate(ingestModuleFactory, settings); + template.setEnabled(true); + List templates = new ArrayList<>(); + templates.add(template); + IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); + IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); + + /* + * Purge specific files to be tested. + */ FileManager fileManager = openCase.getServices().getFileManager(); - Blackboard bb = openCase.getServices().getBlackboard(); - List results = fileManager.findFiles("%%", "ole2"); - results.addAll(fileManager.findFiles("%%", "ooxml")); - results.addAll(fileManager.findFiles("%%", "pdf")); + List> allResults = new ArrayList<>(0); + + List ole2Results = fileManager.findFiles("%%", "ole2"); + assertEquals("Unexpected number of OLE2 results.", 11, ole2Results.size()); + + List ooxmlResults = fileManager.findFiles("%%", "ooxml"); + assertEquals("Unexpected number of OOXML results.", 13, ooxmlResults.size()); + + List pdfResults = fileManager.findFiles("%%", "pdf"); + assertEquals("Unexpected number of PDF results.", 6, pdfResults.size()); + + List mdbResults = fileManager.findFiles("%%", "mdb"); + assertEquals("Unexpected number of MDB results.", 25, mdbResults.size()); + + List accdbResults = fileManager.findFiles("%%", "accdb"); + assertEquals("Unexpected number of ACCDB results.", 10, accdbResults.size()); + + allResults.add(ole2Results); + allResults.add(ooxmlResults); + allResults.add(pdfResults); + allResults.add(mdbResults); + allResults.add(accdbResults); - for (AbstractFile file : results) { - /* - * Process only non-slack files. - */ - if (file.isFile() && !file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) { + for (List results : allResults) { + for (AbstractFile file : results) { /* - * Determine which assertions to use for the file based on - * its name. + * Process only non-slack files. */ - boolean fileProtected = file.getName().split("\\.")[0].endsWith("-protected"); - List artifactsList = file.getAllArtifacts(); - if (fileProtected) { + if (file.isFile() && !file.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK)) { /* - * Check that the protected file has one - * TSK_ENCRYPTION_DETECTED artifact. + * Determine which assertions to use for the file based on + * its name. */ - int artifactsListSize = artifactsList.size(); - String errorMessage = String.format("File '%s' (objId=%d) has %d artifacts, but 1 was expected.", file.getName(), file.getId(), artifactsListSize); - assertEquals(errorMessage, 1, artifactsListSize); + boolean fileProtected = file.getName().split("\\.")[0].endsWith("-protected"); + List artifactsList = file.getAllArtifacts(); + if (fileProtected) { + /* + * Check that the protected file has one + * TSK_ENCRYPTION_DETECTED artifact. + */ + int artifactsListSize = artifactsList.size(); + String errorMessage = String.format("File '%s' (objId=%d) has %d artifacts, but 1 was expected.", file.getName(), file.getId(), artifactsListSize); + assertEquals(errorMessage, 1, artifactsListSize); - String artifactTypeName = artifactsList.get(0).getArtifactTypeName(); - errorMessage = String.format("File '%s' (objId=%d) has an unexpected '%s' artifact.", file.getName(), file.getId(), artifactTypeName); - assertEquals(errorMessage, BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED.toString(), artifactTypeName); - } else { - /* - * Check that the unprotected file has no artifacts. - */ - int artifactsListSize = artifactsList.size(); - String errorMessage = String.format("File '%s' (objId=%d) has %d artifacts, but none were expected.", file.getName(), file.getId(), artifactsListSize); - assertEquals(errorMessage, 0, artifactsListSize); + String artifactTypeName = artifactsList.get(0).getArtifactTypeName(); + errorMessage = String.format("File '%s' (objId=%d) has an unexpected '%s' artifact.", file.getName(), file.getId(), artifactTypeName); + assertEquals(errorMessage, BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED.toString(), artifactTypeName); + } else { + /* + * Check that the unprotected file has no artifacts. + */ + int artifactsListSize = artifactsList.size(); + String errorMessage = String.format("File '%s' (objId=%d) has %d artifacts, but none were expected.", file.getName(), file.getId(), artifactsListSize); + assertEquals(errorMessage, 0, artifactsListSize); + } } } } @@ -172,22 +158,4 @@ public class EncryptionDetectionTest extends NbTestCase { Assert.fail(ex); } } - - private void runIngestJob(List datasources, IngestModuleFactory factory) { - IngestModuleIngestJobSettings settings = factory.getDefaultIngestJobSettings(); - IngestModuleTemplate template = new IngestModuleTemplate(factory, settings); - template.setEnabled(true); - ArrayList templates = new ArrayList<>(); - templates.add(template); - IngestJobSettings ingestJobSettings = new IngestJobSettings(EncryptionDetectionTest.class.getCanonicalName(), IngestType.FILES_ONLY, templates); - try { - List ingestModuleErrorsList = IngestJobRunner.runIngestJob(datasources, ingestJobSettings); - String errorMessage = String.format("The ingest job runner produced %d error messages.", ingestModuleErrorsList.size()); - assertEquals(errorMessage, 0, ingestModuleErrorsList.size()); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); - } - } - } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java index dad3f6d142..5eecf425bd 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/CaseUtils.java @@ -29,29 +29,46 @@ import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.CaseActionException; import org.sleuthkit.autopsy.casemodule.CaseDetails; +/** + * Common case utility methods. + */ public final class CaseUtils { - + + /** + * CaseUtils constructor. Since this class is not meant to allow for + * instantiation, this constructor is 'private'. + */ private CaseUtils() { } - - public static void createCase(Path caseDirectoryPath) { + + /** + * Create a new case. If the case already exists at the specified path, the + * existing case will be removed prior to creation of the new case. + * + * @param caseDirectoryPath The path to the case data. + * @param caseDisplayName The display name for the case. + */ + public static void createCase(Path caseDirectoryPath, String caseDisplayName) { //Make sure the test is starting with a clean state. So delete the test directory, if it exists. deleteCaseDir(caseDirectoryPath); assertFalse("Unable to delete existing test directory", caseDirectoryPath.toFile().exists()); - + // Create the test directory caseDirectoryPath.toFile().mkdirs(); assertTrue("Unable to create test directory", caseDirectoryPath.toFile().exists()); try { - Case.createAsCurrentCase(Case.CaseType.SINGLE_USER_CASE, caseDirectoryPath.toString(), new CaseDetails("IngestFiltersTest")); + Case.createAsCurrentCase(Case.CaseType.SINGLE_USER_CASE, caseDirectoryPath.toString(), new CaseDetails(caseDisplayName)); } catch (CaseActionException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); - } + } assertTrue(caseDirectoryPath.toFile().exists()); } - + + /** + * Close the currently opened case. + */ public static void closeCase() { try { Case.closeCurrentCase(); @@ -64,9 +81,14 @@ public final class CaseUtils { } catch (CaseActionException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); - } + } } - + + /** + * Delete a case at the specified path. + * + * @param caseDirectoryPath The path to the case to be removed. + */ public static void deleteCaseDir(Path caseDirectoryPath) { if (!caseDirectoryPath.toFile().exists()) { return; diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java index 893f2d8cb2..fba62cdbde 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/testutils/IngestUtils.java @@ -16,7 +16,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.sleuthkit.autopsy.testutils; import java.nio.file.Path; @@ -32,41 +31,69 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestModuleTemplate; import org.sleuthkit.datamodel.Content; +/** + * Common image utility methods. + */ public final class IngestUtils { - + + /** + * IngestUtils constructor. Since this class is not meant to allow for + * instantiation, this constructor is 'private'. + */ private IngestUtils() { } - + + /** + * Add a data source for the data source processor. + * + * @param dataSourceProcessor The data source processor. + * @param dataSourcePath The path to the data source to be added. + */ public static void addDataSource(AutoIngestDataSourceProcessor dataSourceProcessor, Path dataSourcePath) { try { DataSourceProcessorRunner.ProcessorCallback callBack = DataSourceProcessorRunner.runDataSourceProcessor(dataSourceProcessor, dataSourcePath); - List errorMessages = callBack.getErrorMessages(); - assertEquals(0, errorMessages.size()); + List callbackErrorMessageList = callBack.getErrorMessages(); + String errorMessage = String.format("The data source processor callback produced %d error messages.", callbackErrorMessageList.size()); + assertEquals(errorMessage, 0, callbackErrorMessageList.size()); } catch (AutoIngestDataSourceProcessor.AutoIngestDataSourceProcessorException | InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); - - } + + } } - public static void runIngestJob(List datasources, IngestJobSettings ingestJobSettings) { + /** + * Run an ingest job. + * + * @param dataSourceList The list of data sources to process. + * @param ingestJobSettings The ingest job settings to use for ingest. + */ + public static void runIngestJob(List dataSourceList, IngestJobSettings ingestJobSettings) { try { - List errs = IngestJobRunner.runIngestJob(datasources, ingestJobSettings); - for (IngestModuleError err : errs) { + List ingestModuleErrorsList = IngestJobRunner.runIngestJob(dataSourceList, ingestJobSettings); + for (IngestModuleError err : ingestModuleErrorsList) { System.out.println(String.format("Error: %s: %s.", err.getModuleDisplayName(), err.toString())); } - assertEquals(0, errs.size()); + String errorMessage = String.format("The ingest job runner produced %d error messages.", ingestModuleErrorsList.size()); + assertEquals(errorMessage, 0, ingestModuleErrorsList.size()); } catch (InterruptedException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); - } + } } + /** + * Build a new ingest module template based on the given factory. + * + * @param factory The ingest module factory. + * + * @return The ingest module template. + */ public static IngestModuleTemplate getIngestModuleTemplate(IngestModuleFactoryAdapter factory) { IngestModuleIngestJobSettings settings = factory.getDefaultIngestJobSettings(); IngestModuleTemplate template = new IngestModuleTemplate(factory, settings); template.setEnabled(true); return template; } - + } diff --git a/Experimental/nbproject/project.xml b/Experimental/nbproject/project.xml index 54e7d881b2..6d3d3f6730 100644 --- a/Experimental/nbproject/project.xml +++ b/Experimental/nbproject/project.xml @@ -135,7 +135,7 @@ 10 - 10.10 + 10.11 @@ -153,7 +153,7 @@ 6 - 6.3 + 6.5 diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AddArchiveTask.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AddArchiveTask.java index 3baf91b871..9830cecbe9 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AddArchiveTask.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AddArchiveTask.java @@ -100,7 +100,7 @@ class AddArchiveTask implements Runnable { // extract the archive and pass the extracted folder as input try { - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); // create folder to extract archive to Path destinationFolder = createDirectoryForFile(archivePath, currentCase.getModuleDirectory()); diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.form b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.form new file mode 100644 index 0000000000..9f0ddc84c8 --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.form @@ -0,0 +1,93 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.java new file mode 100644 index 0000000000..b68553039d --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboard.java @@ -0,0 +1,151 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import java.awt.Cursor; +import java.awt.EventQueue; +import java.util.Observable; +import java.util.Observer; +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.AutoIngestNodeState; + +/** + * A dashboard for monitoring the existing AutoIngestNodes and their status. + */ +final class AinStatusDashboard extends javax.swing.JPanel implements Observer { + + private final AutoIngestMonitor autoIngestMonitor; + private final AinStatusPanel nodesPanel; + + /** + * Creates new form AutoIngestNodeStatus + */ + AinStatusDashboard(AutoIngestMonitor monitor) { + initComponents(); + autoIngestMonitor = monitor; + nodesPanel = new AinStatusPanel(); + nodesPanel.setSize(nodesPanel.getSize()); + nodeStatusScrollPane.add(nodesPanel); + nodeStatusScrollPane.setViewportView(nodesPanel); + refreshTables(); + } + + /** + * Adds this panel as an observer of AutoIngestMonitor. + */ + void startUp() { + autoIngestMonitor.addObserver(this); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + refreshButton = new javax.swing.JButton(); + clusterMetricsButton = new javax.swing.JButton(); + nodeStatusScrollPane = new javax.swing.JScrollPane(); + nodeStatusTableTitle = new javax.swing.JLabel(); + + org.openide.awt.Mnemonics.setLocalizedText(refreshButton, org.openide.util.NbBundle.getMessage(AinStatusDashboard.class, "AinStatusDashboard.refreshButton.text")); // NOI18N + refreshButton.setToolTipText(org.openide.util.NbBundle.getMessage(AinStatusDashboard.class, "AinStatusDashboard.refreshButton.toolTipText")); // NOI18N + refreshButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + refreshButtonActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(clusterMetricsButton, org.openide.util.NbBundle.getMessage(AinStatusDashboard.class, "AinStatusDashboard.clusterMetricsButton.text")); // NOI18N + clusterMetricsButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + clusterMetricsButtonActionPerformed(evt); + } + }); + + nodeStatusTableTitle.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(nodeStatusTableTitle, org.openide.util.NbBundle.getMessage(AinStatusDashboard.class, "AinStatusDashboard.nodeStatusTableTitle.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(nodeStatusScrollPane) + .addGroup(layout.createSequentialGroup() + .addComponent(nodeStatusTableTitle) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(refreshButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 715, Short.MAX_VALUE) + .addComponent(clusterMetricsButton))) + .addContainerGap()) + ); + + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {clusterMetricsButton, refreshButton}); + + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(40, 40, 40) + .addComponent(nodeStatusTableTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(nodeStatusScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(382, 382, 382) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(refreshButton) + .addComponent(clusterMetricsButton)) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + refreshTables(); + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + }//GEN-LAST:event_refreshButtonActionPerformed + + private void refreshTables() { + nodesPanel.refresh(autoIngestMonitor); + } + + private void clusterMetricsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clusterMetricsButtonActionPerformed + new AutoIngestMetricsDialog(this.getTopLevelAncestor()); + }//GEN-LAST:event_clusterMetricsButtonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton clusterMetricsButton; + private javax.swing.JScrollPane nodeStatusScrollPane; + private javax.swing.JLabel nodeStatusTableTitle; + private javax.swing.JButton refreshButton; + // End of variables declaration//GEN-END:variables + + @Override + public void update(Observable o, Object arg) { + if (arg instanceof AutoIngestNodeState) + EventQueue.invokeLater(() -> { + refreshTables(); + }); + } +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.form b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.form new file mode 100644 index 0000000000..5f3eab1a5f --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.form @@ -0,0 +1,28 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.java new file mode 100644 index 0000000000..1ab19b4a77 --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusDashboardTopComponent.java @@ -0,0 +1,140 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import java.util.List; +import java.util.logging.Level; +import java.util.stream.Collectors; +import org.openide.util.NbBundle.Messages; +import org.openide.windows.Mode; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; +import org.sleuthkit.autopsy.coreutils.Logger; + +/** + * Top component which displays the Auto Ingest Node Status Dashboard interface. + */ +@TopComponent.Description( + preferredID = "AinStatusDashboardTopComponent", + persistenceType = TopComponent.PERSISTENCE_NEVER +) +@TopComponent.Registration(mode = "nodeStatus", openAtStartup = false) +@Messages({ + "CTL_AinStatusDashboardAction=Auto Ingest Nodes", + "CTL_AinStatusDashboardTopComponent=Auto Ingest Nodes"}) +final class AinStatusDashboardTopComponent extends TopComponent { + + private static final long serialVersionUID = 1L; + public final static String PREFERRED_ID = "AinStatusDashboardTopComponent"; // NON-NLS + private static final Logger logger = Logger.getLogger(AinStatusDashboardTopComponent.class.getName()); + private static boolean topComponentInitialized = false; + + @Messages({ + "AinStatusDashboardTopComponent.exceptionMessage.failedToCreateDashboard=Failed to create Auto Ingest Node Status Dashboard.",}) + static void openTopComponent(AutoIngestMonitor monitor) { + final AinStatusDashboardTopComponent tc = (AinStatusDashboardTopComponent) WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (tc != null) { + topComponentInitialized = true; + WindowManager.getDefault().isTopComponentFloating(tc); + + if (tc.isOpened() == false) { + Mode mode = WindowManager.getDefault().findMode("nodeStatus"); // NON-NLS + if (mode != null) { + mode.dockInto(tc); + } + /* + * Make sure we have a clean-slate before attaching a new + * dashboard instance so we don't accumulate them. + */ + tc.removeAll(); + + /* + * Create a new dashboard instance to ensure we're using the + * most recent configuration. + */ + AinStatusDashboard nodeTab = new AinStatusDashboard(monitor); + nodeTab.startUp(); + nodeTab.setSize(nodeTab.getPreferredSize()); + tc.add(nodeTab); + tc.open(); + } + tc.toFront(); + tc.requestActive(); + } + } + + static void closeTopComponent() { + if (topComponentInitialized) { + final TopComponent tc = WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (tc != null) { + try { + tc.close(); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to close " + PREFERRED_ID, e); // NON-NLS + } + } + } + } + + AinStatusDashboardTopComponent() { + initComponents(); + setName(Bundle.CTL_AinStatusDashboardTopComponent()); + } + + + @Override + public List availableModes(List modes) { + /* + * This looks like the right thing to do, but online discussions seems + * to indicate this method is effectively deprecated. A break point + * placed here was never hit. + */ + return modes.stream().filter(mode -> mode.getName().equals("nodeStatus") || mode.getName().equals("ImageGallery")) + .collect(Collectors.toList()); + } + + @Override + public void componentOpened() { + super.componentOpened(); + WindowManager.getDefault().setTopComponentFloating(this, true); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusNode.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusNode.java new file mode 100644 index 0000000000..444a6fce8b --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusNode.java @@ -0,0 +1,156 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import javax.swing.Action; +import java.util.ArrayList; +import java.util.List; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.ChildFactory; +import org.openide.nodes.Children; +import org.openide.nodes.Node; +import org.openide.nodes.Sheet; +import org.openide.util.NbBundle.Messages; +import org.sleuthkit.autopsy.datamodel.NodeProperty; +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.AutoIngestNodeState; + +/** + * A node which represents all AutoIngestNodes. Each AutoIngestNode will have a + * child node representing it and its status. + */ +final class AinStatusNode extends AbstractNode { + + /** + * Construct a new AinStatusNode. + */ + AinStatusNode(AutoIngestMonitor monitor) { + super(Children.create(new AinStatusChildren(monitor), false)); + } + + /** + * A ChildFactory for generating StatusNodes. + */ + static class AinStatusChildren extends ChildFactory { + + private final AutoIngestMonitor monitor; + + /** + * Create children nodes for the AutoIngestNodeState which will each + * represent a single node state + * + * @param autoIngestMonitor the monitor which contains the node states + */ + AinStatusChildren(AutoIngestMonitor autoIngestMonitor) { + monitor = autoIngestMonitor; + } + + @Override + protected boolean createKeys(List list) { + list.addAll(monitor.getNodeStates()); + return true; + } + + @Override + protected Node createNodeForKey(AutoIngestNodeState key) { + return new StatusNode(key); + } + } + + /** + * A node which represents a single AutoIngestNode and its status. + */ + static final class StatusNode extends AbstractNode { + + private final AutoIngestNodeState nodeState; + + /** + * Construct a new StatusNode to represent an AutoIngestNode and its + * status. + * + * @param nodeState - the AutoIngestNodeState being represented by this + * node + */ + StatusNode(AutoIngestNodeState nodeState) { + super(Children.LEAF); + this.nodeState = nodeState; + setName(nodeState.getName()); + setDisplayName(nodeState.getName()); + } + + @Override + @Messages({"AinStatusNode.hostName.title=Host Name", + "AinStatusNode.status.title=Status", + "AinStatusNode.status.running=Running", + "AinStatusNode.status.pausedByUser=Paused By User", + "AinStatusNode.status.pausedForError=Paused Due to System Error", + "AinStatusNode.status.startingup=Starting Up", + "AinStatusNode.status.shuttingdown=Shutting Down", + "AinStatusNode.status.unknown=Unknown" + }) + protected Sheet createSheet() { + Sheet s = super.createSheet(); + Sheet.Set ss = s.get(Sheet.PROPERTIES); + if (ss == null) { + ss = Sheet.createPropertiesSet(); + s.put(ss); + } + ss.put(new NodeProperty<>(Bundle.AinStatusNode_hostName_title(), Bundle.AinStatusNode_hostName_title(), Bundle.AinStatusNode_hostName_title(), + nodeState.getName())); + String status = Bundle.AinStatusNode_status_unknown(); + switch (nodeState.getState()) { + case RUNNING: + status = Bundle.AinStatusNode_status_running(); + break; + case STARTING_UP: + status = Bundle.AinStatusNode_status_startingup(); + break; + case SHUTTING_DOWN: + status = Bundle.AinStatusNode_status_shuttingdown(); + break; + case PAUSED_BY_REQUEST: + status = Bundle.AinStatusNode_status_pausedByUser(); + break; + case PAUSED_DUE_TO_SYSTEM_ERROR: + status = Bundle.AinStatusNode_status_pausedForError(); + break; + default: + break; + } + ss.put(new NodeProperty<>(Bundle.AinStatusNode_status_title(), Bundle.AinStatusNode_status_title(), Bundle.AinStatusNode_status_title(), + status)); + return s; + } + + @Override + public Action[] getActions(boolean context) { + List actions = new ArrayList<>(); + if (AutoIngestDashboard.isAdminAutoIngestDashboard()) { + if (nodeState.getState() == AutoIngestNodeState.State.PAUSED_BY_REQUEST + || nodeState.getState() == AutoIngestNodeState.State.PAUSED_DUE_TO_SYSTEM_ERROR) { + actions.add(new AutoIngestAdminActions.ResumeAction()); + } else if (nodeState.getState() == AutoIngestNodeState.State.RUNNING){ + actions.add(new AutoIngestAdminActions.PauseAction()); + } + actions.add(new AutoIngestAdminActions.ShutdownAction()); + } + return actions.toArray(new Action[actions.size()]); + } + } + +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.form b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.form new file mode 100644 index 0000000000..bde4db4324 --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.form @@ -0,0 +1,18 @@ + + +
+ + + + + + + + + + + + + + + diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.java new file mode 100644 index 0000000000..095badff9a --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AinStatusPanel.java @@ -0,0 +1,142 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import java.awt.Dimension; +import java.beans.PropertyVetoException; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; +import org.netbeans.swing.outline.DefaultOutlineModel; +import org.netbeans.swing.outline.Outline; +import org.openide.explorer.ExplorerManager; +import org.openide.nodes.Node; +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJobsNode.JobNode; + +/** + * A panel which displays an outline view with all auto ingest nodes and their + * status. + */ +final class AinStatusPanel extends javax.swing.JPanel implements ExplorerManager.Provider { + + private static final long serialVersionUID = 1L; + private final org.openide.explorer.view.OutlineView outlineView; + private final Outline outline; + private ExplorerManager explorerManager; + + /** + * Creates a new AinStatusPanel + */ + AinStatusPanel() { + initComponents(); + outlineView = new org.openide.explorer.view.OutlineView(); + outline = outlineView.getOutline(); + customize(); + } + + /** + * Set up the AinStatusPanel's so that its outlineView is displaying the + * host name and the node status. + */ + void customize() { + ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel(Bundle.AinStatusNode_hostName_title()); + outline.setRowSelectionAllowed(false); //rows will be made selectable after table has been populated + outline.setFocusable(false); //table will be made focusable after table has been populated + if (null == explorerManager) { + explorerManager = new ExplorerManager(); + } + outlineView.setPropertyColumns( + Bundle.AinStatusNode_status_title(), Bundle.AinStatusNode_status_title()); + outline.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + outline.setRootVisible(false); + add(outlineView, java.awt.BorderLayout.CENTER); + } + + @Override + public void setSize(Dimension d) { + super.setSize(d); + outlineView.setMaximumSize(new Dimension(400, 100)); + outline.setPreferredScrollableViewportSize(new Dimension(400, 100)); + } + + /** + * Add a list selection listener to the selection model of the outline being + * used in this panel. + * + * @param listener the ListSelectionListener to add + */ + void addListSelectionListener(ListSelectionListener listener) { + outline.getSelectionModel().addListSelectionListener(listener); + } + + @Override + public ExplorerManager getExplorerManager() { + return explorerManager; + } + + /** + * Update the contents of this AinStatusPanel while retaining currently + * selected node. + * + * @param monitor - the AutoIngestMonitor which will provide the new + * contents + */ + void refresh(AutoIngestMonitor monitor) { + outline.setRowSelectionAllowed(false); + Node[] selectedNodes = explorerManager.getSelectedNodes(); + AinStatusNode autoIngestNode = new AinStatusNode(monitor); + explorerManager.setRootContext(autoIngestNode); + outline.setRowSelectionAllowed(true); + if (selectedNodes.length > 0 && autoIngestNode.getChildren().findChild(selectedNodes[0].getName()) != null && outline.isFocusable()) { //don't allow saved selections of empty nodes to be restored + try { + explorerManager.setSelectedNodes(new Node[]{autoIngestNode.getChildren().findChild(selectedNodes[0].getName())}); + } catch (PropertyVetoException ignore) { + //Unable to select previously selected node + } + } + outline.setFocusable(true); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + setLayout(new java.awt.BorderLayout()); + }// //GEN-END:initComponents + + /** + * Get the AutoIngestJob for the currently selected node of this panel. + * + * @return AutoIngestJob which is currently selected in this panel + */ + AutoIngestJob getSelectedAutoIngestJob() { + Node[] selectedRows = explorerManager.getSelectedNodes(); + if (selectedRows.length == 1) { + return ((JobNode) selectedRows[0]).getAutoIngestJob(); + } + return null; + } + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/ArchiveFilePanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/ArchiveFilePanel.java index 449c36dfff..e0a5378444 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/ArchiveFilePanel.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/ArchiveFilePanel.java @@ -217,7 +217,7 @@ class ArchiveFilePanel extends JPanel implements DocumentListener { // display warning if there is one (but don't disable "next" button) try { - if (false == PathValidator.isValid(path, Case.getOpenCase().getCaseType())) { + if (false == PathValidator.isValid(path, Case.getCurrentCaseThrows().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(Bundle.DataSourceOnCDriveError_text()); } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java index 15374f22ee..1a5f2657b6 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java @@ -25,7 +25,7 @@ import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.ingest.IngestProgressSnapshotDialog; final class AutoIngestAdminActions { - + @NbBundle.Messages({"AutoIngestAdminActions.progressDialogAction.title=Ingest Progress"}) static final class ProgressDialogAction extends AbstractAction { @@ -152,4 +152,65 @@ final class AutoIngestAdminActions { return super.clone(); //To change body of generated methods, choose Tools | Templates. } } + + @NbBundle.Messages({"AutoIngestAdminActions.pause.title=Pause Node"}) + static final class PauseAction extends AbstractAction { + + private static final long serialVersionUID = 1L; + + PauseAction() { + super(Bundle.AutoIngestAdminActions_pause_title()); + } + + @Override + public void actionPerformed(ActionEvent e) { + //TODO JIRA- + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); //To change body of generated methods, choose Tools | Templates. + } + } + + @NbBundle.Messages({"AutoIngestAdminActions.resume.title=Resume Node"}) + static final class ResumeAction extends AbstractAction { + + private static final long serialVersionUID = 1L; + + ResumeAction() { + super(Bundle.AutoIngestAdminActions_resume_title()); + } + + @Override + public void actionPerformed(ActionEvent e) { + //TODO JIRA- + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); //To change body of generated methods, choose Tools | Templates. + } + } + + @NbBundle.Messages({"AutoIngestAdminActions.shutdown.title=Shutdown Node"}) + static final class ShutdownAction extends AbstractAction { + + private static final long serialVersionUID = 1L; + + ShutdownAction() { + super(Bundle.AutoIngestAdminActions_shutdown_title()); + } + + @Override + public void actionPerformed(ActionEvent e) { + //TODO JIRA- + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); //To change body of generated methods, choose Tools | Templates. + } + } + } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java index 12218f203c..3704bf7a7e 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java @@ -26,22 +26,27 @@ import java.awt.Color; import java.awt.EventQueue; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.File; import java.util.HashSet; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.swing.JPanel; import javax.swing.SwingWorker; import javax.swing.UIManager; +import org.openide.modules.Places; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.core.ServicesMonitor; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.JobsSnapshot; /** * A dashboard for monitoring an automated ingest cluster. */ final class AutoIngestDashboard extends JPanel implements Observer { - + + private final static String ADMIN_ACCESS_FILE_NAME = "adminAccess"; + private final static String ADMIN_ACCESS_FILE_PATH = Places.getUserDirectory().getAbsolutePath() + File.separator + ADMIN_ACCESS_FILE_NAME; private static final long serialVersionUID = 1L; private static final Logger LOGGER = Logger.getLogger(AutoIngestDashboard.class.getName()); private AutoIngestMonitor autoIngestMonitor; @@ -242,16 +247,18 @@ final class AutoIngestDashboard extends JPanel implements Observer { @Override public void update(Observable observable, Object arg) { - EventQueue.invokeLater(() -> { - refreshTables(); - }); + if (arg instanceof JobsSnapshot) { + EventQueue.invokeLater(() -> { + refreshTables(); + }); + } } /** * Reloads the table models using a jobs snapshot and refreshes the JTables * that use the models. * - * @param jobsSnapshot The jobs snapshot. + * @param nodeStateSnapshot The jobs snapshot. */ void refreshTables() { pendingJobsPanel.refresh(autoIngestMonitor.getJobsSnapshot()); @@ -290,6 +297,11 @@ final class AutoIngestDashboard extends JPanel implements Observer { } + static boolean isAdminAutoIngestDashboard() { + File f = new File(ADMIN_ACCESS_FILE_PATH); + return f.exists(); + } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboardTopComponent.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboardTopComponent.java index 915e2a981f..195df4e4e7 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboardTopComponent.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboardTopComponent.java @@ -19,6 +19,7 @@ package org.sleuthkit.autopsy.experimental.autoingest; import java.awt.Component; +import java.awt.EventQueue; import java.util.List; import java.util.logging.Level; import java.util.stream.Collectors; @@ -39,8 +40,8 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; ) @TopComponent.Registration(mode = "dashboard", openAtStartup = false) @Messages({ - "CTL_AutoIngestDashboardAction=Auto Ingest Dashboard", - "CTL_AutoIngestDashboardTopComponent=Auto Ingest Dashboard"}) + "CTL_AutoIngestDashboardAction=Auto Ingest Jobs", + "CTL_AutoIngestDashboardTopComponent=Auto Ingest Jobs"}) public final class AutoIngestDashboardTopComponent extends TopComponent { private static final long serialVersionUID = 1L; @@ -75,8 +76,14 @@ public final class AutoIngestDashboardTopComponent extends TopComponent { AutoIngestDashboard dashboard = AutoIngestDashboard.createDashboard(); tc.add(dashboard); dashboard.setSize(dashboard.getPreferredSize()); - + //if the user has administrator access enabled open the Node Status top component as well + if (AutoIngestDashboard.isAdminAutoIngestDashboard()) { + EventQueue.invokeLater(() -> { + AinStatusDashboardTopComponent.openTopComponent(dashboard.getMonitor()); + }); + } tc.open(); + } tc.toFront(); tc.requestActive(); diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java index b623a2281f..60f84e566c 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java @@ -18,13 +18,11 @@ */ package org.sleuthkit.autopsy.experimental.autoingest; -import java.io.File; import javax.swing.Action; import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.openide.modules.Places; import org.openide.nodes.AbstractNode; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; @@ -41,8 +39,6 @@ import org.sleuthkit.autopsy.guiutils.StatusIconCellRenderer; * Each job with the specified status will have a child node representing it. */ final class AutoIngestJobsNode extends AbstractNode { - private final static String ADMIN_ACCESS_FILE_NAME = "adminAccess"; - private final static String ADMIN_ACCESS_FILE_PATH = Places.getUserDirectory().getAbsolutePath() + File.separator + ADMIN_ACCESS_FILE_NAME; @Messages({ "AutoIngestJobsNode.caseName.text=Case Name", @@ -132,7 +128,6 @@ final class AutoIngestJobsNode extends AbstractNode { super(Children.LEAF); jobStatus = status; autoIngestJob = job; - super.setName(autoIngestJob.getManifest().getCaseName()); setName(autoIngestJob.getManifest().getCaseName()); setDisplayName(autoIngestJob.getManifest().getCaseName()); } @@ -193,8 +188,7 @@ final class AutoIngestJobsNode extends AbstractNode { @Override public Action[] getActions(boolean context) { List actions = new ArrayList<>(); - File f = new File(ADMIN_ACCESS_FILE_PATH); - if (f.exists()) { + if (AutoIngestDashboard.isAdminAutoIngestDashboard()) { switch (jobStatus) { case PENDING_JOB: actions.add(new PrioritizationAction.PrioritizeJobAction(autoIngestJob)); diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java index 8a1228cde4..b7f90f100f 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestManager.java @@ -133,7 +133,8 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen Event.JOB_STATUS_UPDATED.toString(), Event.JOB_COMPLETED.toString(), Event.CASE_PRIORITIZED.toString(), - Event.JOB_STARTED.toString()})); + Event.JOB_STARTED.toString(), + Event.REPORT_STATE.toString()})); private static final long JOB_STATUS_EVENT_INTERVAL_SECONDS = 10; private static final String JOB_STATUS_PUBLISHING_THREAD_NAME = "AIM-job-status-event-publisher-%d"; private static final long MAX_MISSED_JOB_STATUS_UPDATES = 10; @@ -165,6 +166,8 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen private volatile State state; private volatile ErrorState errorState; + private volatile AutoIngestNodeStateEvent lastPublishedStateEvent; + /** * Gets a singleton auto ingest manager responsible for processing auto * ingest jobs defined by manifest files that can be added to any level of a @@ -235,6 +238,8 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen jobStatusPublishingExecutor.scheduleWithFixedDelay(new PeriodicJobStatusEventTask(), JOB_STATUS_EVENT_INTERVAL_SECONDS, JOB_STATUS_EVENT_INTERVAL_SECONDS, TimeUnit.SECONDS); eventPublisher.addSubscriber(EVENT_LIST, instance); state = State.RUNNING; + + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.RUNNING, LOCAL_HOST_NAME)); errorState = ErrorState.NONE; } @@ -275,6 +280,8 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen handleRemoteCasePrioritizationEvent((AutoIngestCasePrioritizedEvent) event); } else if (event instanceof AutoIngestCaseDeletedEvent) { handleRemoteCaseDeletedEvent((AutoIngestCaseDeletedEvent) event); + } else if (event instanceof AutoIngestRequestNodeStateEvent) { + handleRemoteRequestNodeStateEvent(); } } } @@ -377,7 +384,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen } /** - * Processes a case deletin event from another node by triggering an + * Processes a case deletion event from another node by triggering an * immediate input directory scan. * * @param event A case deleted event from another auto ingest node. @@ -390,6 +397,14 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen notifyObservers(Event.CASE_DELETED); } + /** + * Handle a request for current state by re-sending the last state event. + */ + private void handleRemoteRequestNodeStateEvent() { + // Re-publish last state event. + eventPublisher.publishRemotely(lastPublishedStateEvent); + } + /** * Shuts down auto ingest. */ @@ -400,6 +415,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen sysLogger.log(Level.INFO, "Auto ingest shutting down"); state = State.SHUTTING_DOWN; try { + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.SHUTTING_DOWN, AutoIngestManager.LOCAL_HOST_NAME)); eventPublisher.removeSubscriber(EVENT_LIST, instance); stopInputFolderScans(); stopJobProcessing(); @@ -1681,6 +1697,12 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen */ setChanged(); notifyObservers(Event.PAUSED_BY_REQUEST); + + /** + * Publish an event to let remote listeners know that the + * node has been paused. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.PAUSED_BY_REQUEST, AutoIngestManager.LOCAL_HOST_NAME)); } } } @@ -1704,6 +1726,12 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen */ setChanged(); notifyObservers(Event.RESUMED); + + /** + * Publish an event to let remote listeners know that the + * node has been resumed. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.RESUMED, AutoIngestManager.LOCAL_HOST_NAME)); } pauseLock.notifyAll(); } @@ -1724,10 +1752,23 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen pauseRequested = false; setChanged(); notifyObservers(Event.PAUSED_BY_REQUEST); + + /** + * Publish an event to let remote listeners know that the + * node has been paused. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.PAUSED_BY_REQUEST, AutoIngestManager.LOCAL_HOST_NAME)); + pauseLock.wait(); sysLogger.log(Level.INFO, "Job processing resumed after pause request"); setChanged(); notifyObservers(Event.RESUMED); + + /** + * Publish an event to let remote listeners know that the + * node has been resumed. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.RESUMED, AutoIngestManager.LOCAL_HOST_NAME)); } } } @@ -1744,11 +1785,24 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen sysLogger.log(Level.SEVERE, "Job processing paused for system error"); setChanged(); notifyObservers(Event.PAUSED_FOR_SYSTEM_ERROR); + + /** + * Publish an event to let remote listeners know that the node + * has been paused. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.PAUSED_FOR_SYSTEM_ERROR, AutoIngestManager.LOCAL_HOST_NAME)); + pauseLock.wait(); errorState = ErrorState.NONE; sysLogger.log(Level.INFO, "Job processing resumed after system error"); setChanged(); notifyObservers(Event.RESUMED); + + /** + * Publish an event to let remote listeners know that the node + * has been resumed. + */ + eventPublisher.publishRemotely(lastPublishedStateEvent = new AutoIngestNodeStateEvent(Event.RESUMED, AutoIngestManager.LOCAL_HOST_NAME)); } } @@ -2255,13 +2309,13 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen Case.openAsCurrentCase(metadataFilePath.toString()); } else { caseDirectoryPath = PathUtils.createCaseFolderPath(rootOutputDirectory, caseName); - + // Create the case directory now in case it is needed by selectSolrServerForCase Case.createCaseDirectory(caseDirectoryPath.toString(), CaseType.MULTI_USER_CASE); - + // If a list of servers exists, choose one to use for this case Server.selectSolrServerForCase(rootOutputDirectory, caseDirectoryPath); - + CaseDetails caseDetails = new CaseDetails(caseName); Case.createAsCurrentCase(CaseType.MULTI_USER_CASE, caseDirectoryPath.toString(), caseDetails); /* @@ -2272,7 +2326,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen Thread.sleep(AutoIngestUserPreferences.getSecondsToSleepBetweenCases() * 1000); } currentJob.setCaseDirectoryPath(caseDirectoryPath); - Case caseForJob = Case.getOpenCase(); + Case caseForJob = Case.getCurrentCase(); sysLogger.log(Level.INFO, "Opened case {0} for {1}", new Object[]{caseForJob.getName(), manifest.getFilePath()}); return caseForJob; @@ -2280,13 +2334,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen throw new CaseManagementException(String.format("Error creating solr settings file for case %s for %s", caseName, manifest.getFilePath()), ex); } catch (CaseActionException ex) { throw new CaseManagementException(String.format("Error creating or opening case %s for %s", caseName, manifest.getFilePath()), ex); - } catch (NoCurrentCaseException ex) { - /* - * Deal with the unfortunate fact that - * Case.getOpenCase throws NoCurrentCaseException. - */ - throw new CaseManagementException(String.format("Error getting current case %s for %s", caseName, manifest.getFilePath()), ex); - } + } } else { throw new CaseManagementException(String.format("Timed out acquiring case name lock for %s for %s", caseName, manifest.getFilePath())); } @@ -2490,7 +2538,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen sysLogger.log(Level.INFO, "Identified data source type for {0} as {1}", new Object[]{manifestPath, selectedProcessor.getDataSourceType()}); selectedProcessor.process(dataSource.getDeviceId(), dataSource.getPath(), progressMonitor, callBack); ingestLock.wait(); - + // at this point we got the content object(s) from the current DSP. // check whether the data source was processed successfully if ((dataSource.getResultDataSourceProcessorResultCode() == CRITICAL_ERRORS) @@ -2500,7 +2548,7 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen logDataSourceProcessorResult(dataSource); continue; } - + logDataSourceProcessorResult(dataSource); return; } @@ -3016,7 +3064,11 @@ final class AutoIngestManager extends Observable implements PropertyChangeListen CASE_DELETED, PAUSED_BY_REQUEST, PAUSED_FOR_SYSTEM_ERROR, - RESUMED + RESUMED, + STARTING_UP, + RUNNING, + SHUTTING_DOWN, + REPORT_STATE } /** diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestMonitor.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestMonitor.java index b8c5fcf23a..229128dae1 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestMonitor.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestMonitor.java @@ -25,11 +25,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Observable; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.logging.Level; +import java.util.stream.Collectors; import javax.annotation.concurrent.GuardedBy; import org.sleuthkit.autopsy.coordinationservice.CoordinationService; import org.sleuthkit.autopsy.coordinationservice.CoordinationService.CoordinationServiceException; @@ -38,7 +41,7 @@ import org.sleuthkit.autopsy.coreutils.NetworkUtils; import org.sleuthkit.autopsy.events.AutopsyEventException; import org.sleuthkit.autopsy.events.AutopsyEventPublisher; import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJob.ProcessingStatus; - +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestManager.Event; /** * An auto ingest monitor responsible for monitoring and reporting the * processing of auto ingest jobs. @@ -56,7 +59,13 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen AutoIngestManager.Event.JOB_STATUS_UPDATED.toString(), AutoIngestManager.Event.JOB_COMPLETED.toString(), AutoIngestManager.Event.CASE_PRIORITIZED.toString(), - AutoIngestManager.Event.JOB_STARTED.toString()})); + AutoIngestManager.Event.JOB_STARTED.toString(), + AutoIngestManager.Event.RUNNING.toString(), + AutoIngestManager.Event.PAUSED_BY_REQUEST.toString(), + AutoIngestManager.Event.PAUSED_FOR_SYSTEM_ERROR.toString(), + AutoIngestManager.Event.STARTING_UP.toString(), + AutoIngestManager.Event.SHUTTING_DOWN.toString(), + AutoIngestManager.Event.RESUMED.toString()})); private final AutopsyEventPublisher eventPublisher; private CoordinationService coordinationService; private final ScheduledThreadPoolExecutor coordSvcQueryExecutor; @@ -64,6 +73,8 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen @GuardedBy("jobsLock") private JobsSnapshot jobsSnapshot; + private final Map nodeStates = new ConcurrentHashMap<>(); + /** * Constructs an auto ingest monitor responsible for monitoring and * reporting the processing of auto ingest jobs. @@ -94,6 +105,9 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen } coordSvcQueryExecutor.scheduleWithFixedDelay(new CoordinationServiceQueryTask(), 0, CORRD_SVC_QUERY_INERVAL_MINS, TimeUnit.MINUTES); eventPublisher.addSubscriber(EVENT_LIST, this); + + // Publish an event that asks running nodes to send their state. + eventPublisher.publishRemotely(new AutoIngestRequestNodeStateEvent(AutoIngestManager.Event.REPORT_STATE)); } /** @@ -130,6 +144,8 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen handleCasePrioritizationEvent((AutoIngestCasePrioritizedEvent) event); } else if (event instanceof AutoIngestCaseDeletedEvent) { handleCaseDeletedEvent((AutoIngestCaseDeletedEvent) event); + } else if (event instanceof AutoIngestNodeStateEvent) { + handleAutoIngestNodeStateEvent((AutoIngestNodeStateEvent) event); } } @@ -193,12 +209,31 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen /** * Handles a case deletion event. * - * @param event A job/case prioritization event. + * @param event A job/case deletion event. */ private void handleCaseDeletedEvent(AutoIngestCaseDeletedEvent event) { coordSvcQueryExecutor.submit(new CoordinationServiceQueryTask()); } + /** + * Handles an auto ingest node state change event. + * + * @param event A node state change event. + */ + private void handleAutoIngestNodeStateEvent(AutoIngestNodeStateEvent event) { + if (event.getEventType() == AutoIngestManager.Event.SHUTTING_DOWN) { + // Remove node from collection. + nodeStates.remove(event.getNodeName()); + } else { + // Otherwise either create an entry for the given node name or update + // an existing entry in the map. + nodeStates.put(event.getNodeName(), new AutoIngestNodeState(event.getNodeName(), event.getEventType())); + } + setChanged(); + // Trigger a dashboard refresh. + notifyObservers(nodeStates.get(event.getNodeName())); + } + /** * Gets the auto ingest monitor's current snapshot of the pending jobs * queue, running jobs list, and completed jobs list for an auto ingest @@ -212,6 +247,14 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen } } + /** + * Gets the current state of known AIN's in the system. + * @return + */ + List getNodeStates() { + return nodeStates.values().stream().collect(Collectors.toList()); + } + /** * Makes the auto ingest monitor's refresh its current snapshot of the * pending jobs queue, running jobs list, and completed jobs list for an @@ -505,8 +548,8 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen } /** - * A snapshot of the pending jobs queue, running jobs list, and completed - * jobs list for an auto ingest cluster. + * A snapshot of the pending jobs queue, running jobs list and completed jobs + * list for an auto ingest cluster. */ static final class JobsSnapshot { @@ -622,6 +665,62 @@ final class AutoIngestMonitor extends Observable implements PropertyChangeListen } + /** + * Class that represents the state of an AIN for the dashboard. + */ + static final class AutoIngestNodeState { + + /** + * The set of AIN states. + */ + enum State { + STARTING_UP, + SHUTTING_DOWN, + RUNNING, + PAUSED_BY_REQUEST, + PAUSED_DUE_TO_SYSTEM_ERROR, + UNKNOWN + } + + private final String nodeName; + private final State nodeState; + + AutoIngestNodeState(String name, Event event) { + nodeName = name; + switch (event) { + case STARTING_UP: + nodeState = State.STARTING_UP; + break; + case SHUTTING_DOWN: + nodeState = State.SHUTTING_DOWN; + break; + case RUNNING: + nodeState = State.RUNNING; + break; + case PAUSED_BY_REQUEST: + nodeState = State.PAUSED_BY_REQUEST; + break; + case PAUSED_FOR_SYSTEM_ERROR: + nodeState = State.PAUSED_DUE_TO_SYSTEM_ERROR; + break; + case RESUMED: + nodeState = State.RUNNING; + break; + default: + nodeState = State.UNKNOWN; + break; + } + } + + String getName() { + return nodeName; + } + + State getState() { + return nodeState; + } + } + /** * Exception type thrown when there is an error completing an auto ingest * monitor operation. diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeStateEvent.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeStateEvent.java new file mode 100644 index 0000000000..d1a71c3c0a --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeStateEvent.java @@ -0,0 +1,46 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import java.io.Serializable; +import org.sleuthkit.autopsy.events.AutopsyEvent; + +/** + * Event published when an auto ingest node is started, paused, + * resumed or shutdown. + */ +public final class AutoIngestNodeStateEvent extends AutopsyEvent implements Serializable { + private static final long serialVersionUID = 1L; + private final AutoIngestManager.Event eventType; + private final String nodeName; + + public AutoIngestNodeStateEvent(AutoIngestManager.Event eventType, String nodeName) { + super(eventType.toString(), null, null); + this.eventType = eventType; + this.nodeName = nodeName; + } + + public AutoIngestManager.Event getEventType() { + return this.eventType; + } + + public String getNodeName() { + return this.nodeName; + } +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestRequestNodeStateEvent.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestRequestNodeStateEvent.java new file mode 100644 index 0000000000..d756020520 --- /dev/null +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestRequestNodeStateEvent.java @@ -0,0 +1,34 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2018 Basis Technology Corp. + * Contact: carrier sleuthkit 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.experimental.autoingest; + +import java.io.Serializable; +import org.sleuthkit.autopsy.events.AutopsyEvent; + +/** + * Event published to request that auto ingest nodes send their current state. + * This event is sent on auto ingest dashboard startup. + */ +public class AutoIngestRequestNodeStateEvent extends AutopsyEvent implements Serializable { + private static final long serialVersionUID = 1L; + + public AutoIngestRequestNodeStateEvent(AutoIngestManager.Event eventType) { + super(eventType.toString(), null, null); + } +} diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties index 6194815f69..e4fe649e18 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties @@ -258,3 +258,7 @@ AutoIngestControlPanel.bnPrioritizeJob.toolTipText=Move this folder to the top o AutoIngestControlPanel.bnPrioritizeCase.toolTipText=Move all images associated with a case to top of Pending queue. AutoIngestControlPanel.bnPrioritizeJob.actionCommand=Prioritize Job AutoIngestControlPanel.bnDeprioritizeJob.actionCommand=Deprioritize Job +AinStatusDashboard.refreshButton.toolTipText=Refresh displayed tables +AinStatusDashboard.refreshButton.text=&Refresh +AinStatusDashboard.clusterMetricsButton.text=Auto Ingest &Metrics +AinStatusDashboard.nodeStatusTableTitle.text=Auto Ingest Nodes diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExportRuleSet.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExportRuleSet.java index 0029150e3d..399ae574ba 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExportRuleSet.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExportRuleSet.java @@ -375,7 +375,7 @@ final class FileExportRuleSet implements Serializable, Comparable evaluate(long dataSourceId) throws ExportRulesException { try { - SleuthkitCase db = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase db = Case.getCurrentCaseThrows().getSleuthkitCase(); try (SleuthkitCase.CaseDbQuery queryResult = db.executeQuery(getQuery(dataSourceId))) { ResultSet resultSet = queryResult.getResultSet(); List fileIds = new ArrayList<>(); @@ -1063,7 +1063,7 @@ final class FileExportRuleSet implements Serializable, Comparable dataSources) throws FileExportException { SleuthkitCase skCase; try { - skCase = Case.getOpenCase().getSleuthkitCase(); + skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex) { throw new FileExportException("Exception while getting open case.", ex); } @@ -341,7 +341,7 @@ final class FileExporter { * storage. */ private void exportFile(Long fileId, List ruleNames, Supplier cancelCheck) throws TskCoreException, IOException, NoCurrentCaseException { - AbstractFile file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(fileId); + AbstractFile file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(fileId); if (!shouldExportFile(file)) { return; } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExporterSettingsPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExporterSettingsPanel.java index 62b01b558f..cea7338f51 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExporterSettingsPanel.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/FileExporterSettingsPanel.java @@ -529,7 +529,7 @@ public final class FileExporterSettingsPanel extends JPanel { void populateArtifacts() { Set artifactTypes = scanRulesForArtifacts(); try { - SleuthkitCase currentCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase currentCase = Case.getCurrentCaseThrows().getSleuthkitCase(); for (BlackboardArtifact.Type type : currentCase.getArtifactTypes()) { artifactTypes.add(type.getTypeName()); } @@ -603,7 +603,7 @@ public final class FileExporterSettingsPanel extends JPanel { Set attributeTypes = scanRulesForAttributes(); try { - SleuthkitCase currentCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase currentCase = Case.getCurrentCaseThrows().getSleuthkitCase(); for (BlackboardAttribute.Type type : currentCase.getAttributeTypes()) { attributeTypes.add(type.getTypeName()); attributeTypeMap.put(type.getTypeName(), type.getValueType()); diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/AddMemoryImageTask.java b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/AddMemoryImageTask.java index e5f67909da..bcae2b3153 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/AddMemoryImageTask.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/AddMemoryImageTask.java @@ -145,7 +145,7 @@ final class AddMemoryImageTask implements Runnable { private Image addImageToCase() throws NoCurrentCaseException, TskCoreException { progressMonitor.setProgressText(Bundle.AddMemoryImageTask_progressMessage_addingImageFile( memoryImagePath)); - SleuthkitCase caseDatabase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase caseDatabase = Case.getCurrentCaseThrows().getSleuthkitCase(); caseDatabase.acquireSingleUserCaseWriteLock(); try { /* diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/MemoryDSInputPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/MemoryDSInputPanel.java index 134cdbc914..a26136fd1a 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/MemoryDSInputPanel.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/MemoryDSInputPanel.java @@ -421,7 +421,7 @@ final class MemoryDSInputPanel extends JPanel implements DocumentListener { }) private void warnIfPathIsInvalid(String path) { try { - if (!PathValidator.isValid(path, Case.getOpenCase().getCaseType())) { + if (!PathValidator.isValid(path, Case.getCurrentCaseThrows().getCaseType())) { errorLabel.setVisible(true); errorLabel.setText(Bundle.MemoryDSInputPanel_errorMsg_dataSourcePathOnCdrive()); } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/VolatilityProcessor.java b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/VolatilityProcessor.java index 9d3fcd15d5..bff999c810 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/VolatilityProcessor.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/volatilityDSP/VolatilityProcessor.java @@ -108,7 +108,7 @@ class VolatilityProcessor { this.errorMsgs.clear(); try { - this.currentCase = Case.getOpenCase(); + this.currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { throw new VolatilityProcessorException(Bundle.VolatilityProcessor_progressMessage_noCurrentCase(), ex); } diff --git a/ImageGallery/nbproject/project.xml b/ImageGallery/nbproject/project.xml index eb907611cf..0fdad950f2 100644 --- a/ImageGallery/nbproject/project.xml +++ b/ImageGallery/nbproject/project.xml @@ -127,7 +127,7 @@ 10 - 10.10 + 10.11 diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java index 5c9acf45bf..c8837fa13b 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryController.java @@ -194,7 +194,7 @@ public final class ImageGalleryController { stale.set(b); }); try { - new PerCaseProperties(Case.getOpenCase()).setConfigSetting(ImageGalleryModule.getModuleName(), PerCaseProperties.STALE, b.toString()); + new PerCaseProperties(Case.getCurrentCaseThrows()).setConfigSetting(ImageGalleryModule.getModuleName(), PerCaseProperties.STALE, b.toString()); } catch (NoCurrentCaseException ex) { Logger.getLogger(ImageGalleryController.class.getName()).log(Level.WARNING, "Exception while getting open case."); //NON-NLS } @@ -214,7 +214,7 @@ public final class ImageGalleryController { listeningEnabled.addListener((observable, oldValue, newValue) -> { try { //if we just turned on listening and a case is open and that case is not up to date - if (newValue && !oldValue && ImageGalleryModule.isDrawableDBStale(Case.getOpenCase())) { + if (newValue && !oldValue && ImageGalleryModule.isDrawableDBStale(Case.getCurrentCaseThrows())) { //populate the db queueDBTask(new CopyAnalyzedFiles(instance, db, sleuthKitCase)); } diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryOptionsPanel.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryOptionsPanel.java index b97a116ad8..beb2bc0a3d 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryOptionsPanel.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/ImageGalleryOptionsPanel.java @@ -189,7 +189,7 @@ final class ImageGalleryOptionsPanel extends javax.swing.JPanel { try { if (IngestManager.getInstance().isIngestRunning() == false) { enabledForCaseBox.setEnabled(true); - enabledForCaseBox.setSelected(ImageGalleryModule.isEnabledforCase(Case.getOpenCase())); + enabledForCaseBox.setSelected(ImageGalleryModule.isEnabledforCase(Case.getCurrentCaseThrows())); } else { enabledForCaseBox.setEnabled(false); enabledForCaseBox.setSelected(enabledByDefaultBox.isSelected()); @@ -204,7 +204,7 @@ final class ImageGalleryOptionsPanel extends javax.swing.JPanel { void store() { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { Logger.getLogger(ImageGalleryOptionsPanel.class.getName()).log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS return; diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java index 2145b76d3f..efe279bba3 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/DeleteTagAction.java @@ -123,7 +123,7 @@ public class DeleteTagAction extends Action { try { List existingTagsList - = Case.getOpenCase().getServices().getTagsManager() + = Case.getCurrentCaseThrows().getServices().getTagsManager() .getContentTagsByContent(file); Collection tagNamesList diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenAction.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenAction.java index f318b0d44c..e10a679792 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenAction.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/actions/OpenAction.java @@ -109,7 +109,7 @@ public final class OpenAction extends CallableSystemAction { public boolean isEnabled() { Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { return false; } @@ -154,7 +154,7 @@ public final class OpenAction extends CallableSystemAction { //check case final Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); return; @@ -188,7 +188,7 @@ public final class OpenAction extends CallableSystemAction { private boolean tooManyFiles() { try { - return FILE_LIMIT < Case.getOpenCase().getSleuthkitCase().countFilesWhere("1 = 1"); + return FILE_LIMIT < Case.getCurrentCaseThrows().getSleuthkitCase().countFilesWhere("1 = 1"); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Can not open image gallery with no case open.", ex); } catch (TskCoreException ex) { diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java index f62bfd1bc6..34c9d5a4c5 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/DrawableFile.java @@ -75,7 +75,7 @@ public abstract class DrawableFile { } public static DrawableFile create(Long id, boolean analyzed) throws TskCoreException, NoCurrentCaseException { - return create(Case.getOpenCase().getSleuthkitCase().getAbstractFileById(id), analyzed); + return create(Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(id), analyzed); } private SoftReference imageRef; diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/VideoFile.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/VideoFile.java index 81fc907069..5f6f72279e 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/VideoFile.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/datamodel/VideoFile.java @@ -91,7 +91,7 @@ public class VideoFile extends DrawableFile { if (media != null) { return media; } - final File cacheFile = VideoUtils.getTempVideoFile(this.getAbstractFile()); + final File cacheFile = VideoUtils.getVideoFileInTempDir(this.getAbstractFile()); if (cacheFile.exists() == false || cacheFile.length() < getAbstractFile().getSize()) { Files.createParentDirs(cacheFile); diff --git a/KeywordSearch/manifest.mf b/KeywordSearch/manifest.mf index 60d5379544..9f3126687e 100644 --- a/KeywordSearch/manifest.mf +++ b/KeywordSearch/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 AutoUpdate-Show-In-Client: true OpenIDE-Module: org.sleuthkit.autopsy.keywordsearch/6 -OpenIDE-Module-Implementation-Version: 18 +OpenIDE-Module-Implementation-Version: 19 OpenIDE-Module-Install: org/sleuthkit/autopsy/keywordsearch/Installer.class OpenIDE-Module-Layer: org/sleuthkit/autopsy/keywordsearch/layer.xml OpenIDE-Module-Localizing-Bundle: org/sleuthkit/autopsy/keywordsearch/Bundle.properties diff --git a/KeywordSearch/nbproject/project.properties b/KeywordSearch/nbproject/project.properties index 600396fb43..4af4a610bf 100644 --- a/KeywordSearch/nbproject/project.properties +++ b/KeywordSearch/nbproject/project.properties @@ -142,4 +142,4 @@ license.file=../LICENSE-2.0.txt nbm.homepage=http://www.sleuthkit.org/autopsy/ nbm.needs.restart=true source.reference.commons-validator-1.5.1.jar=release/modules/ext/commons-validator-1.5.1-sources.jar -spec.version.base=6.4 +spec.version.base=6.5 diff --git a/KeywordSearch/nbproject/project.xml b/KeywordSearch/nbproject/project.xml index a8b49012cf..25142d8119 100644 --- a/KeywordSearch/nbproject/project.xml +++ b/KeywordSearch/nbproject/project.xml @@ -119,7 +119,7 @@ 10 - 10.10 + 10.11 diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchChildFactory.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchChildFactory.java index 4424ead298..ced485d9c6 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchChildFactory.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/AdHocSearchChildFactory.java @@ -148,7 +148,7 @@ class AdHocSearchChildFactory extends ChildFactory { } SleuthkitCase tskCase; try { - tskCase = Case.getOpenCase().getSleuthkitCase(); + tskCase = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "There was no case open.", ex); //NON-NLS return false; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactTextExtractor.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactTextExtractor.java index 61b9bb3b20..a2724e72da 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactTextExtractor.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactTextExtractor.java @@ -58,9 +58,9 @@ class ArtifactTextExtractor implements TextExtractor { Case currentCase; try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ignore) { - // thorown by Case.getOpenCase() if currentCase is null + // thorown by Case.getCurrentOpenCase() if currentCase is null return null; } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java index 9d3acafaf4..da4c49def1 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java @@ -220,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.getOpenCase().getSleuthkitCase().getBlackboardArtifact(artifactId); + BlackboardArtifact associatedArtifact = Case.getCurrentCaseThrows().getSleuthkitCase().getBlackboardArtifact(artifactId); rawArtifactText = new RawText(associatedArtifact, associatedArtifact.getArtifactID()); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordHit.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordHit.java index c45b70c863..c147618558 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordHit.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordHit.java @@ -119,7 +119,7 @@ class KeywordHit implements Comparable { // If the hit was in an artifact, look up the source content for the artifact. SleuthkitCase caseDb; try { - caseDb = Case.getOpenCase().getSleuthkitCase(); + caseDb = Case.getCurrentCaseThrows().getSleuthkitCase(); } catch (NoCurrentCaseException ex) { throw new TskCoreException("Exception while getting open case.", ex); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java index f9c06d34ad..83b770bc58 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java @@ -184,7 +184,7 @@ public final class KeywordSearchIngestModule implements FileIngestModule { // if first instance of this module for this job then check the server and existence of keywords Case openCase; try { - openCase = Case.getOpenCase(); + openCase = Case.getCurrentCaseThrows(); } catch (NoCurrentCaseException ex) { throw new IngestModuleException(Bundle.KeywordSearchIngestModule_noOpenCase_errMsg(), ex); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/QueryResults.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/QueryResults.java index b4e07d0d8a..e27a01b063 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/QueryResults.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/QueryResults.java @@ -213,7 +213,7 @@ class QueryResults { */ Content content = null; try { - SleuthkitCase tskCase = Case.getOpenCase().getSleuthkitCase(); + SleuthkitCase tskCase = Case.getCurrentCaseThrows().getSleuthkitCase(); content = tskCase.getContentById(hit.getContentID()); } catch (TskCoreException | NoCurrentCaseException tskCoreException) { logger.log(Level.SEVERE, "Failed to get text source object for ", tskCoreException); //NON-NLS diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java index 62be15c2c8..cb640e20bd 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RegexQuery.java @@ -594,7 +594,7 @@ final class RegexQuery implements KeywordSearchQuery { * Create an account instance. */ try { - AccountFileInstance ccAccountInstance = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString() , MODULE_NAME, content); + AccountFileInstance ccAccountInstance = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString() , MODULE_NAME, content); ccAccountInstance.addAttributes(attributes); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index ec6542812d..fe7009128d 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2018 Basis Technology Corp. + * Copyright 2015-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,63 +68,70 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { private static final Logger logger = Logger.getLogger(SolrSearchService.class.getName()); /** - * Adds an artifact to the keyword search text index as a concantenation of - * all of its attributes. + * Indexes the given content for keyword search. * - * @param artifact The artifact to index. + * IMPORTANT: Currently, there are two correct uses for this code: + * + * 1) Indexing an artifact created during while either the file level ingest + * module pipeline or the first stage data source level ingest module + * pipeline of an ingest job is running. + * + * 2) Indexing a report. * - * @throws org.sleuthkit.datamodel.TskCoreException - */ - @Override - public void indexArtifact(BlackboardArtifact artifact) throws TskCoreException { - if (artifact == null) { - return; - } - - // We only support artifact indexing for Autopsy versions that use - // the negative range for artifact ids. - if (artifact.getArtifactID() > 0) { - return; - } - final Ingester ingester = Ingester.getDefault(); - - try { - ingester.indexMetaDataOnly(artifact); - ingester.indexText(new ArtifactTextExtractor(), artifact, null); - } catch (Ingester.IngesterException ex) { - throw new TskCoreException(ex.getCause().getMessage(), ex); - } - } - - /** - * Add the given Content object to the text index. * @param content The content to index. - * @throws TskCoreException + * + * @throws TskCoreException If there is a problem indexing the content. */ @Override public void index(Content content) throws TskCoreException { + /* + * TODO (JIRA-1099): The following code has some issues that need to be + * resolved. For artifacts, it is assumed that the posting of artifacts + * is only occuring during an ingest job with an enabled keyword search + * ingest module handling index commits; it also assumes that the + * artifacts are only posted by modules in the either the file level + * ingest pipeline or the first stage data source level ingest pipeline, + * so that the artifacts will be searched during a periodic or final + * keyword search. It also assumes that the only other type of Content + * for which this API will be called are Reports generated at a time + * when doing a commit is required and desirable, i.e., in a context + * other than an ingest job. + */ if (content == null) { return; } final Ingester ingester = Ingester.getDefault(); - - try { - ingester.indexText(new TikaTextExtractor(), content, null); - } catch (Ingester.IngesterException ex) { + if (content instanceof BlackboardArtifact) { + BlackboardArtifact artifact = (BlackboardArtifact) content; + if (artifact.getArtifactID() > 0) { + /* + * Artifact indexing is only supported for artifacts that use + * negative artifact ids to avoid overlapping with the object + * ids of other types of Content. + */ + return; + } try { - // Try the StringsTextExtractor if Tika extractions fails. - ingester.indexText(new StringsTextExtractor(), content, null); - } catch (Ingester.IngesterException ex1) { - throw new TskCoreException(ex.getCause().getMessage(), ex1); - } + ingester.indexMetaDataOnly(artifact); + ingester.indexText(new ArtifactTextExtractor(), artifact, null); + } catch (Ingester.IngesterException ex) { + throw new TskCoreException(ex.getCause().getMessage(), ex); + } + } else { + try { + ingester.indexText(new TikaTextExtractor(), content, null); + } catch (Ingester.IngesterException ex) { + try { + // Try the StringsTextExtractor if Tika extractions fails. + ingester.indexText(new StringsTextExtractor(), content, null); + } catch (Ingester.IngesterException ex1) { + throw new TskCoreException(ex.getCause().getMessage(), ex1); + } + } + ingester.commit(); } - - // TODO: Review whether this is the right thing to do. We typically use - // a combination of autoCommit and the SearchRunner to ensure that data - // is committed but that might not be sufficient for reports (or artifacts). - ingester.commit(); } - + /** * Tries to connect to the keyword search service. * @@ -205,7 +212,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { */ KeywordSearch.getServer().deleteCore(index.getIndexName(), metadata); if (!FileUtil.deleteDir(new File(index.getIndexPath()).getParentFile())) { - throw new KeywordSearchServiceException(Bundle.SolrSearchService_exceptionMessage_failedToDeleteIndexFiles(index.getIndexPath())); + throw new KeywordSearchServiceException(Bundle.SolrSearchService_exceptionMessage_failedToDeleteIndexFiles(index.getIndexPath())); } } return; //only one core exists for each combination of solr and schema version @@ -213,9 +220,9 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { //this code this code will only execute if an index for the current core was not found logger.log(Level.WARNING, NbBundle.getMessage(SolrSearchService.class, - "SolrSearchService.exceptionMessage.noCurrentSolrCore")); + "SolrSearchService.exceptionMessage.noCurrentSolrCore")); throw new KeywordSearchServiceException(NbBundle.getMessage(SolrSearchService.class, - "SolrSearchService.exceptionMessage.noCurrentSolrCore")); + "SolrSearchService.exceptionMessage.noCurrentSolrCore")); } @Override @@ -231,6 +238,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { * Creates/opens the Solr core/text index for a case * * @param context The case context. + * * @throws * org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException */ @@ -366,7 +374,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { } else { progress.switchToIndeterminate(Bundle.SolrSearch_openGiantCore_msg()); } - + KeywordSearch.getServer().openCoreForCase(theCase, currentVersionIndex); } catch (KeywordSearchModuleException ex) { throw new AutopsyServiceException(String.format("Failed to open or create core for %s", caseDirPath), ex); @@ -379,6 +387,7 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { * Closes the open core. * * @param context + * * @throws * org.sleuthkit.autopsy.appservices.AutopsyService.AutopsyServiceException */ @@ -403,4 +412,36 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService { throw new AutopsyServiceException(String.format("Failed to close core for %s", context.getCase().getCaseDirectory()), ex); } } + + /** + * Adds an artifact to the keyword search text index as a concantenation of + * all of its attributes. + * + * @param artifact The artifact to index. + * + * @throws org.sleuthkit.datamodel.TskCoreException + * @deprecated Call index(Content) instead. + */ + @Deprecated + @Override + public void indexArtifact(BlackboardArtifact artifact) throws TskCoreException { + if (artifact == null) { + return; + } + + // We only support artifact indexing for Autopsy versions that use + // the negative range for artifact ids. + if (artifact.getArtifactID() > 0) { + return; + } + final Ingester ingester = Ingester.getDefault(); + + try { + ingester.indexMetaDataOnly(artifact); + ingester.indexText(new ArtifactTextExtractor(), artifact, null); + } catch (Ingester.IngesterException ex) { + throw new TskCoreException(ex.getCause().getMessage(), ex); + } + } + } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermsComponentQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermsComponentQuery.java index b2d1ef37e1..7b3893df98 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermsComponentQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermsComponentQuery.java @@ -495,7 +495,7 @@ final class TermsComponentQuery implements KeywordSearchQuery { * Create an account. */ try { - AccountFileInstance ccAccountInstance = Case.getOpenCase().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString(), MODULE_NAME, content); + AccountFileInstance ccAccountInstance = Case.getCurrentCaseThrows().getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(Account.Type.CREDIT_CARD, ccnAttribute.getValueString(), MODULE_NAME, content); ccAccountInstance.addAttributes(attributes); } catch (TskCoreException | NoCurrentCaseException ex) { LOGGER.log(Level.SEVERE, "Error creating CCN account instance", ex); //NON-NLS diff --git a/NEWS.txt b/NEWS.txt index 54e0acb883..de1a1e576e 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,3 +1,23 @@ +---------------- VERSION 4.7.0 -------------- +New Features: +- A graph visualization was added to the Communications tool to make it easier to find messages and relationships. +- A new Application content viewer provides custom views of media files, SQLite files, and Plists. +- A data source processor that runs Volatility was added to support ingesting memory images. +- Reports (e.g., RegRipper output) generated by ingest modules are now indexed for keyword search. +- Passwords to open password protected archive files can be entered. +- PhotoRec carving module can be configured to keep corrupted files. +- Filters to reduce files processed by ingest modules can have data range conditions. +- L01 files can be imported as data sources. +- Block size can be supplied for local drives and for images for which SleuthKit auto detect fails. +- Assorted small enhancements are included. + +Bug Fixes: +- Memory leaks and other issues revealed by fuzzing the SleuthKit have +been fixed. +- Result views (upper right) and content views (lower right) stay in synch when switching result views. +- Concurrency bugs in the ingest tasks scheduler have been fixed. +- Assorted small bug fixes are included. + ---------------- VERSION 4.6.0 -------------- New Features: - A new Message content viewer was added to make it easier to view email message contents. diff --git a/RecentActivity/nbproject/project.xml b/RecentActivity/nbproject/project.xml index 4b173c70c1..fd72fa7dfe 100644 --- a/RecentActivity/nbproject/project.xml +++ b/RecentActivity/nbproject/project.xml @@ -60,7 +60,7 @@ 10 - 10.10 + 10.11 diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Extract.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Extract.java index 8ae8dc0261..8ec5b79d56 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Extract.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Extract.java @@ -53,7 +53,7 @@ abstract class Extract { final void init() throws IngestModuleException { try { - currentCase = Case.getOpenCase(); + currentCase = Case.getCurrentCaseThrows(); tskCase = currentCase.getSleuthkitCase(); } catch (NoCurrentCaseException ex) { throw new IngestModuleException(Bundle.Extract_indexError_message(), ex); @@ -126,7 +126,7 @@ abstract class Extract { "Extract.noOpenCase.errMsg=No open case available."}) void indexArtifact(BlackboardArtifact bbart) { try { - Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard(); + Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); // index the artifact for keyword search blackboard.indexArtifact(bbart); } catch (Blackboard.BlackboardException ex) { diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java index 3e8bb2d611..1af8761144 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java @@ -75,7 +75,7 @@ class ExtractIE extends Extract { ExtractIE() throws NoCurrentCaseException { moduleName = NbBundle.getMessage(ExtractIE.class, "ExtractIE.moduleName.text"); - moduleTempResultsDir = RAImageIngestModule.getRATempPath(Case.getOpenCase(), "IE") + File.separator + "results"; //NON-NLS + moduleTempResultsDir = RAImageIngestModule.getRATempPath(Case.getCurrentCaseThrows(), "IE") + File.separator + "results"; //NON-NLS JAVA_PATH = PlatformUtil.getJavaPath(); } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Util.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Util.java index 9048c57da0..a47d33f22a 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Util.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Util.java @@ -193,7 +193,7 @@ class Util { parent_path = parent_path.substring(0, index); List files = null; try { - FileManager fileManager = Case.getOpenCase().getServices().getFileManager(); + FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); files = fileManager.findFiles(dataSource, name, parent_path); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.WARNING, "Error fetching 'index.data' files for Internet Explorer history."); //NON-NLS diff --git a/Running_Linux_OSX.txt b/Running_Linux_OSX.txt new file mode 100644 index 0000000000..386c4c5899 --- /dev/null +++ b/Running_Linux_OSX.txt @@ -0,0 +1,45 @@ +This document outlines how to run a packaged version of Autopsy on Linux or OS X. It does not cover how to compile it from source or the Windows installer. + + +* Prerequisites * + +The following need to be done at least once. They do not need to be repeated for each Autopsy release. + +- Install testdisk for photorec functionality +-- Linux: % sudo apt-get install testdisk +-- OS X: % brew install testdisk + +- Install Oracle Java and set JAVA_HOME. +-- Linux: Use the instructions here: https://medium.com/coderscorner/installing-oracle-java-8-in-ubuntu-16-10-845507b13343 +-- OS X: Use The Oracle website: https://www.java.com/ + Set JAVA_HOME with something like: export JAVA_HOME=`/usr/libexec/java_home` in .bash_profile + + +* Install The Sleuth Kit Java Bindings * + +Autopsy depends on a specific version of The Sleuth Kit. You need the Java libraries of The Sleuth Kit installed, which is not part of all packages. + +- Linux: Install the sleuthkit-java.deb file that you can download from github.com/sleuthkit/sleuthkit/releases. This will install libewf, etc. +-- % sudo apt install ./sleuthkit-java_4.6.0-1_amd64.deb + +- OS X: Install The Sleuth Kit from brew. +-- % brew install sleuthkit + + +* Install Autopsy * + +- Extract the contents of the Autopsy ZIP file to a folder. +- Open a terminal and cd into the Autopsy folder. +- Run the unix_setup.sh script to configure Autopsy + % sh unix_setup.sh + + +* Running Autopsy * + +- In a terminal, change to the ‘bin’ directory in the Autopsy folder. +- Run Autopsy + % ./autopsy + +* Limitations (Updated May 2018) * +- Timeline does not work on OS X +- Video thumbnails are not generated (need to get a consistent version of OpenCV) diff --git a/build.xml b/build.xml index 0995b07e10..a1ff9d665a 100644 --- a/build.xml +++ b/build.xml @@ -91,6 +91,7 @@ + @@ -144,9 +145,9 @@ - + - + @@ -285,9 +286,20 @@ - + + + + + + - + + + + + + + diff --git a/docs/doxygen-user/Doxyfile b/docs/doxygen-user/Doxyfile index f2f31448a0..84605ac34f 100755 --- a/docs/doxygen-user/Doxyfile +++ b/docs/doxygen-user/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Autopsy User Documentation" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.6.0 +PROJECT_NUMBER = 4.7.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1025,7 +1025,7 @@ GENERATE_HTML = YES # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_OUTPUT = 4.6.0 +HTML_OUTPUT = 4.7.0 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). diff --git a/docs/doxygen-user/case_management.dox b/docs/doxygen-user/case_management.dox index 48e2fbc2fa..b4d9d0daba 100644 --- a/docs/doxygen-user/case_management.dox +++ b/docs/doxygen-user/case_management.dox @@ -34,7 +34,7 @@ To open a case, either: "Open Recent Case" will always bring up a screen allowing you to select one of the recently opened cases. "Open Case" will do one of two things; - If multi-user cases are not enabled, it will bring up a file chooser that can be used to browse to the ".aut" file in the case directory of the desired case -- If multi-user cases are enabled, it will bring up the multi-user case selection screen. This uses the coordination services to find a list of multi-user cases. If needed, the "Open Single-User Case" button can be used to bring up the normal file chooser. The multi-user case selection screen has a \ref quick_search feature which can be used to quickly find a case in the table. The following shows the multi-user case selection screen: +- If multi-user cases are enabled, it will bring up the multi-user case selection screen. This uses the coordination services to find a list of multi-user cases. If needed, the "Open Single-User Case" button can be used to bring up the normal file chooser. The multi-user case selection screen has a \ref ui_quick_search feature which can be used to quickly find a case in the table. The following shows the multi-user case selection screen: \image html multi_user_case_select.png diff --git a/docs/doxygen-user/communications.dox b/docs/doxygen-user/communications.dox index 2080f910e5..ced0a044d3 100644 --- a/docs/doxygen-user/communications.dox +++ b/docs/doxygen-user/communications.dox @@ -20,7 +20,7 @@ The middle column displays each account, its device and type, and the number of Selecting an account in the middle column will bring up the messages for that account in the right hand column. Here data about each message is displayed in the top section, and the messages itself can be seen in the bottom section (if applicable). -The middle column and the right hand column both have a \ref quick_search feature which can be used to quickly find a visible item in their section's table. +The middle column and the right hand column both have a \ref ui_quick_search feature which can be used to quickly find a visible item in their section's table. \image html cvt_messages.png diff --git a/docs/doxygen-user/main.dox b/docs/doxygen-user/main.dox index f03ad68041..8aabf7a03b 100644 --- a/docs/doxygen-user/main.dox +++ b/docs/doxygen-user/main.dox @@ -39,7 +39,7 @@ The following topics are available here: - \subpage tree_viewer_page - \subpage result_viewer_page - \subpage content_viewer_page - - \subpage quick_search + - \subpage ui_quick_search - \subpage image_gallery_page - \subpage file_search_page - \subpage ad_hoc_keyword_search_page diff --git a/docs/doxygen-user/quick_start_guide.dox b/docs/doxygen-user/quick_start_guide.dox index e1bece678b..b12c65c2a3 100644 --- a/docs/doxygen-user/quick_start_guide.dox +++ b/docs/doxygen-user/quick_start_guide.dox @@ -59,7 +59,7 @@ If you are viewing files from the Views and Results nodes, you can right-click o If you want to search for single keywords, then you can use the search box in the upper right of the program. The results will be shown in a table in the upper right. -The tree on the left as well as the table on the right have a \ref quick_search feature which can be used to quickly find a visible node. +The tree on the left as well as the table on the right have a \ref ui_quick_search feature which can be used to quickly find a visible node. You can tag (bookmark) arbitrary files so that you can more quickly find them later or so that you can include them specifically in a report. diff --git a/docs/doxygen-user/timeline.dox b/docs/doxygen-user/timeline.dox index f992c57d26..d55f9a43bf 100644 --- a/docs/doxygen-user/timeline.dox +++ b/docs/doxygen-user/timeline.dox @@ -69,7 +69,7 @@ The __Counts View__ shows a stacked bar chart. Use this type of graph to show ho The __Details View__ shows individual or groups of related events. Date/time is represented horizontally along the x-axis, but the vertical axis does not represent any specific units. You would use this interface to answer questions about what specific events happened in a given time frame or what events occurred before or after a given event. You would generally use this type of interface after using the Counts View to identify a period of time that you wanted details on. There can be a lot of details in this view and we have introduced zooming concepts, as described in the next section, to help with this. -The table on the bottom left hand side of the panel has a \ref quick_search feature which can be used to quickly find a node in the table. +The table on the bottom left hand side of the panel has a \ref ui_quick_search feature which can be used to quickly find a node in the table. Visualization settings ---------------------- diff --git a/docs/doxygen-user/quick_search.dox b/docs/doxygen-user/ui_quick_search.dox similarity index 54% rename from docs/doxygen-user/quick_search.dox rename to docs/doxygen-user/ui_quick_search.dox index e1bb65248a..901427243e 100644 --- a/docs/doxygen-user/quick_search.dox +++ b/docs/doxygen-user/ui_quick_search.dox @@ -1,10 +1,10 @@ -/*! \page quick_search Quick Search +/*! \page ui_quick_search UI Quick Search -The quick search feature allows you to search within the data on a panel for a given string, it will not search data in hidden columns or collapsed nodes. +The user interface quick search feature allows you to search within the data on a panel for a given string, it will not search data in hidden columns or collapsed nodes. How to use it ----- -In order to use the search you need to select any item in the area you wish to search, and start typing. If quick search is available in the area you have selected a search field will appear in the bottom left hand corner of the area. As you type the string you are searching for it will auto-update to select one of the results which matches your string. You can switch between the results which match the string you have typed with the up and down keys. The search does not support the use of regular expressions but will match against any sub-sting in the fields it searches, not just at the beginning of the field. +In order to use the search you need to select any item in the area you wish to search, and start typing. If user interface quick search is available in the area you have selected a search field will appear in the bottom left hand corner of the area. As you type the string you are searching for it will auto-update to select one of the results which matches your string. You can switch between the results which match the string you have typed with the up and down keys. The search does not support the use of regular expressions but will match against any sub-sting in the fields it searches, not just at the beginning of the field. \image html quick_search_result.PNG Configuration diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 3f4797ace0..5dbdbf1479 100755 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "Autopsy" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.6.0 +PROJECT_NUMBER = 4.7.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -1063,7 +1063,7 @@ GENERATE_HTML = YES # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_OUTPUT = api-docs/4.6.0/ +HTML_OUTPUT = api-docs/4.7.0/ # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). diff --git a/nbproject/project.properties b/nbproject/project.properties index 781ec2c83b..3cbde84d3e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -4,7 +4,7 @@ app.title=Autopsy ### lowercase version of above app.name=${branding.token} ### if left unset, version will default to today's date -app.version=4.6.0 +app.version=4.7.0 ### build.type must be one of: DEVELOPMENT, RELEASE #build.type=RELEASE build.type=DEVELOPMENT diff --git a/pythonExamples/README.txt b/pythonExamples/README.txt index 3564182ec9..cbf1d60095 100644 --- a/pythonExamples/README.txt +++ b/pythonExamples/README.txt @@ -5,7 +5,7 @@ your needs. See the developer guide for more details and how to use and load the modules. - http://sleuthkit.org/autopsy/docs/api-docs/4.6.0/index.html + http://sleuthkit.org/autopsy/docs/api-docs/4.7.0/index.html Each module in this folder should have a brief description about what they can do. diff --git a/thunderbirdparser/nbproject/project.xml b/thunderbirdparser/nbproject/project.xml index 2e738ef588..110c3b8ede 100644 --- a/thunderbirdparser/nbproject/project.xml +++ b/thunderbirdparser/nbproject/project.xml @@ -36,7 +36,7 @@ 10 - 10.10 + 10.11 @@ -45,7 +45,7 @@ 6 - 6.3 + 6.5 diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index c6587da68d..bfa1542ce1 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -79,7 +79,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { public void startUp(IngestJobContext context) throws IngestModuleException { this.context = context; try { - fileManager = Case.getOpenCase().getServices().getFileManager(); + fileManager = Case.getCurrentCaseThrows().getServices().getFileManager(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); throw new IngestModuleException(Bundle.ThunderbirdMboxFileIngestModule_noOpenCase_errMsg(), ex); @@ -90,7 +90,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { public ProcessResult process(AbstractFile abstractFile) { try { - blackboard = Case.getOpenCase().getServices().getBlackboard(); + blackboard = Case.getCurrentCaseThrows().getServices().getBlackboard(); } catch (NoCurrentCaseException ex) { logger.log(Level.SEVERE, "Exception while getting open case.", ex); return ProcessResult.ERROR; @@ -307,7 +307,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { * @return the temporary folder */ static String getTempPath() throws NoCurrentCaseException { - String tmpDir = Case.getOpenCase().getTempDirectory() + File.separator + String tmpDir = Case.getCurrentCaseThrows().getTempDirectory() + File.separator + "EmailParser"; //NON-NLS File dir = new File(tmpDir); if (dir.exists() == false) { @@ -323,7 +323,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { * @return the module output folder */ static String getModuleOutputPath() throws NoCurrentCaseException { - String outDir = Case.getOpenCase().getModuleDirectory() + File.separator + String outDir = Case.getCurrentCaseThrows().getModuleDirectory() + File.separator + EmailParserModuleFactory.getModuleName(); File dir = new File(outDir); if (dir.exists() == false) { @@ -339,7 +339,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { * @return the relative path of the module output folder */ static String getRelModuleOutputPath() throws NoCurrentCaseException { - return Case.getOpenCase().getModuleOutputDirectoryRelativePath() + File.separator + return Case.getCurrentCaseThrows().getModuleOutputDirectoryRelativePath() + File.separator + EmailParserModuleFactory.getModuleName(); } @@ -460,7 +460,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule { AccountFileInstance senderAccountInstance = null; - Case openCase = Case.getOpenCase(); + Case openCase = Case.getCurrentCaseThrows(); if (senderAddressList.size() == 1) { senderAddress = senderAddressList.get(0); diff --git a/unix_setup.sh b/unix_setup.sh index a1e2f6215b..970c35a5c2 100755 --- a/unix_setup.sh +++ b/unix_setup.sh @@ -2,7 +2,7 @@ # Verifies programs are installed and copies native code into the Autopsy folder structure -TSK_VERSION=4.6.0 +TSK_VERSION=4.6.1 # Verify PhotoRec was installed photorec_filepath=/usr/bin/photorec @@ -44,7 +44,7 @@ ext_jar_filepath=$PWD/autopsy/modules/ext/sleuthkit-postgresql-$TSK_VERSION.jar; if [ -f "$sleuthkit_jar_filepath" ]; then echo "$sleuthkit_jar_filepath found" echo "Copying into the Autopsy directory" - rm $ext_jar_filepath; + rm -f $ext_jar_filepath; if [ "$?" -gt 0 ]; then #checking if remove operation failed echo "exiting .." exit 1