javazoom.upload
Class UploadBean

java.lang.Object
  |
  +--javazoom.upload.UploadBean
All Implemented Interfaces:
java.io.Serializable

public class UploadBean
extends java.lang.Object
implements java.io.Serializable

This class implements an UploadBean.
Features :
- Store file(s) under a remote folder.
- Store file(s) in a zip archive.
- Store file(s) in a database.
- Store file(s) in a memory folder.

- Events generated on upload.

See Also:
Serialized Form

Field Summary
static int DATABASESTORE
           
static java.lang.String EMPTYENTRY
           
static int FOLDERSTORE
           
static boolean INSERTASBYTES
          Internal switch to use setBytes or setBinaryStream : Default is false (setBinaryStream)
static int MAXUPLOADEDFILES
          Maximum uploaded files.
static long MAXUPLOADEDFILESIZE
          Size limit for an uploaded file.
static int MEMORYSTORE
           
static char SEPARATOR
           
static int SERIALIZEDFILESTORE
          Reserved for future usage.
static java.lang.String SQLUPLOADFILE
          Column name to store uploaded data : Default is BINARYFILE
static java.lang.String SQLUPLOADFILENAME
          Column name to store uploaded filename : Default is FILENAME
static java.lang.String SQLUPLOADID
          Column name to store uploaded file id : Default is UPLOADID
static java.lang.String SQLUPLOADTABLE
          Database table name to store uploaded file : Default is UPLOADS
static int TARGZIPFILESTORE
          Reserved for future usage.
static int TRANSFERTBUFFERSIZE
           
static int XMLFILESTORE
          Reserved for future usage.
static int ZIPFILESTORE
           
 
Constructor Summary
UploadBean()
          Dummy constructor (needed for JavaBeans).
 
Method Summary
 void addUploadListener(UploadListener listener)
          Adds UploadListener to be notified.
 java.lang.String getBlacklist()
          Returns blacklist.
 java.sql.Connection getDatabasestore()
          Returns database store connection.
 DBStore getDatabasestoreimplementation()
          Returns database store concrete implementation.
 long getFilesizelimit()
          Returns maximum size allowed for an uploaded file.
 java.lang.String getFolderstore()
          Returns store folder.
 java.util.Vector getHistory()
          Returns a Vector[UploadParameters].
 int getMaxfiles()
          Returns maximum amount of stored files.
 java.util.Vector getMemorystore()
          Returns a Vector[UploadFile] from memory store.
 boolean getOverwrite()
          Returns overwrite state.
 java.lang.String getParser()
          Gets current multipart parser.
 java.lang.String getParsertmpdir()
          Gets multipart parser tempory directory if applicable.
 java.lang.String getWhitelist()
          Returns whitelist.
 java.lang.String getZipfilestore()
          Returns zip store filename.
 boolean isBlacklistEnabled()
          Returns true if blacklist is enabled or false if whitelist is enabled.
 void resetStore()
          Cleans and resets the current store.
 void setBlacklist(java.lang.String blacklist)
          Setup blacklist : filenames separated by comma.
 void setDatabasestore(java.sql.Connection jdbcconnection)
          Setup the store database that suits to JDBC 2.0 extension.
 void setDatabasestore(java.lang.String driver, java.lang.String URL, java.util.Properties credentials)
          Setup the store database.
 void setDatabasestoreimplementation(java.lang.String impl)
          Setup your own database store implemention DBStore API compliant.
 void setFilesizelimit(long max)
          Sets maximum size allowed for an uploaded file.
 void setFolderstore(java.lang.String serverfolder)
          Sets the remote store folder.
 void setMaxfiles(int max)
          Sets maximum amount of stored files.
 void setMemorystore()
          Sets the memory store folder.
 void setOverwrite(boolean overwrite)
          Enables/Disables entry overwrite.
 void setParser(java.lang.String parserid)
          Selects a multipart Parser.
 void setParsertmpdir(java.lang.String dir)
          Sets temporary directory for Struts multipart parser only.
 void setStoremodel(int storeid)
          Selects the store model.
 void setWhitelist(java.lang.String whitelist)
          Setup whitelist : filenames separated by comma.
 void setZipfilestore(java.lang.String file)
          Sets the remote store zipfile.
 void store(MultipartFormDataRequest mrequest)
          Moves all files to the store.
 void store(MultipartFormDataRequest mrequest, java.lang.String field)
          Moves one file identified by its form field to the store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXUPLOADEDFILES

