From: Dmitriy S. <sha...@gm...> - 2012-02-08 12:44:25
|
On Wed, Feb 8, 2012 at 5:33 PM, Joe Wicentowski <jo...@gm...> wrote: > > But I did just notice a bug - I'm just not sure if this is an app level or > system level issue. The demo app (in svn, /exist/apps/demo > ant build.xml > > build/demo.xar) , the JSON demo at > http://localhost:8080/exist/apps/demo/examples/special/json.xql returns > this error to the browser: > > <exception> > <path>/db/demo/examples/special/json.xql</path> > <message> > Could not locate collection: /db/system/security [at line 14, > column 22] In function: local:sub-collections(xs:string*) > [33:9:/db/demo/examples/special/json.xql] local:collections(xs:string*, > xs:string*) [18:19:/db/demo/examples/special/json.xql] > local:sub-collections(xs:string*) [33:9:/db/demo/examples/special/json.xql] > local:collections(xs:string*, xs:string*) > [18:19:/db/demo/examples/special/json.xql] > local:sub-collections(xs:string*) [33:9:/db/demo/examples/special/json.xql] > local:collections(xs:string*, xs:string*) > [40:6:/db/demo/examples/special/json.xql] > </message> > </exception> > > I think this is triggered by a call to *xmldb:get-child-collections*(* > '/db/system/security'*) on line 14 column 22 of the json.xql. eXide's > collection browser (eXide/modules/collections.xql) prevents this error by > adding this conditional: > > * if* (*sm:has-access*(*xs:anyURI*(*$root*), "x")) *then* > *let **$children* := *xmldb:get-child-collections*(*$root*) > Is this the suggested best practice -- checking for sm:has-access before > trying to use xmldb:get-*? > Yes, if you do want to avoid exception to be send out you should check permissions first or use try-catch. -- Dmitriy Shabanov |