You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Kurt Verduyckt <ku...@modulo1.be> on 2005/11/10 13:30:46 UTC

nt:resource nodes and versioning/textfiltering

Hi all,
 
I have some troubles regarding the following situation:
 
I'm writing an application that needs to store some xml content which needs
to be versioned and searchable on some -not all- of those xml fields. So my
best guess was to use the nt:resource node, add a mixin type mix:versionable
to do the versioning and store the xml data in the jcr:data property. This
should allow me to write a custom textfilter to filter the xml content and
index only those xml fields that I'm interested in for searching, right?
 
Now these are the problems I'm having:
 
1) first of all I noticed that when I make the nt:resource node versionable,
the node somehow loses the jcr:data content after a checkIn operation... and
only transfers it to the frozen node of the baseversion. Is this normal?
What really troubles my is if I close the application (properly) and
restart, doing a dump of the jcr contents, the jcr:data is filled again...
so it seems it is kept in the session somewhere, but only persisted after a
repository close operation... 
 
the code sample (with just 'text/plain' mimetype for now because I don't
have a custom filter yet):
 

Node content = rootnode.addNode("myns:xmlcontent","nt:resource");
content.addMixin("mix:versionable"); //apparently performs a checkout behind
the scenes
content.setProperty("jcr:mimeType", "text/plain");
content.setProperty("jcr:encoding", "");
content.setProperty("jcr:data", xmlData2stream(xmlData));
content.setProperty("jcr:lastModified", Calendar.getInstance ());
session.save();

//debugging showed that at this point jcr:data is filled with content but
checkout=true
     
content.checkin();
 
//debugging showed that at this point jcr:data field is cleared! Until
restart of the application, then the node contains data again ?!?
 

so to retrieve the jcr:data field while running, the only way to find it for
now is find the node, get the baseversion, get the frozennode under it and
get the jcr:data field from there... but this doesn't feel quite right does
it?
 
2) to search for a node with a certain text content (inside the jcr:data,
which should be indexed by the textfilter), I guess I need to write an Xpath
query... the only thing is I can't find any example on the net. My own best
shot was something like this:
 

Query q = qm.createQuery("//myns:xmlcontent[jcr:contains(.,'" + searchtext +
"')]", Query.XPATH);

 
but this returns no results... maybe this is just because of the problem
stated in 1) ?
 
Anybody who knows what I might be doing wrong?
 
Kind regards,
 
Kurt

    
    
 
 

RE: nt:resource nodes and versioning/textfiltering

Posted by Kurt Verduyckt <ku...@modulo1.be>.
Hi Stefan, just did some tests with the new version and yes it's solved!

Thanks for the fast response!

Greetings
Kurt

-----Original Message-----
From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com] 
Sent: vrijdag 11 november 2005 17:37
To: jackrabbit-dev@incubator.apache.org
Subject: Re: nt:resource nodes and versioning/textfiltering


hi kurt
i think i found the problem. i committed a fix (svn r332593).

please let me know if this solves your problem.

cheers
stefan

