Created
March 21, 2019 18:04
-
-
Save prestonmcgowan/0150567583238fb4b20f7e49a210f5d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
import module namespace sec="http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy"; | |
declare function local:get-role-names($role-ids) { | |
xdmp:invoke-function( | |
function() { | |
sec:get-role-names($role-ids) | |
}, | |
<options xmlns="xdmp:eval"> | |
<database>{xdmp:security-database()}</database> | |
</options> | |
) | |
}; | |
text { | |
"(", | |
fn:string-join( | |
for $p in xdmp:document-get-permissions("/sources/asdf/0687d420902_metadata.xml") | |
let $capability := $p/sec:capability/text() | |
let $role-name := local:get-role-names($p/sec:role-id/text()) | |
return fn:concat('xdmp:permission("', $role-name, '", "', $capability, '")') | |
, ", " | |
), | |
")" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output:
( xdmp:permission("rest-extension-user", "execute"), xdmp:permission("rest-admin", "update"), xdmp:permission("rest-admin", "read") )