Search code examples
javaadobeaemjcr

Adobe CQ. How to get blueprint page of a LiveCopy


I have a page(A) which is a LiveCopy of another page(B), which is a LiveCopy of another Blueprint page(C). Some pages have longer hierarchy from a LiveCopy to a Blueprint page.

So how I can find Blueprint page of some LiveCopy page programmatically? I found a solution how to check if page is LiveCopy. But how to find her Blueprint page?

Thanks in advance


Solution

  • You'd again use the LiveRelationshipManager that Tomek linked to in that answer.

    First by calling getLiveRelationship & then asking the returned LiveRelationship for its source:

    Resource pageA; //LiveCopy of Page B;
    LiveRelationshipManager liveRelationshipManager = resourceResolver.adaptTo(LiveRelationshipManager.class);
    PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
    
    LiveRelationship liveRelationship = liveRelationshipManager.getLiveRelationship(pageA, false);
    String pageBPath = liveRelationship.getSourcePath();
    
    Page pageB = pageManager.getPage(pageBPath);
    

    The false on the getLiveRelationship method above refers to an "Advanced Status" — no reference to what this is according to the JavaDocs apart that it is 'time-consuming' to compute.