Expand my Community achievements bar.

SOLVED

Using the JCR API to access a CRX child node

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

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