Loading TOC...

temporal.documentProtect

temporal.documentProtect(
   temporal-collection as String,
   uri as String,
   [options as Object?]
) as null

Summary

Protects a temporal document from certain temporal operations, such as update, delete or wipe for a specific period of time. Subsequent update operations on that document against which this operation is protected will get a TEMPORAL-PROTECTED exception. If an archive path is specified optionally save a serialized copy of the document to the specified location and record the file path and copy time in the document's metadata.

Parameters
temporal-collection The URI for the protected temporal collection in which the document is to belong. This must have been previously created by the temporal:collectionCreate function. All versions of the temporal document will be associated with this temporal collection.
uri The URI to be used to identify the document in the database. If the document is not the latest version, a suffix will be concatenated to the document URI with a dot as the new URI of the document.
options Options with which to customize this operation. This function supports the following options:
level
Protection level: "noWipe","noDelete","noUpdate". Default value is "noDelete" when omitted.
duration
Duration between the time the protection starts and ends. Used to compute the expiration time. Can be either a year-month duration or a day-time duration.
expireTime
Exact date and time when the protection expires. Useful for idempotency. Overrides the duration option for expiration time computation.
archivePath
File path to save a serlialized copy of the current version of the document.

Required Privileges

By default http://marklogic.com/xdmp/privileges/temporal-document-protect or the one user specified for this temporal collection.

Usage Notes

CamelCased option names should be used if the options are specified as map:map.

TEMPORAL-NOEXTIME is thrown if archive path option is specified and no expire time or duration option is specified.

When archive path option is specified, the latest version of the temporal document will be archived if it exists; else the version with the temporal document URI will be archived. If none of the above exists (such as the temporal document is deleted and version URI is used to create them), the protection will still be applied but no archive copy will be made.

Example

declareUpdate();
temporal.documentProtect('bitemp','tempdoc3.xml',
    {archivePath: 'blah.xml', 
     expireTime: '2019-09-22T23:59:19.340475Z',
     duration: 'PT5D'})

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.