Created
August 8, 2016 20:33
-
-
Save rogerblanton/a2ea832644edd97d81c228efc44b1cb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void visitRecursively(Node node, Session currentSession) { | |
try{ | |
NodeIterator list = node.getNodes(); | |
while(list.hasNext()) { | |
Node childNode = list.nextNode(); | |
// Verify child node for cqPage type | |
if((childNode.hasProperty("jcr:primaryType")) && (childNode.getProperty("jcr:primaryType").getValue().getString()).equals("cq:Page") ){ | |
Node jcrNode = childNode.getNode("jcr:content"); | |
// Iterate some of the page properties | |
String articleTitle="";String jcrDesc="";String jcrTitle="";String keywords=""; | |
if(jcrNode.hasProperty("articleTitle")){ | |
articleTitle = jcrNode.getProperty("articleTitle").getString(); | |
log.info("articleTitle--->"+articleTitle); | |
} | |
if(jcrNode.hasProperty("jcr:description")){ | |
jcrDesc = jcrNode.getProperty("jcr:description").getString(); | |
log.info("jcr:description--->"+jcrDesc); | |
} | |
if(jcrNode.hasProperty("jcr:title")){ | |
jcrTitle = jcrNode.getProperty("jcr:title").getString(); | |
log.info("jcr:title--->"+jcrTitle); | |
} | |
if(jcrNode.hasProperty("keywords")){ | |
keywords = jcrNode.getProperty("keywords").getString(); | |
log.info("keywords--->"+keywords); | |
} | |
String pagePropertiesString = "articleTitle--->"+articleTitle + "jcr:description--->"+jcrDesc+"jcr:title--->"+jcrTitle + "keywords--->"+keywords ; | |
log.info("Page Properties :---> Node "+ childNode.getName()+ "Properties : " + pagePropertiesString ); | |
} | |
visitRecursively(childNode,currentSession); | |
} | |
} catch (RepositoryException rpe){ | |
log.info("Exception in recursive listing:"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment