+ /**
+ * Executes the request with a random delay and with a maximum number of
+ * retries.
+ * @param aClient HTTP client to use.
+ * @param aMethod Method representing the request.
+ * @return XML document describing the response.
+ * @throws TransformerException In case transformation of the HTML to XML fails.
+ */
+ protected Document executeMethod(HttpClient aClient, HttpMethod aMethod)
+ throws TransformerException {
+ int triesLeft = _maxTries;
+ while (triesLeft > 0) {
+ triesLeft--;
+ try {
+ return executeMethodWithoutRetries(aClient, aMethod);
+ } catch (TransformerException e) {
+ if (triesLeft == 0) {
+ throw e;
+ }
+ }
+ }
+ throw new RuntimeException("Code should never reach this point");
+ }
+
+ /**
+ * Executes the request without doing any retries in case XSLT transformation
+ * fails.
+ * @param aClient HTTP client to use.
+ * @param aMethod Method to execute.
+ * @return XML document containing the result.
+ * @throws TransformerException In case transformation of the result to XML fails.
+ */
+ protected Document executeMethodWithoutRetries(HttpClient aClient,
+ HttpMethod aMethod) throws TransformerException {