]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
7c673cae FG |
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 | ||
20effc67 | 15 | using namespace std; |
7c673cae FG |
16 | |
17 | bool RGWMultiDelObject::xml_end(const char *el) | |
18 | { | |
19 | RGWMultiDelKey *key_obj = static_cast<RGWMultiDelKey *>(find_first("Key")); | |
20 | RGWMultiDelVersionId *vid = static_cast<RGWMultiDelVersionId *>(find_first("VersionId")); | |
21 | ||
22 | if (!key_obj) | |
23 | return false; | |
24 | ||
25 | string s = key_obj->get_data(); | |
26 | if (s.empty()) | |
27 | return false; | |
28 | ||
29 | key = s; | |
30 | ||
31 | if (vid) { | |
32 | version_id = vid->get_data(); | |
33 | } | |
34 | ||
35 | return true; | |
36 | } | |
37 | ||
38 | bool RGWMultiDelDelete::xml_end(const char *el) { | |
39 | RGWMultiDelQuiet *quiet_set = static_cast<RGWMultiDelQuiet *>(find_first("Quiet")); | |
40 | if (quiet_set) { | |
41 | string quiet_val = quiet_set->get_data(); | |
42 | quiet = (strcasecmp(quiet_val.c_str(), "true") == 0); | |
43 | } | |
44 | ||
45 | XMLObjIter iter = find("Object"); | |
46 | RGWMultiDelObject *object = static_cast<RGWMultiDelObject *>(iter.get_next()); | |
47 | while (object) { | |
48 | const string& key = object->get_key(); | |
49 | const string& instance = object->get_version_id(); | |
50 | rgw_obj_key k(key, instance); | |
51 | objects.push_back(k); | |
52 | object = static_cast<RGWMultiDelObject *>(iter.get_next()); | |
53 | } | |
54 | return true; | |
55 | } | |
56 | ||
57 | XMLObj *RGWMultiDelXMLParser::alloc_obj(const char *el) { | |
58 | XMLObj *obj = NULL; | |
59 | if (strcmp(el, "Delete") == 0) { | |
60 | obj = new RGWMultiDelDelete(); | |
61 | } else if (strcmp(el, "Quiet") == 0) { | |
62 | obj = new RGWMultiDelQuiet(); | |
63 | } else if (strcmp(el, "Object") == 0) { | |
64 | obj = new RGWMultiDelObject (); | |
65 | } else if (strcmp(el, "Key") == 0) { | |
66 | obj = new RGWMultiDelKey(); | |
67 | } else if (strcmp(el, "VersionId") == 0) { | |
68 | obj = new RGWMultiDelVersionId(); | |
69 | } | |
70 | ||
71 | return obj; | |
72 | } | |
73 |