sford/yet-another-commit-checker — pull request #28 by bbaetz (2014-09-07 12:34:34+00:00)
Title: Support multiple JIRA instances

Currently YACC only grabs the first JIRA instance (via the primary application link). This means that if Stash is linked to multiple JIRA instances, only the first is checked.

This PR uses all the application links instead. Its careful to keep iterating through all of the application links when there is an error, and only report an error if there are no matches. There are a few reasons for this:

* Some JQL statements (eg using custom fields) might not be valid in all linked JIRAs
* JIRA returns an error from the /search REST api when the issue doesn't exist, and older versions don't allow that behaviour to be disabled.
* A user may not have access to all linked JIRA instances

This is a large change, but its mostly mechanical:

* Most of the changes moves the translation from JIRA/application link exceptions to strings into a central place (JiraLookupsException.getPrintableErrors), and resulting cleanups
* The ErrorParsingReturningResponseHandler is needed to capture the error response, since the default Atlassian stuff seemed to drop the error message (and using the stream also stops logging warnings into the logs on each request, although that might be a dev-only thing)
* There's a fair bit of whitespace changes
* The tests got a lot of changes/enhancements

This has *only* been tested on my desktop with two dev JIRA instances - I've done this in preparation for a JIRA migration/upgrade at work, but the second instance won't be set up there for another few weeks. Consider this a preview :)

There are some optimisations that could be done (eg trying the JQL query before the issue lookup, to reduce the number of queries done), but they are independent, and this was getting large enough....