From bfd7701d11ba720a689604d850ab3f898f72d0da Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Mon, 12 Apr 2021 18:58:21 -0400 Subject: [PATCH] 7471 adjust messages and add pop up on start up if unable to open case --- .../autopsy/apputils/Bundle.properties-MERGED | 2 +- .../autopsy/apputils/ResetWindowsAction.java | 4 ++-- .../casemodule/Bundle.properties-MERGED | 6 +++++ .../casemodule/StartupWindowProvider.java | 22 ++++++++++++++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/apputils/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/apputils/Bundle.properties-MERGED index dd9fc3b03e..de7c28c948 100644 --- a/Core/src/org/sleuthkit/autopsy/apputils/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/apputils/Bundle.properties-MERGED @@ -1,4 +1,4 @@ CTL_ResetWindowsAction=Reset Windows ResetWindowAction.caseCloseFailure.text=Unable to close the current case, the software will restart and the windows locations will reset the next time the software is closed. ResetWindowAction.caseSaveMetadata.text=Unable to save current case path, the software will restart and the windows locations will reset but the current case will not be opened upon restart. -ResetWindowAction.confirm.text=In order to perform the resetting of window locations the software will close and restart. If a case is currently open it will be closed. If ingest or a search is currently running it will be terminated. Are you sure you want to restart the software to reset all window locations? +ResetWindowAction.confirm.text=In order to perform the resetting of window locations the software will close and restart. If a case is currently open, it will be closed. If ingest or a search is currently running, it will be terminated. Are you sure you want to restart the software to reset all window locations? diff --git a/Core/src/org/sleuthkit/autopsy/apputils/ResetWindowsAction.java b/Core/src/org/sleuthkit/autopsy/apputils/ResetWindowsAction.java index faab218a59..c5298bc64e 100644 --- a/Core/src/org/sleuthkit/autopsy/apputils/ResetWindowsAction.java +++ b/Core/src/org/sleuthkit/autopsy/apputils/ResetWindowsAction.java @@ -61,7 +61,7 @@ public final class ResetWindowsAction extends CallableSystemAction { } @NbBundle.Messages({"ResetWindowAction.confirm.text=In order to perform the resetting of window locations the software will close and restart. " - + "If a case is currently open it will be closed. If ingest or a search is currently running it will be terminated. " + + "If a case is currently open, it will be closed. If ingest or a search is currently running, it will be terminated. " + "Are you sure you want to restart the software to reset all window locations?", "ResetWindowAction.caseCloseFailure.text=Unable to close the current case, " + "the software will restart and the windows locations will reset the next time the software is closed.", @@ -90,7 +90,7 @@ public final class ResetWindowsAction extends CallableSystemAction { if (Case.isCaseOpen()) { String caseMetadataFilePath = Case.getCurrentCase().getMetadata().getFilePath().toString(); File caseToOpenFile = new File(ResetWindowsAction.getCaseToReopenFilePath()); - Charset encoding = null; + Charset encoding = null; //prevents writeStringToFile from having ambiguous arguments FileUtils.writeStringToFile(caseToOpenFile, caseMetadataFilePath, encoding); Case.closeCurrentCase(); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED index f731913af5..1a5bb3d251 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties-MERGED @@ -346,6 +346,12 @@ RecentCases.getName.text=Clear Recent Cases RecentItems.openRecentCase.msgDlg.text=Case {0} no longer exists. SelectDataSourceProcessorPanel.name.text=Select Data Source Type StartupWindow.title.text=Welcome +# {0} - autFilePath +StartupWindowProvider.openCase.cantOpen=Unable to open previously open case with metadata file: {0} +# {0} - reOpenFilePath +StartupWindowProvider.openCase.deleteOpenFailure=Unable to open or delete file containing path {0} to previously open case. The previous case will not be opened. +# {0} - autFilePath +StartupWindowProvider.openCase.noFile=Unable to open previously open case because metadata file not found at: {0} UnpackagePortableCaseDialog.title.text=Unpackage Portable Case UnpackagePortableCaseDialog.UnpackagePortableCaseDialog.extensions=Portable case package (.zip, .zip.001) UnpackagePortableCaseDialog.validatePaths.badExtension=File extension must be .zip or .zip.001 diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java index bb624254ff..4d8c5ac538 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/StartupWindowProvider.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.logging.Level; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.apputils.ResetWindowsAction; @@ -65,6 +66,13 @@ public class StartupWindowProvider implements StartupWindowInterface { return instance; } + @NbBundle.Messages({ + "# {0} - autFilePath", + "StartupWindowProvider.openCase.noFile=Unable to open previously open case because metadata file not found at: {0}", + "# {0} - reOpenFilePath", + "StartupWindowProvider.openCase.deleteOpenFailure=Unable to open or delete file containing path {0} to previously open case. The previous case will not be opened.", + "# {0} - autFilePath", + "StartupWindowProvider.openCase.cantOpen=Unable to open previously open case with metadata file: {0}"}) private void init() { if (startupWindowToUse == null) { // first check whether we are running from command line @@ -90,7 +98,9 @@ public class StartupWindowProvider implements StartupWindowInterface { File openPreviousCaseFile = new File(ResetWindowsAction.getCaseToReopenFilePath()); String caseFilePath = ""; + if (openPreviousCaseFile.exists()) { + String unableToOpenMessage = null; try { Charset encoding = null; caseFilePath = FileUtils.readFileToString(openPreviousCaseFile, encoding); @@ -100,12 +110,18 @@ public class StartupWindowProvider implements StartupWindowInterface { //the case is now open we do not want to display the start up windows return; } else { - logger.log(Level.WARNING, "Unable to open previously open case because metadata file not found at: {0}", caseFilePath); + unableToOpenMessage = Bundle.StartupWindowProvider_openCase_noFile(caseFilePath); + logger.log(Level.WARNING, unableToOpenMessage); } } catch (IOException ex) { - logger.log(Level.WARNING, "Unable to open or delete file containing path " + ResetWindowsAction.getCaseToReopenFilePath() + " to previously open case, will not open previous case.", ex); + unableToOpenMessage = Bundle.StartupWindowProvider_openCase_deleteOpenFailure(ResetWindowsAction.getCaseToReopenFilePath()); + logger.log(Level.WARNING, unableToOpenMessage, ex); } catch (CaseActionException ex) { - logger.log(Level.WARNING, "Unable to open previously open case with metadata file: " + caseFilePath, ex); + unableToOpenMessage = Bundle.StartupWindowProvider_openCase_cantOpen(caseFilePath); + logger.log(Level.WARNING, unableToOpenMessage, ex); + } + if (RuntimeProperties.runningWithGUI() && !StringUtils.isBlank(unableToOpenMessage)) { + MessageNotifyUtil.Message.warn(unableToOpenMessage); } } //discover the registered windows