Both problems fixed.  Here is how:

   - I had transposed the 2 parameters in my Java method call.
   - I unzipped and the re-zipped the defective archive using WIndows'
   built-in zip and it no longer generates the error.  My only guess is that
   it was created using some non-standard zip utility.


On Fri, Dec 11, 2015 at 2:05 PM, E. Wray Johnson <wray.john...@gmail.com>
wrote:

> Steps:
>
>    1. Create or choose a database (e.g. named 'db')
>    2. Store in BaseX a raw zip file (e.g.
>    'alpha/bravo/charlie/delta.zip').  My zip file has files in folders.
>    3. Choose a target name that also has a ".zip" extension to similar to
>    'include name of archive in path' behavior.  Note, it should not be the
>    same as the raw zip file stored (e.g. 'delta.zip')
>    4. Run the following in the BaseX GUI client - it will work
>    5. Repeat 1 and 2 using the BaseX Java Client example - it does not
>    work
>
>
> GUI CLIENT - DOES WORK
> ========================================
> let $database := 'db'
> let $extractTo := 'target.zip'
> let $archivePath := 'alpha/bravo/charlie/delta.zip'
>
> let $archive  := db:retrieve($database, $archivePath)
> let $basePath := replace($archivePath, '[^/]+$', '') || $extractTo
> let $entries  := archive:entries($archive)
> let $contents := archive:extract-binary($archive)
> return for-each-pair($entries, $contents, %updating function($entry,
> $content) {
>   let $target := $basePath || '/' || $entry/text()
>   return try {
>       db:store($database, $target, $content)
>     } catch * {
>       ()
>     }
> })
>
>
> JAVA - DOES NOT WORK:
> ===============================================
> // Usage: Create a BaseXClient object and call this method.
> // For example:
> // ExplodeArchive("db", "target.zip", "alpha/bravo/charlie/delta.zip", ..)
>
> private static void ExplodeArchive(final String database, String
> extractTo, String archivePath, BaseXClient session) throws IOException {
>         try {
>             String queryString =
>                     "let $database := '" + database +"' " +
>                     "let $extractTo := '" + extractTo + "' " +
>                     "let $archivePath := '"+ archivePath + "' " +
>                     "let $archive  := db:retrieve($database, $archivePath)
> " +
>                     "let $basePath := replace($archivePath, '[^/]+$', '')
> || $extractTo " +
>                     "let $entries  := archive:entries($archive) " +
>                     "let $contents := archive:extract-binary($archive) " +
>                     "for $entry at $pos in $entries " +
>                     "let $content := $contents[$pos] " +
>                     "let $target := $basePath || '/' || $entry/text() " +
>                     "return db:store($database, "+ "$target, $content)";
>             final BaseXClient.Query query = session.query(queryString);
>             query.execute();
>         } finally {
>             session.close();
>         }
>     }
>
>
>
>
> On Fri, Dec 11, 2015 at 1:28 PM, Christian Grün <christian.gr...@gmail.com
> > wrote:
>
>> Could you please provide me with a minimized example that shows the
>> problem, and which I can run both in the GUI and via the Java client?
>>
>>
>> On Fri, Dec 11, 2015 at 6:24 PM, E. Wray Johnson <wray.john...@gmail.com>
>> wrote:
>> > What is the format for an absolute path for db:store?
>> > Neither of the following works:
>> >
>> > '/db/alpha/bravo/charlie/delta.zip/subfolder/subfile.ext'
>> > and '/'alpha/bravo/charlie/delta.zip/subfolder/subfile.ext'
>> >
>> > However my original code works in the BaseX GUI, just not through the
>> Java
>> > Client.
>> >
>> > Could it have something to the with the period or .zip in the middle of
>> the
>> > path?
>> >
>> >
>> >
>> > On Fri, Dec 11, 2015 at 11:11 AM, Christian Grün <
>> christian.gr...@gmail.com>
>> > wrote:
>> >>
>> >> > This is happening in the call to db:store where the path is
>> >> > 'alpha/bravo/charlie/delta.zip/subfolder/subfile.ext'
>> >>
>> >> Hm, so this is the relative path to the local resource you want to
>> >> store? Does it work if you specify the absolute path?
>> >>
>> >> > Could it have something to do with a default archive parser for
>> archives
>> >> > in
>> >> > the Java Client ?
>> >>
>> >> The Java client (if it’s the one I believe it is) is very dumb; it
>> >> just passes on everything to the server.
>> >>
>> >>
>> >> >
>> >> >
>> >> >
>> >> > On Fri, Dec 11, 2015 at 10:10 AM, Christian Grün
>> >> > <christian.gr...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> > In the meantime can you shed some light into the >  [FODC0002]
>> >> >> > Resource
>> >> >> > 'delta.zip' does not exist.' error?
>> >> >>
>> >> >> (cc to the list): It simply says that a database resource does not
>> >> >> exist.
>> >> >>
>> >> >> Maybe you have more than one BaseX database directory in your
>> >> >> environment? Could you try db:list('...db...') and check what
>> results
>> >> >> are returned in the GUI and via the client?
>> >> >>
>> >> >>
>> >> >> > On Fri, Dec 11, 2015 at 9:53 AM, Christian Grün
>> >> >> > <christian.gr...@gmail.com>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> > The raw stored file was slightly larger than the original zip.
>> >> >> >>
>> >> >> >> Do you have an example for that?
>> >> >> >>
>> >> >> >> > But when I submit the exact same query using the Java client I
>> get
>> >> >> >> > the
>> >> >> >> > following error:
>> >> >> >> >
>> >> >> >> > Stopped at ., 1/216:
>> >> >> >> >  [FODC0002] Resource 'delta.zip' does not exist.
>> >> >> >>
>> >> >> >> It shouldn’t make a difference. I’ll probably need more info to
>> >> >> >> track
>> >> >> >> this
>> >> >> >> down.
>> >> >> >
>> >> >> >
>> >> >
>> >> >
>> >
>> >
>>
>
>

Reply via email to