]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_tag_s3.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rgw / rgw_tag_s3.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 <map>
5 #include <string>
6 #include <iostream>
7
8 #include "include/types.h"
9
10 #include "rgw_tag_s3.h"
11
12 void RGWObjTagEntry_S3::decode_xml(XMLObj *obj) {
13 RGWXMLDecoder::decode_xml("Key", key, obj, true);
14 RGWXMLDecoder::decode_xml("Value", val, obj, true);
15 }
16
17 void RGWObjTagEntry_S3::dump_xml(Formatter *f) const {
18 encode_xml("Key", key, f);
19 encode_xml("Value", val, f);
20
21 if (key.empty()) {
22 throw RGWXMLDecoder::err("empty key");
23 }
24
25 if (val.empty()) {
26 throw RGWXMLDecoder::err("empty val");
27 }
28 }
29
30 void RGWObjTagSet_S3::decode_xml(XMLObj *obj) {
31 vector<RGWObjTagEntry_S3> entries;
32
33 RGWXMLDecoder::decode_xml("Tag", entries, obj, true);
34
35 for (auto& entry : entries) {
36 const std::string& key = entry.get_key();
37 const std::string& val = entry.get_val();
38 if (!add_tag(key,val)) {
39 throw RGWXMLDecoder::err("failed to add tag");
40 }
41 }
42 }
43
44 int RGWObjTagSet_S3::rebuild(RGWObjTags& dest) {
45 int ret;
46 for (const auto &it : tag_map){
47 ret = dest.check_and_add_tag(it.first, it.second);
48 if (ret < 0)
49 return ret;
50 }
51 return 0;
52 }
53
54 void RGWObjTagging_S3::decode_xml(XMLObj *obj) {
55 RGWXMLDecoder::decode_xml("TagSet", tagset, obj, true);
56 }
57
58 void RGWObjTagSet_S3::dump_xml(Formatter *f) const {
59 for (const auto& tag : tag_map){
60 Formatter::ObjectSection os(*f, "Tag");
61 encode_xml("Key", tag.first, f);
62 encode_xml("Value", tag.second, f);
63 }
64 }
65