April 3, 2020
Estimated Post Reading Time ~

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


Resource: https://cqwemblog.wordpress.com/2015/10/22/how-to-check-if-the-page-is-published-cq5aem/


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.