diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index e2f553ca3c..a336dd9bd9 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -47,8 +47,8 @@ import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; /** - * Manages the creation and execution of ingest jobs, i.e., processing of data - * sources by ingest modules. + * Manages the creation and execution of ingest jobs, i.e., the processing of + * data sources by ingest modules. */ public class IngestManager { @@ -130,9 +130,10 @@ public class IngestManager { }; /** - * Gets the ingest manager. + * Gets the manager of the creation and execution of ingest jobs, i.e., the + * processing of data sources by ingest modules. * - * @return A singleton IngestManager object. + * @return A singleton ingest manager object. */ public synchronized static IngestManager getInstance() { if (instance == null) { @@ -157,8 +158,8 @@ public class IngestManager { } /** - * Starts an ingest job, i.e., processing by ingest modules, for a - * collection of data sources. + * Starts an ingest job, i.e., processing by ingest modules, for each data + * source in a collection of data sources. * * @param dataSources The data sources to be processed. * @param settings The ingest job settings. @@ -179,7 +180,7 @@ public class IngestManager { } /** - * Queries whether any ingest jobs are in progress. + * Queries whether or not any ingest jobs are in progress. * * @return True or false. */ @@ -250,7 +251,7 @@ public class IngestManager { } /** - * Remove an ingest job and ingest module event property change listener. + * Removes an ingest job and ingest module event property change listener. * * @param listener The PropertyChangeListener to unregister. * @deprecated Use removeIngestJobEventListener() and/or @@ -263,10 +264,11 @@ public class IngestManager { } /** - * Starts the ingest monitor and submits task execution tasks (Callable - * objects) to the data source ingest and file ingest thread pools. The task - * execution tasks are simple consumers that will normally run as long as - * the application runs + * Constructs a manager of the creation and execution of ingest jobs, i.e., + * the processing of data sources by ingest modules. The manager immediately + * submits ingest task executers (Callable objects) to the data source level + * ingest and file level ingest thread pools. The ingest task executers are + * simple consumers that will normally run as long as the application runs. */ private IngestManager() { startDataSourceIngestThread(); @@ -292,7 +294,7 @@ public class IngestManager { } /** - * Submits a ExecuteIngestTasksTask Callable to the data source ingest task + * Submits an ingest task executer Callable to the data source level ingest * thread pool. */ private void startDataSourceIngestThread() { @@ -302,8 +304,8 @@ public class IngestManager { } /** - * Submits a ExecuteIngestTasksTask Callable to the data source ingest - * thread pool. + * Submits a ingest task executer Callable to the file level ingest thread + * pool. */ private void startFileIngestThread() { long threadId = nextThreadId.incrementAndGet(); @@ -551,94 +553,100 @@ public class IngestManager { @Override public Void call() { - if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) { - return null; - } - - /** - * Set up a progress bar. - */ - final String displayName = NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.displayName"); - progress = ProgressHandleFactory.createHandle(displayName, new Cancellable() { - @Override - public boolean cancel() { - if (progress != null) { - progress.setDisplayName(NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.cancelling", - displayName)); - } - Future handle = ingestJobStarters.remove(threadId); - handle.cancel(true); - return true; - } - }); - progress.start(dataSources.size()); - try { + /** + * Bail out if there is nothing to do or cancellation has been + * requested. + */ + if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) { + return null; + } + + /** + * Set up a progress bar. + */ + final String displayName = NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.displayName"); + progress = ProgressHandleFactory.createHandle(displayName, new Cancellable() { + @Override + public boolean cancel() { + if (progress != null) { + progress.setDisplayName(NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.cancelling", + displayName)); + } + Future handle = ingestJobStarters.remove(threadId); + handle.cancel(true); + return true; + } + }); + progress.start(dataSources.size()); + + /** + * Try to start the ingest jobs. + */ int workUnitsCompleted = 0; for (Content dataSource : this.dataSources) { - try { - if (Thread.currentThread().isInterrupted()) { - return null; - } - String progressMessage = NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.progressingDisplayName", - dataSource.getName()); - progress.progress(progressMessage); - - /** - * Start an ingest job for the data source. - */ - List errors = IngestJob.startJob(dataSource, this.settings); - if (!errors.isEmpty() && this.doStartupErrorsMsgBox) { - StringBuilder moduleStartUpErrors = new StringBuilder(); - for (IngestModuleError error : errors) { - String moduleName = error.getModuleDisplayName(); - moduleStartUpErrors.append(moduleName); - moduleStartUpErrors.append(": "); - moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage()); - moduleStartUpErrors.append("\n"); - } - StringBuilder notifyMessage = new StringBuilder(); - notifyMessage.append(NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg")); - notifyMessage.append("\n"); - notifyMessage.append(NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution")); - notifyMessage.append("\n"); - notifyMessage.append(NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList", - moduleStartUpErrors.toString())); - notifyMessage.append("\n\n"); - JOptionPane.showMessageDialog(null, notifyMessage.toString(), - NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE); - } - - progress.progress(progressMessage, ++workUnitsCompleted); - - } catch (Throwable ex) { - /** - * This is an exceptions firewall. - */ - logger.log(Level.SEVERE, "Failed to create ingest job for " + dataSource.getName(), ex); //NON-NLS - if (this.doStartupErrorsMsgBox) { - JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(), - NbBundle.getMessage(this.getClass(), - "IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE); - } + /** + * Cancellation check. + */ + if (Thread.currentThread().isInterrupted()) { + return null; } + + /** + * Add a "subtitle" to the display name of the progress bar + * to indicate an ingest job is being started for this data + * source. + */ + String progressMessage = NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.progressingDisplayName", + dataSource.getName()); + progress.progress(progressMessage); + + /** + * Start an ingest job for this data source. + */ + List errors = IngestJob.startJob(dataSource, this.settings); + if (!errors.isEmpty() && this.doStartupErrorsMsgBox) { + StringBuilder moduleStartUpErrors = new StringBuilder(); + for (IngestModuleError error : errors) { + String moduleName = error.getModuleDisplayName(); + moduleStartUpErrors.append(moduleName); + moduleStartUpErrors.append(": "); + moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage()); + moduleStartUpErrors.append("\n"); + } + StringBuilder notifyMessage = new StringBuilder(); + notifyMessage.append(NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg")); + notifyMessage.append("\n"); + notifyMessage.append(NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution")); + notifyMessage.append("\n"); + notifyMessage.append(NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList", + moduleStartUpErrors.toString())); + notifyMessage.append("\n\n"); + JOptionPane.showMessageDialog(null, notifyMessage.toString(), + NbBundle.getMessage(this.getClass(), + "IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE); + } + + progress.progress(progressMessage, ++workUnitsCompleted); } + + return null; + } finally { - progress.finish(); + if (null != progress) { + progress.finish(); + } ingestJobStarters.remove(threadId); } - - return null; } - + } /**