Add an ErrorHandler which handles errors by either continuing or aborting.
The action taken is determined by a property set on a ConfigHolder. In the
case of continuing, both details of the error and context of the error are
logged. Context is provided by introducing request-specific exceptions
which store the parameters of the request, a call to the Smartsheet API. A
wrapper service ErrorContextualizingSmartsheetService creates these
exceptions which are are received by the ErrorHandler. Add a unit test to
simulate continuing on connection errors.
For exceptions related to sheets, store sheet name & id with the
exception. For exceptions related to attachments, store attachment name &
id as well as sheet name with the exception. Include all these properties
when logging these exceptions to provide context.
Add context to exception thrown when saving sheet to folder.
- Move the request for the download URL of a Smartsheet attachment from the
  main thread to the download worker thread. Do this because the URL is on
  AWS S3 and only valid for 2 minutes, so want to delay requesting the URL
  until the worker is actually ready to download the attachment, rather
  than at the time the job for the worker is posted in the main thread.
- Accomplish this cleanly by introducing the abstraction of an
  InternetContentSource which is passed from the SheetSaver to the
  ParallelDownloadService. The SheetShaver instantiates a
  Smartsheet-specific implementation of the source, keeping the
  ParallelDownloadService, which only deals with the abstraction, decoupled
  from Smartsheet-specific details, and hence generally reusable.
Add context to the error logged when an asynchronous download job fails.
Refactor ProgressWatcher as a singleton instance, and track the number of errors received by the watcher.
Cleanup the saveUrlToFile method in HttpUtils for indentation & consistent style. Also make the unexpected exception log message clearer.
If continue on error is set, still complete the org backup even if not all download jobs were done. Logs will indicate what wasn't done in this case.
Use ErrorContextualizingSmartsheetService to wrap
RetryingSmartsheetService so that context will be applied to any service
errors for the purpose of providing helpful logs to the user for
diagnostics or recovery. In the event there are errors and the user
elected to continue on errors, make the last line of the tool's output a
clear message that errors occurred, specifying how many exactly and also
the path to the log file where the details and context of each error were
recorded.
Add a continueOnError property to the properties file, default false. Set this in the ConfigHolder for use globally.
Enable logging errors to a log file if continue on errors is set. The log
file is created in the current directory with name:
"smartsheet-backup-error-log_XXX.log" where XXX is the current date and
time to make the file name quasi-unique. Each error in the log will be
numbered starting from one and will be timestamped. A message will appear
on the console if for any reason the error log file cannot be written.
Enable error logging in the continueOnErrors unit test to test creation
and writing of the error log file. Change .gitignore to ignore .log files.
Change the summary message about parallel download jobs didn't complete from ERROR to WARNING because the individual errors would have been already recorded, so the summary doesn't need to be recorded as a separate error.
Change the stub service used by the continueOnError unit test such that if the request to get the details of a Smartsheet attachment succeeds, then randomly return an invalid S3 URL in those details, to simulate and hence test an error downloading an Smartsheet attachment from S3, for example due to expiry of the link or network error.
Make the summary logs in the ParallelDownloadService clearer.
Make the continueOnError unit test call waitTillAllDownloadJobsDone before logging the error log file path so that shows up last in the test output.
Upgrade to latest maven-surefire-plugin 2.16 (2013-08-11) for latest test mojo.
Add Smartsheet copyright notices for consistency with existing source files.
Update the README with explanation of the new continueOnError property and the error log file. Note the README is for end users and not for developers, hence the updates were written for that audience.
Make the ErrorHandler notify the ProgressWatcher to log the error before checking continueOnError, so that errors are always notified.
To supplement the random network errors test, add deterministic tests for specific request failures, for the cases of both continueOnError set to true and to false (default).