net.sourceforge.stripes.controller.multipart
Class CommonsMultipartWrapper

java.lang.Object
  extended by net.sourceforge.stripes.controller.multipart.CommonsMultipartWrapper
All Implemented Interfaces:
MultipartWrapper

public class CommonsMultipartWrapper
extends Object
implements MultipartWrapper

An implementation of MultipartWrapper that uses Jakarta Commons FileUpload (from apache) to parse the request parts. This implementation requires that both commons-fileupload and commons-io be present in the classpath. While this implementation does introduce additional dependencies, it's licensing (ASL 2.0) is significantly less restrictive than the licensing for COS - the other alternative provided by Stripes.

Since:
Stripes 1.4
Author:
Tim Fennell

Constructor Summary
CommonsMultipartWrapper()
           
 
Method Summary
 void build(HttpServletRequest request, File tempDir, long maxPostSize)
          Pseudo-constructor that allows the class to perform any initialization necessary.
 Enumeration<String> getFileParameterNames()
          Fetches the names of all file parameters in the request.
 FileBean getFileParameterValue(String name)
          Responsible for constructing a FileBean object for the named file parameter.
 Enumeration<String> getParameterNames()
          Fetches the names of all non-file parameters in the request.
 String[] getParameterValues(String name)
          Fetches all values of a specific parameter in the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonsMultipartWrapper

public CommonsMultipartWrapper()
Method Detail

build

public void build(HttpServletRequest request,
                  File tempDir,
                  long maxPostSize)
           throws IOException,
                  FileUploadLimitExceededException
Pseudo-constructor that allows the class to perform any initialization necessary.

Specified by:
build in interface MultipartWrapper
Parameters:
request - an HttpServletRequest that has a content-type of multipart.
tempDir - a File representing the temporary directory that can be used to store file parts as they are uploaded if this is desirable
maxPostSize - the size in bytes beyond which the request should not be read, and a FileUploadLimitExceeded exception should be thrown
Throws:
IOException - if a problem occurs processing the request of storing temporary files
FileUploadLimitExceededException - if the POST content is longer than the maxPostSize supplied.

getParameterNames

public Enumeration<String> getParameterNames()
Fetches the names of all non-file parameters in the request. Directly analogous to the method of the same name in HttpServletRequest when the request is non-multipart.

Specified by:
getParameterNames in interface MultipartWrapper
Returns:
an Enumeration of all non-file parameter names in the request

getParameterValues

public String[] getParameterValues(String name)
Fetches all values of a specific parameter in the request. To simulate the HTTP request style, the array should be null for non-present parameters, and values in the array should never be null - the empty String should be used when there is value.

Specified by:
getParameterValues in interface MultipartWrapper
Parameters:
name - the name of the request parameter
Returns:
an array of non-null parameters or null

getFileParameterNames

public Enumeration<String> getFileParameterNames()
Fetches the names of all file parameters in the request. Note that these are not the file names, but the names given to the form fields in which the files are specified.

Specified by:
getFileParameterNames in interface MultipartWrapper
Returns:
the names of all file parameters in the request.

getFileParameterValue

public FileBean getFileParameterValue(String name)
Responsible for constructing a FileBean object for the named file parameter. If there is no file parameter with the specified name this method should return null.

Specified by:
getFileParameterValue in interface MultipartWrapper
Parameters:
name - the name of the file parameter
Returns:
a FileBean object wrapping the uploaded file


? Copyright 2005-2006, Stripes Development Team.