Chapter 18. ZIP File Sequencer

18.1. ZIP File Sequencer

The ZIP file sequencer is included in ModeShape and extracts the files and folders contained in the ZIP archive file, extracting the files and folders into the repository using JCR's nt:file and nt:folder built-in node types. The structure of the output thus matches the logical structure of the contents of the ZIP file.

18.2. ZIP File Sequencer Example

This sequencer generates a graph structure that maps to the files and folders in the ZIP file. An example (listed in the JCR document view) from sequencing a ZIP file written into /a/foo and containing one file, /x/y/z.txt is provided below:
<foo jcr:primaryType="zip:file"
     mode:derivedFrom="/files/docForReferenceGuide.xml" >
  <x jcr:primaryType="nt:folder" 
    <y jcr:primaryType="nt:folder" 
      <z.txt jcr:primaryType="nt:file">
        <jcr:content jcr:primaryType="nt:resource"
                     jcr:data="This is the file content"
                     jcr:mimeType="text/plain" />

18.3. ZIP File Sequencer Node Types

The CND for the zip:file node type is listed below.
[zip:file] > nt:folder, mix:mimeType

18.4. Configuring a ZIP File Sequencer

  1. Include the relevant libraries

    Include modeshape-sequencer-zip-VERSION.jar in your application.
  2. Choose one of the following for sequencing configuration

    • Define sequencing configuration based on standard example provided in SOA-ROOT/eds/modeshape/resources/modeshape-config-standard.xml:
      <mode:sequencer jcr:name="ZIP File Sequencer" mode:classname="">
          Sequences ZIP files loaded under '/files', extracting the archive file contents into the equivalent JCR graph structure of 'nt:file' and 'nt:folder' nodes.
          eds-store:default:/files(//)(*.zip[*])/jcr:content[@jcr:data] => eds-store:default:/sequenced/zip/$1
    • Configure via org.modeshape.jcr.JcrConfiguration:
      JcrConfiguration config = ...
      config.sequencer("ZIP File Sequencer")
            .setDescription("Sequences ZIP files loaded under '/files', extracting the archive file contents into the equivalent JCR graph structure of 'nt:file' and 'nt:folder' nodes.")


    Refer to SOA-ROOT/eds/modeshape/resources/modeshape-config-standard.xml for more information.