Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
SOLVED

How to find live copies pages for a blueprint page

Avatar

Level 1

Hi All,

 

How can I find out live copies for a blueprint page in my servlet or any backend class (event listener - node move of type cq:Page)? I have tried the LiveRelationshipManager API but it was not working?

 

we get the live copies in the left side rail when select a blueprint page in sites.

 

Thanks in Advance

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hello @ASK_93 , The below piece of code is working fine for me to get the live relation copies from the master page.

 

LiveRelationshipManager liveRelationManager = resourceResolver.adaptTo(LiveRelationshipManager.class);
Resource resource = resourceResolver.getResource(<path to master page>);
try {
RangeIterator iterator = liveRelationManager.getLiveRelationships(resource, null, null);
while(iterator.hasNext()) {
LiveRelationship liveCopy = (LiveRelationship)iterator.next();
}
} catch (WCMException e) {
//Log the error
}

 

 

View solution in original post

5 Replies

Avatar

Level 5

I will try doing this if the LiveRelationship api is not working:

Get the node from jcr which is storing the livecopy related info and process them as required in your code. I am not sure if that works for your use case.

Avatar

Employee Advisor

@ASK_93  : LiveRelationshipManager should ideally work. What is the error you are getting?

 

Avatar

Correct answer by
Level 4

Hello @ASK_93 , The below piece of code is working fine for me to get the live relation copies from the master page.

 

LiveRelationshipManager liveRelationManager = resourceResolver.adaptTo(LiveRelationshipManager.class);
Resource resource = resourceResolver.getResource(<path to master page>);
try {
RangeIterator iterator = liveRelationManager.getLiveRelationships(resource, null, null);
while(iterator.hasNext()) {
LiveRelationship liveCopy = (LiveRelationship)iterator.next();
}
} catch (WCMException e) {
//Log the error
}

 

 

Avatar

Level 2

Hi @ASK_93 

I would suggest you to try to refresh the session, as this is triggered on NODE_MOVED, so it might be the case that when repository session was taken, the live copy wasn't synced to moved page.

Thanks
Anupam