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

Function objectPutRetention

lib/api/objectPutRetention.js:26–146  ·  view source on GitHub ↗

* Object Put Retention - Adds retention information to object * @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 server * @return {unde

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

24 * @return {undefined}
25 */
26function objectPutRetention(authInfo, request, log, callback) {
27 log.debug('processing request', { method: 'objectPutRetention' });
28
29 const { bucketName, objectKey } = request;
30
31 const decodedVidResult = decodeVersionId(request.query);
32 if (decodedVidResult instanceof Error) {
33 log.trace('invalid versionId query', {
34 versionId: request.query.versionId,
35 error: decodedVidResult,
36 });
37 return process.nextTick(() => callback(decodedVidResult));
38 }
39 const reqVersionId = decodedVidResult;
40
41 const metadataValParams = {
42 authInfo,
43 bucketName,
44 objectKey,
45 versionId: reqVersionId,
46 getDeleteMarker: true,
47 requestType: request.apiMethods || 'objectPutRetention',
48 request,
49 };
50
51 const hasGovernanceBypass = hasGovernanceBypassHeader(request.headers);
52
53 return async.waterfall([
54 next => {
55 log.trace('parsing retention information');
56 parseRetentionXml(request.post, log,
57 (err, retentionInfo) => {
58 if (err) {
59 log.trace('error parsing retention information',
60 { error: err });
61 return next(err);
62 }
63 const remainingDays = Math.ceil(
64 (new Date(retentionInfo.date) - Date.now()) / (1000 * 3600 * 24));
65 metadataValParams.request.objectLockRetentionDays = remainingDays;
66 return next(null, retentionInfo);
67 });
68 },
69 (retentionInfo, next) => standardMetadataValidateBucketAndObj(metadataValParams,
70 request.actionImplicitDenies, log, (err, bucket, objectMD) => {
71 if (err) {
72 log.trace('request authorization failed',
73 { method: 'objectPutRetention', error: err });
74 return next(err);
75 }
76 if (!objectMD) {
77 const err = reqVersionId ? errors.NoSuchVersion :
78 errors.NoSuchKey;
79 log.trace('error no object metadata found',
80 { method: 'objectPutRetention', error: err });
81 return next(err, bucket);
82 }
83 if (objectMD.isDeleteMarker) {

Callers 2

Calls 11

canModifyPolicyMethod · 0.95
getReplicationInfoFunction · 0.85
collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
getVersionIdResHeaderFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80
decodeVersionIdFunction · 0.50

Tested by

no test coverage detected