private Response handleResponse(OAuthRequest request, OAuth10aService service) throws InterruptedException, ExecutionException, IOException, SAXException, InstantiationException, IllegalAccessException, ParserConfigurationException, FlickrException {
com.github.scribejava.core.model.Response scribeResponse = service.execute(request);
if (!scribeResponse.isSuccessful()) {
throw new FlickrException(FLICKR_SERVICE_UNAVAILABLE, String.format("Received '%s' error from Flickr with status %d", scribeResponse.getMessage(), scribeResponse.getCode()));
}
Response f4jResponse;
String strXml = scribeResponse.getBody().trim();
if (Flickr.debugStream) {
logger.debug(strXml);
}
if (strXml.startsWith("oauth_problem=")) {
throw new FlickrRuntimeException(strXml);
}
DocumentBuilder builder = getDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(strXml)));
f4jResponse = (Response) responseClass.newInstance();
f4jResponse.parse(document);
return f4jResponse;
}