]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: parser for multi upload completion
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 31 May 2011 22:32:47 +0000 (15:32 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 31 May 2011 22:32:47 +0000 (15:32 -0700)
src/Makefile.am
src/rgw/rgw_multi.cc [new file with mode: 0644]
src/rgw/rgw_multi.h [new file with mode: 0644]

index ec6a47f76117b3c53fbcb9a134fa07356e078a6d..e4f295e9b7b826587b41320cc3f2820e46af7717 100644 (file)
@@ -308,6 +308,7 @@ my_radosgw_src = \
        rgw/rgw_os_auth.cc \
        rgw/rgw_formats.cc \
        rgw/rgw_log.cc \
+       rgw/rgw_multi.cc \
        rgw/rgw_escape.c
 
 my_radosgw_ldadd = \
@@ -1089,6 +1090,7 @@ noinst_HEADERS = \
        rgw/rgw_formats.h\
        rgw/rgw_fs.h\
        rgw/rgw_log.h\
+       rgw/rgw_multi.h\
        rgw/rgw_op.h\
        rgw/rgw_os.h\
        rgw/rgw_os_auth.h\
diff --git a/src/rgw/rgw_multi.cc b/src/rgw/rgw_multi.cc
new file mode 100644 (file)
index 0000000..74693fe
--- /dev/null
@@ -0,0 +1,60 @@
+#include <string.h>
+
+#include <iostream>
+#include <map>
+
+#include "include/types.h"
+
+#include "rgw_xml.h"
+#include "rgw_multi.h"
+
+using namespace std;
+
+
+bool RGWMultiPart::xml_end(const char *el)
+{
+  RGWMultiPartNumber *num_obj = (RGWMultiPartNumber *)find_first("PartNumber");
+  RGWMultiETag *etag_obj = (RGWMultiETag *)find_first("ETag");
+
+  if (!num_obj || !etag_obj)
+    return false;
+
+  string s = num_obj->get_data();
+  if (s.empty())
+    return false;
+
+  num = atoi(s.c_str());
+
+  s = etag_obj->get_data();
+  etag = s;
+
+  return true;
+}
+
+bool RGWMultiCompleteUpload::xml_end(const char *el) {
+  XMLObjIter iter = find("Part");
+  RGWMultiPart *part = (RGWMultiPart *)iter.get_next();
+  while (part) {
+    int num = part->get_num();
+    string etag = part->get_etag();
+    parts[num] = etag;
+  }
+  return true;
+}
+
+
+XMLObj *RGWXMLParser::alloc_obj(const char *el) {
+  XMLObj * obj;
+  if (strcmp(el, "CompleteMultipartUpload") == 0) {
+    obj = new RGWMultiCompleteUpload();
+  } else if (strcmp(el, "Part") == 0) {
+    obj = new RGWMultiPart();
+  } else if (strcmp(el, "PartNumber") == 0) {
+    obj = new RGWMultiPartNumber();
+  } else if (strcmp(el, "ETag") == 0) {
+    obj = new RGWMultiETag();
+  }
+
+  return obj;
+}
+
diff --git a/src/rgw/rgw_multi.h b/src/rgw/rgw_multi.h
new file mode 100644 (file)
index 0000000..f7dc482
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef CEPH_RGW_MULTI_H
+#define CEPH_RGW_MULTI_H
+
+#include <map>
+#include "rgw_xml.h"
+
+class RGWMultiCompleteUpload : public XMLObj
+{
+  std::map<int, string> parts;
+public:
+  RGWMultiCompleteUpload() {}
+  ~RGWMultiCompleteUpload() {}
+  bool xml_end(const char *el);
+
+  std::map<int, string>& get_parts() { return parts; }
+};
+
+class RGWMultiPart : public XMLObj
+{
+  string etag;
+  int num;
+public:
+  RGWMultiPart() : num(0) {}
+  ~RGWMultiPart() {}
+  bool xml_end(const char *el);
+
+  string& get_etag() { return etag; }
+  int get_num() { return num; }
+};
+
+class RGWMultiPartNumber : public XMLObj
+{
+public:
+  RGWMultiPartNumber() {}
+  ~RGWMultiPartNumber() {}
+};
+
+class RGWMultiETag : public XMLObj
+{
+public:
+  RGWMultiETag() {}
+  ~RGWMultiETag() {}
+};
+
+class RGWMultiXMLParser : public RGWXMLParser
+{
+  XMLObj *alloc_obj(const char *el);
+public:
+  RGWMultiXMLParser() {}
+};
+
+#endif