2689 |
02 Oct 06 |
nicklas |
1 |
/** |
2689 |
02 Oct 06 |
nicklas |
$Id$ |
2689 |
02 Oct 06 |
nicklas |
3 |
|
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg |
2689 |
02 Oct 06 |
nicklas |
5 |
|
2689 |
02 Oct 06 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
2689 |
02 Oct 06 |
nicklas |
Available at http://base.thep.lu.se/ |
2689 |
02 Oct 06 |
nicklas |
8 |
|
2689 |
02 Oct 06 |
nicklas |
BASE is free software; you can redistribute it and/or |
2689 |
02 Oct 06 |
nicklas |
modify it under the terms of the GNU General Public License |
4479 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
2689 |
02 Oct 06 |
nicklas |
of the License, or (at your option) any later version. |
2689 |
02 Oct 06 |
nicklas |
13 |
|
2689 |
02 Oct 06 |
nicklas |
BASE is distributed in the hope that it will be useful, |
2689 |
02 Oct 06 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2689 |
02 Oct 06 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2689 |
02 Oct 06 |
nicklas |
GNU General Public License for more details. |
2689 |
02 Oct 06 |
nicklas |
18 |
|
2689 |
02 Oct 06 |
nicklas |
You should have received a copy of the GNU General Public License |
4515 |
11 Sep 08 |
jari |
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 |
This interface should be implemented by plugins that can unpack a single compressed |
2689 |
02 Oct 06 |
nicklas |
file into the BASE file system. The plugin may extend the |
2689 |
02 Oct 06 |
nicklas |
{@link net.sf.basedb.util.zip.AbstractFileUnpacker} class which implements most of the |
2689 |
02 Oct 06 |
nicklas |
plugin specified parts, leaving only the actual unpacking to the subclass. |
2689 |
02 Oct 06 |
nicklas |
<p> |
2689 |
02 Oct 06 |
nicklas |
The file upload functionality checks all plugins that implement this interface to |
2689 |
02 Oct 06 |
nicklas |
provide automatic unpacking of uploaded files without having to store them in a |
2689 |
02 Oct 06 |
nicklas |
temporary place first. |
2689 |
02 Oct 06 |
nicklas |
44 |
|
2689 |
02 Oct 06 |
nicklas |
@author nicklas |
2689 |
02 Oct 06 |
nicklas |
@version 2.0 |
2689 |
02 Oct 06 |
nicklas |
@base.modified $Date$ |
2689 |
02 Oct 06 |
nicklas |
@see net.sf.basedb.plugins.ZipFileUnpacker |
2689 |
02 Oct 06 |
nicklas |
@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 |
Get the name of the compressed file format this unpacker supports. |
2691 |
03 Oct 06 |
nicklas |
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 |
Get the file extensions that this unpacker supports. For example |
2689 |
02 Oct 06 |
nicklas |
[ zip, jar ]. |
2689 |
02 Oct 06 |
nicklas |
@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 |
Get the MIME type for the file formats this unpacker supports. For example |
2689 |
02 Oct 06 |
nicklas |
[ application/zip, application/java-archive ]. |
2689 |
02 Oct 06 |
nicklas |
@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 |
Unpack the given input stream into a BASE directory. If a source |
5758 |
23 Sep 11 |
nicklas |
file is given it can be used as a template for setting certain |
5758 |
23 Sep 11 |
nicklas |
properties on the unpcked files. See {@link |
5758 |
23 Sep 11 |
nicklas |
PackUtil#copyProperties(File, File)}. |
2689 |
02 Oct 06 |
nicklas |
81 |
|
2689 |
02 Oct 06 |
nicklas |
@param dc The DbControl to use for database access |
2689 |
02 Oct 06 |
nicklas |
@param dir The directory to unpack the files to |
2689 |
02 Oct 06 |
nicklas |
@param in The input stream containing the packed data |
5758 |
23 Sep 11 |
nicklas |
@param sourceFile The source packed file that the input stream is |
5758 |
23 Sep 11 |
nicklas |
coming from or null if not known |
2689 |
02 Oct 06 |
nicklas |
@param overwrite If existing files should be overwritten or ignored |
2689 |
02 Oct 06 |
nicklas |
@param progress A optional progress reporter which expects the number |
2689 |
02 Oct 06 |
nicklas |
of compressed bytes that has been uncompressed |
2689 |
02 Oct 06 |
nicklas |
@return The number of unpacked files |
2689 |
02 Oct 06 |
nicklas |
@throws IOException If there is an error reading the input stream |
2689 |
02 Oct 06 |
nicklas |
@throws BaseException If there is another error |
5758 |
23 Sep 11 |
nicklas |
@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 |
} |