通过路径获取Alfresco NodeRef(实时,安全的竞争条件)

编程入门 行业动态 更新时间:2024-10-23 05:48:13
本文介绍了通过路径获取Alfresco NodeRef(实时,安全的竞争条件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想获取存储在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).

我的代码需要在出现竞争条件时保持安全,例如,它必须找到之前创建的第二个节点。在这种情况下,不能使用常用方法(基于搜索)。

My code needs to be safe against race conditions, for instance it must find nodes that have been created a second before. In this context, the usual methods (search-based) can not be used.

怎么办?

推荐答案

您需要避免碰触任何东西SOLR,如那些API最终都是一致的

You need to avoid anything that touches SOLR, as those APIs are only Eventually Consistent

具体来说,您需要一个基于 canned的API查询。您的用例主要是 NodeService.getChildAssocs 和 NodeService.getChildByName 。某些 FileFolderService

Specifically, you need an API that's based on canned queries. The main ones for your use-case are NodeService.getChildAssocs and NodeService.getChildByName. Some of FileFolderService will work immediately too

您最好的选择是将路径拆分为多个组件,然后通过它进行递归/循环下降。根据要使用名称( cm:name )还是QName(基于asoc),您将使用两个 NodeService之一方法

Your best bet would be to split a path into components, then do a recursive / looping descent through it. Depending on if you want it by Name (cm:name) or QName (based on the assoc), you'd use one of the two NodeService methods

例如(未完全测试...)

eg (not fully tested...)

String[] parts = path.split("\\/"); NodeRef nodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); for (String name : parts) { NodeRef child = nodeService.getChildByName(nodeRef, ContentModel.ASSOC_CONTAINS, name); if (child == null) throw new Exception("Path part not found "+name+" in "+path+" at "+nodeRef); nodeRef = child; } return nodeRef;

更多推荐

通过路径获取Alfresco NodeRef(实时,安全的竞争条件)

本文发布于:2023-11-28 13:03:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   实时   条件   竞争   NodeRef

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!