Hi guys, at-times we come across a requirement in CQ5/AEM where we have to check if a page is published or not in Author mode programmatically . I encountered a similar situation where I had to show only those page which are published or activated.
So, after searching the web I came across a Service that CQ/AEM provides out of the box "Replication Status (com.day.cq.replication.ReplicationStatus)". This service provides us a way to see if, resource with which it is associated is : activated or deactivated or delivered or status-queue or we can even find out last published time of the page or by whom was the particular page last published.The service can be adapted from the resource object :
ReplicationStatus replicationStatus = resource.adaptTo(ReplicationStatus.class);
Here is the link for documentation of the ReplicationStatus Interface :