int maxKeys = Converter.toInt(request.getParameter("max-keys"), 1000);
engineRequest.setMaxKeys(maxKeys);
S3ListBucketResponse engineResponse = ServiceProvider.getInstance().getS3Engine().listBucketContents( engineRequest, false );
// -> serialize using the apache's Axiom classes
ListBucketResponse oneBucket = S3SoapServiceImpl.toListBucketResponse( engineResponse );
OutputStream os = response.getOutputStream();
response.setStatus(200);
response.setContentType("text/xml; charset=UTF-8");
XMLStreamWriter xmlWriter = xmlOutFactory.createXMLStreamWriter( os );
String documentStart = new String( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
os.write( documentStart.getBytes());
MTOMAwareXMLSerializer MTOMWriter = new MTOMAwareXMLSerializer( xmlWriter );
oneBucket.serialize( new QName( "http://s3.amazonaws.com/doc/2006-03-01/", "ListBucketResponse", "ns1" ), factory, MTOMWriter );
xmlWriter.flush();
xmlWriter.close();
os.close();
}