]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't output optional DisplayName if not set
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 5 May 2011 00:23:44 +0000 (17:23 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 5 May 2011 00:25:20 +0000 (17:25 -0700)
Don't output optional DisplayName if not set. Be a little more explicit
about zeroing other optional fields during xml parsing.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/rgw/rgw_acl.cc
src/rgw/rgw_acl.h

index 634de67963a2625f3c45e0acf75a766392bb87f6..f95e55f34a03b25d3e686676b109d1bf8c0410bf 100644 (file)
@@ -81,6 +81,8 @@ bool ACLOwner::xml_end(const char *el) {
   // DisplayName is optional
   if (acl_name)
     display_name = acl_name->get_data();
+  else
+    display_name = "";
 
   return true;
 }
@@ -105,6 +107,11 @@ bool ACLGrant::xml_end(const char *el) {
     return false;
   permission = *acl_permission;
 
+  id.clear();
+  name.clear();
+  uri.clear();
+  email.clear();
+
   switch (type.get_type()) {
   case ACL_TYPE_CANON_USER:
     acl_id = (ACLID *)acl_grantee->find_first("ID");
index d2c5c40f2434354da03b242b6c24663c0b2993ea..1ae6e558d6228d1d848e2899b6dbee459051ef64 100644 (file)
@@ -367,10 +367,10 @@ public:
   void to_xml(ostream& out) {
     if (id.empty())
       return;
-    out << "<Owner>" <<
-                   "<ID>" << id << "</ID>" <<
-                   "<DisplayName>" << display_name << "</DisplayName>" <<
-                  "</Owner>";
+    out << "<Owner>" << "<ID>" << id << "</ID>";
+    if (!display_name.empty())
+      out << "<DisplayName>" << display_name << "</DisplayName>";
+    out << "</Owner>";
   }
   void set_id(string& _id) { id = _id; }
   void set_name(string& name) { display_name = name; }