Extracting the Page resources(Sling resource type, name, template, title, description) | Community
Skip to main content
Level 6
Sep 8, 2021 8:59 AM UTC
Solved

Extracting the Page resources(Sling resource type, name, template, title, description)

I am creating the workflow to update the previously used components (Aem 6.0), to latest version so I want to write workflow to update its sling resource type, description for 15+ pages.

 

I am confused how to get the resource name, template name, title and description of new and old component update it accordingly used Java workflows. 

 

If possible help me in writing the workflow to extract Sling resource type, name, template, title and description of new component that would also help a lot .

Thanks in advance

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
Sep 8, 2021 9:09 AM UTC

You can build a logic in Java which will iterate through all the pages that you want and will try to retrieve the JSON value. Now convert the JSON to Java Objects and then retrieve whatever information is required from the JSON.

 

Thanks!

6 replies

Kiran_Vedantam
New Participant
Sep 8, 2021 12:26 PM UTC

Hi @ronnie09,

 

You can extract the properties of any node via java using sling models as explained by me here. If you are not interested in doing it via models, you can do it by adapting it to other classes which I have mentioned in the same post. 

 

Hope this helps!

 

Thanks,

Kiran Vedantam.

Translate
Ronnie09Author
Level 6
Sep 8, 2021 2:18 PM UTC

Will give a try.

Translate
Asutosh_Jena_
New Participant
Sep 8, 2021 9:02 AM UTC

Hi @ronnie09 

 

If you access any of the page with .infinity.json as the extension, you can see the complete page information.

 

Here is a sample:

http://localhost:4502/content/we-retail/ca/en/experience.infinity.json

 

Thanks!

Translate
Ronnie09Author
Level 6
Sep 8, 2021 9:07 AM UTC

Can you help me extracting the same (Sling resource type, name, template, title, description) using the Java code or provide some other link

 

Translate
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
Sep 8, 2021 9:09 AM UTC

You can build a logic in Java which will iterate through all the pages that you want and will try to retrieve the JSON value. Now convert the JSON to Java Objects and then retrieve whatever information is required from the JSON.

 

Thanks!

Translate