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

Approach for page manipulation operations

Avatar

Level 9

Hi All,

PFA, for a basic front end page created in crxde-lite. 

Details as below :

- Want to update a page property,for huge number of pages.Each page has different property value which has to be replaced with corresponding new set of values.

- Just to test couple of pages, thinking will enter the page in front end page(created by this jsp) and integrate this jsp[attached] with a java code. But not getting how this is to be done.

- Can someone suggest a better approach/snippet of code.

Any thoughts will be really helpful.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

When you can define an algorithm how these 70k pages are updates, then it's best to use a modification method inside AEM. For the begin a simple servlet might be ok. You can even omit the UI (form) part and just start with the modification code itself. You can implement it in AEM as a Sling servlet and do the modification inside the POST. See [1] for a description how to do Sling servlets.

kind regards,
Jörg

[1] https://sling.apache.org/documentation/the-sling-engine/servlets.html

View solution in original post

9 Replies

Avatar

Employee Advisor

Hi,

have you ever checked the bulk editor [1]? It might the solution you were looking for but it enables you too change lot of content pages in a very intuitive way.

kind regards,
Jörg

[1] http://localhost:4502/etc/importers/bulkeditor.html,

Avatar

Level 10

A page is like any other resource in the JCR.  Lets assume we want to change title prop on this page:

/content/xtype2 (this is a page of type cq:Page)

You can manipulate node props via the JCR API. THerefore updating page properties can be done using JCR API. Once you post the path of the node, programmatically change the properties using the JCR API.  

           Node root = session.getRootNode(); 
          
          // Retrieve content 
          Node node = root.getNode("content/xtype2/jcr:content"); 
          node.setProperty("jcr:title", "NewTitleProp");
              
          // Save the session changes and log out
          session.save(); 
          session.logout();

This change we made - as shown here:

[img]CoolPageChange.png[/img]

Avatar

Level 9

Hi Jorg,

Thanks a lot for your reply.

Suppose if I have 70k+ pages and need to change few custom properties on all of them

- Probably this would be the best approach?

- If we make use of this, we can export the tsv file from bulk editor,do the necessary manipulation[ probably by some program]. But how do we put the new values back into cq. I mean how do we import pages with new values, back into the system.

Avatar

Level 9

Hi Scott/All,

Thank you for your reply.

PFA, wherein I am able to set one property of a page correctly.

But,if I want to 

-Update a multi-valued property with 3 values in it, how is that to be done.

-Also, is this approach correct for multiple pages at a time.

Any code snippet/pointers will be helpful.

Avatar

Level 9

Hi All,

Any thoughts on this will be helpful.

Avatar

Correct answer by
Employee Advisor

Hi,

When you can define an algorithm how these 70k pages are updates, then it's best to use a modification method inside AEM. For the begin a simple servlet might be ok. You can even omit the UI (form) part and just start with the modification code itself. You can implement it in AEM as a Sling servlet and do the modification inside the POST. See [1] for a description how to do Sling servlets.

kind regards,
Jörg

[1] https://sling.apache.org/documentation/the-sling-engine/servlets.html

Avatar

Level 9

Hi Jorg,

Thank you for your reply.

Actually we are planning to take data related to 70k pages from a database, wherein all the metadata related to pages are stored.

This being the case, probably we were thinking we will take the page along with two custom properties[single/multi valued] we want to change
in a file.Compare the property values with the new values, with which it has to be replaced and then import via Bulk editor.

Please let us know your thoughts on this.