Expand my Community achievements bar.

SOLVED

How to get replication status of multiple pages using groovy script?

Avatar

Level 1

I am trying to retrieve the page details using groovy script. I need to get replication status from those details but, the cq:lastReplicationAction is not available for the page in the jcr content.
What is the way to achieve this. A code snippet will be really helpful.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@YashW  In your groovy script, adapt resource/page to ReplicationStatus

 

ReplicationStatus replicationStatus = resource.adaptTo(ReplicationStatus.class)

or 

ReplicationStatus replicationStatus = page.adaptTo(ReplicationStatus.class)

 

now you can add conditions to validate if resource/page is activated

 

if ( null != replicationStatus){
  return replicationStatus.isActivated()
}

 

This will return true if page is activated

 

def replicationStatus = pageResource.adaptTo(ReplicationStatus)

if(null != replicationStatus{
    def status = replicationStatus.isActivated();
    if(status){
	// Your operation
    }
}

 

You may use this for reference, and apply to your use case

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@YashW  In your groovy script, adapt resource/page to ReplicationStatus

 

ReplicationStatus replicationStatus = resource.adaptTo(ReplicationStatus.class)

or 

ReplicationStatus replicationStatus = page.adaptTo(ReplicationStatus.class)

 

now you can add conditions to validate if resource/page is activated

 

if ( null != replicationStatus){
  return replicationStatus.isActivated()
}

 

This will return true if page is activated

 

def replicationStatus = pageResource.adaptTo(ReplicationStatus)

if(null != replicationStatus{
    def status = replicationStatus.isActivated();
    if(status){
	// Your operation
    }
}

 

You may use this for reference, and apply to your use case