从MarkLogic 8中的其余端点调用具有依赖性的xquery库 [英] Calling xquery libraries with dependencies from rest endpoints in MarkLogic 8

查看:44
本文介绍了从MarkLogic 8中的其余端点调用具有依赖性的xquery库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从MarkLogic 6升级到8,并且在调用库模块时遇到了一些问题.我们有从自定义REST扩展和非REST xquery调用的xquery库模块.

We're in the process of upgrading from MarkLogic 6 to 8 and have run into some problems calling library modules. We have xquery library modules that are called both from custom REST extensions and from non-REST xquery.

MarkLogic的文档表示REST端点可以使用通过以下方式安装的库他们的新/ext端点或库以旧方式安装(放置在模块数据库中的其他位置).但是,例如当库模块使用MarkLogic随附的functx包时,我无法使分频器正常工作.

MarkLogic's documentation says that REST endpoints can use libraries installed either with their new /ext endpoint or libraries installed the old way (placed somewhere else in the modules database). However, when the library module is using, for example, the functx package that comes with MarkLogic, I can't get the cross-over to work.

说我有两个相同的库模块,一个是通过/ext安装的,另一个不是:

Say I have two identical library modules, one installed via /ext and one not:

xquery version "1.0-ml";
module namespace test = "test/lib";
import module namespace functx = "http://www.functx.com" at "/MarkLogic/functx/functx-1.0-nodoc-2007-01.xqy";
declare function test:stuff() { 
    <foo/>
};

第一个使用此命令安装,以防万一:

The first is installed using this command, in case it matters:

curl --anyauth --user user:pwd -X PUT -i -d @".\\module\\testlib-ext.xqy" -H "Content-type: application/xquery" "http://host:8020/v1/ext/test/testlib-ext.xqy?perm:rest-reader=execute"

我有使用每个模块的其余端点(唯一的区别是名称空间和导入):

I have rest endpoints that use each module (the only difference is the namespace and import):

xquery version "1.0-ml";
module namespace te = "http://marklogic.com/rest-api/resource/test-ext-to-ext";
import module namespace test = "test/lib" at "/ext/test/testlib-ext.xqy";
declare function te:get($context as map:map, $params as map:map) as document-node()* {
    document { test:stuff() }
};

使用使用/ext安装的库的计算机可以工作.使用简单地放在模块数据库中的模块的安装程序不会出现错误,但是当由非管理员用户调用时会给我一个错误(当由管理员调用时有效):

The one using the library installed using /ext works. The one using the module that's simply placed in the modules database installs without errors but gives me an error when called by a non-admin user (it works when called by admin):

RESTAPI-INVALIDREQ: (err:FOER0000) Invalid request:  reason: Extension test-ext-to-lib does not exist.

我只是使用/ext安装它们,但是使用xdmp:invoke的xquery会中断.这是一个不同的错误,但似乎是相同的潜在问题.使用放置在模块数据库中的库调用模块是可行的.使用通过/ext安装的库调用模块失败,并显示以下错误:

I'd just install them all using /ext, but then xquery that uses xdmp:invoke breaks. It's a different error, but it seems to be the same underlying issue. Invoking a module using the library placed in the modules database works. Invoking a module using the library installed via /ext fails with this error:

XDMP-MODNOTFOUND: (err:XQST0059) xdmp:invoke("/test/test-module-to-ext.xqy", (), ()) -- Module C:\Program Files\MarkLogic\Modules\MarkLogic\functx\functx-1.0-nodoc-2007-01.xqy not found

如果我将admin角色添加到主叫用户,则所有这些都可以工作.如果我将functx导入,即使没有管理员角色,它们也可以工作.

If I add the admin role to the calling user, all of them work. They also work even without the admin role if I take the functx import out.

这似乎是权限问题,但我找不到能解决该问题的角色或权限.用户具有除复选框admin本身之外的每个复选框的角色.我发现只有最后一个复选框能够使这项工作有效,这显然不是可行的解决方案.

It looks like a permission problem, but I can't find a role or permission that will fix it. The user has a role with every checkbox except admin itself checked. Checking that last checkbox is the only thing I've found that makes this work, and that's obviously not a viable solution.

我们并不真的在乎库的安装方式,但是我们不想重复代码.我们如何才能使这些导入与REST和非REST xquery一起使用?

We don't really care how the libraries are installed, but we don't want to duplicate code. How can we make these imports work with both REST and non-REST xquery?

推荐答案

要获得许可,主模块和依赖关系链中的每个库必须可以由分配给用户的至少一个角色执行(其中分配包括继承)和电流).

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).

REST API在安装在/ext下的模块上设置rest-extension-user角色.

The REST API sets the rest-extension-user role on modules that it installs under /ext.

因此,具有rest-extension-user角色的用户应该能够在/ext下调用REST API安装的模块.

So, a user who has the rest-extension-user role should be able to invoke a module installed by the REST API under /ext.

通常,任何由rest-extension-user角色执行的模块(无论其安装方式如何)都应能够依赖REST API在/ext下安装的库(当然,假设所有路径正确).

More generally, any module (regardless of how it is installed) that is executable by the rest-extension-user role should be able to have dependencies on libraries installed by the REST API under /ext (assuming, of course, that all paths are correct).

这篇关于从MarkLogic 8中的其余端点调用具有依赖性的xquery库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