On 11/11/05, Stefan Guggisberg <st...@gmail.com> wrote:
> hi kurt
>
> On 11/10/05, Kurt Verduyckt <ku...@modulo1.be> wrote:
> > Hi all,
> >
> > I have some troubles regarding the following situation:
> >
> > I'm writing an application that needs to store some xml content 
> > which needs to be versioned and searchable on some -not all- of 
> > those xml fields. So my best guess was to use the nt:resource node, 
> > add a mixin type mix:versionable to do the versioning and store the 
> > xml data in the jcr:data property. This should allow me to write a 
> > custom textfilter to filter the xml content and index only those xml 
> > fields that I'm interested in for searching, right?
> >
> > Now these are the problems I'm having:
> >
> > 1) first of all I noticed that when I make the nt:resource node 
> > versionable, the node somehow loses the jcr:data content after a 
> > checkIn operation... and only transfers it to the frozen node of the 
> > baseversion. Is this normal? What really troubles my is if I close 
> > the application (properly) and restart, doing a dump of the jcr 
> > contents, the jcr:data is filled again... so it seems it is kept in 
> > the session somewhere, but only persisted after a repository close 
> > operation...
> >
> > the code sample (with just 'text/plain' mimetype for now because I 
> > don't have a custom filter yet):
> >
> >
> > Node content = rootnode.addNode("myns:xmlcontent","nt:resource");
> > content.addMixin("mix:versionable"); //apparently performs a 
> > checkout behind the scenes content.setProperty("jcr:mimeType", 
> > "text/plain"); content.setProperty("jcr:encoding", "");
> > content.setProperty("jcr:data", xmlData2stream(xmlData));
> > content.setProperty("jcr:lastModified", Calendar.getInstance ());
> > session.save();
> >
> > //debugging showed that at this point jcr:data is filled with 
> > content but checkout=true
> >
> > content.checkin();
> >
> > //debugging showed that at this point jcr:data field is cleared! 
> > Until restart of the application, then the node contains data again 
> > ?!?
> >
> >
> > so to retrieve the jcr:data field while running, the only way to 
> > find it for now is find the node, get the baseversion, get the 
> > frozennode under it and get the jcr:data field from there... but 
> > this doesn't feel quite right does it?
> >
> > 2) to search for a node with a certain text content (inside the 
> > jcr:data, which should be indexed by the textfilter), I guess I need 
> > to write an Xpath query... the only thing is I can't find any 
> > example on the net. My own best shot was something like this:
> >
> >
> > Query q = qm.createQuery("//myns:xmlcontent[jcr:contains(.,'" + 
> > searchtext + "')]", Query.XPATH);
> >
> >
> > but this returns no results... maybe this is just because of the 
> > problem stated in 1) ?
> >
> > Anybody who knows what I might be doing wrong?
>
> you're not doing anything wrong, the problem you're describing is 
> clearly a bug. please post a jira issue.
>
> thanks for reporting this issue!
>
> cheers
> stefan
>
> >
> > Kind regards,
> >
> > Kurt
> >
> >
> >
> >
> >
> >
> >
>




Re: nt:resource nodes and versioning/textfiltering

Posted by Stefan Guggisberg <st...@gmail.com>.
hi kurt
i think i found the problem. i committed a fix (svn r332593).

please let me know if this solves your problem.

cheers
stefan

On 11/11/05, Stefan Guggisberg <st...@gmail.com> wrote:
> hi kurt
>
> On 11/10/05, Kurt Verduyckt <ku...@modulo1.be> wrote:
> > Hi all,
> >
> > I have some troubles regarding the following situation:
> >
> > I'm writing an application that needs to store some xml content which needs
> > to be versioned and searchable on some -not all- of those xml fields. So my
> > best guess was to use the nt:resource node, add a mixin type mix:versionable
> > to do the versioning and store the xml data in the jcr:data property. This
> > should allow me to write a custom textfilter to filter the xml content and
> > index only those xml fields that I'm interested in for searching, right?
> >
> > Now these are the problems I'm having:
> >
> > 1) first of all I noticed that when I make the nt:resource node versionable,
> > the node somehow loses the jcr:data content after a checkIn operation... and
> > only transfers it to the frozen node of the baseversion. Is this normal?
> > What really troubles my is if I close the application (properly) and
> > restart, doing a dump of the jcr contents, the jcr:data is filled again...
> > so it seems it is kept in the session somewhere, but only persisted after a
> > repository close operation...
> >
> > the code sample (with just 'text/plain' mimetype for now because I don't
> > have a custom filter yet):
> >
> >
> > Node content = rootnode.addNode("myns:xmlcontent","nt:resource");
> > content.addMixin("mix:versionable"); //apparently performs a checkout behind
> > the scenes
> > content.setProperty("jcr:mimeType", "text/plain");
> > content.setProperty("jcr:encoding", "");
> > content.setProperty("jcr:data", xmlData2stream(xmlData));
> > content.setProperty("jcr:lastModified", Calendar.getInstance ());
> > session.save();
> >
> > //debugging showed that at this point jcr:data is filled with content but
> > checkout=true
> >
> > content.checkin();
> >
> > //debugging showed that at this point jcr:data field is cleared! Until
> > restart of the application, then the node contains data again ?!?
> >
> >
> > so to retrieve the jcr:data field while running, the only way to find it for
> > now is find the node, get the baseversion, get the frozennode under it and
> > get the jcr:data field from there... but this doesn't feel quite right does
> > it?
> >
> > 2) to search for a node with a certain text content (inside the jcr:data,
> > which should be indexed by the textfilter), I guess I need to write an Xpath
> > query... the only thing is I can't find any example on the net. My own best
> > shot was something like this:
> >
> >
> > Query q = qm.createQuery("//myns:xmlcontent[jcr:contains(.,'" + searchtext +
> > "')]", Query.XPATH);
> >
> >
> > but this returns no results... maybe this is just because of the problem
> > stated in 1) ?
> >
> > Anybody who knows what I might be doing wrong?
>
> you're not doing anything wrong, the problem you're describing is
> clearly a bug. please post a jira issue.
>
> thanks for reporting this issue!
>
> cheers
> stefan
>
> >
> > Kind regards,
> >
> > Kurt
> >
> >
> >
> >
> >
> >
> >
>

