}
// Send response, sets encoding of the response writer.
response.setContentType(MIME_XML_UTF8);
final Persister persister = new Persister(getPersisterFormat(requestModel));
final PrintWriter writer = response.getWriter();
if (RequestType.CARROT2.equals(requestModel.type) ||
RequestType.CARROT2DOCUMENTS.equals(requestModel.type))
{
// Check for an empty processing result.
if (processingException != null)
{
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Internal server error: " + processingException.getMessage());
return;
}
persister.write(processingResult, writer);
}
else
{
response.setContentType(MIME_XML_UTF8);
final PageModel pageModel = new PageModel(webappConfig, request, requestModel,
jawrUrlGenerator, processingResult, processingException);
persister.write(pageModel, writer);
}
}