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

Function _parseXML

lib/api/bucketPut.js:84–113  ·  view source on GitHub ↗
(request, log, cb)

Source from the content-addressed store, hash-verified

82 */
83
84function _parseXML(request, log, cb) {
85 if (request.post) {
86 return parseString(request.post, (err, result) => {
87 if (err || !result.CreateBucketConfiguration
88 || !result.CreateBucketConfiguration.LocationConstraint
89 || !result.CreateBucketConfiguration.LocationConstraint[0]) {
90 log.debug('request xml is malformed');
91 return cb(errors.MalformedXML);
92 }
93 const locationConstraint = result.CreateBucketConfiguration
94 .LocationConstraint[0];
95 log.trace('location constraint',
96 { locationConstraint });
97 const locationCheck = checkLocationConstraint(request,
98 locationConstraint, log);
99 if (locationCheck.error) {
100 return cb(locationCheck.error);
101 }
102 return cb(null, locationCheck.locationConstraint);
103 });
104 }
105 return process.nextTick(() => {
106 const locationCheck = checkLocationConstraint(request,
107 undefined, log);
108 if (locationCheck.error) {
109 return cb(locationCheck.error);
110 }
111 return cb(null, locationCheck.locationConstraint);
112 });
113}
114
115function _buildConstantParams({
116 request, bucketName, authInfo, authParams, ip, isSecure, locationConstraint, apiMethod }) {

Callers 1

bucketPutFunction · 0.70

Calls 3

checkLocationConstraintFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80

Tested by

no test coverage detected