Reputation: 137
how to check permission on a document whether it has any update/read permission or not, if there is no permission on the document in marklogic? For example :
let $schema := fn:doc($schema-uri)/xs:schema
return
else if (fn:exists ($schema)) then ()
else
fn:error(xs:QName('e:no-schema'), 'The schema does not exist.', $schema-uri)";
In this case, if $schema-uri does not have any permission it will goes to else condition as fn:doc($schema-uri) does not able to read the document and it is mapped to "The schema does not exist" error which is incorrect as the schema exist but have not any permissions on it. So how can I handle it in condition if the schema exist but does not have any permission on it.
Upvotes: 0
Views: 78
Reputation: 7770
To get the permissions of a document, xdmp:document-get-permissions().
This will get you a sequence of permissions. In that will be references to role-ids. If you want to know the associated role names, You can pass the IDs to xdmp:role-names()
However... I strongly suggest that you refrain from adding documents into any database (modules, schemas, etc) without permissions. As quickly as possible step away from using Admin for any type of work.
Upvotes: 1