use of com.day.cq.replication.ReplicationStatus in project acs-aem-commons by Adobe-Consulting-Services.
the class PageReplicationStatusModel method getReplicationStatus.
public String getReplicationStatus() {
Session session = resource.getResourceResolver().adaptTo(Session.class);
String path = resource.getPath();
if (path.contains(JcrConstants.JCR_CONTENT)) {
path = StringUtils.substringAfter(path, JcrConstants.JCR_CONTENT) + JcrConstants.JCR_CONTENT;
} else {
path += "/" + JcrConstants.JCR_CONTENT;
}
log.debug("Getting replication status for {}", path);
ReplicationStatus status = replicator.getReplicationStatus(session, path);
Status rStatus = Status.NOT_ACTIVATED;
if (status != null) {
if (status.isDeactivated()) {
rStatus = Status.DEACTIVATED;
} else if (status.isPending()) {
rStatus = Status.IN_PROGRESS;
} else if (status.isActivated()) {
Calendar lastModified = getLastModified(resource.getResourceResolver(), path);
if (lastModified != null && status.getLastPublished() != null && lastModified.after(status.getLastPublished())) {
rStatus = Status.MODIFIED;
} else {
rStatus = Status.ACTIVATED;
}
}
}
log.debug("Retrieved replication status {}", rStatus);
return rStatus.toString();
}
Aggregations