public static final int MAXUPLOADEDFILES
Maximum uploaded files. Default is -1 unlimited

See Also:
Constant Field Values

MAXUPLOADEDFILESIZE

public static final long MAXUPLOADEDFILESIZE
Size limit for an uploaded file. Default is 1GB

See Also:
Constant Field Values

SEPARATOR

public static char SEPARATOR

MEMORYSTORE

public static final int MEMORYSTORE
See Also:
Constant Field Values

FOLDERSTORE

public static final int FOLDERSTORE
See Also:
Constant Field Values

DATABASESTORE

public static final int DATABASESTORE
See Also:
Constant Field Values

ZIPFILESTORE

public static final int ZIPFILESTORE
See Also:
Constant Field Values

TARGZIPFILESTORE

public static final int TARGZIPFILESTORE
Reserved for future usage.

See Also:
Constant Field Values

SERIALIZEDFILESTORE

public static final int SERIALIZEDFILESTORE
Reserved for future usage.

See Also:
Constant Field Values

XMLFILESTORE

public static final int XMLFILESTORE
Reserved for future usage.

See Also:
Constant Field Values

EMPTYENTRY

public static final java.lang.String EMPTYENTRY
See Also:
Constant Field Values

TRANSFERTBUFFERSIZE

public static int TRANSFERTBUFFERSIZE

SQLUPLOADTABLE

public static java.lang.String SQLUPLOADTABLE
Database table name to store uploaded file : Default is UPLOADS


SQLUPLOADID

public static java.lang.String SQLUPLOADID
Column name to store uploaded file id : Default is UPLOADID


SQLUPLOADFILENAME

public static java.lang.String SQLUPLOADFILENAME
Column name to store uploaded filename : Default is FILENAME


SQLUPLOADFILE

public static java.lang.String SQLUPLOADFILE
Column name to store uploaded data : Default is BINARYFILE


INSERTASBYTES

public static boolean INSERTASBYTES
Internal switch to use setBytes or setBinaryStream : Default is false (setBinaryStream)

Constructor Detail

UploadBean

public UploadBean()
Dummy constructor (needed for JavaBeans).

Method Detail

addUploadListener

public void addUploadListener(UploadListener listener)
Adds UploadListener to be notified.


setStoremodel

public void setStoremodel(int storeid)
                   throws UploadException
Selects the store model.

UploadException

getDatabasestore

public java.sql.Connection getDatabasestore()
Returns database store connection.


getDatabasestoreimplementation

public DBStore getDatabasestoreimplementation()
Returns database store concrete implementation.


getZipfilestore

public java.lang.String getZipfilestore()
Returns zip store filename.


getFolderstore

public java.lang.String getFolderstore()
Returns store folder.


getMemorystore

public java.util.Vector getMemorystore()
Returns a Vector[UploadFile] from memory store.


setMemorystore

public void setMemorystore()
                    throws UploadException
Sets the memory store folder. All files will be stored in memory.

UploadException

setFolderstore

public void setFolderstore(java.lang.String serverfolder)
                    throws UploadException
Sets the remote store folder. This method check thats if the folder exists (and is RW). If not then it attemps to create it.
i.e. : /usr/client/www/uploaded

UploadException

setZipfilestore

public void setZipfilestore(java.lang.String file)
                     throws UploadException,
                            java.io.IOException
Sets the remote store zipfile.
if the does not exits then it attemps to create one. i.e. : /usr/client/www/uploaded.zip

