org.apache.struts.upload

Class DiskMultipartRequestHandler

Implemented Interfaces:
MultipartRequestHandler

public class DiskMultipartRequestHandler
extends java.lang.Object
implements MultipartRequestHandler

This is a MultipartRequestHandler that writes file data directly to to temporary files on disk.

Field Summary

protected Hashtable
allElements
A Hashtable representing all elemnents.
protected Hashtable
fileElements
A Hashtable representing the form files uploaded.
protected static Log
log
Commons Logging instance.
protected ActionMapping
mapping
The ActionMapping instance used for this class.
protected ActionServlet
servlet
The ActionServlet instance used for this class.
protected String
tempDir
The temporary directory.
protected Hashtable
textElements
A Hashtable representing the form text input names and values.

Fields inherited from interface org.apache.struts.upload.MultipartRequestHandler

ATTRIBUTE_MAX_LENGTH_EXCEEDED

Method Summary

protected void
createDiskFile(MultipartElement element)
protected void
createTextElement(HttpServletRequest request, MultipartElement element)
void
finish()
Calls on rollback() to delete temporary files.
Hashtable
getAllElements()
This method returns all elements of a multipart request.
Hashtable
getFileElements()
This method is called on to retrieve all the FormFile input elements of the request.
ActionMapping
getMapping()
Get the ActionMapping instance for this request
protected long
getMaxSize(String stringSize)
Gets the maximum post data size in bytes from the string representation in the configuration file.
ActionServlet
getServlet()
Get the ActionServlet instance
Hashtable
getTextElements()
This method is called on to retrieve all the text input elements of the request.
void
handleRequest(HttpServletRequest request)
This method populates the internal hashtables with multipart request data.
protected void
retrieveTempDir(ModuleConfig moduleConfig)
Retrieves the temporary directory from either ActionServlet, a context property, or a system property, in that order.
void
rollback()
Delete all the files uploaded.
void
setMapping(ActionMapping mapping)
Convienience method to set a reference to a working ActionMapping instance.
void
setServlet(ActionServlet servlet)
Convienience method to set a reference to a working ActionServlet instance.

Field Details

allElements

protected Hashtable allElements
A Hashtable representing all elemnents.

fileElements

protected Hashtable fileElements
A Hashtable representing the form files uploaded.

log

protected static Log log
Commons Logging instance.

mapping

protected ActionMapping mapping
The ActionMapping instance used for this class.

servlet

protected ActionServlet servlet
The ActionServlet instance used for this class.

tempDir

protected String tempDir
The temporary directory.

textElements

protected Hashtable textElements
A Hashtable representing the form text input names and values.

Method Details

createDiskFile

protected void createDiskFile(MultipartElement element)

createTextElement

protected void createTextElement(HttpServletRequest request,
                                 MultipartElement element)

finish

public void finish()
Calls on rollback() to delete temporary files.
Specified by:
finish in interface MultipartRequestHandler

getAllElements

public Hashtable getAllElements()
This method returns all elements of a multipart request.
Specified by:
getAllElements in interface MultipartRequestHandler
Returns:
A Hashtable where the keys are input names and values are either Strings or FormFiles

getFileElements

public Hashtable getFileElements()
This method is called on to retrieve all the FormFile input elements of the request.
Specified by:
getFileElements in interface MultipartRequestHandler
Returns:
A Hashtable where the keys are the input names of the files and the values are FormFile objects
See Also:
FormFile

getMapping

public ActionMapping getMapping()
Get the ActionMapping instance for this request
Specified by:
getMapping in interface MultipartRequestHandler

getMaxSize

protected long getMaxSize(String stringSize)
            throws ServletException
Gets the maximum post data size in bytes from the string representation in the configuration file.

getServlet

public ActionServlet getServlet()
Get the ActionServlet instance
Specified by:
getServlet in interface MultipartRequestHandler

getTextElements

public Hashtable getTextElements()
This method is called on to retrieve all the text input elements of the request.
Specified by:
getTextElements in interface MultipartRequestHandler
Returns:
A Hashtable where the keys and values are the names and values of the request input parameters

handleRequest

public void handleRequest(HttpServletRequest request)
            throws ServletException
This method populates the internal hashtables with multipart request data. If the request argument is an instance of MultipartRequestWrapper, the request wrapper will be populated as well.
Specified by:
handleRequest in interface MultipartRequestHandler

retrieveTempDir

protected void retrieveTempDir(ModuleConfig moduleConfig)
Retrieves the temporary directory from either ActionServlet, a context property, or a system property, in that order.

rollback

public void rollback()
Delete all the files uploaded.
Specified by:
rollback in interface MultipartRequestHandler

setMapping

public void setMapping(ActionMapping mapping)
Convienience method to set a reference to a working ActionMapping instance.
Specified by:
setMapping in interface MultipartRequestHandler

setServlet

public void setServlet(ActionServlet servlet)
Convienience method to set a reference to a working ActionServlet instance.
Specified by:
setServlet in interface MultipartRequestHandler

Copyright B) 2000-2007 - The Apache Software Foundation