MCPcopy Index your code
hub / github.com/scality/cloudserver / _parseXml

Function _parseXml

lib/api/multiObjectDelete.js:147–174  ·  view source on GitHub ↗
(xmlToParse, next)

Source from the content-addressed store, hash-verified

145}
146
147function _parseXml(xmlToParse, next) {
148 return parseString(xmlToParse, (err, result) => {
149 if (err || !result || !result.Delete || !result.Delete.Object) {
150 return next(errors.MalformedXML);
151 }
152 const json = result.Delete;
153 // not quiet is the default if nothing specified
154 const quietSetting = json.Quiet && json.Quiet[0] === 'true';
155 // format of json is
156 // {"Object":[
157 // {"Key":["test1"],"VersionId":["vid"]},
158 // {"Key":["test2"]}
159 // ]}
160 const objects = [];
161 for (let i = 0; i < json.Object.length; i++) {
162 const item = json.Object[i];
163 if (!item.Key) {
164 return next(errors.MalformedXML);
165 }
166 const object = { key: item.Key[0] };
167 if (item.VersionId) {
168 object.versionId = item.VersionId[0];
169 }
170 objects.push(object);
171 }
172 return next(null, quietSetting, objects);
173 });
174}
175
176/**
177 * decodeObjectVersion - decode object version to be deleted

Callers 1

multiObjectDeleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected