Using the JCR API to access a CRX child node | Community
Skip to main content
Level 2
October 16, 2015
Solved

Using the JCR API to access a CRX child node

  • October 16, 2015
  • 1 reply
  • 734 views

I'd like to use the JCR API to access a node underneath a folder.

I am here: /content/dam/Agility project/agility_products/wm/wmap/wmapsp (this is a sling:orderedFolder)

but I want to point here instead: /content/dam/Agility project/agility_products/wm/wmap/wmapsp/wmapsp.jpg (this is a dam:Asset)

So I want to go one level down from the orderedFolder to the dam:Asset just underneath it. How to I do that through the JCR API please?

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Read this developer article - it uses JCR API to search JCR from an external Java Swing app:

https://helpx.adobe.com/experience-manager/using/java-swing-applications.html

You can search the current folder like this:

String path = node.getPath();
   String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%' AND NOT jcr:path LIKE '"+path +"/%/%'";
 
  javax.jcr.query.Query query = qm.createQuery(sql, Query.SQL);
  //Execute the query and get the results ...
  javax.jcr.query.QueryResult result = query.execute();

Here is a good online resource for more information about JCR SQL/SQL2:

http://docs.jboss.org/jbossdna/0.7/manuals/reference/html/jcr-query-and-search.html

1 reply

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Read this developer article - it uses JCR API to search JCR from an external Java Swing app:

https://helpx.adobe.com/experience-manager/using/java-swing-applications.html

You can search the current folder like this:

String path = node.getPath();
   String sql= "SELECT * FROM sling:Folder WHERE jcr:path LIKE '"+path +"/%' AND NOT jcr:path LIKE '"+path +"/%/%'";
 
  javax.jcr.query.Query query = qm.createQuery(sql, Query.SQL);
  //Execute the query and get the results ...
  javax.jcr.query.QueryResult result = query.execute();

Here is a good online resource for more information about JCR SQL/SQL2:

http://docs.jboss.org/jbossdna/0.7/manuals/reference/html/jcr-query-and-search.html