Created
July 10, 2017 21:18
-
-
Save ableasdale/b2d4caa5515a04c44085a8db1134fc30 to your computer and use it in GitHub Desktop.
MarkLogic: Import permissions from Security Database
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"; | |
declare variable $DATABASE-NAME as xs:string := "Security-Extra"; | |
if (xdmp:database-name(xdmp:database()) eq $DATABASE-NAME ) | |
then( | |
for $i in cts:uris() | |
let $perm := xdmp:eval('xquery version "1.0-ml"; | |
declare variable $URI as xs:string external; | |
xdmp:document-get-permissions( $URI )', | |
(xs:QName("URI"), $i), | |
<options xmlns="xdmp:eval"> | |
<database>{xdmp:database("Security")}</database> | |
</options>) | |
return xdmp:document-set-permissions($i, $perm) | |
) | |
else(fn:error(xs:QName("CONFIGURATION-ERROR"), concat("Database / Content Source not set correctly - expecting ", $DATABASE-NAME, " and instead found ", xdmp:database-name(xdmp:database())) )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment