Expand my Community achievements bar.

SOLVED

Not able to get correct result for published page as the draft pages are also having 'cq:lastReplicated' & 'cq:lastReplicationAction' properties from the templates

Avatar

Level 2

Hi All,

 

I am trying to get the result of pages which are published in author instance. But I am not able to get the correct results as newly created pages from a published template is taking 'cq:lastReplicated' & 'cq:lastReplicationAction' properties from the template. So even if we are not publishing that newly created page, we are seeing these properties being added in the jcr:content from the template as the template was already published. 

 

Can anyone please help on this how we can remove these properties from newly created pages/ draft pages which hasn't been published?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Please do not read these properties directly, as technically they are an implementation detail. 

Rather do something like this:

ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
if (status.getAvailableAgents("preview")) {
  // status available for preview
  boolean canBeViewedOnPreview = status.getStatusForAgent("preview").isActivated();
}

(https://javadoc.io/doc/com.adobe.aem/aem-sdk-api/latest/com/day/cq/replication/ReplicationStatus.htm...)

 

 

View solution in original post

5 Replies

Avatar

Level 9

Hello,

 

Can you check if one of below property helps you there??

 

cq:lastReplicated_publish
cq:lastReplicatedBy_publish

 

Thanks!!

Avatar

Level 2

hi Pawan,

 

Thanks for the suggestion but I am not seeing these properties in the page jcr:content. I am generating the result in author and not from the publish environment. I have to get the list of pages which are activated/published from the authors. So while doing so, I am getting those pages also in the list which are newly created and not activated/published. This is because its taking the lastreplicated property from the template used for creating the page.

 

Thanks & Regards,

Abhishek

Avatar

Level 9

Hi Abhishek,

 

I think you answer the question. if those properties are not available then you can use that as condition to know the pages which are not published because when you publish pages, these two properties should populate corresponding values.

 

I hope you understand it now.

 

Thanks!!

Avatar

Correct answer by
Employee Advisor

Please do not read these properties directly, as technically they are an implementation detail. 

Rather do something like this:

ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
if (status.getAvailableAgents("preview")) {
  // status available for preview
  boolean canBeViewedOnPreview = status.getStatusForAgent("preview").isActivated();
}

(https://javadoc.io/doc/com.adobe.aem/aem-sdk-api/latest/com/day/cq/replication/ReplicationStatus.htm...)

 

 

Avatar

Level 9

Thanks for adding that, i think i missed mentioning. My intention about sharing those properties to mainly query from AEM console to find out those pages from authoring/local search into site path.