Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Access Node hierarchy(includes : child(s) / user defined jcr :content ) for a given node path

Avatar

Level 2

Hi all, 

I need to show the node hierarchy (tree view) based on the node path provided.

For example if path is like : /content/samples/assets/images

      I need to List all the child nodes , files , resource types, assets that are under the given node path. and populate it in html page using tree view structure, I mean to say same structure the node has in CRXDE Lite.

I hope you understand my question.

Please help me fetch all the nodes , childs, files, resources, cr content under the specified node to build same tree view/hierarchical structure with expand (+) buttons to access sub nodes/child(s) from the html page by user

 

any suggestion is greatly appreciated.+

Thanks

 

Shabarinadh.V

1 Accepted Solution

Avatar

Correct answer by
Level 10

To query the AEM JCR (and child nodes) - you should use the JCR API (JCR-SQL).

See this article for a good discussion on using JCR SQL:

http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html

For your use case -- i would consider using JCR SQL. You can build algorithms to query child nodes and thier child nodes, etc. Then place the results in a collection to track them. 

There are some examples here of querying children nodes:

http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html#d0e3517

If you are going to build JCR API logic from within an OSGi bundle -- you will want to read this community article. It talks about using the JCR API to query AEM data from within a bundle:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

View solution in original post

3 Replies

Avatar

Level 2

Hi, 

I tried to pull data for a path like : /content/samples/assets/images 

using 

string url = http://host ip:4502//content/samples/assets/images.xml

var webrequest = new httpwebreqeust(url);

//pass credentials

httpwebresponse response = webrequest.getresponse()

string resultxml = response.getresponsestream().readtoend();

            xmldocument xdoc = new xmldocument();

xdoc.loadxml( resultxml);

//loop through xdoc and build tree view.   

 

but,  I feel this is not the correct way , looking for some other ways to achieve the same, 

I am looking for query builder to query assets and fetch xml

 

do u have any idea/suggestions?

Avatar

Correct answer by
Level 10

To query the AEM JCR (and child nodes) - you should use the JCR API (JCR-SQL).

See this article for a good discussion on using JCR SQL:

http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html

For your use case -- i would consider using JCR SQL. You can build algorithms to query child nodes and thier child nodes, etc. Then place the results in a collection to track them. 

There are some examples here of querying children nodes:

http://docs.jboss.org/exojcr/1.12.13-GA/developer/en-US/html/ch-jcr-query-usecases.html#d0e3517

If you are going to build JCR API logic from within an OSGi bundle -- you will want to read this community article. It talks about using the JCR API to query AEM data from within a bundle:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html