2.17.2: 2011-06-17

net.sf.basedb.plugins
Class TarFileUnpacker

java.lang.Object
  extended by net.sf.basedb.core.plugin.AbstractPlugin
      extended by net.sf.basedb.util.zip.AbstractFileUnpacker
          extended by net.sf.basedb.plugins.TarFileUnpacker
All Implemented Interfaces:
InteractivePlugin, Plugin, SignalTarget, FileUnpacker

public class TarFileUnpacker
extends AbstractFileUnpacker

A plugin for unpacking tar, gzipped tar and bzipped tar files to the BASE file system.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2010-09-10 13:09:05 +0200 (Fri, 10 Sep 2010) $

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
 
Field Summary
private static About about
          Plugin description
private static Set<String> extensions
           
private static Set<String> mimeTypes
           
private  Map<String,Directory> paths
           
 
Fields inherited from class net.sf.basedb.util.zip.AbstractFileUnpacker
OVERWRITE, UNPACK_DIRECTORY, ZIP_FILE
 
Fields inherited from class net.sf.basedb.core.plugin.AbstractPlugin
annotationSection, configuration, COPY_ANNOTATIONS, job, OVERWRITE_ANNOTATIONS, sc
 
Constructor Summary
TarFileUnpacker()
           
 
Method Summary
 About getAbout()
          Get information about the plugin, such as name, version, authors, etc.
private  Directory getDirectory(DbControl dc, Path path)
          Get the directory for the specified path.
 Set<String> getExtensions()
          Return a set containing the strings [ tar, tar.gz, tgz, tar.bz2 ].
 String getFormatName()
          Get the name of the compressed file format this unpacker supports.
 Set<String> getMimeTypes()
          Return a set containing the strings [ application/x-tar, application/x-gzip, application/x-bzip2 ].
 int unpack(DbControl dc, Directory rootDir, InputStream in, boolean overwrite, AbsoluteProgressReporter progress)
          Unpack the given input stream into a BASE directory.
 
Methods inherited from class net.sf.basedb.util.zip.AbstractFileUnpacker
configure, getCurrentDirectory, getCurrentFile, getDirectoryParameter, getGuiContexts, getMainType, getOverwrite, getOverwriteParameter, getPermissions, getRequestInformation, getSignalHandler, getUnpackDirectory, getZipFile, getZipFileParameter, isInContext, requiresConfiguration, run, supportsConfigurations
 
Methods inherited from class net.sf.basedb.core.plugin.AbstractPlugin
checkInterrupted, cloneParameterWithDefaultValue, closeLogFile, createLogFile, done, getCopyAnnotationsParmeter, getCurrentConfiguration, getCurrentJob, getJobOrConfigurationValue, getOverwriteAnnotationsParameters, init, log, log, storeValue, storeValue, storeValues, validateRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, init
 

Field Detail

about

private static final About about
Plugin description


extensions

private static final Set<String> extensions

mimeTypes

private static final Set<String> mimeTypes

paths

private Map<String,Directory> paths
Constructor Detail

TarFileUnpacker

public TarFileUnpacker()
Method Detail

getAbout

public About getAbout()
Description copied from interface: Plugin
Get information about the plugin, such as name, version, authors, etc.

Returns:
An About object

getFormatName

public String getFormatName()
Description copied from interface: FileUnpacker
Get the name of the compressed file format this unpacker supports. For example: ZIP files


getExtensions

public Set<String> getExtensions()
Return a set containing the strings [ tar, tar.gz, tgz, tar.bz2 ].

Returns:
A set containing file extensions (do not inlcude the dot)

getMimeTypes

public Set<String> getMimeTypes()
Return a set containing the strings [ application/x-tar, application/x-gzip, application/x-bzip2 ].

Returns:
A set containing MIME types

unpack

public int unpack(DbControl dc,
                  Directory rootDir,
                  InputStream in,
                  boolean overwrite,
                  AbsoluteProgressReporter progress)
           throws IOException
Description copied from interface: FileUnpacker
Unpack the given input stream into a BASE directory.

Parameters:
dc - The DbControl to use for database access
rootDir - 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

getDirectory

private Directory getDirectory(DbControl dc,
                               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

2.17.2: 2011-06-17