Reputation: 1591
I would like to get the list of live copy pages for any given blue print page. So, if I have given a page path, I should be able to list out all its live copies(if any). Can this be achieved with any API?
Upvotes: 2
Views: 2662
Reputation: 1820
Need to do the following steps
Add dependency to pom.xml
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-msm-api</artifactId>
<version>5.7.2</version>
<scope>provided</scope>
</dependency>
Add two references
@Reference
private ResourceResolverFactory resolverFactory;
@Reference
LiveRelationshipManager liveRelManager;
Add the code where you need liveCopy list.
List<LiveCopy> liveCopyList = new ArrayList();
try {
ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
String givenPageOrBlueprint = "/content/we-retail/ca/en/experience/climbing-in-the-massif-du-mont-blanc";
Resource res = resourceResolver.getResource(givenPageOrBlueprint);
RangeIterator rangeIterator = liveRelManager.getLiveRelationships(res,"",null);
while (rangeIterator.hasNext())
{
LiveRelationship liveCopy =(LiveRelationship) rangeIterator.next();
liveCopyList.add(liveCopy.getLiveCopy());
}
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 0
Reputation: 3444
Live copies of a resource (page) can be obtained by the official API
You just need to use LiveRelationshipManager.getLiveRelationships
in order to get the live relationships.
Depending on the version of AEM you are using and the complexity of your BluePrint setup and depth of LiveCopy inheritance (and cancellations) this API could have performance impacts.
In effect, it should return the same data which is visible via CQ Blueprint manager screen.
Upvotes: 4