Remove newlines from ingest module startup localization bundles

This commit is contained in:
Richard Cordovano 2016-05-06 16:40:00 -04:00
parent c7de7284d5
commit 1b52050e3b
2 changed files with 53 additions and 41 deletions

View File

@ -65,12 +65,6 @@ import org.sleuthkit.datamodel.Content;
* Manages the creation and execution of ingest jobs, i.e., the processing of * Manages the creation and execution of ingest jobs, i.e., the processing of
* data sources by ingest modules. * 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 { public class IngestManager {
private static final Logger logger = Logger.getLogger(IngestManager.class.getName()); 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 * @return The IngestJobStartResult describing the results of attempting to
* start the ingest job. * 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) { private IngestJobStartResult startIngestJob(IngestJob job) {
List<IngestModuleError> errors = null; List<IngestModuleError> errors = null;
if (this.jobCreationIsEnabled) { if (this.jobCreationIsEnabled) {
@ -576,47 +576,29 @@ public class IngestManager {
this.jobsById.remove(job.getId()); this.jobsById.remove(job.getId());
} }
for (IngestModuleError error : errors) { 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 IngestManager.logger.log(Level.SEVERE, "Ingest job {0} could not be started", job.getId()); //NON-NLS
if (RuntimeProperties.coreComponentsAreActive()) { if (RuntimeProperties.coreComponentsAreActive()) {
final StringBuilder message = new StringBuilder();
StringBuilder moduleStartUpErrors = 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) { for (IngestModuleError error : errors) {
String moduleName = error.getModuleDisplayName(); String moduleName = error.getModuleDisplayName();
moduleStartUpErrors.append(moduleName); String errorMessage = error.getThrowable().getLocalizedMessage();
moduleStartUpErrors.append(": "); message.append(moduleName).append(": ").append(errorMessage).append("\n");
moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage());
moduleStartUpErrors.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); 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) { synchronized void finishIngestJob(IngestJob job) {
long jobId = job.getId(); long jobId = job.getId();
synchronized (jobsById) { synchronized (jobsById) {

View File

@ -19,24 +19,54 @@
package org.sleuthkit.autopsy.ingest; package org.sleuthkit.autopsy.ingest;
/** /**
* Encapsulates an exception thrown by an ingest module during an operation such * Encapsulates a Throwable thrown by an ingest module with the display name of
* as startup or shut down with an exception object for the error that occurred. * the module for logging purposes.
*/ */
public final class IngestModuleError { public final class IngestModuleError {
private final String moduleDisplayName; 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.moduleDisplayName = moduleDisplayName;
this.error = error; this.throwable = throwable;
} }
/**
* Gets the module display name.
*
* @return The module display name.
*/
public String getModuleDisplayName() { public String getModuleDisplayName() {
return this.moduleDisplayName; 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() { public Throwable getModuleError() {
return this.error; return this.throwable;
} }
} }