Closed farblos closed 7 months ago
Another fat PR ... at least I split it up into separate commits this time. Please check and let me know what you think.
This was (hopefully) the last "infrastructure" work, so the following commits/PRs should be more focused.
I will try to monitor the issues, just in case any of these changes breaks things. In any case, feel free to CC my as @farblos if there should be need for it!
Improve previous password entry changes
OraclePatchDownloader.java:
Factor out common code from methods readLine and readPassword to a new method readThing. Protect from reading EOF in that method.
Change syntax for reading passwords from environment to a more explicit env:ENV_VAR.
Simplify calls to readLine, readPrompt.
README.md:
Sync online help.
Change example to the env:ENV_VAR syntax.
Clean up code
OraclePatchDownloader.java:
Reorder definitions of global variables to be more consistent with rest of code.
Make variable tempdirDelete local to main method, renamed patchRegexp to patternList.
Completely remove unused code referring to checkPatchList. (That variable never gets set to true as of commit 7aaba1e.)
Consistently use "private static" methods, make the constructor a "public static" method.
Check for empty download list after processing all search results.
Move exception handling from method download to main to avoid exiting prematurely (thus circumventing clean-up code in main).
Simplify handling of patterns in command line processing.
Streamline error handling
OraclePatchDownloader.java:
Add methods format(), error(), warn(), usage() as main APIs to handle errors and use them as appropriate. When none of these is appropriate, throw a RuntimeExcpetion. Extend main method to handle any ExitExceptions thrown by the new methods.
Redo web scraping to use methods that throw ElementNotFoundExceptions when a page does not look as expected. Handle these exceptions.
Simplify download link loop by using an XPath query.
Turn "no dowmloads error" into a warning (since this is a legitimate use case, not an error).
Use try-with-resource where appropriate.