How to get absolute page path of the live copies from the source/master path | Community
Skip to main content
vijays80591732
Level 3
December 7, 2020
Solved

How to get absolute page path of the live copies from the source/master path

  • December 7, 2020
  • 1 reply
  • 1777 views

Hello Guys,

 

I have the master page "/content/we-retail/ca/en/experience/climbing-in-the-massif-du-mont-blanc" and I have created live copies for the below markets,

 

au - /content/we-retail/au/en/experience/climbing-in-the-massif-du-mont-blanc

nz - /content/we-retail/nz/en/experience/climbing-in-the-massif-du-mont-blanc

 

I'm trying to get the live copy URL's from the master page. I have tried with the below code, but it's returning up to the market level ("content/we-retail/au/en",/content/we-retail/nz/en) and not the absolute path.

 

I wanted to get the exact path of the live copy URL "/content/we-retail/nz/en/experience/climbing-in-the-massif-du-mont-blanc". Any idea? 

 

String itemPath = "/content/we-retail/ca/en/experience/climbing-in-the-massif-du-mont-blanc";
Resource res = resourceResolver.getResource(itemPath);
RangeIterator rangeIterator = liveRelManager.getLiveRelationships(res,"",null);
while (rangeIterator.hasNext())
{
LiveRelationship liveCopy =(LiveRelationship) rangeIterator.next();
log.debug("LiveCopies URL's..." + liveCopy.getLiveCopy());

}

@14414417 @vijayalakshmi_s @veenavikraman @ratna_kumar @kautuk_sahni @smacdonald2008 @brijeshyadav 

 

Regards,

Vijay

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 Manjunath_K

Hi @vijays80591732 ,

Use liveCopy.getTargetPath() instead of liveCopy.getLiveCopy() as highlighted below, it will return the absolute path of the live sync resource.

 

https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/msm/api/LiveRelationship.html

 

String itemPath = "/content/we-retail/ca/en/experience/climbing-in-the-massif-du-mont-blanc";
Resource res = resourceResolver.getResource(itemPath);
RangeIterator rangeIterator = liveRelManager.getLiveRelationships(res,"",null);
while (rangeIterator.hasNext())
{
LiveRelationship liveCopy =(LiveRelationship) rangeIterator.next();
log.debug("LiveCopies URL's..." + liveCopy.getTargetPath()); //returns the absolute path of the live sync resource.

}

 

Hope this helps!

1 reply

Manjunath_K
Manjunath_KAccepted solution
Level 7
December 7, 2020

Hi @vijays80591732 ,

Use liveCopy.getTargetPath() instead of liveCopy.getLiveCopy() as highlighted below, it will return the absolute path of the live sync resource.

 

https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/com/day/cq/wcm/msm/api/LiveRelationship.html

 

String itemPath = "/content/we-retail/ca/en/experience/climbing-in-the-massif-du-mont-blanc";
Resource res = resourceResolver.getResource(itemPath);
RangeIterator rangeIterator = liveRelManager.getLiveRelationships(res,"",null);
while (rangeIterator.hasNext())
{
LiveRelationship liveCopy =(LiveRelationship) rangeIterator.next();
log.debug("LiveCopies URL's..." + liveCopy.getTargetPath()); //returns the absolute path of the live sync resource.

}

 

Hope this helps!

vijays80591732
Level 3
December 7, 2020
Thanks, Manjunath. It's worked.