Retrieving the page version of the page in java class | Community
Skip to main content
October 16, 2015
Solved

Retrieving the page version of the page in java class

  • October 16, 2015
  • 2 replies
  • 1997 views

Hi,

 I have created a version for the page. How can i retrieve the page version of the page like cq:lastReplicated we can retrieve the last published date. Is it possible to retrieve the page version of the page.

Thanks in advance.

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 Tim_Donovanuk

You can use PageManager to get all revisions (I think what you are calling 'versions') of a page by calling PageManager.getRevisions - this returns a Collection of Revisions, and on a Revision you can do .getVersion, .getLabel etc. See:

http://docs.adobe.com/docs/kr/aem/6-0/develop/ref/javadoc/com/day/cq/wcm/api/PageManager.html#getRevisions(java.lang.String, java.util.Calendar)

http://docs.adobe.com/docs/kr/aem/6-0/develop/ref/javadoc/com/day/cq/wcm/api/Revision.html

2 replies

Adobe Employee
October 16, 2015

last published is last replicated...the code is as follows

com.day.cq.replication.ReplicationStatus rs=jcrcontentresource.adaptTo(ReplicationStatus.class);
            if(rs!=null&&rs.getLastPublished()!=null){
            activatedTime=rs.getLastPublished().getTimeInMillis();
            }

Tim_Donovanuk
Tim_DonovanukAccepted solution
Level 2
October 16, 2015

You can use PageManager to get all revisions (I think what you are calling 'versions') of a page by calling PageManager.getRevisions - this returns a Collection of Revisions, and on a Revision you can do .getVersion, .getLabel etc. See:

http://docs.adobe.com/docs/kr/aem/6-0/develop/ref/javadoc/com/day/cq/wcm/api/PageManager.html#getRevisions(java.lang.String, java.util.Calendar)

http://docs.adobe.com/docs/kr/aem/6-0/develop/ref/javadoc/com/day/cq/wcm/api/Revision.html