Class MultipartServletWebRequestImpl
- java.lang.Object
-
- org.apache.wicket.request.Request
-
- org.apache.wicket.request.http.WebRequest
-
- org.apache.wicket.protocol.http.servlet.ServletWebRequest
-
- org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest
-
- 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, HEADER_ORIGIN, HEADER_REFERER, PARAM_AJAX, PARAM_AJAX_BASE_URL, PARAM_AJAX_REQUEST_ANTI_CACHE
-
-
Constructor Summary
Constructors Constructor Description MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload)
Constructor.MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload, org.apache.commons.fileupload.FileItemFactory factory)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearUploadInfo(javax.servlet.http.HttpServletRequest req, String upload)
Clears theUploadInfo
object from session if one exists.protected Map<String,List<StringValue>>
generatePostParameters()
List<org.apache.commons.fileupload.FileItem>
getFile(String fieldName)
Gets the file that was uploaded using the given field name.Map<String,List<org.apache.commons.fileupload.FileItem>>
getFiles()
static UploadInfo
getUploadInfo(javax.servlet.http.HttpServletRequest req, String upload)
RetrievesUploadInfo
from session, null if not found.protected org.apache.commons.fileupload.FileUploadBase
newFileUpload(String encoding)
Factory method for creating new instances of FileUploadBaseMultipartServletWebRequest
newMultipartWebRequest(Bytes maxSize, String upload)
Creates multipart web request from this request.MultipartServletWebRequest
newMultipartWebRequest(Bytes maxSize, String upload, org.apache.commons.fileupload.FileItemFactory factory)
Creates multipart web request from this request.protected void
onUploadCompleted()
Upload completed callbackprotected void
onUploadStarted(int totalBytes)
Upload start callbackprotected void
onUploadUpdate(int bytesUploaded, int total)
Upload status update callbackvoid
parseFileParts()
Parses the multipart body of the request.static void
setUploadInfo(javax.servlet.http.HttpServletRequest req, String upload, UploadInfo uploadInfo)
Sets theUploadInfo
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, getFileCountMax, getFileMaxSize, getMaxSize, setFileCountMax, setFileMaxSize, setMaxSize
-
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
-
-
-
-
Constructor Detail
-
MultipartServletWebRequestImpl
public MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload) throws org.apache.commons.fileupload.FileUploadException
Constructor. This constructor will useDiskFileItemFactory
to store uploads.- Parameters:
request
- the servlet requestfilterPrefix
- prefix to wicket filter mappingmaxSize
- the maximum size allowed for this requestupload
- upload identifier forUploadInfo
- Throws:
org.apache.commons.fileupload.FileUploadException
- Thrown if something goes wrong with upload
-
MultipartServletWebRequestImpl
public MultipartServletWebRequestImpl(javax.servlet.http.HttpServletRequest request, String filterPrefix, Bytes maxSize, String upload, org.apache.commons.fileupload.FileItemFactory factory) throws org.apache.commons.fileupload.FileUploadException
Constructor- Parameters:
request
- the servlet requestfilterPrefix
- prefix to wicket filter mappingmaxSize
- the maximum size allowed for this requestupload
- upload identifier forUploadInfo
factory
-DiskFileItemFactory
to use when creating file items used to represent uploaded files- Throws:
org.apache.commons.fileupload.FileUploadException
- Thrown if something goes wrong with upload
-
-
Method Detail
-
parseFileParts
public void parseFileParts() throws org.apache.commons.fileupload.FileUploadException
Description copied from class:MultipartServletWebRequest
Parses the multipart body of the request.- Specified by:
parseFileParts
in classMultipartServletWebRequest
- Throws:
org.apache.commons.fileupload.FileUploadException
-
newFileUpload
protected org.apache.commons.fileupload.FileUploadBase newFileUpload(String encoding)
Factory method for creating new instances of FileUploadBase- Parameters:
encoding
- The encoding to use while reading the data- Returns:
- A new instance of FileUploadBase
-
getFiles
public Map<String,List<org.apache.commons.fileupload.FileItem>> getFiles()
- Returns:
- Returns the files.
-
getFile
public List<org.apache.commons.fileupload.FileItem> getFile(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 Map<String,List<StringValue>> generatePostParameters()
- Overrides:
generatePostParameters
in classServletWebRequest
-
wantUploadProgressUpdates
protected boolean wantUploadProgressUpdates()
Subclasses that want to receive upload notifications should return true. By default it takes the value fromApplicationSettings.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, String upload) throws org.apache.commons.fileupload.FileUploadException
Description copied from class:ServletWebRequest
Creates multipart web request from this request.- Overrides:
newMultipartWebRequest
in classServletWebRequest
- Parameters:
maxSize
- max allowed size of requestupload
- upload identifier forUploadInfo
- Returns:
- multipart request
- Throws:
org.apache.commons.fileupload.FileUploadException
-
newMultipartWebRequest
public MultipartServletWebRequest newMultipartWebRequest(Bytes maxSize, String upload, org.apache.commons.fileupload.FileItemFactory factory) throws org.apache.commons.fileupload.FileUploadException
Description copied from class:ServletWebRequest
Creates multipart web request from this request.- Overrides:
newMultipartWebRequest
in classServletWebRequest
- Parameters:
maxSize
- max allowed size of requestupload
- upload identifier forUploadInfo
- Returns:
- multipart request
- Throws:
org.apache.commons.fileupload.FileUploadException
-
getUploadInfo
public static UploadInfo getUploadInfo(javax.servlet.http.HttpServletRequest req, String upload)
RetrievesUploadInfo
from session, null if not found.- Parameters:
req
- http servlet request, not nullupload
- upload identifier- Returns:
UploadInfo
object from session, or null if not found
-
setUploadInfo
public static void setUploadInfo(javax.servlet.http.HttpServletRequest req, String upload, UploadInfo uploadInfo)
Sets theUploadInfo
object into session.- Parameters:
req
- http servlet request, not nullupload
- upload identifieruploadInfo
-UploadInfo
object to be put into session, not null
-
clearUploadInfo
public static void clearUploadInfo(javax.servlet.http.HttpServletRequest req, String upload)
Clears theUploadInfo
object from session if one exists.- Parameters:
req
- http servlet request, not nullupload
- upload identifier
-
-