Class ZipUnpacker


  • public class ZipUnpacker
    extends Object
    This class can be used to unpack zip files into the BASE directory structure. The class supports unpacking multiple zip files in the same transaction.
    Version:
    2.0
    Author:
    nicklas
    Last modified
    $Date: 2011-09-23 09:05:23 +0200 (fr, 23 sep 2011) $
    • Constructor Detail

      • ZipUnpacker

        public ZipUnpacker​(DbControl dc)
        Create a new zip unpacker.
        Parameters:
        dc - The DbControl to use for database access
    • Method Detail

      • unpackZipFile

        public int unpackZipFile​(Directory rootDir,
                                 ZipInputStream zip,
                                 File sourceFile,
                                 boolean overwrite,
                                 AbsoluteProgressReporter progress)
                          throws IOException,
                                 BaseException
        Unpack a zip file.
        Parameters:
        rootDir - The directory where the contents of the zip file should be placed
        zip - The contents of the zip file
        overwrite - If existing files should be overwritten or ignored
        progress - An optional progress reporter for displaying progress
        Returns:
        The number of files unpacked
        Throws:
        IOException - If there is an error when unpacking the zip file
        BaseException - If there is a BASE error
        Since:
        3.0
      • getDirectory

        private Directory getDirectory​(Path path)
        Get the directory for the specified path. We first check the internal cache. If not found we try to load it from the database. If still not found we create a new directory and save it to the database.
        Parameters:
        path - The path
        Returns:
        The directory