我正在开发一个基于REST API的Alfresco客户端。但是我还没有找到一个方法,允许用它的路径来检索一个节点。
[ base url: /alfresco/api/-default-/public/alfresco/versions/1 , api version: 1 ]
你能告诉我怎么做吗?
7uhlpewt1#
下面的代码将从文件夹/文件路径返回您所期望的noderef。
public static void main(String[] args) throws IOException { client = new AlfrescoClient.Builder().connect("http://localhost:8080/alfresco", "admin", "admin").build(); NodeRepresentation node = findNodeByPath("Sites/testsite/documentLibrary/TestFolder/UploadTest.txt"); System.out.println(node == null ? "null" : node.getName()); } private static NodeRepresentation findNodeByPath(String path) throws IOException { if (path.startsWith("/")) path = path.substring(1); if (path.endsWith("/")) path = path.substring(0, path.length() - 1); return findNodeByPath("-root-", path); } private static NodeRepresentation findNodeByPath(String parentNodeId, String path) throws IOException { String[] pathParts = path.split("/"); String name = pathParts[0]; String remaining = pathParts.length == 1 ? "" : path.substring(name.length() + 1, path.length()); List<NodeRepresentation> children = client.getNodesAPI().listNodeChildrenCall(parentNodeId).execute().body() .getList(); for (NodeRepresentation child : children) { if (child.getName().equals(name)) { return pathParts.length == 1 ? child : findNodeByPath(child.getId(), remaining); } } return null; }
eqfvzcg82#
你可以尝试使用AFTS和PATH操作符,它应该工作。你基本上是在写一个查询,而不是使用一个特定的API方法来"按路径查找"。例如:
{ "query": { "language": "afts", "query": "PATH:'/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Agency_x0020_Files//*' OR PATH:'/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Budget_x0020_Files//*'" } }
2条答案
按热度按时间7uhlpewt1#
下面的代码将从文件夹/文件路径返回您所期望的noderef。
eqfvzcg82#
你可以尝试使用AFTS和PATH操作符,它应该工作。你基本上是在写一个查询,而不是使用一个特定的API方法来"按路径查找"。例如: