Expand my Community achievements bar.

AEM assets : how to identify asset expiry date: isAssetExpired boolean from where this can resolved

Avatar

Level 4

Hi Team

I am working on AEM assets. Currently when an asset is expired, we are getting a flag mentioning asset is expired. 

 

I have identified it is coming from /libs/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp

 

so I have overlayed to /apps/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp

 

I want to understand how the below line is resolved so that I can get expirydate and display it when I hover over flag icon.

 

boolean isAssetExpired = request.getAttribute(IS_ASSETEXPIRED) != null ? (boolean) request.getAttribute(IS_ASSETEXPIRED) : false;

 

Kindly suggest

 

@AmitVishwakarma @aanchal-sikka  @SantoshSai @Adilos-Cantuerk @lukasz-m 

3 Replies

Avatar

Level 2

Hi @Prashardan 

 

In AEM Assets Metadata contains prism:expirationDate which is responsible for displaying expiry flag, Also look out for the offtime property under jcr:content, try to modify these values and see if the flag is not visible.

Avatar

Level 4

how can I retrieve these properties. Any out of the box java class?

I want to display this date. 
like if any asset is about in expire in next 3 days. I want to get its expiry date and calculate how many days from today. 

 

How can I retrieve and print prim:expirationDate

Avatar

Level 2

you can use below code snippet for reference in the overridden jsp file

 

ValueMap metadata = asset.adaptTo(Resource.class).getChild("jcr:content/metadata").adaptTo(ValueMap.class);
Calendar expiryDate = metadata.get("prism:expirationDate", Calendar.class);

if (expiryDate != null) {
    String expiryDateStr = new SimpleDateFormat("yyyy-MM-dd").format(expiryDate.getTime());
    // Now use expiryDateStr to show as tooltip or hover text
}

now that you have the expirydate, you can use it anyway you want.