On Thu, Nov 12, 2009 at 4:07 PM, Christophe Lombart <[email protected]> wrote: > 2009/11/12 Vidar Ramdal <[email protected]> > >> >> What if you could post to a (Json)QueryServlet URL, something like: >> >> POST >> >> >> http://localhost:8080/.query.json?statement=//*[sling:resourceType='myContentType >> >> '] >> >> ... with the fields >> >> myprop=123 >> >> anotherProp="new value" >> >> ...etc >> >> >> >> The servlet would then run the query, and run the modifications on >> >> each result node. >> >> On Thu, Nov 12, 2009 at 3:47 PM, Christophe Lombart >> <[email protected]> wrote: >> > This is exactly what I'm thinking about :-) >> > I think we should have one servlet (or extension) / type of operation >> > (delete props, rename prop, update value, ...). >> >> Those operations, aren't those already handled by SlingPostServlet? >> >> The SlingPostSerlvet already supports the :applyTo parameter [1], so >> you can act on multiple nodes by supplying their paths. >> Perhaps :applyTo could be extended to support XPath queries? >> > > This is maybe something that we can evaluate.
After some more investigation, there seems to be only two things that needs to be done to implement this: 1) It seems applyTo is handled by AbstractSlingPostOperation.getApplyToResources(). However, this method is never called by ModifyOperation, which is the class doing all Property modifications. Thus, :applyTo is not supported for property modifications (but for node delete/move/copy etc), but looks not too hard to implement. 2) The getApplyToResources() method creates an ApplyToIterator, which assumes all :applyTo values are absolute paths, and looks them up via resolver.getResource. It should be absolutely possible to modify this functionality to use resolver.findResources instead, or something similar, so that xpath queries could be supported. The advantage, IMO, of implementing this via SlingPostServlet, is that we suddenly can do all kinds of operations on a set of nodes - since SlingPostServlet already supports custom SllingPostOperations and SlingPostProcessors. -- Vidar S. Ramdal <[email protected]> - http://www.idium.no Sommerrogata 13-15, N-0255 Oslo, Norway + 47 22 00 84 00 / +47 21 531941, ext 2070
