which property should we use to check if an asset is published or not in "AEM as a cloud service"? | Community
Skip to main content
Level 4
May 30, 2023

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

  • May 30, 2023
  • 6 replies
  • 2374 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

6 replies

cwalter-1
Level 2
May 30, 2023
Sady_Rifat
Community Advisor
Community Advisor
May 30, 2023

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.

Level 4
May 30, 2023

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

Sady_Rifat
Community Advisor
Community Advisor
May 30, 2023

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.

iamnjain
Community Advisor
Community Advisor
May 30, 2023

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) 

Community Advisor
May 30, 2023

@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.html

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

 

rawvarun
Community Advisor
Community Advisor
May 30, 2023

You can check Asset published or unpublished through Publish Asset Report:

https://experienceleague.adobe.com/docs/experience-manager-learn/assets/advanced/asset-reports.html?lang=en

aanchal-sikka
Community Advisor
Community Advisor
May 31, 2023

Hello @rahul234dabas 

 

Please assure that the property is indexed.

jcr:content/cq:lastReplicationAction

OOTB its not defined in indexes

Aanchal Sikka