Class UnzipPipe

All Implemented Interfaces:
HasTransactionAttribute, IConfigurable, IConfigurationAware, IForwardTarget, INamedObject, IPipe, IScopeProvider, IWithParameters, EventThrowing, HasStatistics, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@ElementType(TRANSLATOR) public class UnzipPipe extends FixedForwardPipe
Assumes input to be the file name of a ZIP archive, and unzips it to a directory and/or an XML message.
The output of each unzipped item is returned in XML as follows when collectFileContents is false:
  <results count="num_of_items">
    <result item="1">
      <zipEntry>name in ZIP archive of first item</zipEntry>
      <fileName>filename of first item</fileName>
    </result>
    <result item="2">
      <zipEntry>name in ZIP archive of second item</zipEntry>
      <fileName>filename of second item</fileName>
    </result>
       ...
  </results>
 

The output of each unzipped item is returned in XML as follows when collectFileContents is true:
  <results count="num_of_items">
    <result item="1">
      <zipEntry>name in ZIP archive of first item</zipEntry>
      <fileContent>content of first item</fileContent>
    </result>
    <result item="2">
      <zipEntry>name in ZIP archive of second item</zipEntry>
      <fileContent>content of second item</fileContent>
    </result>
       ...
  </results>
 

By default, this pipe takes care to produce unique file names, as follows. When the filename within the archive is:
<basename> + "." + <extension>
then the extracted filename (path omitted) becomes
<basename> + <unique number> + "." + <extension>

Since:
4.9
Author:
Gerrit van Brakel
  • Constructor Details

    • UnzipPipe

      public UnzipPipe()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from class: FixedForwardPipe
      checks for correct configuration of forward
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IPipe
      Overrides:
      configure in class FixedForwardPipe
      Throws:
      ConfigurationException
    • getInputStream

      protected InputStream getInputStream(Message message, PipeLineSession session) throws PipeRunException
      Throws:
      PipeRunException
    • doPipe

      public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException
      Description copied from interface: IPipe
      This is where the action takes place. Pipes may only throw a PipeRunException, to be handled by the caller of this object. Implementations must either consume the message, or pass it on to the next Pipe in the PipeRunResult. If the result of the Pipe does not depend on the input, like for the FixedResultPipe, the Pipe can schedule the input to be closed at session exit, by calling Message.closeOnCloseOf(PipeLineSession, String) This allows the previous Pipe to release any resources (e.g. connections) that it might have kept open until the message was consumed. Doing so avoids connections leaking from pools, while it enables efficient streaming processing of data while it is being read from a stream.
      Throws:
      PipeRunException
    • setDirectory

      public void setDirectory(String string)
      Directory to extract the archive to
    • setDirectorySessionKey

      public void setDirectorySessionKey(String directorySessionKey)
      Sessionkey with a directory value to extract the archive to
    • setDeleteOnExit

      @Deprecated @ConfigurationWarning("This flag is no longer supported as it leaks server memory. Temporary files should be removed by other means.") public void setDeleteOnExit(boolean b)
      Deprecated.
      If true, file is automatically deleted upon normal JVM termination
      Default value
      true
    • setCollectResults

      public void setCollectResults(boolean b)
      If set false, only a small summary (count of items in zip) is returned
      Default value
      true
    • setCollectFileContents

      public void setCollectFileContents(boolean b)
      If set true, the contents of the files in the zip are returned in the result xml message of this pipe. Please note this can consume a lot of memory for large files or a large number of files
      Default value
      false
    • setCollectFileContentsBase64Encoded

      public void setCollectFileContentsBase64Encoded(String string)
      Comma separated list of file extensions. Files with an extension which is part of this list will be base64 encoded. All other files are assumed to have UTF-8 when reading it from the zip and are added as escaped xml with non-unicode-characters being replaced by inverted question mark appended with #, the character number and ;
      Default value
      false
    • setKeepOriginalFileName

      public void setKeepOriginalFileName(boolean b)
      If set false, a suffix is added to the original filename to be sure it is unique
      Default value
      false
    • setCreateSubDirectories

      @Deprecated @ConfigurationWarning("the attribute \'createSubDirectories\' has been renamed to \'keepOriginalFilePath\'") public void setCreateSubDirectories(boolean b)
      Deprecated.
    • setKeepOriginalFilePath

      public void setKeepOriginalFilePath(boolean b)
      If set true, the path of the zip entry will be preserved. Otherwise, the zip entries will be extracted to the root folder
      Default value
      false
    • setAssumeDirectoryExists

      public void setAssumeDirectoryExists(boolean assumeDirectoryExists)
      If set true, validation of directory is ignored
      Default value
      false
    • setCheckDirectory

      @Deprecated @ConfigurationWarning("the attribute \'checkDirectory\' has been renamed to \'assumeDirectoryExists\'") public void setCheckDirectory(boolean checkDirectory)
      Deprecated.
    • setProcessFile

      @Deprecated @ConfigurationWarning("Please add a LocalFileSystemPipe with action=read in front of this pipe instead") public void setProcessFile(boolean b)
      Deprecated.
      If set true, the input is assumed to be the name of a file to be processed. Otherwise, the input itself is used.
      Default value
      false
    • getDirectory

      public String getDirectory()
    • getDirectorySessionKey

      public String getDirectorySessionKey()
    • isDeleteOnExit

      @Deprecated public boolean isDeleteOnExit()
      Deprecated.
    • isCollectResults

      public boolean isCollectResults()
    • isCollectFileContents

      public boolean isCollectFileContents()
    • getCollectFileContentsBase64Encoded

      public String getCollectFileContentsBase64Encoded()
    • isKeepOriginalFileName

      public boolean isKeepOriginalFileName()
    • isKeepOriginalFilePath

      public boolean isKeepOriginalFilePath()
    • isAssumeDirectoryExists

      public boolean isAssumeDirectoryExists()
    • isProcessFile

      public boolean isProcessFile()