Loading TOC...

temporal:document-protect

temporal:document-protect(
   $temporal-collection as xs:string,
   $uri as xs:string,
   [$options as (element()|map:map)?]
) as empty-sequence()

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:collection-create 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. You can specify options in either an XML options element in the "temporal:document-protect" namespace, or as a map:map. The options names below are XML element localnames. When using a map, replace any hyphens in an option name with camel casing. For example, "an-option" becomes "anOption" when used as a map:map key. 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.
expire-time
Exact date and time when the protection expires. Useful for idempotency. Overrides the duration option for expiration time computation.
archive-path
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

temporal:document-protect("bitemp","tempdoc5.xml",
<options xmlns="temporal:document-protect"><archivePath>blah2.xml</archivePath>
<duration>P6Y</duration>
</options>)

Example

temporal:document-protect("bitemp", "tempdoc.xml",
map:map(<map:map xmlns:map="http://marklogic.com/xdmp/map">
 <map:entry key="archivePath">
   <map:value>world.xml</map:value>
 </map:entry>
 <map:entry key="expireTime">
   <map:value>2016-06-27T14:13:05.472585-07:00</map:value>
 </map:entry>
</map:map>))

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