UploadException
java.io.IOException

setDatabasestoreimplementation

public void setDatabasestoreimplementation(java.lang.String impl)
                                    throws UploadException
Setup your own database store implemention DBStore API compliant.

UploadException

setDatabasestore

public void setDatabasestore(java.lang.String driver,
                             java.lang.String URL,
                             java.util.Properties credentials)
                      throws java.lang.Exception
Setup the store database.
i.e. : Driver : oracle.jdbc.driver.OracleDriver
i.e. : URL : jdbc:oracle:thin:@dbserver:1521:DEMODB

java.lang.Exception

setDatabasestore

public void setDatabasestore(java.sql.Connection jdbcconnection)
                      throws java.lang.Exception
Setup the store database that suits to JDBC 2.0 extension.
Think about DataSource to fill in the jdbcconnection parameter.

java.lang.Exception

getBlacklist

public java.lang.String getBlacklist()
Returns blacklist.


setBlacklist

public void setBlacklist(java.lang.String blacklist)
Setup blacklist : filenames separated by comma.
i.e. : "install.exe,setup.zip,*.cab"


getWhitelist

public java.lang.String getWhitelist()
Returns whitelist.


setWhitelist

public void setWhitelist(java.lang.String whitelist)
Setup whitelist : filenames separated by comma.
i.e. : "mysong.ogg,*.mp2,*.mp3"


isBlacklistEnabled

public boolean isBlacklistEnabled()
Returns true if blacklist is enabled or false if whitelist is enabled.

Returns:

setOverwrite

public void setOverwrite(boolean overwrite)
Enables/Disables entry overwrite. For folder ans zip store, overwrite=false will append System.currentTimeMillis() to duplicate filename. You could get the new filename through UploadParameters.getAltFilename().
For memory store, all uploaded files are appended to a list.
For database store (default implementation), overwrite=false will insert a new record, overwrite=true will update it.


getOverwrite

public boolean getOverwrite()
Returns overwrite state.


setParser

public void setParser(java.lang.String parserid)
Selects a multipart Parser.

Parameters:
parserid - MultipartFormDataRequest.COSPARSER, MultipartFormDataRequest.STRUTSPARSER, MultipartFormDataRequest.CFUPARSER

getParser

public java.lang.String getParser()
Gets current multipart parser.

Returns:
Parser class name

getParsertmpdir

public java.lang.String getParsertmpdir()
Gets multipart parser tempory directory if applicable.

Returns:
null if multipart parser is not Struts.

setParsertmpdir

public void setParsertmpdir(java.lang.String dir)
Sets temporary directory for Struts multipart parser only. If this folder doesn't exist then it will be created automatically by this method.

Parameters:
dir - Something like c:\\Temp or /tmp

setMaxfiles

public void setMaxfiles(int max)
Sets maximum amount of stored files.

Parameters:
max - -1 means no limit

getMaxfiles

public int getMaxfiles()
Returns maximum amount of stored files.


getFilesizelimit

public long getFilesizelimit()
Returns maximum size allowed for an uploaded file.


setFilesizelimit

public void setFilesizelimit(long max)
Sets maximum size allowed for an uploaded file.


store

public void store(MultipartFormDataRequest mrequest,
                  java.lang.String field)
           throws UploadException,
                  java.io.IOException
Moves one file identified by its form field to the store.

UploadException
java.io.IOException

store

public void store(MultipartFormDataRequest mrequest)
           throws UploadException,
                  java.io.IOException
Moves all files to the store.

UploadException
java.io.IOException

getHistory

public java.util.Vector getHistory()
Returns a Vector[UploadParameters].


resetStore

public void resetStore()
                throws UploadException,
                       java.io.IOException
Cleans and resets the current store.
MemoryStore will be empty.
ZipFileStore will be deleted and recreated.
All files in FolderStore will be deleted.

UploadException
java.io.IOException