HttpServletResponse response)
throws ServletException, IOException {
setSession(request.getSession());
ModelParser parser =
ModelParserFactory.getDefaultInstance().createModelParser();
SendRequest sendRequest = parser.readSendRequest(
request.getInputStream());
IOUtils.closeQuietly(request.getInputStream());
// Create an internal message service to process the request.
InternalMessageService service =
(InternalMessageService)MessageServiceFactory.
getDefaultInstance().createMessageService("internal:");
Failures failures;
try {
failures = service.process(sendRequest, session);
} catch (MessageServiceException e) {
throw new ServletException(e.getMessage(), e);
}
response.setStatus(HttpServletResponse.SC_OK);
parser.write(failures, response.getOutputStream());
IOUtils.closeQuietly(response.getOutputStream());
}