marklogic - 为什么需要管理员才能查看 REST 扩展的语义库?

标签 marklogic

通过 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/

相关文章:

xquery - 如何使节点变量摆脱错误

MarkLogic - 如何使用 Java API 进行集合删除?

sparql - 如何优化返回可选属性的 SPARQL 查询?

javascript - MarkLogic:MarkLogic 数据中心 Content.sjs 中的协调错误

database - 有没有办法在 XQuery 中获取 MarkLogic 服务器中的所有数据库名称?

marklogic - 如何在 Apache Tomcat 中部署 Marklogic XCC 库?

javascript - 空 JSON 数组的 MarkLogic Javascript 查询

marklogic - 在 Marklogic 中使用 REST API 运行数据中心流时遇到问题

database - 如何完全删除 MarkLogic 数据库及其服务器和林?

node.js - 尝试对日期时间索引上的 MarkLogic 集合查询结果进行排序