Re: nt:resource nodes and versioning/textfiltering

Posted by Stefan Guggisberg <st...@gmail.com>.
hi kurt

On 11/10/05, Kurt Verduyckt <ku...@modulo1.be> wrote:
> Hi all,
>
> I have some troubles regarding the following situation:
>
> I'm writing an application that needs to store some xml content which needs
> to be versioned and searchable on some -not all- of those xml fields. So my
> best guess was to use the nt:resource node, add a mixin type mix:versionable
> to do the versioning and store the xml data in the jcr:data property. This
> should allow me to write a custom textfilter to filter the xml content and
> index only those xml fields that I'm interested in for searching, right?
>
> Now these are the problems I'm having:
>
> 1) first of all I noticed that when I make the nt:resource node versionable,
> the node somehow loses the jcr:data content after a checkIn operation... and
> only transfers it to the frozen node of the baseversion. Is this normal?
> What really troubles my is if I close the application (properly) and
> restart, doing a dump of the jcr contents, the jcr:data is filled again...
> so it seems it is kept in the session somewhere, but only persisted after a
> repository close operation...
>
> the code sample (with just 'text/plain' mimetype for now because I don't
> have a custom filter yet):
>
>
> Node content = rootnode.addNode("myns:xmlcontent","nt:resource");
> content.addMixin("mix:versionable"); //apparently performs a checkout behind
> the scenes
> content.setProperty("jcr:mimeType", "text/plain");
> content.setProperty("jcr:encoding", "");
> content.setProperty("jcr:data", xmlData2stream(xmlData));
> content.setProperty("jcr:lastModified", Calendar.getInstance ());
> session.save();
>
> //debugging showed that at this point jcr:data is filled with content but
> checkout=true
>
> content.checkin();
>
> //debugging showed that at this point jcr:data field is cleared! Until
> restart of the application, then the node contains data again ?!?
>
>
> so to retrieve the jcr:data field while running, the only way to find it for
> now is find the node, get the baseversion, get the frozennode under it and
> get the jcr:data field from there... but this doesn't feel quite right does
> it?
>
> 2) to search for a node with a certain text content (inside the jcr:data,
> which should be indexed by the textfilter), I guess I need to write an Xpath
> query... the only thing is I can't find any example on the net. My own best
> shot was something like this:
>
>
> Query q = qm.createQuery("//myns:xmlcontent[jcr:contains(.,'" + searchtext +
> "')]", Query.XPATH);
>
>
> but this returns no results... maybe this is just because of the problem
> stated in 1) ?
>
> Anybody who knows what I might be doing wrong?

you're not doing anything wrong, the problem you're describing is
clearly a bug. please post a jira issue.

thanks for reporting this issue!

cheers
stefan

>
> Kind regards,
>
> Kurt
>
>
>
>
>
>
>