Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Retrieving the page version of the page in java class

Avatar

Level 1

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.

1 Accepted Solution

Avatar

Correct answer by
Level 2

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#getRev..., java.util.Calendar)

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

View solution in original post

2 Replies

Avatar

Employee

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();
            }

Avatar

Correct answer by
Level 2

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#getRev..., java.util.Calendar)

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