Question

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

if Adobe CQ5(CRX) provides any api to do the same?

Was it helpful?

Solution

Use a JCR query:

String query = "SELECT * FROM [nt:base] AS s WHERE NAME(s) = '%s'";
resourceResolver.findResources(String.format(query, "node-name"), "JCR-SQL2");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top