How to custmize default sling content exporter behaviour in AEM? | Community
Skip to main content
Mario248
New Participant
June 15, 2022
Solved

How to custmize default sling content exporter behaviour in AEM?

  • June 15, 2022
  • 3 replies
  • 1982 views

I want to export the entire page to front end application. The page may contain 1 or 2 text component and image etc. Need to expose all of it is content. for example, http://localhost:4502/editor.html/content/we-retail/language-masters/en/men.model.tidy.json. This will give me the entire page content but along with some misc properties, like lastModifiedDate, allowedComponents, replicatedBy.

 

 

Is there a way to exclude these properties (lastModifiedDate, allowedComponents etc)?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sunil_kumar_

Hi @mario248 ,
Ideally you should not customised existing servlet. If your page structure is fixed or at least you know combinations of components. Then you can easily write a resource type servlet to expose/export required custom content. Add some different selector to differentiate from default servlet.  

3 replies

sunil_kumar_
sunil_kumar_Accepted solution
New Participant
June 16, 2022

Hi @mario248 ,
Ideally you should not customised existing servlet. If your page structure is fixed or at least you know combinations of components. Then you can easily write a resource type servlet to expose/export required custom content. Add some different selector to differentiate from default servlet.  

Mario248
Mario248Author
New Participant
June 16, 2022

Thank you for your valuable input

SantoshSai
New Participant
June 15, 2022

Hi @mario248 ,

As per @pallavi_shukla_ suggested yes, you can do it through Sling Model Exporter by annotating @JsonIgnore to the variable which you don't want to expose.

fore more details please have a look at this article: https://experienceleague.adobe.com/docs/experience-manager-learn/foundation/development/develop-sling-model-exporter.html?lang=en

Hope that helps you!

Regards,

Santosh

Santosh Sai
Mario248
Mario248Author
New Participant
June 15, 2022

Yeah I know we can create a model class for a specific component meaning we can create a model class for specific resource type but how do we do it for the entire page? like in my description, I want to export the entire page (/content/we-retail/language-masters/en/men.model.tidy.json) meaning all the component content to be exported. how do we do this at page level ?

 

Also please tell if we can tweak OOTB exporter with exclude properties ?

SantoshSai
New Participant
June 15, 2022

@mario248 honestly, I'm not sure whether we can able to tweak OOTB API. 

However, to answer your first question - please refer this article to customize page properties: https://www.linkedin.com/pulse/how-customize-properties-image-converted-json-aem-65-ragul-r

 

Santosh Sai
Pallavi_Shukla_
New Participant
June 15, 2022

hi @mario248 

 

You can implement a custom model and then pick the properties you want to have in the json.

 

Thanks,

Pallavi Shukla