Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

which property should we use to check if an asset is published or not in "AEM as a cloud service"?

Avatar

Level 5

I have a requirement in which I have to access all the published assets from one path.

I need only published assets and unpublished assets should be skipped.

 

currently, I used the property 

jcr:content/cq:lastReplicationAction == "Activate"

 to validate it but it seems like the unpublished assets are also getting picked.

what are the other ways to validate it?

 

 

Thank you

8 Replies

Avatar

Community Advisor

Hello @rahul234dabas ,
You can run the following query builder to get all the published assets under a path.

path=/content/dam/my-project/master/english/home
type=dam:Asset
property=jcr:content/cq:lastReplicationAction
property.value=Activate
p.limit=-1

By this query the unpublished will not comeup and no need for extra validation for this.

Avatar

Level 5

I did the same but seems like it's not fetching the published assets

Avatar

Community Advisor

The query was to fetch the published assets. No working in your local or higher environment?


Can you populate this problem from the we-retail project? This will be more clear to understand it.

Avatar

Community Advisor

Hello @rahul234dabas 

We are first setting a metadata ( Publish Status ) on all assets for a particular folder and then in Java code we are using to fetch status for individual asset.

assetMetadataNode.getProperty(PUBLISH_STATUS) 

Avatar

Community Advisor

@rahul234dabas , If you don't want to rely on any property. You can use ReplicationStatus API
https://javadoc.io/doc/com.adobe.aem/aem-sdk-api/latest/com/day/cq/replication/ReplicationStatus.htm...

ReplicationStatus replicationStatus = resource.adaptTo(ReplicationStatus.class)
return replicationStatus.isActivated()

 

Avatar

Community Advisor

Hello @rahul234dabas 

 

Please assure that the property is indexed.

jcr:content/cq:lastReplicationAction

OOTB its not defined in indexes


Aanchal Sikka