com.ibm.portal.struts.upload
Class WpCommonsMultipartRequestHandler

java.lang.Object
  extended by CommonsMultipartRequestHandler
      extended by com.ibm.portal.struts.upload.WpCommonsMultipartRequestHandler
All Implemented Interfaces:
IWpsCommonsMultipartRequestHandler

public class WpCommonsMultipartRequestHandler
extends CommonsMultipartRequestHandler
implements IWpsCommonsMultipartRequestHandler

This is a modified version of the Struts CommonsMultipartRequestHandler that will allow the file element's name to be namescoped. The FileItem.getFieldName will now return the un-namescoped name so the processPopulate step can work.

Since:
5.1

Field Summary
protected  java.util.Hashtable elementsAll
          The combined text and file request parameters.
protected  java.util.Hashtable elementsFile
          The file request parameters.
protected  java.util.Hashtable elementsText
          The text request parameters.
protected static Log log
          Commons Logging instance.
 
Constructor Summary
WpCommonsMultipartRequestHandler()
          WpCommonsMultipartRequestHandler constructor.
 
Method Summary
protected  void addFileParameter(HttpServletRequest request, FileItem item)
          Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.
protected  void addTextParameter(HttpServletRequest request, FileItem item)
          Adds a regular text parameter to the set of text parameters for this request and also to the list of all parameters.
 void finish()
          Cleans up at the end of a request.
 java.util.Hashtable getAllElements()
          Returns a hash table containing both text and file request parameters.
protected  java.lang.String getFieldName(HttpServletRequest request, FileItem item)
          Gets the field name.
 java.util.Hashtable getFileElements()
          Returns a hash table containing the file (that is, non-text) request parameters.
protected  long getSizeFieldThreshold(ModuleConfig mc)
          Returns the size field threshold which determines whether an uploaded file will be written to disk or cached in memory.
 java.util.Hashtable getTextElements()
          Returns a hash table containing the text (that is, non-file) request parameters.
 void handleRequest(HttpServletRequest request)
          Parses the input stream and partitions the parsed items into a set of form fields and a set of file items.
 void rollback()
          Cleans up when a problem occurs during request processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log
Commons Logging instance.


elementsAll

protected java.util.Hashtable elementsAll
The combined text and file request parameters.


elementsFile

protected java.util.Hashtable elementsFile
The file request parameters.


elementsText

protected java.util.Hashtable elementsText
The text request parameters.

Constructor Detail

WpCommonsMultipartRequestHandler

public WpCommonsMultipartRequestHandler()
WpCommonsMultipartRequestHandler constructor.

Method Detail

handleRequest

public void handleRequest(HttpServletRequest request)
                   throws ServletException
Parses the input stream and partitions the parsed items into a set of form fields and a set of file items. In the process, the parsed items are translated from Commons FileUpload FileItem instances to Struts FormFile instances.

Parameters:
request - The multipart request to be processed.
Throws:
ServletException - if an unrecoverable error occurs.

getTextElements

public java.util.Hashtable getTextElements()
Returns a hash table containing the text (that is, non-file) request parameters.

Returns:
The text request parameters.

getFileElements

public java.util.Hashtable getFileElements()
Returns a hash table containing the file (that is, non-text) request parameters.

Returns:
The file request parameters.

getAllElements

public java.util.Hashtable getAllElements()
Returns a hash table containing both text and file request parameters.

Returns:
The text and file request parameters.

rollback

public void rollback()
Cleans up when a problem occurs during request processing.


finish

public void finish()
Cleans up at the end of a request.


addTextParameter

protected void addTextParameter(HttpServletRequest request,
                                FileItem item)
Adds a regular text parameter to the set of text parameters for this request and also to the list of all parameters. Handles the case of multiple values for the same parameter by using an array for the parameter value.

Parameters:
request - The request in which the parameter was specified.
item - The file item for the parameter to add.

addFileParameter

protected void addFileParameter(HttpServletRequest request,
                                FileItem item)
Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.

Parameters:
item - The file item for the parameter to add.

getFieldName

protected java.lang.String getFieldName(HttpServletRequest request,
                                        FileItem item)
Gets the field name. If the name is namescoped then remove the namescoping.

Parameters:
request - the request object
item - the file item
Returns:
String the field name

getSizeFieldThreshold

protected long getSizeFieldThreshold(ModuleConfig mc)
Returns the size field threshold which determines whether an uploaded file will be written to disk or cached in memory.

Parameters:
mc - The current module's configuration.
Returns:
The size threshold, in bytes.