MCPcopy
hub / github.com/scality/cloudserver / getXml

Method getXml

tests/unit/helpers.js:134–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132 this.RoutingRules.push(newRule);
133 }
134 getXml() {
135 const xml = [];
136 function _pushChildren(obj) {
137 Object.keys(obj).forEach(element => {
138 xml.push(`<${element}>${obj[element]}</${element}>`);
139 });
140 }
141
142 xml.push('<WebsiteConfiguration xmlns=' +
143 '"http://s3.amazonaws.com/doc/2006-03-01/">');
144
145 if (this.IndexDocument) {
146 xml.push('<IndexDocument>',
147 `<Suffix>${this.IndexDocument.Suffix}</Suffix>`,
148 '</IndexDocument>');
149 }
150
151 if (this.ErrorDocument) {
152 xml.push('<ErrorDocument>',
153 `<Key>${this.ErrorDocument.Key}</Key>`,
154 '</ErrorDocument>');
155 }
156
157 if (this.RedirectAllRequestsTo) {
158 xml.push('<RedirectAllRequestsTo>');
159 if (this.RedirectAllRequestsTo.HostName) {
160 xml.push('<HostName>',
161 `${this.RedirectAllRequestsTo.HostName})`,
162 '</HostName>');
163 }
164 if (this.RedirectAllRequestsTo.Protocol) {
165 xml.push('<Protocol>',
166 `${this.RedirectAllRequestsTo.Protocol})`,
167 '</Protocol>');
168 }
169 xml.push('</RedirectAllRequestsTo>');
170 }
171
172 if (this.RoutingRules) {
173 xml.push('<RoutingRules>');
174 this.RoutingRules.forEach(rule => {
175 xml.push('<RoutingRule>');
176 if (rule.Condition) {
177 xml.push('<Condition>');
178 _pushChildren(rule.Condition);
179 xml.push('</Condition>');
180 }
181 if (rule.Redirect) {
182 xml.push('<Redirect>');
183 _pushChildren(rule.Redirect);
184 xml.push('</Redirect>');
185 }
186 xml.push('</RoutingRule>');
187 });
188 xml.push('</RoutingRules>');
189 }
190
191 xml.push('</WebsiteConfiguration>');

Callers 3

objectPutACL.jsFile · 0.45

Calls 1

_pushChildrenFunction · 0.85

Tested by

no test coverage detected