Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过路径获取露天场地(实时,比赛条件安全)_Java_Alfresco - Fatal编程技术网

Java 通过路径获取露天场地(实时,比赛条件安全)

Java 通过路径获取露天场地(实时,比赛条件安全),java,alfresco,Java,Alfresco,我想获取存储在Alfresco中的文档(或空间)的节点 我的代码是Java,在Alfresco中运行(例如在AMP中) 我的代码需要在竞争条件下是安全的,例如,它必须找到前一秒创建的节点。在此上下文中,不能使用(基于搜索的) 怎么做?你需要避免任何与SOLR有关的事情,例如 具体来说,您需要一个基于的API。您的用例主要有和。其中一些也将立即起作用 最好的办法是将路径拆分为多个组件,然后在其中进行递归/循环下降。根据您是按名称(cm:Name)还是按QName(基于assoc),您可以使用两种N

我想获取存储在Alfresco中的文档(或空间)的节点

我的代码是Java,在Alfresco中运行(例如在AMP中)

我的代码需要在竞争条件下是安全的,例如,它必须找到前一秒创建的节点。在此上下文中,不能使用(基于搜索的)


怎么做?

你需要避免任何与SOLR有关的事情,例如

具体来说,您需要一个基于的API。您的用例主要有和。其中一些也将立即起作用

最好的办法是将路径拆分为多个组件,然后在其中进行递归/循环下降。根据您是按名称(
cm:Name
)还是按QName(基于assoc),您可以使用两种
NodeService
方法之一

例如(未完全测试…)


此方法获取始终可用(至少从基于露天应用程序的角度来看)的公司主节点ref,然后使用不基于搜索的节点

预期路径的语法示例:
/Company Home/Shared/My Folder/123.txt

public NodeRef getNode(String path) {

    // Get company home NodeRef. No race condition because it is always exists.
    NodeRef companyHomeNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Get NodeRef for the path using path elements and resolveNamePath.
    List<String> pathElements = new LinkedList<>(Arrays.asList(path.split("/")));
    pathElements.remove(0); // Remove leading empty element before first slash
    pathElements.remove(0); // Remove Company Home element
    try {
        FileInfo fileInfo = fileFolderService.resolveNamePath(
                companyHomeNode, pathElements);
        return fileInfo.getNodeRef();
    } catch (FileNotFoundException e) {
        return null; // No node with such a path.
    }
}
public节点ref getNode(字符串路径){
//将公司总部设为NodeRef。无竞争条件,因为它始终存在。
NodeRef companyHomeNode=nodeService.getRootNode(StoreRef.STORE\u REF\u WORKSPACE\u SPACESSTORE);
//使用path元素和resolveNamePath获取路径的NodeRef。
List pathElements=新的LinkedList(Arrays.asList(path.split(“/”));
pathElements.remove(0);//在第一个斜杠之前删除前导的空元素
pathElements.remove(0);//删除公司主元素
试一试{
FileInfo FileInfo=fileFolderService.resolveNamePath(
公司母节点、路径元素);
返回fileInfo.getNodeRef();
}catch(filenotfounde异常){
返回null;//没有具有此路径的节点。
}
}

公共域,可以自由编辑和改进:-)

至少在某种程度上支持事务查询。

FileFolderService.resolveNamePath
调用
searchSimple()
方法,此方法调用
nodeService.getChildByName()
。因此,我建议直接调用
nodeService.getChildByName()
而不是调用
FileFolderSerivce.resolveNamePath()
方法。谢谢您的提示!我的目标是不重新发明轮子,因此只执行一次调用,而不是自己实现循环。但是重视性能而不是重用的项目应该使用Gagravarr的解决方案(事实上:-)当不同的用户调用不同的Web脚本同时修改相同的节点时,您能解释一下这会有帮助吗?谢谢!:-)
public NodeRef getNode(String path) {

    // Get company home NodeRef. No race condition because it is always exists.
    NodeRef companyHomeNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Get NodeRef for the path using path elements and resolveNamePath.
    List<String> pathElements = new LinkedList<>(Arrays.asList(path.split("/")));
    pathElements.remove(0); // Remove leading empty element before first slash
    pathElements.remove(0); // Remove Company Home element
    try {
        FileInfo fileInfo = fileFolderService.resolveNamePath(
                companyHomeNode, pathElements);
        return fileInfo.getNodeRef();
    } catch (FileNotFoundException e) {
        return null; // No node with such a path.
    }
}