MultipleResourceHttpFetcher parallelFetcher =
new MultipleResourceHttpFetcher(requestPipeline, executor);
List<Pair<Uri, FutureTask<RequestContext>>> futureTasks = parallelFetcher.fetchAll(requests);
for (Pair<Uri, FutureTask<RequestContext>> futureTask : futureTasks) {
RequestContext requestCxt;
try {
try {
requestCxt = futureTask.two.get();
} catch (InterruptedException ie) {
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, ie);
} catch (ExecutionException ee) {
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, ee);
}
if (requestCxt.getGadgetException() != null) {
throw requestCxt.getGadgetException();
}
HttpResponse httpResp = requestCxt.getHttpResp();
if (httpResp != null) {
if (contentRewriterRegistry != null) {
try {
httpResp = contentRewriterRegistry.rewriteHttpResponse(requestCxt.getHttpReq(),
httpResp, null);
} catch (RewritingException e) {
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e,
e.getHttpStatusCode());
}