Annoying Collection-Name Bug

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Annoying Collection-Name Bug

Jens Külzer
Hi! I think I have found an uncritical but annoying bug in the way collection
names are treated. I had a collection called "dbfiles" and it was impossible to
retrieve a document out of it using fn:doc("/dbfiles/data.xml"). The same works
fine if you use another collection name like fn:doc("/files/data.xml") or the
absolute path fn:doc("/db/dbfiles/data.xml").
So I took a look at the sources and found pieces of code like this:

> if (!fileName.startsWith("/"))
        fileName = '/' + fileName;
> if (!fileName.startsWith("/db"))
        fileName = "/db" + fileName;

This works fine if you do not have collection names starting with a "db" -
otherwise you get in trouble like me ;-).

However, there are over 30 occurrences in various source files with code like
this, so I spared to create quick patches for all of them... Maybe it would be a
good idea to refactor this redundant piece of code out.
(The quick and dirty solution would be to prohibit collection names starting
with a "db"...)

Jens



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Annoying Collection-Name Bug

Adam Retter-7
Jens,

Im guessing although I may be shortly corrected, that collection names
should always be specified as the full path i.e. starting "/db" and that
eXist merely implements the code you have mentioned to assist users who
dont specify the correct path and/or because /db is in effect a constant
and so it seems a shame to have to specify it for every call involving a
collection name.

If the code is intended to stay, it should be changed to something like-

if (!fileName.startsWith("/"))
        fileName = '/' + fileName;
if (!fileName.startsWith("/db/"))
        fileName = "/db" + fileName;

Note the trailing slash in the second fileName.startsWith()!!!

Cheers Adam


On Wed, 2005-10-19 at 16:01 +0100, Jens wrote:

> Hi! I think I have found an uncritical but annoying bug in the way
> collection  
> names are treated. I had a collection called "dbfiles" and it was
> impossible to  
> retrieve a document out of it using fn:doc("/dbfiles/data.xml"). The
> same works  
> fine if you use another collection name like fn:doc("/files/data.xml")
> or the  
> absolute path fn:doc("/db/dbfiles/data.xml").
> So I took a look at the sources and found pieces of code like this:
>
> > if (!fileName.startsWith("/"))
>         fileName = '/' + fileName;
> > if (!fileName.startsWith("/db"))
>         fileName = "/db" + fileName;
> This works fine if you do not have collection names starting with a
> "db" -  
> otherwise you get in trouble like me ;-).
>
> However, there are over 30 occurrences in various source files with
> code like  
> this, so I spared to create quick patches for all of them... Maybe it
> would be a  
> good idea to refactor this redundant piece of code out.  
> (The quick and dirty solution would be to prohibit collection names
> starting  
> with a "db"...)
>
> Jens
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl 
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Annoying Collection-Name Bug

Adam Retter-7
Jens,

I have implemented a fix to this (and some of the other guys have tidied
it up a little - Thanks :-)). Its in CVS at the moment and will
presumably make it into the next snapshot.

Hope it works for you?

Cheers Adam.


On Wed, 2005-10-19 at 18:37 +0100, Adam Retter wrote:

> Jens,
>
> Im guessing although I may be shortly corrected, that collection
> names
> should always be specified as the full path i.e. starting "/db" and
> that
> eXist merely implements the code you have mentioned to assist users
> who
> dont specify the correct path and/or because /db is in effect a
> constant
> and so it seems a shame to have to specify it for every call involving
> a
> collection name.
>
> If the code is intended to stay, it should be changed to something
> like-
>
> if (!fileName.startsWith("/"))  
>         fileName = '/' + fileName;  
> if (!fileName.startsWith("/db/"))  
>         fileName = "/db" + fileName;
>
> Note the trailing slash in the second fileName.startsWith()!!!
>
> Cheers Adam
>
>
> On Wed, 2005-10-19 at 16:01 +0100, Jens wrote:
> > Hi! I think I have found an uncritical but annoying bug in the way
> > collection  
> > names are treated. I had a collection called "dbfiles" and it was
> > impossible to  
> > retrieve a document out of it using fn:doc("/dbfiles/data.xml").
> The
> > same works  
> > fine if you use another collection name like
> fn:doc("/files/data.xml")
> > or the  
> > absolute path fn:doc("/db/dbfiles/data.xml").  
> > So I took a look at the sources and found pieces of code like
> this:  
> >  
> > > if (!fileName.startsWith("/"))  
> >         fileName = '/' + fileName;  
> > > if (!fileName.startsWith("/db"))  
> >         fileName = "/db" + fileName;
> > This works fine if you do not have collection names starting with a
> > "db" -  
> > otherwise you get in trouble like me ;-).  
> >  
> > However, there are over 30 occurrences in various source files with
> > code like  
> > this, so I spared to create quick patches for all of them... Maybe
> it
> > would be a  
> > good idea to refactor this redundant piece of code out.  
> > (The quick and dirty solution would be to prohibit collection names
> > starting  
> > with a "db"...)
> >  
> > Jens
> >  
> >  
> >  
> > -------------------------------------------------------  
> > This SF.Net email is sponsored by:  
> > Power Architecture Resource Center: Free content, downloads,
> > discussions,  
> > and more. http://solutions.newsforge.com/ibmarch.tmpl 
> > _______________________________________________  
> > Exist-open mailing list  
> > [hidden email]  
> > https://lists.sourceforge.net/lists/listinfo/exist-open 
> >
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads,
> discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl 
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Annoying Collection-Name Bug

Pierrick Brihaye-2
Hi all,

Adam Retter wrote:

> I have implemented a fix to this (and some of the other guys have tidied
> it up a little - Thanks :-)).

I'm the tidier and I plan to tidy more in the coming days, package by
package.

In fact, I would like the collections (and the resources) names to
follow the URI conventions to avoid "naive" calls such as :

http://localhost:8080/exist/servlet/db/côllêctïôn/döcùmént.xml

I know that we currently accept "unicode" collection names (see the
"città" test cases). Should we continue to do so ? Should we go towards
URI compliance ? Should we unescape the provided URIs ?  Well.. this is
worth a discussion I think.

This, however, doesn't prevent to continue tidying ;-)

Cheers,

--
Pierrick Brihaye, informaticien
Service régional de l'Inventaire
DRAC Bretagne
mailto:[hidden email]
+33 (0)2 99 29 67 78
http://usenet-fr.news.eu.org/fr-chartes/rfc1855.html. L'avez-vous lu ?


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open