com.xpn.xwiki.plugin.fileupload
Class FileUploadPlugin

java.lang.Object
  extended by com.xpn.xwiki.plugin.XWikiDefaultPlugin
      extended by com.xpn.xwiki.plugin.fileupload.FileUploadPlugin
All Implemented Interfaces:
XWikiPluginInterface

public class FileUploadPlugin
extends XWikiDefaultPlugin
implements XWikiPluginInterface


Field Summary
private static org.apache.commons.logging.Log mLogger
           
private static long UPLOAD_DEFAULT_MAXSIZE
           
private static long UPLOAD_DEFAULT_SIZETHRESHOLD
           
 
Constructor Summary
FileUploadPlugin(java.lang.String name, java.lang.String className, XWikiContext context)
           
 
Method Summary
 void cleanFileList(XWikiContext context)
          Deletes all temporary files of the upload
 void endRendering(XWikiContext context)
          endRendering to make sure we don't leave files in temp directories
 java.lang.String getFileItem(java.lang.String name, XWikiContext context)
          Allows to retrieve the data of FileItem named name loadFileList needs to be called beforehand
 byte[] getFileItemData(java.lang.String name, XWikiContext context)
          Allows to retrieve the data of FileItem named name loadFileList needs to be called beforehand
 java.util.List getFileItemNames(XWikiContext context)
          Allows to retrieve the list of FileItem names loadFileList needs to be called beforehand
 java.util.List getFileItems(XWikiContext context)
          Allows to retrieve the current FileItem list loadFileList needs to be called beforehand
 java.lang.String getFileName(java.lang.String name, XWikiContext context)
          Get file name from FileItem
 java.lang.String getName()
          Allow to get the plugin name
 Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
           
 void init(XWikiContext context)
           
 void loadFileList(long uploadMaxSize, int uploadSizeThreashold, java.lang.String tempdir, XWikiContext context)
          Allows to load the file list in the context if there is a file upload
 void loadFileList(XWikiContext context)
          Allows to load the file list in the context if there is a file upload Default uploadMaxSize, uploadSizeThreashold and temporary directory are used
 void virtualInit(XWikiContext context)
           
 
Methods inherited from class com.xpn.xwiki.plugin.XWikiDefaultPlugin
beginRendering, commonTagsHandler, downloadAttachment, endRenderingHandler, flushCache, getClassName, insidePREHandler, outsidePREHandler, setClassName, setName, startRenderingHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xpn.xwiki.plugin.XWikiPluginInterface
beginRendering, commonTagsHandler, downloadAttachment, endRenderingHandler, flushCache, getClassName, insidePREHandler, outsidePREHandler, setClassName, setName, startRenderingHandler
 

Field Detail

mLogger

private static org.apache.commons.logging.Log mLogger

UPLOAD_DEFAULT_MAXSIZE

private static final long UPLOAD_DEFAULT_MAXSIZE
See Also:
Constant Field Values

UPLOAD_DEFAULT_SIZETHRESHOLD

private static final long UPLOAD_DEFAULT_SIZETHRESHOLD
See Also:
Constant Field Values
Constructor Detail

FileUploadPlugin

public FileUploadPlugin(java.lang.String name,
                        java.lang.String className,
                        XWikiContext context)
Method Detail

getName

public java.lang.String getName()
Allow to get the plugin name

Specified by:
getName in interface XWikiPluginInterface
Overrides:
getName in class XWikiDefaultPlugin
Returns:
plugin name

init

public void init(XWikiContext context)
Specified by:
init in interface XWikiPluginInterface
Overrides:
init in class XWikiDefaultPlugin

virtualInit

public void virtualInit(XWikiContext context)
Specified by:
virtualInit in interface XWikiPluginInterface
Overrides:
virtualInit in class XWikiDefaultPlugin

getPluginApi

public Api getPluginApi(XWikiPluginInterface plugin,
                        XWikiContext context)
Specified by:
getPluginApi in interface XWikiPluginInterface
Overrides:
getPluginApi in class XWikiDefaultPlugin

endRendering

public void endRendering(XWikiContext context)
endRendering to make sure we don't leave files in temp directories

Specified by:
endRendering in interface XWikiPluginInterface
Overrides:
endRendering in class XWikiDefaultPlugin
Parameters:
context - Context of the request

cleanFileList

public void cleanFileList(XWikiContext context)
Deletes all temporary files of the upload

Parameters:
context - Context of the request

loadFileList

public void loadFileList(XWikiContext context)
                  throws XWikiException
Allows to load the file list in the context if there is a file upload Default uploadMaxSize, uploadSizeThreashold and temporary directory are used

Parameters:
context - Context of the request
Throws:
XWikiException - An XWikiException is thrown if the request could not be parser

loadFileList

public void loadFileList(long uploadMaxSize,
                         int uploadSizeThreashold,
                         java.lang.String tempdir,
                         XWikiContext context)
                  throws XWikiException
Allows to load the file list in the context if there is a file upload

Parameters:
uploadMaxSize - Maximum size of the request
uploadSizeThreashold - Threashold over which the data should be on disk and not in memory
tempdir - Temporary Directory to store temp data
context - Context of the request
Throws:
XWikiException - An XWikiException is thrown if the request could not be parser

getFileItems

public java.util.List getFileItems(XWikiContext context)
Allows to retrieve the current FileItem list loadFileList needs to be called beforehand

Parameters:
context - Context of the request
Returns:
a list of FileItem elements

getFileItemData

public byte[] getFileItemData(java.lang.String name,
                              XWikiContext context)
                       throws XWikiException
Allows to retrieve the data of FileItem named name loadFileList needs to be called beforehand

Parameters:
name - Name of the item
context - Context of the request
Returns:
byte[] of the data
Throws:
XWikiException - Exception is thrown if the data could not be read

getFileItem

public java.lang.String getFileItem(java.lang.String name,
                                    XWikiContext context)
                             throws XWikiException
Allows to retrieve the data of FileItem named name loadFileList needs to be called beforehand

Parameters:
name - Name of the item
context - Context of the request
name -
context -
Returns:
String of the data
Throws:
XWikiException - Exception is thrown if the data could not be read
XWikiException

getFileItemNames

public java.util.List getFileItemNames(XWikiContext context)
Allows to retrieve the list of FileItem names loadFileList needs to be called beforehand

Parameters:
context - Context of the request
Returns:
List of strings of the item names

getFileName

public java.lang.String getFileName(java.lang.String name,
                                    XWikiContext context)
Get file name from FileItem

Parameters:
name - of the field
context - Context of the request
Returns:
The file name


Copyright 2003 Ludovic Dubost