}
String responseString = sb.toString();
EntityUtils.consume(response.getEntity());
if (response.getStatusLine().getStatusCode() != 200) {
throw new RequestFailedException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode() + " " + responseString);
}
// for whatever reason the ping response isn't well-formed
if (ServiceMethods.Users.PING.equals(serviceMethod) && responseString.indexOf("PONG!") > -1) {
return new BaseMandrillStringResponse(responseString);
}
if (reference == null) {
return convertResponseData(responseString, responseClass);
} else {
return convertAnonymousListResponseData(responseString, responseClass, reference);
}
} catch (MalformedURLException mURLE) {
throw new RequestFailedException("Malformed url", mURLE);
} catch (JsonGenerationException jge) {
throw new RequestFailedException("Json Generation Exception", jge);
} catch (JsonMappingException jme) {
throw new RequestFailedException("Json Mapping Exception", jme);
} catch (IOException ioe) {
throw new RequestFailedException("IOException", ioe);
}
}