简体   繁体   English

如何在Adobe CQ5中按名称查找节点

[英]How to find a node by name in adobe cq5

I am trying to find out the best way to get the Node in repository by its name. 我正在尝试找出按名称获取存储库中节点的最佳方法。 I can make sure that no 2 nodes will have the same name in the repository. 我可以确保没有两个节点在存储库中具有相同的名称。

I can write a recursive code to get the node by name but that can degrade the system performance if my node is at root --> level 1000 --> level 1k 我可以编写一个递归代码来按名称获取节点,但是如果我的节点位于root-> 1000级-> 1k级,则会降低系统性能。

if Adobe CQ5(CRX) provides any api to do the same? 如果Adobe CQ5(CRX)提供了任何API来执行相同的操作?

Use a JCR query: 使用JCR查询:

String query = "SELECT * FROM [nt:base] AS s WHERE NAME(s) = '%s'";
resourceResolver.findResources(String.format(query, "node-name"), "JCR-SQL2");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM