2.17.2: 2011-06-17

net.sf.basedb.util.zip
Interface FileUnpacker

All Superinterfaces:
Plugin
All Known Implementing Classes:
AbstractFileUnpacker, 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: 2008-09-11 22:08:14 +0200 (Thu, 11 Sep 2008) $

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
 
Method Summary
 Set<String> getExtensions()
          Get the file extensions that this unpacker supports.
 String getFormatName()
          Get the name of the compressed file format this unpacker supports.
 Set<String> getMimeTypes()
          Get the MIME type for the file formats this unpacker supports.
 int unpack(DbControl dc, Directory dir, InputStream in, boolean overwrite, AbsoluteProgressReporter progress)
          Unpack the given input stream into a BASE directory.
 
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getAbout, getMainType, getPermissions, init, requiresConfiguration, run, supportsConfigurations
 

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,
           boolean overwrite,
           AbsoluteProgressReporter progress)
           throws IOException,
                  BaseException
Unpack the given input stream into a BASE directory.

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
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

2.17.2: 2011-06-17