Interface FileUnpacker

  • All Superinterfaces:
    Plugin
    All Known Implementing Classes:
    AbstractFileUnpacker, Bzip2FileUnpacker, GzipFileUnpacker, TarFileUnpacker, ZipFileUnpacker

    public interface FileUnpacker
    extends Plugin
    This interface should be implemented by plugins that can unpack a single compressed file into the BASE file system. The plugin may extend the AbstractFileUnpacker class which implements most of the plugin specified parts, leaving only the actual unpacking to the subclass.

    The file upload functionality checks all plugins that implement this interface to provide automatic unpacking of uploaded files without having to store them in a temporary place first.

    Version:
    2.0
    Author:
    nicklas
    See Also:
    ZipFileUnpacker, AbstractFileUnpacker
    Last modified
    $Date: 2011-09-23 09:05:23 +0200 (fr, 23 sep 2011) $
    • Method Detail

      • getFormatName

        String getFormatName()
        Get the name of the compressed file format this unpacker supports. For example: ZIP files
      • getExtensions

        Set<String> getExtensions()
        Get the file extensions that this unpacker supports. For example [ zip, jar ].
        Returns:
        A set containing file extensions (do not inlcude the dot)
      • getMimeTypes

        Set<String> getMimeTypes()
        Get the MIME type for the file formats this unpacker supports. For example [ application/zip, application/java-archive ].
        Returns:
        A set containing MIME types
      • unpack

        int unpack​(DbControl dc,
                   Directory dir,
                   InputStream in,
                   File sourceFile,
                   boolean overwrite,
                   AbsoluteProgressReporter progress)
            throws IOException,
                   BaseException
        Unpack the given input stream into a BASE directory. If a source file is given it can be used as a template for setting certain properties on the unpcked files. See PackUtil.copyProperties(File, File).
        Parameters:
        dc - The DbControl to use for database access
        dir - The directory to unpack the files to
        in - The input stream containing the packed data
        sourceFile - The source packed file that the input stream is coming from or null if not known
        overwrite - If existing files should be overwritten or ignored
        progress - A optional progress reporter which expects the number of compressed bytes that has been uncompressed
        Returns:
        The number of unpacked files
        Throws:
        IOException - If there is an error reading the input stream
        BaseException - If there is another error
        Since:
        3.0