how to get content fragment model name from contentfragment object which support junit test case. | Community
Skip to main content
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 Ritesh_Mittal

Hi @sudarshan1992 ,

 

One solution could be to traverse till <content-fragment-path>/jcr:content/data node as a resource, fetch the 'cq:model' property and fetch using ValueMap.

 

Resource res = resourceResolver.getResource("/content/dam/<yourproject-cf-path>/<cf-name>/jcr:content/data");

 

ValueMap map = res.adaptTo(ValueMap .class);

String modelTitle = map.get("cq:model").toString();

 

Thanks,

Ritesh Mittal

 

1 reply

Ritesh_Mittal
Community Advisor and Adobe Champion
Ritesh_MittalCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
March 23, 2023

Hi @sudarshan1992 ,

 

One solution could be to traverse till <content-fragment-path>/jcr:content/data node as a resource, fetch the 'cq:model' property and fetch using ValueMap.

 

Resource res = resourceResolver.getResource("/content/dam/<yourproject-cf-path>/<cf-name>/jcr:content/data");

 

ValueMap map = res.adaptTo(ValueMap .class);

String modelTitle = map.get("cq:model").toString();

 

Thanks,

Ritesh Mittal