6 #include "include/types.h"
12 #define dout_subsys ceph_subsys_rgw
16 bool LCExpiration_S3::xml_end(const char * el
) {
17 LCDays_S3
*lc_days
= static_cast<LCDays_S3
*>(find_first("Days"));
18 LCDeleteMarker_S3
*lc_dm
= static_cast<LCDeleteMarker_S3
*>(find_first("ExpiredObjectDeleteMarker"));
20 if ((!lc_days
&& !lc_dm
) || (lc_days
&& lc_dm
)) {
24 days
= lc_days
->get_data();
26 dm_expiration
= lc_dm
->get_data().compare("true") == 0;
34 bool LCNoncurExpiration_S3::xml_end(const char *el
) {
35 LCDays_S3
*lc_noncur_days
= static_cast<LCDays_S3
*>(find_first("NoncurrentDays"));
36 if (!lc_noncur_days
) {
39 days
= lc_noncur_days
->get_data();
43 bool LCMPExpiration_S3::xml_end(const char *el
) {
44 LCDays_S3
*lc_mp_days
= static_cast<LCDays_S3
*>(find_first("DaysAfterInitiation"));
48 days
= lc_mp_days
->get_data();
52 bool RGWLifecycleConfiguration_S3::xml_end(const char *el
) {
53 XMLObjIter iter
= find("Rule");
54 LCRule_S3
*rule
= static_cast<LCRule_S3
*>(iter
.get_next());
57 rule
= static_cast<LCRule_S3
*>(iter
.get_next());
62 bool LCRule_S3::xml_end(const char *el
) {
64 LCPrefix_S3
*lc_prefix
;
65 LCStatus_S3
*lc_status
;
66 LCExpiration_S3
*lc_expiration
;
67 LCNoncurExpiration_S3
*lc_noncur_expiration
;
68 LCMPExpiration_S3
*lc_mp_expiration
;
73 dm_expiration
= false;
75 lc_id
= static_cast<LCID_S3
*>(find_first("ID"));
78 id
= lc_id
->get_data();
80 lc_prefix
= static_cast<LCPrefix_S3
*>(find_first("Prefix"));
83 prefix
= lc_prefix
->get_data();
85 lc_status
= static_cast<LCStatus_S3
*>(find_first("Status"));
88 status
= lc_status
->get_data();
89 if (status
.compare("Enabled") != 0 && status
.compare("Disabled") != 0)
92 lc_expiration
= static_cast<LCExpiration_S3
*>(find_first("Expiration"));
93 lc_noncur_expiration
= static_cast<LCNoncurExpiration_S3
*>(find_first("NoncurrentVersionExpiration"));
94 lc_mp_expiration
= static_cast<LCMPExpiration_S3
*>(find_first("AbortIncompleteMultipartUpload"));
95 if (!lc_expiration
&& !lc_noncur_expiration
&& !lc_mp_expiration
) {
99 if (!lc_expiration
->empty()) {
100 expiration
.set_days(lc_expiration
->get_days_str());
102 dm_expiration
= lc_expiration
->get_dm_expiration();
105 if (lc_noncur_expiration
) {
106 noncur_expiration
= *lc_noncur_expiration
;
108 if (lc_mp_expiration
) {
109 mp_expiration
= *lc_mp_expiration
;
116 void LCRule_S3::to_xml(CephContext
*cct
, ostream
& out
) {
118 out
<< "<ID>" << id
<< "</ID>";
119 out
<< "<Prefix>" << prefix
<< "</Prefix>";
120 out
<< "<Status>" << status
<< "</Status>";
121 if (!expiration
.empty() || dm_expiration
) {
122 LCExpiration_S3
expir(expiration
.get_days_str(), dm_expiration
);
125 if (!noncur_expiration
.empty()) {
126 LCNoncurExpiration_S3
& noncur_expir
= static_cast<LCNoncurExpiration_S3
&>(noncur_expiration
);
127 noncur_expir
.to_xml(out
);
129 if (!mp_expiration
.empty()) {
130 LCMPExpiration_S3
& mp_expir
= static_cast<LCMPExpiration_S3
&>(mp_expiration
);
131 mp_expir
.to_xml(out
);
136 int RGWLifecycleConfiguration_S3::rebuild(RGWRados
*store
, RGWLifecycleConfiguration
& dest
)
139 multimap
<string
, LCRule
>::iterator iter
;
140 for (iter
= rule_map
.begin(); iter
!= rule_map
.end(); ++iter
) {
141 LCRule
& src_rule
= iter
->second
;
142 ret
= dest
.check_and_add_rule(&src_rule
);
146 if (!dest
.validate()) {
147 ret
= -ERR_INVALID_REQUEST
;
152 void RGWLifecycleConfiguration_S3::dump_xml(Formatter
*f
) const
154 f
->open_object_section_in_ns("LifecycleConfiguration", XMLNS_AWS_S3
);
156 for (auto iter
= rule_map
.begin(); iter
!= rule_map
.end(); ++iter
) {
157 const LCRule_S3
& rule
= static_cast<const LCRule_S3
&>(iter
->second
);
161 f
->close_section(); // Lifecycle
164 XMLObj
*RGWLCXMLParser_S3::alloc_obj(const char *el
)
167 if (strcmp(el
, "LifecycleConfiguration") == 0) {
168 obj
= new RGWLifecycleConfiguration_S3(cct
);
169 } else if (strcmp(el
, "Rule") == 0) {
170 obj
= new LCRule_S3();
171 } else if (strcmp(el
, "ID") == 0) {
173 } else if (strcmp(el
, "Prefix") == 0) {
174 obj
= new LCPrefix_S3();
175 } else if (strcmp(el
, "Status") == 0) {
176 obj
= new LCStatus_S3();
177 } else if (strcmp(el
, "Expiration") == 0) {
178 obj
= new LCExpiration_S3();
179 } else if (strcmp(el
, "Days") == 0) {
180 obj
= new LCDays_S3();
181 } else if (strcmp(el
, "ExpiredObjectDeleteMarker") == 0) {
182 obj
= new LCDeleteMarker_S3();
183 } else if (strcmp(el
, "NoncurrentVersionExpiration") == 0) {
184 obj
= new LCNoncurExpiration_S3();
185 } else if (strcmp(el
, "NoncurrentDays") == 0) {
186 obj
= new LCDays_S3();
187 } else if (strcmp(el
, "AbortIncompleteMultipartUpload") == 0) {
188 obj
= new LCMPExpiration_S3();
189 } else if (strcmp(el
, "DaysAfterInitiation") == 0) {
190 obj
= new LCDays_S3();