log.debug("Processing model request: " + requestData);
SAXReader xmlReader = new SAXReader();
Document doc = xmlReader.read(new StringReader(requestData));
final Element env = doc.getRootElement();
final RequestContext ctx = new RequestContext(env.element("header"));
try
{
activateConversationContext(request, ctx.getConversationId());
Element modelElement = env.element("body").element("model");
String operation = modelElement.attributeValue("operation");
if ("expand".equals(operation))
{
processExpandRequest(modelElement, ctx, response.getOutputStream());
}
else
{
Model model = null;
if ("fetch".equals(operation))
{
model = processFetchRequest(modelElement);
}
else if ("apply".equals(operation))
{
model = processApplyRequest(modelElement);
}
if (model.getAction() != null && model.getAction().getException() != null)
{
response.getOutputStream().write(ENVELOPE_TAG_OPEN);
response.getOutputStream().write(BODY_TAG_OPEN);
MarshalUtils.marshalException(model.getAction().getException(),
model.getAction().getContext(), response.getOutputStream());
response.getOutputStream().write(BODY_TAG_CLOSE);
response.getOutputStream().write(ENVELOPE_TAG_CLOSE);
response.getOutputStream().flush();
return;
}
model.evaluate();
ctx.setConversationId(conversation.isTransient() ? null : conversation.getId());
marshalResponse(model, ctx, response.getOutputStream());
}
}
finally
{