Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rgw / rgw_multi_del.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include <string.h>
5
6 #include <iostream>
7
8 #include "include/types.h"
9
10 #include "rgw_xml.h"
11 #include "rgw_multi_del.h"
12
13 #define dout_subsys ceph_subsys_rgw
14
15 using namespace std;
16
17
18 bool RGWMultiDelObject::xml_end(const char *el)
19 {
20   RGWMultiDelKey *key_obj = static_cast<RGWMultiDelKey *>(find_first("Key"));
21   RGWMultiDelVersionId *vid = static_cast<RGWMultiDelVersionId *>(find_first("VersionId"));
22
23   if (!key_obj)
24     return false;
25
26   string s = key_obj->get_data();
27   if (s.empty())
28     return false;
29
30   key = s;
31
32   if (vid) {
33     version_id = vid->get_data();
34   }
35
36   return true;
37 }
38
39 bool RGWMultiDelDelete::xml_end(const char *el) {
40   RGWMultiDelQuiet *quiet_set = static_cast<RGWMultiDelQuiet *>(find_first("Quiet"));
41   if (quiet_set) {
42     string quiet_val = quiet_set->get_data();
43     quiet = (strcasecmp(quiet_val.c_str(), "true") == 0);
44   }
45
46   XMLObjIter iter = find("Object");
47   RGWMultiDelObject *object = static_cast<RGWMultiDelObject *>(iter.get_next());
48   while (object) {
49     const string& key = object->get_key();
50     const string& instance = object->get_version_id();
51     rgw_obj_key k(key, instance);
52     objects.push_back(k);
53     object = static_cast<RGWMultiDelObject *>(iter.get_next());
54   }
55   return true;
56 }
57
58 XMLObj *RGWMultiDelXMLParser::alloc_obj(const char *el) {
59   XMLObj *obj = NULL;
60   if (strcmp(el, "Delete") == 0) {
61     obj = new RGWMultiDelDelete();
62   } else if (strcmp(el, "Quiet") == 0) {
63     obj = new RGWMultiDelQuiet();
64   } else if (strcmp(el, "Object") == 0) {
65     obj = new RGWMultiDelObject ();
66   } else if (strcmp(el, "Key") == 0) {
67     obj = new RGWMultiDelKey();
68   } else if (strcmp(el, "VersionId") == 0) {
69     obj = new RGWMultiDelVersionId();
70   }
71
72   return obj;
73 }
74