-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathbucketGetObjectLock.js
More file actions
68 lines (65 loc) · 2.59 KB
/
bucketGetObjectLock.js
File metadata and controls
68 lines (65 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { errors } = require('arsenal');
const { metadataValidateBucket } = require('../metadata/metadataUtils');
const { pushMetric } = require('../utapi/utilities');
const collectCorsHeaders = require('../utilities/collectCorsHeaders');
const ObjectLockConfiguration =
require('arsenal').models.ObjectLockConfiguration;
// Format of the xml response:
/**
* <ObjectLockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <ObjectLockEnabled>string</ObjectLockEnabled>
* <Rule>
* <DefaultRetention>
* <Mode>string</Mode>
* <Days>integer</Days>
* <Years>integer</Years>
* </DefaultRetention>
* </Rule>
* </ObjectLockConfiguration>
*/
/**
* bucketGetObjectLock - Return object lock configuration for the bucket
* @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info
* @param {object} request - http request object
* @param {object} log - Werelogs logger
* @param {function} callback - callback to respond to http request
* @return {undefined}
*/
function bucketGetObjectLock(authInfo, request, log, callback) {
log.debug('processing request', { method: 'bucketGetObjectLock' });
const { bucketName, headers, method } = request;
const metadataValParams = {
authInfo,
bucketName,
requestType: 'bucketGetObjectLock',
request,
};
return metadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
if (err) {
log.debug('error processing request', {
error: err,
method: 'bucketGetObjectLock',
});
return callback(err, null, corsHeaders);
}
const objectLockEnabled = bucket.isObjectLockEnabled();
const bucketObjLockConfig = bucket.getObjectLockConfiguration();
const objLockConfig = bucketObjLockConfig || {};
if (!objectLockEnabled) {
log.debug('object lock is not enabled', {
error: errors.ObjectLockConfigurationNotFoundError,
method: 'bucketGetObjectLock',
});
return callback(errors.ObjectLockConfigurationNotFoundError, null,
corsHeaders);
}
const xml = ObjectLockConfiguration.getConfigXML(objLockConfig);
pushMetric('getBucketObjectLock', log, {
authInfo,
bucket: bucketName,
});
return callback(null, xml, corsHeaders);
});
}
module.exports = bucketGetObjectLock;