case JSON:
return DirectMemoryParser.instance().buildResponse( inputStream );
case JAVA_SERIALIZED_OBJECT:
try
{
DirectMemoryResponse response = new DirectMemoryResponse();
response.setResponse( request.getSerializer().deserialize( IOUtils.toByteArray( inputStream ),
request.getObjectClass() ) );
return response;
}
catch ( IOException e )
{
throw new DirectMemoryException( e.getMessage(), e );
}
catch ( ClassNotFoundException e )
{
throw new DirectMemoryException( e.getMessage(), e );
}
catch ( IllegalAccessException e )
{
throw new DirectMemoryException( e.getMessage(), e );
}
catch ( InstantiationException e )
{
throw new DirectMemoryException( e.getMessage(), e );
}
case TEXT_PLAIN:
try
{
DirectMemoryResponse<String> response = new DirectMemoryResponse<String>();
response.setResponse( IOUtils.toString( inputStream ) );
return response;
}
catch ( IOException e )
{
throw new DirectMemoryException( e.getMessage(), e );