String aemUrl = "http://localhost:4502/crx/server" ; //Create a connection to the CQ repository running on local host Repository repository = JcrUtils.getRepository(aemUrl);
//Create a Session javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));
//Obtain the query manager for the session ... javax.jcr.query.QueryManager queryManager = session.getWorkspace().getQueryManager();
//Specify the AEM JCR path where examples users are stored at /home/users/test
String sqlStatement = "select * from [cq:PageContent] as p where isdescendantnode (p, [/content/geometrixx])";
//Execute the query and get the results ... javax.jcr.query.QueryResult result = query.execute();
//Iterate over the nodes in the results ... javax.jcr.NodeIterator nodeIter = result.getNodes();
long mySize = nodeIter.getSize();
while ( nodeIter.hasNext() ) {
//For each node-- get the path of the node javax.jcr.Node node = nodeIter.nextNode();
//check to see if node has jcr.title String title = "" ; if (node.hasProperty("jcr:title")) { title = node.getProperty("jcr:title").getString() ; System.out.println(title); }
}
// Save the session changes and log out session.save(); session.logout();
} catch(Exception e){ e.printStackTrace(); }
}
}
This give me the result set:
Board of Directors Press Center Press Center Asset Editor Press Center Asset Viewer Discover Geometrixx Company News Articles Press Releases Management Team Search Community GeoBlog TechSummit DSC Berlin Events User Conference Event Edit Form Event View Form ShapeCon Las Vegas Customer Satisfaction Survey Thank you Support English Newsletter Sitemap Account Request Thank You Account Login My Geometrixx Search Change Password Success View Profile Profiles Edit Profile Forgot Password Thank You Toolbar Contact Feedback Overview Square Features Overview Mandelbrot Set Features Products Overview Circle Features Overview Triangle Features Banking Services Strategic Consulting Services Certification Services Empresa Comunidad Eventos Soporte Español Productos Servicios Azienda Forum Eventi Supporto Italiano Prodotti Servizi Société Communauté Événements Support Français Produits Services 会社 コミュニティ イベント サポート 日本語 製品 サービス 公司 社区 事件 支持 简体中文 产品 服务 Unternehmen Community Events Support Deutsch Produkte Dienstleistungen