only create nodes if there is content associated with it

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1849 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-08-09 22:54:51 +00:00
parent b2987c9682
commit f001f26298
1 changed files with 4 additions and 3 deletions

View File

@ -61,15 +61,16 @@ public class AccessControlListBinder implements EntityBinder {
protected XMLBuilder generateBuilder(AccessControlList acl) throws ParserConfigurationException, protected XMLBuilder generateBuilder(AccessControlList acl) throws ParserConfigurationException,
FactoryConfigurationError { FactoryConfigurationError {
XMLBuilder ownerBuilder = XMLBuilder.create("AccessControlPolicy").attr("xmlns", XMLBuilder rootBuilder = XMLBuilder.create("AccessControlPolicy").attr("xmlns",
S3Constants.S3_REST_API_XML_NAMESPACE).elem("Owner"); S3Constants.S3_REST_API_XML_NAMESPACE);
if (acl.getOwner() != null) { if (acl.getOwner() != null) {
XMLBuilder ownerBuilder = rootBuilder.elem("Owner");
ownerBuilder.elem("ID").text(acl.getOwner().getId()).up(); ownerBuilder.elem("ID").text(acl.getOwner().getId()).up();
if (acl.getOwner().getDisplayName() != null) { if (acl.getOwner().getDisplayName() != null) {
ownerBuilder.elem("DisplayName").text(acl.getOwner().getDisplayName()).up(); ownerBuilder.elem("DisplayName").text(acl.getOwner().getDisplayName()).up();
} }
} }
XMLBuilder grantsBuilder = ownerBuilder.root().elem("AccessControlList"); XMLBuilder grantsBuilder = rootBuilder.elem("AccessControlList");
for (Grant grant : acl.getGrants()) { for (Grant grant : acl.getGrants()) {
XMLBuilder grantBuilder = grantsBuilder.elem("Grant"); XMLBuilder grantBuilder = grantsBuilder.elem("Grant");
XMLBuilder granteeBuilder = grantBuilder.elem("Grantee").attr("xmlns:xsi", XMLBuilder granteeBuilder = grantBuilder.elem("Grantee").attr("xmlns:xsi",