通过路径获取Alfresco NodeRef [英] Get Alfresco NodeRef by path
问题描述
我想获取Alfresco中存储的文档(或空间)的NodeRef.
I want to get the NodeRef of a document (or space) stored in Alfresco.
我的代码是Java语言,在Alfresco(例如AMP)中运行.
My code is in Java, running within Alfresco (for instance in an AMP).
我不在乎竞争条件,因为我只会将其用于我肯定已经存在了几天的节点.
I don't care about race conditions, as I will only use this for nodes that I know for sure have existed for days already.
怎么办?
推荐答案
最简单的方法可能是使用 XPath locatorName +一个xpath表达式
The easiest way is probably using the NodeLocatorService and the XPath locatorName + an xpath expression
使用搜索服务的内幕,但是它为您带来了很多复杂性!
Under the hood, that uses the search service, but it wraps up a lot of the complexity for you!
要使用它,请将NodeLocatorService
注入到您的bean中,然后执行以下操作:
To use it, get the NodeLocatorService
injected into your bean, then do something like:
Map<String,Serializable> params = new HashMap<>();
params.put("query", "/x:path/to:node/pa:th");
NodeRef nodeRef = nodeLocatorService.getNode("xpath",null,params);
其他存在NodeLocators 用于其他查找,也可以通过/alfresco/service/api/nodelocator/{node_locator_name}?params
远程访问.
Other NodeLocators exist for other lookups, and it's also available remotely via /alfresco/service/api/nodelocator/{node_locator_name}?params
这篇关于通过路径获取Alfresco NodeRef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!