requestParameters.keySet().removeAll(
webappConfig.componentInternalAttributeKeys);
// Perform processing
ProcessingResult processingResult = null;
ProcessingException processingException = null;
try
{
if (requestModel.type.requiresProcessing)
{
switch (requestModel.type)
{
case CLUSTERS:
case FULL:
case CARROT2:
logQuery(true, requestModel, null);
processingResult = controller.process(requestParameters,
requestModel.source, requestModel.algorithm);
logQuery(false, requestModel, processingResult);
break;
case DOCUMENTS:
processingResult = controller.process(requestParameters,
requestModel.source,
webappConfig.QUERY_HIGHLIGHTER_ID);
break;
case CARROT2DOCUMENTS:
processingResult = controller.process(requestParameters,
requestModel.source);
break;
default:
throw new RuntimeException("Should not reach here.");
}
setExpires(response, 5);
}
}
catch (ProcessingException e)
{
processingException = e;
if (e.getCause() instanceof IpBannedException)
{
logger.info("Skipping, source IP banned: " + request.getRemoteAddr());
}
else
{
logger.error("Processing error: " + e.getMessage(), e);
}
}
// 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);
}