Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp:default-permissions

xdmp:default-permissions(
   [$uri as xs:string],
   [$output-kind as xs:string]
) as element(sec:permission)*|map:map*

Summary

Returns the permissions any new document would get if the current user were to insert a document without specifying the default permissions.

Parameters
uri The document URI to get default permissions.
$output-kind The output kind. It can be either "elements" or "objects". With "elements", the built-in returns a sequence of XML elements. With "objects", the built-in returns a sequence of map:map. The default is "elements".

Example

(: Fetch permissions as elements (default behavior) :)
xdmp:default-permissions("http://example.com/content/foo.xml")

(: Returns a sequence of elements, such as the following:
 :
 : (<sec:permission>
 :    <sec:capability>read</sec:capability>
 :    <sec:role-id>324978243</sec:role-id>
 :  </sec:permission>,
 :  <sec:permission>
 :    <sec:capability>read</sec:capability>
 :    <sec:role-id>32493478578243</sec:role-id>
 :  </sec:permission>,
 :  <sec:permission>
 :    <sec:capability>update</sec:capability>
 :    <sec:role-id>32493478578243</sec:role-id>
 :  </sec:permission>)
 :)

Example

(: Fetch permissions for the current user, as json objects :)
xquery version "1.0-ml";
xdmp:default-permissions((), "objects")

(: Returns output similar to the following (rendered here as JSON):
 :
 :   {"capability":"read", "roleId":"14918370877051183774"}
 :   {"capability":"update", "roleId":"8487823278258687528"}
 :
 : The following is the underlying XML, which you can pass where an
 : Object or map:map is expected.
 :
 :   <json:object xmlns:json="http://marklogic.com/xdmp/json" 
 :       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 :       xmlns:xs="http://www.w3.org/2001/XMLSchema">
 :     <json:entry key="capability">
 :       <json:value xsi:type="xs:string">read</json:value>
 :     </json:entry>
 :     <json:entry key="roleId">
 :       <json:value xsi:type="xs:integer">14918370877051183774</json:value>
 :     </json:entry>
 :   </json:object>
 :   <json:object xmlns:json="http://marklogic.com/xdmp/json" 
 :       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 :       xmlns:xs="http://www.w3.org/2001/XMLSchema">
 :     <json:entry key="capability">
 :       <json:value xsi:type="xs:string">update</json:value>
 :     </json:entry>
 :     <json:entry key="roleId">
 :       <json:value xsi:type="xs:integer">8487823278258687528</json:value>
 :     </json:entry>
 :   </json:object>
 :)

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