src/core/net/sf/basedb/util/zip/FileUnpacker.java

Code
Comments
Other
Rev Date Author Line
2689 02 Oct 06 nicklas 1 /**
2689 02 Oct 06 nicklas 2   $Id$
2689 02 Oct 06 nicklas 3
3675 16 Aug 07 jari 4   Copyright (C) 2006 Nicklas Nordborg
2689 02 Oct 06 nicklas 5
2689 02 Oct 06 nicklas 6   This file is part of BASE - BioArray Software Environment.
2689 02 Oct 06 nicklas 7   Available at http://base.thep.lu.se/
2689 02 Oct 06 nicklas 8
2689 02 Oct 06 nicklas 9   BASE is free software; you can redistribute it and/or
2689 02 Oct 06 nicklas 10   modify it under the terms of the GNU General Public License
4479 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
2689 02 Oct 06 nicklas 12   of the License, or (at your option) any later version.
2689 02 Oct 06 nicklas 13
2689 02 Oct 06 nicklas 14   BASE is distributed in the hope that it will be useful,
2689 02 Oct 06 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
2689 02 Oct 06 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2689 02 Oct 06 nicklas 17   GNU General Public License for more details.
2689 02 Oct 06 nicklas 18
2689 02 Oct 06 nicklas 19   You should have received a copy of the GNU General Public License
4515 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2689 02 Oct 06 nicklas 21 */
2689 02 Oct 06 nicklas 22 package net.sf.basedb.util.zip;
2689 02 Oct 06 nicklas 23
2689 02 Oct 06 nicklas 24 import java.io.IOException;
2689 02 Oct 06 nicklas 25 import java.io.InputStream;
2689 02 Oct 06 nicklas 26 import java.util.Set;
2689 02 Oct 06 nicklas 27
2689 02 Oct 06 nicklas 28 import net.sf.basedb.core.AbsoluteProgressReporter;
2689 02 Oct 06 nicklas 29 import net.sf.basedb.core.BaseException;
2689 02 Oct 06 nicklas 30 import net.sf.basedb.core.DbControl;
2689 02 Oct 06 nicklas 31 import net.sf.basedb.core.Directory;
5758 23 Sep 11 nicklas 32 import net.sf.basedb.core.File;
2689 02 Oct 06 nicklas 33 import net.sf.basedb.core.plugin.Plugin;
2689 02 Oct 06 nicklas 34
2689 02 Oct 06 nicklas 35 /**
2689 02 Oct 06 nicklas 36   This interface should be implemented by plugins that can unpack a single compressed
2689 02 Oct 06 nicklas 37   file into the BASE file system. The plugin may extend the 
2689 02 Oct 06 nicklas 38   {@link net.sf.basedb.util.zip.AbstractFileUnpacker} class which implements most of the
2689 02 Oct 06 nicklas 39   plugin specified parts, leaving only the actual unpacking to the subclass.
2689 02 Oct 06 nicklas 40   <p>
2689 02 Oct 06 nicklas 41   The file upload functionality checks all plugins that implement this interface to
2689 02 Oct 06 nicklas 42   provide automatic unpacking of uploaded files without having to store them in a
2689 02 Oct 06 nicklas 43   temporary place first.
2689 02 Oct 06 nicklas 44
2689 02 Oct 06 nicklas 45   @author nicklas
2689 02 Oct 06 nicklas 46   @version 2.0
2689 02 Oct 06 nicklas 47   @base.modified $Date$
2689 02 Oct 06 nicklas 48   @see net.sf.basedb.plugins.ZipFileUnpacker
2689 02 Oct 06 nicklas 49   @see net.sf.basedb.util.zip.AbstractFileUnpacker
2689 02 Oct 06 nicklas 50 */
2689 02 Oct 06 nicklas 51 public interface FileUnpacker
2689 02 Oct 06 nicklas 52   extends Plugin
2689 02 Oct 06 nicklas 53 {
2689 02 Oct 06 nicklas 54   
2689 02 Oct 06 nicklas 55   /**
2691 03 Oct 06 nicklas 56     Get the name of the compressed file format this unpacker supports.
2691 03 Oct 06 nicklas 57     For example: ZIP files
2691 03 Oct 06 nicklas 58   */
2691 03 Oct 06 nicklas 59   public String getFormatName();
2691 03 Oct 06 nicklas 60   
2691 03 Oct 06 nicklas 61   /**
2689 02 Oct 06 nicklas 62     Get the file extensions that this unpacker supports. For example
2689 02 Oct 06 nicklas 63     [ zip, jar ].
2689 02 Oct 06 nicklas 64     @return A set containing file extensions (do not inlcude the dot)
2689 02 Oct 06 nicklas 65   */
2689 02 Oct 06 nicklas 66   public Set<String> getExtensions();
2689 02 Oct 06 nicklas 67   
2689 02 Oct 06 nicklas 68   
2689 02 Oct 06 nicklas 69   /**
2689 02 Oct 06 nicklas 70     Get the MIME type for the file formats this unpacker supports. For example
2689 02 Oct 06 nicklas 71     [ application/zip, application/java-archive ].
2689 02 Oct 06 nicklas 72     @return A set containing MIME types
2689 02 Oct 06 nicklas 73   */
2689 02 Oct 06 nicklas 74   public Set<String> getMimeTypes();
2689 02 Oct 06 nicklas 75   
2689 02 Oct 06 nicklas 76   /**
5758 23 Sep 11 nicklas 77     Unpack the given input stream into a BASE directory. If a source
5758 23 Sep 11 nicklas 78     file is given it can be used as a template for setting certain
5758 23 Sep 11 nicklas 79     properties on the unpcked files. See {@link 
5758 23 Sep 11 nicklas 80     PackUtil#copyProperties(File, File)}.
2689 02 Oct 06 nicklas 81     
2689 02 Oct 06 nicklas 82     @param dc The DbControl to use for database access
2689 02 Oct 06 nicklas 83     @param dir The directory to unpack the files to
2689 02 Oct 06 nicklas 84     @param in The input stream containing the packed data
5758 23 Sep 11 nicklas 85     @param sourceFile The source packed file that the input stream is
5758 23 Sep 11 nicklas 86       coming from or null if not known
2689 02 Oct 06 nicklas 87     @param overwrite If existing files should be overwritten or ignored
2689 02 Oct 06 nicklas 88     @param progress A optional progress reporter which expects the number
2689 02 Oct 06 nicklas 89       of compressed bytes that has been uncompressed
2689 02 Oct 06 nicklas 90     @return The number of unpacked files
2689 02 Oct 06 nicklas 91     @throws IOException If there is an error reading the input stream
2689 02 Oct 06 nicklas 92     @throws BaseException If there is another error
5758 23 Sep 11 nicklas 93     @since 3.0
2689 02 Oct 06 nicklas 94   */
5758 23 Sep 11 nicklas 95   public int unpack(DbControl dc, Directory dir, InputStream in, File sourceFile, boolean overwrite, 
2689 02 Oct 06 nicklas 96     AbsoluteProgressReporter progress)
2689 02 Oct 06 nicklas 97     throws IOException, BaseException;
2689 02 Oct 06 nicklas 98   
2689 02 Oct 06 nicklas 99 }