org.barracudamvc.contrib.sam.servlet
Class FileUploadRequestWrapper

java.lang.Object
  extended byjavax.servlet.ServletRequestWrapper
      extended byjavax.servlet.http.HttpServletRequestWrapper
          extended byorg.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper
              extended byorg.barracudamvc.contrib.sam.servlet.FileUploadRequestWrapper
All Implemented Interfaces:
BarracudaServletRequestWrapper, javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class FileUploadRequestWrapper
extends DefaultServletRequestWrapper

Author:
Stefan Armbruster (sam, 2003-11-15) Handle HTTP upload requests using multipart. For handling multipart stuff, we're using Jakarta Commons Fileupload, otherwise we fall back to superclass behaviour

Field Summary
protected  boolean isMultipart
          indicates if the current request is multipart
protected static org.apache.log4j.Logger logger
           
protected  long maxSize
          maximum allowed size of uploads
protected  List uploadItemList
          contains a list of @see org.apache.commons.fileupload.FileItem
 
Fields inherited from class org.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper
DEFAULT_ENCODING
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
FileUploadRequestWrapper(javax.servlet.http.HttpServletRequest ireq)
          simple consturctor, accepts any file size
FileUploadRequestWrapper(javax.servlet.http.HttpServletRequest ireq, long max)
          check if ireq is a multipart request.
 
Method Summary
 org.apache.commons.fileupload.FileItem getFileItem(String name)
          search a fileitem by fieldname
 String getParameter(String name)
          if request is multipart, return matching @see FileItem's value, otherwise fall back to superclass
 Enumeration getParameterNames()
          if request is multipart, return all "simple" (aka non-files) matching @see FileItem's field names, otherwise fall back to superclass
 String[] getParameterValues(String name)
          If multipart, return @see FileItem#getString(), otherwise fall back to superclass' behaviour
protected  String getUploadItemValueByName(String name)
          find a matching item in uploadItems and return its value
 
Methods inherited from class org.barracudamvc.core.helper.servlet.DefaultServletRequestWrapper
addParameter, getCoreRequest, getMethod, getParameterMap, removeAllParameters, removeParameter, resetParameters, setMethod, setRequest
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocale, getLocales, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

maxSize

protected long maxSize
maximum allowed size of uploads


logger

protected static org.apache.log4j.Logger logger

isMultipart

protected boolean isMultipart
indicates if the current request is multipart


uploadItemList

protected List uploadItemList
contains a list of @see org.apache.commons.fileupload.FileItem

Constructor Detail

FileUploadRequestWrapper

public FileUploadRequestWrapper(javax.servlet.http.HttpServletRequest ireq,
                                long max)
check if ireq is a multipart request. If so, call @see #initUploadItemList(HttpServletRequest)

Parameters:
ireq -
max - Maximum allowed size of uploads

FileUploadRequestWrapper

public FileUploadRequestWrapper(javax.servlet.http.HttpServletRequest ireq)
simple consturctor, accepts any file size

Parameters:
ireq -
Method Detail

getParameter

public String getParameter(String name)
if request is multipart, return matching @see FileItem's value, otherwise fall back to superclass

Specified by:
getParameter in interface javax.servlet.ServletRequest
Overrides:
getParameter in class DefaultServletRequestWrapper
Parameters:
name - the key name for the parameter
Returns:
the parameter value associated with a key name
See Also:
ServletRequest.getParameter(java.lang.String)

getParameterNames

public Enumeration getParameterNames()
if request is multipart, return all "simple" (aka non-files) matching @see FileItem's field names, otherwise fall back to superclass

Specified by:
getParameterNames in interface javax.servlet.ServletRequest
Overrides:
getParameterNames in class DefaultServletRequestWrapper
Returns:
an Enumeration of all the parameter names
See Also:
ServletRequest.getParameterNames()

getParameterValues

public String[] getParameterValues(String name)
If multipart, return @see FileItem#getString(), otherwise fall back to superclass' behaviour

Specified by:
getParameterValues in interface javax.servlet.ServletRequest
Overrides:
getParameterValues in class DefaultServletRequestWrapper
Parameters:
name - the key name for the parameter
Returns:
an array of Strings for the given key name

getUploadItemValueByName

protected String getUploadItemValueByName(String name)
find a matching item in uploadItems and return its value

Parameters:
name -
Returns:
@see FileItem's value

getFileItem

public org.apache.commons.fileupload.FileItem getFileItem(String name)
search a fileitem by fieldname

Parameters:
name - name of form field
Returns:
matching @see FileItem or null


Copyright © 2004 BarracudaMVC.org All Rights Reserved.