Hi everyone,
I have a requirement to fetch the number of versions present in an Asset using a servlet.
Can anyone please provide some references?
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @KaibalyaJena_123
As I understood your requirement, you need the number of versions created for a given asset.
You can use VersionHistory Interface to get all the versions and their details. Please refer below doc link for available methods.
https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...
Do let me know if you face any issues or you have different requirement?
Hope it helps.
Hello @KaibalyaJena_123
As I understood your requirement, you need the number of versions created for a given asset.
You can use VersionHistory Interface to get all the versions and their details. Please refer below doc link for available methods.
https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...
Do let me know if you face any issues or you have different requirement?
Hope it helps.
Hello @KaibalyaJena_123
eg: AssetVersionManager versionManager = resolver.adaptTo(AssetVersionManager.class); // to get existing versions Iterator<AssetVersion> versions = versionManager.listVersions("/path/to/asset/document.pdf"); ...
you can readily use the AssetVersionManager API.
- Get path of asset in servlet
- Get resourceResolver from Request
- Adapt to AssetVersionManager
- List all versions of the related asset./
Details are available on https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/adobe/granite/ass...
If you want you use JCR API then below code snippet you can use -
final VersionManager versionManager = node.getSession().getWorkspace().getVersionManager();
final VersionHistory versionHistory = versionManager.getVersionHistory(node.getPath());
final VersionIterator versionIter = versionHistory.getAllVersions();
if you want you use Resource API then you can use
AssetVersionManager versionManager = resolver.adaptTo(AssetVersionManager.class);
Iterator<AssetVersion> versions = versionManager.listVersions("/content/dam/sample.jpg");
Views
Likes
Replies
Views
Like
Replies