Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Update the JCR content properties

Nandujee
Level 3
Level 3

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

1 Accepted Solution
Veena_Vikram
Correct answer by
Community Advisor
Community Advisor

Hi Nanda

       Why are you not using Query Builder ? Check if these helps

https://hashimkhan.in/2015/12/02/query-builder/

Full Text Search in AEM using Query Builder | TO THE NEW Blog

Thanks

Veena

View solution in original post

4 Replies
Veena_Vikram
Correct answer by
Community Advisor
Community Advisor

Hi Nanda

       Why are you not using Query Builder ? Check if these helps

https://hashimkhan.in/2015/12/02/query-builder/

Full Text Search in AEM using Query Builder | TO THE NEW Blog

Thanks

Veena

View solution in original post

Veena_Vikram
Community Advisor
Community Advisor

I think this is more specific to AEM than AEM forms ?

Himanshu_Singhal
Community Advisor
Community Advisor

Hi Nanda,

You can use JCR SQL2 queries to perform the search operation.

Regards,

Himanshu

smacdonald2008
Level 10
Level 10

You are on the correct path - using JCR SQL/2 or QUeryBuilder (which is built on JCR API) is the way to proceed here.