How to check if the page is published? CQ5/AEM

If you want to know if the page is published or not you can use the below utility method to know if the page is published or not

public static Boolean isPublished(Resource resource) {
Boolean activated;
ReplicationStatus status = null;
activated = false;
if (resource != null) {
try {
Page page = resource.adaptTo(Page.class);
status = page.adaptTo(ReplicationStatus.class);
} catch (Exception e) {
LOG.debug(e.getMessage(), e);
}
if (status != null) {
activated = status.isActivated();
}
}
return activated;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s