I have 2-3 component node which are not required. I am writing workflow to check those node. How should I delete the node using Java.
Eg:
Node1- Example
Node2- Test
If I find the resource.getName() as Node1 delete that node
Solved! Go to Solution.
Hi Ronnie,
You can use the delete method https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolver.html#delete-o...
Alternatively, you can use - https://docs.adobe.com/content/docs/en/spec/jcr/1.0/7.1.6_Removing_Nodes_and_Properties.html
javax.jcr.Node jcrNode = jcrsession.getNode("/sites/mySite");
jcrNode.remove();
jcrsession.save();
Regards,
Manpreet
Hi Ronnie,
Please check below link which has examples of deleting nodes, hope this will help you.
https://www.tabnine.com/code/java/methods/org.apache.sling.api.resource.ResourceResolver/delete
Hi Ronnie,
You can use the delete method https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolver.html#delete-o...
Alternatively, you can use - https://docs.adobe.com/content/docs/en/spec/jcr/1.0/7.1.6_Removing_Nodes_and_Properties.html
javax.jcr.Node jcrNode = jcrsession.getNode("/sites/mySite");
jcrNode.remove();
jcrsession.save();
Regards,
Manpreet
Hi @Ronnie09 ,
You need to used Node api for adding and removing .
Using Node API
Adapt the resource to Node
Node node = resource.adaptTo(Node.class);
Then remove a node using function removenode(java.lang.String relPath, java.lang.String primaryNodeTypeName)"
Kr,
Sanjay
Views
Likes
Replies