public byte [ ] convertToXmlByteArray ( AccessControlList acl ) throws SdkClientException { Owner owner = acl . getOwner ( ) ; if ( owner == null ) { throw new SdkClientException ( "Invalid AccessControlList: missing an S3Owner" ) ; } XmlWriter xml = new XmlWriter ( ) ; xml . start ( "AccessControlPolicy" , "xmlns" , Constants . XML_NAMESPACE ) ; xml . start ( "Owner" ) ; if ( owner . getId ( ) != null ) { xml . start ( "ID" ) . value ( owner . getId ( ) ) . end ( ) ; } if ( owner . getDisplayName ( ) != null ) { xml . start ( "DisplayName" ) . value ( owner . getDisplayName ( ) ) . end ( ) ; } xml . end ( ) ; xml . start ( "AccessControlList" ) ; for ( Grant grant : acl . getGrantsAsList ( ) ) { xml . start ( "Grant" ) ; convertToXml ( grant . getGrantee ( ) , xml ) ; xml . start ( "Permission" ) . value ( grant . getPermission ( ) . toString ( ) ) . end ( ) ; xml . end ( ) ; } xml . end ( ) ; xml . end ( ) ; return xml . getBytes ( ) ; }
Converts the specified AccessControlList object to an XML fragment that can be sent to Amazon S3 .