Update the JCR content properties

Nandujee

04-09-2017

Hello All,

Currently, I am working on the migration script where the script will get all 'par' and component of the JCR:Content and search for particular value in all property and update the value on the property.

Sample page structure :

XXX- page

    - jcr:content

       - par1

           |- image property - XXXXX

        -title

        - par2

           |- text property - YYYYY

           |-title

           |- title_0

           |-text-0

YYYY- page

   - jcr:content

      - par1

          |- image property - XXXXX

       -title

       - par2

          |- text property - YYYYY

          |-title

          |- title_0

          |-text-0

Example:

image . - > property - XXXXX

text-0 . - > property - YYYYY

after the script excution

image . - > property - ZZZZZZ

text-0 . - > property - QQQQQ

Code snippet:

  node node = (Node) NodeItr.nextNode();

  NodeIterator NodeItrs = node.getNodes();

  while (NodeItrs.hasNext()) {

  Node node1 = (Node) NodeItrs.nextNode();

----search and update proprery logic----

  if (node1.hasNodes()) {

  NodeIterator NodeItr2 = node1.getNodes();

  while (NodeItr2.hasNext()) {

  Node node2 = (Node) NodeItr2.nextNode();

     ----search and update proprery logic----

}

.....

...

....

while (NodeItr10.hasNext()) {

  Node node10 = (Node) NodeItr10.nextNode();

----search and update proprery logic----

}

}

So I have to read each and every node and find the property. Property will be updated with new value.

My Question :

1. Is there any optimal way to search for the JCR content property?

2. Say if the parent node contains 10 children, I have to read 10 children contents and search the particular property(code snippet). suggest me the optimal way to search for the jcr:content

Thanks

Nanda