logAccess(command,
context, bytesRead,
0, requestMediaType,
null, ResponseCode.Ok);
} else {
RescriptResponse responseWrapper = binding.getBindingDescriptor().getResponseClass().newInstance();
responseWrapper.setResult(result);
MediaType responseMediaType = getContentTypeNormaliser().getNormalisedResponseMediaType(request);
DataBindingFactory dataBindingFactory = DataBindingManager.getInstance().getFactory(responseMediaType);
Marshaller marshaller = dataBindingFactory.getMarshaller();
String encoding = getContentTypeNormaliser().getNormalisedEncoding(request);
response.setContentType(responseMediaType.toString());
ByteCountingOutputStream out = null;
try {
out = new ByteCountingOutputStream(response.getOutputStream());
Object toMarshall = responseWrapper;
if (responseMediaType.getSubtype().equals("json")) {
toMarshall = responseWrapper.getResult();
}
marshaller.marshall(out, toMarshall, encoding, false);
logAccess(command,
context, bytesRead,
out.getCount(), requestMediaType,