Hi Everyone,
I have a requirement to delete an Asset from AEM through servlet.
I'm using below method to delete Asset.
Resource assetRes = resourceResolver.getResource(assetPath);
Node assetNode = assetRes.adaptTo(Node.class)
assetNode = assetNode.remove();
resourceResolver.commit();
My question is does assetNode.remove() will remove the asset and its related data like all child nodes, version, history from CRX?
Also came accross removeRecursive(Node n, int saveEveryHowManyNodes) what does this method do.?
Thanks,
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @girishb83316758
assetNode.remove() will remove the asset and its child nodes.
Regarding versions:
They would not be deleted by assetNode.remove() API
purgeVersions(Node node, boolean dryRun, int maxVersions, int maxAge)
versionManager = node.getSession().getWorkspace().getVersionManager();
Hi,
When we call node.remove() on a node in AEM, it will remove the specified node and its properties, but it does not automatically remove all child nodes, versions, or history related to that node. The removal of child nodes and related data is not done automatically because it may have significant implications on your content structure and history.
Regarding removeRecursive
@Ravi_Pampana I want to delete the Asset from AEM programmatically. All the child nodes, history, versions from CRX. Basically the goal to save space and improve performance is the goal.In this case how should we do it?
Can you please if share if you have any references for this.
Hello @girishb83316758
assetNode.remove() will remove the asset and its child nodes.
Regarding versions:
They would not be deleted by assetNode.remove() API
purgeVersions(Node node, boolean dryRun, int maxVersions, int maxAge)
versionManager = node.getSession().getWorkspace().getVersionManager();
@girishb83316758 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Suggestions provided was helpful.
Thanks
Views
Likes
Replies