通过 REST 扩展调用库函数时出现以下错误:
{
"errorResponse": {
"statusCode": 500,
"status": "Internal Server Error",
"messageCode": "INTERNAL ERROR",
"message": "RESTAPI-INVALIDREQ: (err:FOER0000) Invalid request: reason: Extension citedByCount or a dependency does not exist: XDMP-MODNOTFOUND: (err:XQST0059) xdmp:annotation(xdmp:function(fn:QName(\"http://marklogic.com/rest-api/resource/citedByCount\",\"post\"), \"/marklogic.rest.resource/citedByCount/assets/resource.xqy\"), xs:QName(\"rapi:transaction-mode\")) -- Module /opt/MarkLogic/Modules/MarkLogic/semantics.xqy not found . See the MarkLogic server error log for further detail."
}
}
关键部分:“未找到模块/opt/MarkLogic/Modules/MarkLogic/semantics.xqy”。
如果我在查询控制台中调用该函数,如下所示,它会起作用:
xdmp:eval(
'
import module namespace some = "http://example.org/some-lib" at "/lib/some-lib.xqy";
some:my-func("abc")
',
map:entry("userId", xdmp:user("my-user"))
)
如果我从 REST 扩展调用相同的函数,如下所示:
xquery version "1.0-ml";
module namespace resource = "http://marklogic.com/rest-api/resource/someResource";
import module namespace some = "http://example.org/some-lib" at "/lib/some-lib.xqy";
declare namespace rapi = "http://marklogic.com/rest-api";
declare %rapi:transaction-mode("update") function post(
$context as map:map,
$params as map:map,
$input as document-node()*
) as document-node()*
{
some:my-func("abc")
};
然后,当使用 my-user
调用时,我收到上述错误。该用户有一个角色;如果我向该角色授予除管理员之外的所有其他角色和权限,我会收到错误消息。如果我授予管理员权限,它就可以正常工作。
该库具有以下导入:
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
并调用以下sem
函数:
sem:iri
sem:sparql
sem:graph-delete
sem:三重
sem:rdf-insert
关于为什么会发生这种情况有什么想法吗?
最佳答案
This answer from Erik Hennum有关键提示:
For the permissions to work, the main module and each library in the dependency chain must be executable by at least one role assigned to the user (where assignment includes inheritance and amping).
@ehennum 随后引用了 rest-extension-user
角色。
我将“rest-extension-user,read,rest-extension-user,execute”添加到 ml-gradle 的 mlModulePermissions
属性中,并且它起作用了。
关于marklogic - 为什么需要管理员才能查看 REST 扩展的语义库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65830220/