jfileupload.transfer.client.core
Class ArchiveFilter

java.lang.Object
  extended by jfileupload.transfer.client.core.ArchiveFilter
All Implemented Interfaces:
TransferFilter

public class ArchiveFilter
extends java.lang.Object
implements TransferFilter

Archive files into a ZIP archive. Known limitation : Non-ASCII characters such as ÄÜäöüùéàè... are ZIP tools dependent. See : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499 SUN ZIP implementation stores non-ASCII characters as UTF-8. JAVA_HOME/bin/jar.exe tool is able to unzip them. WinZip can't.


Field Summary
static int BUFFERSIZE
           
protected  boolean cancelled
           
protected  java.lang.String comment
           
protected  java.lang.String countrenamed
           
 java.lang.String ENTRIES_RENAMED
           
 java.lang.String ENTRIES_SKIPPED
           
protected  java.lang.String extension
           
protected  java.lang.String filesskipped
           
protected  java.util.List filesSkipped
           
protected  java.lang.String fullname
           
protected  java.lang.String hiddenEntry
           
protected  java.lang.String identifier
           
protected  int level
           
protected  long maxsize
           
protected  java.util.Properties props
           
protected  java.lang.String template
           
 
Constructor Summary
ArchiveFilter(Conf cnf)
          Constructor.
 
Method Summary
protected  void addFile(java.io.File file, java.util.zip.ZipOutputStream zos, byte[] buffer)
          Add file to compress.
protected  void addFolder(java.util.zip.ZipOutputStream zos, java.io.File folder, java.io.File rootFolder, byte[] buffer, long level, long depth)
          Compress folder recursively.
 void cancel()
          Cancel archive creation.
 void clean()
          Delete temporary ZIP archive.
 java.lang.Object execute(java.lang.Object input)
          Execute the Filter such as file content checking or modification.
 void init(TransferController tc, java.lang.String id)
          Initialize Filter such as loading configuration file.
protected  boolean isAllowed(java.io.File file)
          Check if file is allowed (blacklist, maxsize ...)
protected  void loadParameters()
          Load Filter parameters.
protected  void notifyOnComplete(java.io.File output, java.lang.String txt)
          Notify Filter listeners about complete.
protected  void notifyOnFail(ClientException e)
          Notify Filter listeners about failure.
protected  void notifyOnStarted(java.io.File input, java.lang.String txt)
          Notify Filter listeners about filter status = started.
protected  void notifyOnStarting(java.lang.Object input, java.lang.String txt)
          Notify Filter listeners about filter status = starting.
protected  java.io.File processCompress(java.util.List list)
          Compress files and folders selected.
protected  java.lang.String serializeList(java.util.List list)
          Serialize list of File
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFERSIZE

public static int BUFFERSIZE

ENTRIES_RENAMED

public java.lang.String ENTRIES_RENAMED

ENTRIES_SKIPPED

public java.lang.String ENTRIES_SKIPPED

identifier

protected java.lang.String identifier

props

protected java.util.Properties props

level

protected int level

maxsize

protected long maxsize

comment

protected java.lang.String comment

extension

protected java.lang.String extension

fullname

protected java.lang.String fullname

template

protected java.lang.String template

countrenamed

protected java.lang.String countrenamed

filesskipped

protected java.lang.String filesskipped

hiddenEntry

protected java.lang.String hiddenEntry

filesSkipped

protected java.util.List filesSkipped

cancelled

protected boolean cancelled
Constructor Detail

ArchiveFilter

public ArchiveFilter(Conf cnf)
Constructor.

Parameters:
cnf -
Method Detail

init

public void init(TransferController tc,
                 java.lang.String id)
          throws ClientException
Description copied from interface: TransferFilter
Initialize Filter such as loading configuration file.

Specified by:
init in interface TransferFilter
id - identifier
Throws:
ClientException

loadParameters

protected void loadParameters()
Load Filter parameters.


execute

public java.lang.Object execute(java.lang.Object input)
                         throws ClientException
Description copied from interface: TransferFilter
Execute the Filter such as file content checking or modification.

Specified by:
execute in interface TransferFilter
Returns:
Throws:
ClientException

clean

public void clean()
Delete temporary ZIP archive.

Specified by:
clean in interface TransferFilter

processCompress

protected java.io.File processCompress(java.util.List list)
                                throws ClientException
Compress files and folders selected.

Parameters:
list -
Returns:
Throws:
ClientException

addFile

protected void addFile(java.io.File file,
                       java.util.zip.ZipOutputStream zos,
                       byte[] buffer)
                throws java.io.IOException
Add file to compress.

Parameters:
file -
zos -
buffer -
Throws:
java.io.IOException

addFolder

protected void addFolder(java.util.zip.ZipOutputStream zos,
                         java.io.File folder,
                         java.io.File rootFolder,
                         byte[] buffer,
                         long level,
                         long depth)
                  throws java.io.IOException
Compress folder recursively. Empty folders are included.

Parameters:
zos - ZipOutputStream
folder - File
rootFolder - File
buffer - byte[]
level -
depth -
Throws:
java.io.IOException

cancel

public void cancel()
Cancel archive creation.


notifyOnStarting

protected void notifyOnStarting(java.lang.Object input,
                                java.lang.String txt)
Notify Filter listeners about filter status = starting.

Parameters:
input -
txt -

notifyOnStarted

protected void notifyOnStarted(java.io.File input,
                               java.lang.String txt)
Notify Filter listeners about filter status = started.

Parameters:
input -
txt -

notifyOnComplete

protected void notifyOnComplete(java.io.File output,
                                java.lang.String txt)
Notify Filter listeners about complete.

Parameters:
output -
txt -

notifyOnFail

protected void notifyOnFail(ClientException e)
Notify Filter listeners about failure.

Parameters:
output -
txt -

isAllowed

protected boolean isAllowed(java.io.File file)
                     throws java.io.IOException
Check if file is allowed (blacklist, maxsize ...)

Parameters:
file -
Returns:
Throws:
java.io.IOException

serializeList

protected java.lang.String serializeList(java.util.List list)
Serialize list of File

Parameters:
list -
Returns:
items separated by | char.