(xml, log, cb)
| 335 | } |
| 336 | |
| 337 | function parseWebsiteConfigXml(xml, log, cb) { |
| 338 | parseString(xml, (err, result) => { |
| 339 | if (err) { |
| 340 | log.trace('xml parsing failed', { |
| 341 | error: err, |
| 342 | method: 'parseWebsiteConfigXml', |
| 343 | }); |
| 344 | log.debug('invalid xml', { xmlObj: xml }); |
| 345 | return cb(errors.MalformedXML); |
| 346 | } |
| 347 | |
| 348 | if (!result || !result.WebsiteConfiguration) { |
| 349 | const errMsg = 'Invalid website configuration xml'; |
| 350 | return cb(errorInstances.MalformedXML.customizeDescription(errMsg)); |
| 351 | } |
| 352 | |
| 353 | const validationRes = |
| 354 | _validateWebsiteConfigXml(result.WebsiteConfiguration); |
| 355 | if (validationRes instanceof Error) { |
| 356 | log.debug('xml validation failed', { |
| 357 | error: validationRes, |
| 358 | method: '_validateWebsiteConfigXml', |
| 359 | xml, |
| 360 | }); |
| 361 | return cb(validationRes); |
| 362 | } |
| 363 | // if no error, validation returns instance of WebsiteConfiguration |
| 364 | log.trace('website configuration', { validationRes }); |
| 365 | return cb(null, validationRes); |
| 366 | }); |
| 367 | } |
| 368 | |
| 369 | function convertToXml(config) { |
| 370 | const xml = []; |
no test coverage detected