org.apache.wicket.protocol.http.servlet
Class MultipartServletWebRequestImpl

java.lang.Object
  extended by org.apache.wicket.request.Request
      extended by org.apache.wicket.request.http.WebRequest
          extended by org.apache.wicket.protocol.http.servlet.ServletWebRequest
              extended by org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest
                  extended by org.apache.wicket.protocol.http.servlet.MultipartServletWebRequestImpl
All Implemented Interfaces:
IMultipartWebRequest

public class MultipartServletWebRequestImpl
extends MultipartServletWebRequest

Servlet specific WebRequest subclass for multipart content uploads.

Author:
Jonathan Locke, Eelco Hillenius, Cameron Braid, Ate Douma, Igor Vaynberg (ivaynberg)

Field Summary
 
Fields inherited from class org.apache.wicket.request.http.WebRequest
HEADER_AJAX, HEADER_AJAX_BASE_URL, PARAM_AJAX, PARAM_AJAX_BASE_URL
 
Constructor Summary
MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, java.lang.String filterPrefix, Bytes maxSize, java.lang.String upload)
          Constructor.
MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, java.lang.String filterPrefix, Bytes maxSize, java.lang.String upload, FileItemFactory factory)
          Constructor
 
Method Summary
static void clearUploadInfo(javax.servlet.http.HttpServletRequest req, java.lang.String upload)
          Clears the UploadInfo object from session if one exists.
protected  java.util.Map<java.lang.String,java.util.List<StringValue>> generatePostParameters()
           
 java.util.List<FileItem> getFile(java.lang.String fieldName)
          Gets the file that was uploaded using the given field name.
 java.util.Map<java.lang.String,java.util.List<FileItem>> getFiles()
           
static UploadInfo getUploadInfo(javax.servlet.http.HttpServletRequest req, java.lang.String upload)
          Retrieves UploadInfo from session, null if not found.
 MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, java.lang.String upload)
          Creates multipart web request from this request.
 MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, java.lang.String upload, FileItemFactory factory)
          Creates multipart web request from this request.
protected  void onUploadCompleted()
          Upload completed callback
protected  void onUploadStarted(int totalBytes)
          Upload start callback
protected  void onUploadUpdate(int bytesUploaded, int total)
          Upload status update callback
static void setUploadInfo(javax.servlet.http.HttpServletRequest req, java.lang.String upload, UploadInfo uploadInfo)
          Sets the UploadInfo object into session.
protected  boolean wantUploadProgressUpdates()
          Subclasses that want to receive upload notifications should return true.
 
Methods inherited from class org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest
cloneWithUrl
 
Methods inherited from class org.apache.wicket.protocol.http.servlet.ServletWebRequest
getCharset, getClientUrl, getContainerRequest, getContextPath, getCookies, getDateHeader, getFilterPath, getFilterPrefix, getHeader, getHeaders, getLocale, getPostParameters, getPrefixToContextPath, getUrl, shouldPreserveClientUrl
 
Methods inherited from class org.apache.wicket.request.http.WebRequest
getCookie, getIfModifiedSinceHeader, isAjax
 
Methods inherited from class org.apache.wicket.request.Request
getOriginalUrl, getQueryParameters, getRequestParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartServletWebRequestImpl

public MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request,
                                      java.lang.String filterPrefix,
                                      Bytes maxSize,
                                      java.lang.String upload)
                               throws FileUploadException
Constructor. This constructor will use DiskFileItemFactory to store uploads.

Parameters:
maxSize - the maximum size allowed for this request
upload - upload identifier for UploadInfo
request - the servlet request
filterPrefix - prefix to wicket filter mapping
Throws:
FileUploadException - Thrown if something goes wrong with upload

MultipartServletWebRequestImpl

public MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request,
                                      java.lang.String filterPrefix,
                                      Bytes maxSize,
                                      java.lang.String upload,
                                      FileItemFactory factory)
                               throws FileUploadException
Constructor

Parameters:
maxSize - the maximum size allowed for this request
upload - upload identifier for UploadInfo
request - the servlet request
filterPrefix - prefix to wicket filter mapping
factory - DiskFileItemFactory to use when creating file items used to represent uploaded files
Throws:
FileUploadException - Thrown if something goes wrong with upload
Method Detail

getFiles

public java.util.Map<java.lang.String,java.util.List<FileItem>> getFiles()
Returns:
Returns the files.

getFile

public java.util.List<FileItem> getFile(java.lang.String fieldName)
Gets the file that was uploaded using the given field name.

Parameters:
fieldName - the field name that was used for the upload
Returns:
the upload with the given field name

generatePostParameters

protected java.util.Map<java.lang.String,java.util.List<StringValue>> generatePostParameters()
Overrides:
generatePostParameters in class ServletWebRequest

wantUploadProgressUpdates

protected boolean wantUploadProgressUpdates()
Subclasses that want to receive upload notifications should return true. By default it takes the value from IApplicationSettings.isUploadProgressUpdatesEnabled().

Returns:
true if upload status update event should be invoked

onUploadStarted

protected void onUploadStarted(int totalBytes)
Upload start callback

Parameters:
totalBytes -

onUploadUpdate

protected void onUploadUpdate(int bytesUploaded,
                              int total)
Upload status update callback

Parameters:
bytesUploaded -
total -

onUploadCompleted

protected void onUploadCompleted()
Upload completed callback


newMultipartWebRequest

public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize,
                                                         java.lang.String upload)
                                                  throws FileUploadException
Description copied from class: ServletWebRequest
Creates multipart web request from this request.

Overrides:
newMultipartWebRequest in class ServletWebRequest
upload - upload identifier for UploadInfo
Returns:
multipart request
Throws:
FileUploadException

newMultipartWebRequest

public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize,
                                                         java.lang.String upload,
                                                         FileItemFactory factory)
                                                  throws FileUploadException
Description copied from class: ServletWebRequest
Creates multipart web request from this request.

Overrides:
newMultipartWebRequest in class ServletWebRequest
upload - upload identifier for UploadInfo
Returns:
multipart request
Throws:
FileUploadException

getUploadInfo

public static UploadInfo getUploadInfo(javax.servlet.http.HttpServletRequest req,
                                       java.lang.String upload)
Retrieves UploadInfo from session, null if not found.

Parameters:
req - http servlet request, not null
upload - upload identifier
Returns:
UploadInfo object from session, or null if not found

setUploadInfo

public static void setUploadInfo(javax.servlet.http.HttpServletRequest req,
                                 java.lang.String upload,
                                 UploadInfo uploadInfo)
Sets the UploadInfo object into session.

Parameters:
req - http servlet request, not null
upload - upload identifier
uploadInfo - UploadInfo object to be put into session, not null

clearUploadInfo

public static void clearUploadInfo(javax.servlet.http.HttpServletRequest req,
                                   java.lang.String upload)
Clears the UploadInfo object from session if one exists.

Parameters:
req - http servlet request, not null
upload - upload identifier


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.