From: Joe W. <jo...@gm...> - 2023-06-07 14:23:55
|
Hi Nicolas, Craig's query will work if you have the shared-resources package installed, but if not (it is no longer included in eXist releases), you will receive an error: > Cannot compile xquery: err:XQST0059 error found while loading module dbutil: failed to load module: 'http://exist-db.org/xquery/dbutil' from: ' http://exist-db.org/xquery/dbutil', location: ' http://exist-db.org/xquery/dbutil'. Source not found. The solution is either to install the shared-resources package via Dashboard > Package Manager, or to use eXide's bundled version, by changing the module import declaration to: import module namespace dbutil="http://exist-db.org/xquery/dbutil" at "/db/apps/eXide/modules/dbutils.xqm"; Joe On Tue, Jun 6, 2023 at 3:42 PM Craig Berry via Exist-open < exi...@li...> wrote: > > > > On Jun 6, 2023, at 2:04 PM, Nicolas Souchon < > sou...@gm...> wrote: > > > > Dear All, > > > > I'm new to eXist-db and can't figure out how to change ownership of a > folder and all the folders and files it contains at once from eXide. > > > > I know how to change ownership of one folder or file at a time but how > can I change ownership of a large number of folders/files at once? Knowing > that changing the ownership of the folder does not change the ownership of > the items it contains. > > > > To be more clear, my application is owned by user A but one of the > folders composing it is owned by user B and user A cannot access the > contents of this folder, so I would like to change the ownership of the > folder and its content from user B to user A. > > > > Thank you in advance for your help. > > I had to do this the other day and couldn't find a straightforward way. I > ended up writing the following. Be sure to substitute your own root path > and the desired owner, group and permissions. > > xquery version "3.1"; > > import module namespace dbutil="http://exist-db.org/xquery/dbutil"; > import module namespace console="http://exist-db.org/xquery/console"; > > declare function local:setperm($path as xs:string) { > let $x := sm:chown($path, 'owner') > let $x := sm:chgrp($path, 'group') > let $x := sm:chmod($path, 'rwxrwxr--') > let $x := console:log('Ownership and permissions set on ' || $path) > return $x > }; > > let $root := '/db/apps/somepath' > return dbutil:scan(xs:anyURI($root), function($col, $path) { > let $x := local:setperm(($path, $col)[1]) > return $x > }) > > > > > > > > ________________________________________ > Craig A. Berry > > "... getting out of a sonnet is much more > difficult than getting in." > Brad Leithauser > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > |