Hi All,
I have a requirement where I need to remove certain properties of a given
node and also add some new child nodes to the same node, e.g. I need to
transform node as in [1] to [2]. I am planning to use content manipulation
operations of sling post servlet [3].
For adding child nodes, import operation seems to work but for removing
properties it seems I need to use default modify operation with "@Delete"
suffix as the "@Delete" suffix does not work when specified within content JSON
of import operation.
Also, I would not like to touch properties which I do not intend to modify.
E.g. in [1] I would not like to write to prop1 and prop2, so I do not have
option to rewrite entire node.
So, I need to use two post requests to perform this complete transformation.
e.g.
/path/to/node
1. {"prop3@Delete":""}
2. {":operation":"import",
":contentType":"json",":content":"{childnode1:{cp1:'',cp2:''},childnode2:{cp3:'',cp4:''}}",":replace":true}
This seems to work but this does not happen atomically i.e. ajax in #1 may
succeed and #2 may fail, which would lead to an inconsistent node structure for
me. So, is there a way to perform both these operations in one sling post
request?
[1]
+ node
- prop1
- prop2
- prop3
[2]
+ node
- prop1
- prop2
+ childnode1
- cp1
- cp2
+ childnode2
-cp3
-cp4
[3]
https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
Thanks
Nitin