From 1b52050e3b0279f953c99af0cd350b638a50e2f2 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 6 May 2016 16:40:00 -0400 Subject: [PATCH] Remove newlines from ingest module startup localization bundles --- .../autopsy/ingest/IngestManager.java | 52 ++++++------------- .../autopsy/ingest/IngestModuleError.java | 42 ++++++++++++--- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 017840ae9b..840c4cd732 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -65,12 +65,6 @@ import org.sleuthkit.datamodel.Content; * Manages the creation and execution of ingest jobs, i.e., the processing of * data sources by ingest modules. */ -@NbBundle.Messages({ - "# {0} - error message", "IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList=\nErrors: \n{0}", - "IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution=Please disable the failed modules or fix the errors and then restart ingest \nby right clicking on the data source and selecting Run Ingest Modules.", - "IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg=Unable to start up one or more ingest modules, ingest job cancelled.", - "IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle=Ingest Failure" -}) public class IngestManager { private static final Logger logger = Logger.getLogger(IngestManager.class.getName()); @@ -532,6 +526,12 @@ public class IngestManager { * @return The IngestJobStartResult describing the results of attempting to * start the ingest job. */ + @NbBundle.Messages({ + "IngestManager.startupErr.dlgTitle=Ingest Module Startup Failure", + "IngestManager.startupErr.dlgMsg=Unable to start up one or more ingest modules, ingest cancelled.", + "IngestManager.startupErr.dlgSolution=Please disable the failed modules or fix the errors before restarting ingest.", + "IngestManager.startupErr.dlgErrorList=Errors:" + }) private IngestJobStartResult startIngestJob(IngestJob job) { List errors = null; if (this.jobCreationIsEnabled) { @@ -576,47 +576,29 @@ public class IngestManager { this.jobsById.remove(job.getId()); } for (IngestModuleError error : errors) { - logger.log(Level.SEVERE, String.format("Error starting %s ingest module for job %d", error.getModuleDisplayName(), job.getId()), error.getModuleError()); //NON-NLS + logger.log(Level.SEVERE, String.format("Error starting %s ingest module for job %d", error.getModuleDisplayName(), job.getId()), error.getThrowable()); //NON-NLS } IngestManager.logger.log(Level.SEVERE, "Ingest job {0} could not be started", job.getId()); //NON-NLS if (RuntimeProperties.coreComponentsAreActive()) { - - StringBuilder moduleStartUpErrors = new StringBuilder(); + final StringBuilder message = new StringBuilder(); + message.append(Bundle.IngestManager_startupErr_dlgMsg()).append("\n"); + message.append(Bundle.IngestManager_startupErr_dlgSolution()).append("\n\n"); + message.append(Bundle.IngestManager_startupErr_dlgErrorList()).append("\n"); for (IngestModuleError error : errors) { String moduleName = error.getModuleDisplayName(); - moduleStartUpErrors.append(moduleName); - moduleStartUpErrors.append(": "); - moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage()); - moduleStartUpErrors.append("\n"); + String errorMessage = error.getThrowable().getLocalizedMessage(); + message.append(moduleName).append(": ").append(errorMessage).append("\n"); } - EventQueue.invokeLater(new NotifyUserOfErrors(moduleStartUpErrors.toString())); + message.append("\n\n"); + EventQueue.invokeLater(() -> { + JOptionPane.showMessageDialog(null, message, Bundle.IngestManager_startupErr_dlgTitle(), JOptionPane.ERROR_MESSAGE); + }); } } } return new IngestJobStartResult(job, null, errors); } - class NotifyUserOfErrors implements Runnable { - - private String startupErrors; - - NotifyUserOfErrors(String startupErrors) { - this.startupErrors = startupErrors; - } - - @Override - public void run() { - StringBuilder notifyMessage = new StringBuilder(); - notifyMessage.append(Bundle.IngestManager_StartIngestJobsTask_run_startupErr_dlgMsg()); - notifyMessage.append("\n"); - notifyMessage.append(Bundle.IngestManager_StartIngestJobsTask_run_startupErr_dlgSolution()); - notifyMessage.append("\n"); - notifyMessage.append(Bundle.IngestManager_StartIngestJobsTask_run_startupErr_dlgErrorList(startupErrors)); - notifyMessage.append("\n\n"); - JOptionPane.showMessageDialog(null, notifyMessage.toString(), Bundle.IngestManager_StartIngestJobsTask_run_startupErr_dlgTitle(), JOptionPane.ERROR_MESSAGE); - } - } - synchronized void finishIngestJob(IngestJob job) { long jobId = job.getId(); synchronized (jobsById) { diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleError.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleError.java index 22ea0f9c08..1ce3770360 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleError.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleError.java @@ -19,24 +19,54 @@ package org.sleuthkit.autopsy.ingest; /** - * Encapsulates an exception thrown by an ingest module during an operation such - * as startup or shut down with an exception object for the error that occurred. + * Encapsulates a Throwable thrown by an ingest module with the display name of + * the module for logging purposes. */ public final class IngestModuleError { private final String moduleDisplayName; - private final Throwable error; + private final Throwable throwable; - IngestModuleError(String moduleDisplayName, Throwable error) { + /** + * Constructs an object that encapsulates a Throwable thrown by an ingest + * module with the display name of the module for logging purposes. + * + * @param moduleDisplayName The display name of the module. + * @param throwable The throwable. + */ + IngestModuleError(String moduleDisplayName, Throwable throwable) { this.moduleDisplayName = moduleDisplayName; - this.error = error; + this.throwable = throwable; } + /** + * Gets the module display name. + * + * @return The module display name. + */ public String getModuleDisplayName() { return this.moduleDisplayName; } + /** + * Gets the throwable. + * + * @return The Throwable + */ + public Throwable getThrowable() { + return this.throwable; + } + + /** + * Gets the throwable. + * + * @return The Throwable + * + * @deprecated Use getThrowable instead. + * + */ + @Deprecated public Throwable getModuleError() { - return this.error; + return this.throwable; } }