]>
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 | #include <map> | |
8 | ||
9 | #include "include/types.h" | |
10 | ||
11 | #include "rgw_xml.h" | |
12 | #include "rgw_multi.h" | |
224ce89b | 13 | #include "rgw_op.h" |
9f95a23c | 14 | #include "rgw_sal.h" |
f67539c2 | 15 | #include "rgw_sal_rados.h" |
7c673cae | 16 | |
11fdf7f2 | 17 | #include "services/svc_sys_obj.h" |
9f95a23c | 18 | #include "services/svc_tier_rados.h" |
11fdf7f2 | 19 | |
7c673cae FG |
20 | #define dout_subsys ceph_subsys_rgw |
21 | ||
20effc67 | 22 | using namespace std; |
11fdf7f2 | 23 | |
7c673cae FG |
24 | bool RGWMultiPart::xml_end(const char *el) |
25 | { | |
26 | RGWMultiPartNumber *num_obj = static_cast<RGWMultiPartNumber *>(find_first("PartNumber")); | |
27 | RGWMultiETag *etag_obj = static_cast<RGWMultiETag *>(find_first("ETag")); | |
28 | ||
29 | if (!num_obj || !etag_obj) | |
30 | return false; | |
31 | ||
32 | string s = num_obj->get_data(); | |
33 | if (s.empty()) | |
34 | return false; | |
35 | ||
36 | num = atoi(s.c_str()); | |
37 | ||
38 | s = etag_obj->get_data(); | |
39 | etag = s; | |
40 | ||
41 | return true; | |
42 | } | |
43 | ||
44 | bool RGWMultiCompleteUpload::xml_end(const char *el) { | |
45 | XMLObjIter iter = find("Part"); | |
46 | RGWMultiPart *part = static_cast<RGWMultiPart *>(iter.get_next()); | |
47 | while (part) { | |
48 | int num = part->get_num(); | |
49 | string etag = part->get_etag(); | |
50 | parts[num] = etag; | |
51 | part = static_cast<RGWMultiPart *>(iter.get_next()); | |
52 | } | |
53 | return true; | |
54 | } | |
55 | ||
20effc67 | 56 | RGWMultiXMLParser::~RGWMultiXMLParser() {} |
7c673cae FG |
57 | |
58 | XMLObj *RGWMultiXMLParser::alloc_obj(const char *el) { | |
59 | XMLObj *obj = NULL; | |
20effc67 | 60 | // CompletedMultipartUpload is incorrect but some versions of some libraries use it, see PR #41700 |
7c673cae | 61 | if (strcmp(el, "CompleteMultipartUpload") == 0 || |
20effc67 | 62 | strcmp(el, "CompletedMultipartUpload") == 0 || |
7c673cae FG |
63 | strcmp(el, "MultipartUpload") == 0) { |
64 | obj = new RGWMultiCompleteUpload(); | |
65 | } else if (strcmp(el, "Part") == 0) { | |
66 | obj = new RGWMultiPart(); | |
67 | } else if (strcmp(el, "PartNumber") == 0) { | |
68 | obj = new RGWMultiPartNumber(); | |
69 | } else if (strcmp(el, "ETag") == 0) { | |
70 | obj = new RGWMultiETag(); | |
71 | } | |
72 | ||
73 | return obj; | |
74 | } | |
75 | ||
76 | bool is_v2_upload_id(const string& upload_id) | |
77 | { | |
78 | const char *uid = upload_id.c_str(); | |
79 | ||
80 | return (strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX, sizeof(MULTIPART_UPLOAD_ID_PREFIX) - 1) == 0) || | |
81 | (strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0); | |
82 | } | |
83 | ||
20effc67 | 84 | void RGWUploadPartInfo::generate_test_instances(list<RGWUploadPartInfo*>& o) |
7c673cae | 85 | { |
20effc67 TL |
86 | RGWUploadPartInfo *i = new RGWUploadPartInfo; |
87 | i->num = 1; | |
88 | i->size = 10 * 1024 * 1024; | |
89 | i->etag = "etag"; | |
90 | o.push_back(i); | |
91 | o.push_back(new RGWUploadPartInfo); | |
7c673cae FG |
92 | } |
93 | ||
20effc67 | 94 | void RGWUploadPartInfo::dump(Formatter *f) const |
7c673cae | 95 | { |
20effc67 TL |
96 | encode_json("num", num, f); |
97 | encode_json("size", size, f); | |
98 | encode_json("etag", etag, f); | |
99 | utime_t ut(modified); | |
100 | encode_json("modified", ut, f); | |
1e59de90 | 101 | encode_json("past_prefixes", past_prefixes, f); |
7c673cae FG |
102 | } |
103 |