You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Christophe Lombart <ch...@gmail.com> on 2009/11/12 14:49:20 UTC
Massive update on properties
Hi all,
Are there some tools/servlets/scripts or whatever to make massive updates on
node properties ?
I would like to have some tools to make some modifications in the repo if
the content model has to be changed for a new release of our Sling based
application.
In the first time, I'm mainly focusing only on node property massive updates
(not on update on child nodes).
Here some use cases of what I'm thinking about :
- Update all contents based on the resource type "MyContentType" where
myprop = 123 and createDate < last month - set anotherProp = "new value"
- Remove the property myprop for resourceType "MyOtherContentType"
- Rename prop 'myprop' into "mynewpropname" where resource type is
"MyContentType"
I'm mainly focusing only on node property massive updates
If nothing exist, I can contribute some basic tools to make massive updates
in the first time or let me know if there is another way for doing this.
br,
Christophe
Re: Massive update on properties
Posted by Christophe Lombart <ch...@gmail.com>.
I plan to work on this after solving some issues on my current projects
(probably next week).
Christophe
2009/11/19 Simon Gaeremynck <ga...@gmail.com>
> Is there any work being done on this?
> I can't seem to find it in JIRA. It looks like something we might be
> interested in as well.
>
> Regards,
> Simon
>
> On 12 Nov 2009, at 16:04, Christophe Lombart wrote:
>
> Thanks for the input. I will create a new Jira issue and try the solution
>> you suggest.
>>
>> br,
>> Christophe
>>
>>
>> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>>
>> On Thu, Nov 12, 2009 at 4:07 PM, Christophe Lombart
>>> <ch...@gmail.com> wrote:
>>>
>>>> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>>>>
>>>> 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
>>>>> <ch...@gmail.com> 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 <vi...@idium.no> - http://www.idium.no
>>> Sommerrogata 13-15, N-0255 Oslo, Norway
>>> + 47 22 00 84 00 / +47 21 531941, ext 2070
>>>
>>>
>
Re: Massive update on properties
Posted by Simon Gaeremynck <ga...@gmail.com>.
Is there any work being done on this?
I can't seem to find it in JIRA. It looks like something we might be
interested in as well.
Regards,
Simon
On 12 Nov 2009, at 16:04, Christophe Lombart wrote:
> Thanks for the input. I will create a new Jira issue and try the
> solution
> you suggest.
>
> br,
> Christophe
>
>
> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>
>> On Thu, Nov 12, 2009 at 4:07 PM, Christophe Lombart
>> <ch...@gmail.com> wrote:
>>> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>>>
>>>>>> 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
>>>> <ch...@gmail.com> 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 <vi...@idium.no> - http://www.idium.no
>> Sommerrogata 13-15, N-0255 Oslo, Norway
>> + 47 22 00 84 00 / +47 21 531941, ext 2070
>>
Re: Massive update on properties
Posted by Christophe Lombart <ch...@gmail.com>.
Thanks for the input. I will create a new Jira issue and try the solution
you suggest.
br,
Christophe
2009/11/12 Vidar Ramdal <vi...@idium.no>
> On Thu, Nov 12, 2009 at 4:07 PM, Christophe Lombart
> <ch...@gmail.com> wrote:
> > 2009/11/12 Vidar Ramdal <vi...@idium.no>
> >
> >> >> 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
> >> <ch...@gmail.com> 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 <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
>
Re: Massive update on properties
Posted by Vidar Ramdal <vi...@idium.no>.
On Thu, Nov 12, 2009 at 4:07 PM, Christophe Lombart
<ch...@gmail.com> wrote:
> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>
>> >> 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
>> <ch...@gmail.com> 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 <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070
Re: Massive update on properties
Posted by Christophe Lombart <ch...@gmail.com>.
2009/11/12 Vidar Ramdal <vi...@idium.no>
> >> 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
> <ch...@gmail.com> 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.
>
> [1]
> http://dev.day.com/microsling/content/blogs/main/cheatsheet/docroot/back.png
> - lower left corner
> --
> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
>
Re: Massive update on properties
Posted by Vidar Ramdal <vi...@idium.no>.
>> 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
<ch...@gmail.com> 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?
[1] http://dev.day.com/microsling/content/blogs/main/cheatsheet/docroot/back.png
- lower left corner
--
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070
Re: Massive update on properties
Posted by Christophe Lombart <ch...@gmail.com>.
>
> Ah, OK. That could be interesting.
> 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.
>
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, ...).
Re: Massive update on properties
Posted by Vidar Ramdal <vi...@idium.no>.
>> On Thu, Nov 12, 2009 at 2:49 PM, Christophe Lombart
>> <ch...@gmail.com> wrote:
>> > Are there some tools/servlets/scripts or whatever to make massive updates on
>> > node properties ? [...]
> 2009/11/12 Vidar Ramdal <vi...@idium.no>
>> In our project, we usually do that kind of stuff in a .esp script.
>> We get the nodes we need to change with an XPath query, and iterate
>> over the result, doing the changes we need to do on each node.
>> [...]
>> That works well for us - but if you have a simpler solution, that
>> would certainly be interesting.
On Thu, Nov 12, 2009 at 3:23 PM, Christophe Lombart
<ch...@gmail.com> wrote:
> I have not a simpler solution but I would like to have a some "generic"
> scripts or servlets for doing something like this.
Ah, OK. That could be interesting.
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.
--
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070
Re: Massive update on properties
Posted by Christophe Lombart <ch...@gmail.com>.
Hi vidar,
I have not a simpler solution but I would like to have a some "generic"
scripts or servlets for doing something like this.
Christophe
2009/11/12 Vidar Ramdal <vi...@idium.no>
> On Thu, Nov 12, 2009 at 2:49 PM, Christophe Lombart
> <ch...@gmail.com> wrote:
> > Hi all,
> >
> > Are there some tools/servlets/scripts or whatever to make massive updates
> on
> > node properties ?
> > I would like to have some tools to make some modifications in the repo if
> > the content model has to be changed for a new release of our Sling based
> > application.
> > In the first time, I'm mainly focusing only on node property massive
> updates
> > (not on update on child nodes).
> >
> > Here some use cases of what I'm thinking about :
> >
> > - Update all contents based on the resource type "MyContentType" where
> > myprop = 123 and createDate < last month - set anotherProp = "new value"
> > - Remove the property myprop for resourceType "MyOtherContentType"
> > - Rename prop 'myprop' into "mynewpropname" where resource type is
> > "MyContentType"
>
> In our project, we usually do that kind of stuff in a .esp script.
> We get the nodes we need to change with an XPath query, and iterate
> over the result, doing the changes we need to do on each node.
> E.g., your "Remove the property myprop for resourceType
> 'MyOtherContentType'" example:
> <%
> var nodes = resource.resourceResolver.findResources(str,
> "/jcr:root//*[@sling:resourceType='MyOtherContentType']");
> for each (node in nodes) {
> node.setProperty("myprop", null);
> }
> %>
>
> That works well for us - but if you have a simpler solution, that
> would certainly be interesting.
>
> --
> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
>
Re: Massive update on properties
Posted by Vidar Ramdal <vi...@idium.no>.
On Thu, Nov 12, 2009 at 2:49 PM, Christophe Lombart
<ch...@gmail.com> wrote:
> Hi all,
>
> Are there some tools/servlets/scripts or whatever to make massive updates on
> node properties ?
> I would like to have some tools to make some modifications in the repo if
> the content model has to be changed for a new release of our Sling based
> application.
> In the first time, I'm mainly focusing only on node property massive updates
> (not on update on child nodes).
>
> Here some use cases of what I'm thinking about :
>
> - Update all contents based on the resource type "MyContentType" where
> myprop = 123 and createDate < last month - set anotherProp = "new value"
> - Remove the property myprop for resourceType "MyOtherContentType"
> - Rename prop 'myprop' into "mynewpropname" where resource type is
> "MyContentType"
In our project, we usually do that kind of stuff in a .esp script.
We get the nodes we need to change with an XPath query, and iterate
over the result, doing the changes we need to do on each node.
E.g., your "Remove the property myprop for resourceType
'MyOtherContentType'" example:
<%
var nodes = resource.resourceResolver.findResources(str,
"/jcr:root//*[@sling:resourceType='MyOtherContentType']");
for each (node in nodes) {
node.setProperty("myprop", null);
}
%>
That works well for us - but if you have a simpler solution, that
would certainly be interesting.
--
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070