Hi All,
I have a requirement where I have to display the latest version number of the asset in the card view below the thumbnail. We are already displaying the metadata properties of asset by overriding the PropertyList.jsp under apps /apps/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp.
How do I fetch the version number here?
Any pointers would be helpful.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @nithya90
Please try
AssetVersionManager versionManager = resolver.adaptTo(AssetVersionManager.class);
versionManager.listVersions(assetPath)
Hi @nithya90
Please try
AssetVersionManager versionManager = resolver.adaptTo(AssetVersionManager.class);
versionManager.listVersions(assetPath)
Hi @nithya90
As @arunpatidar suggested you can use the AssetVersionManager to fetch the version number and that's a ideal way as well below is a code snippet which might help you:
Resource assetResource = resourceResolver.getResource(assetPath); Asset asset = assetResource.adaptTo(Asset.class); String versionNumber = "N/A"; if (asset != null) { AssetVersionManager versionManager = resourceResolver.adaptTo(AssetVersionManager.class); if (versionManager != null) { Iterator<Version> versions = versionManager.listVersions(asset.getPath()); if (versions.hasNext()) { Version latestVersion = versions.next(); versionNumber = latestVersion.getVersionLabel(); } } }
Ensure you have all the necessary imports for Asset, AssetVersionManager, Resource, ResourceResolver, and Version. integrate this changes in your propertyList.jsp accordingly.
Hope this helps!
Views
Replies
Total Likes
Views
Likes
Replies