public class

CommonsPortletMultipartResolver

extends CommonsFileUploadSupport
implements PortletContextAware PortletMultipartResolver
java.lang.Object
   ↳ org.springframework.web.multipart.commons.CommonsFileUploadSupport
     ↳ org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver

Class Overview

PortletMultipartResolver implementation for Jakarta Commons FileUpload 1.2 or above.

Provides "maxUploadSize", "maxInMemorySize" and "defaultEncoding" settings as bean properties (inherited from CommonsFileUploadSupport). See corresponding PortletFileUpload / DiskFileItemFactory properties ("sizeMax", "sizeThreshold", "headerEncoding") for details in terms of defaults and accepted values.

Saves temporary files to the portlet container's temporary directory. Needs to be initialized either by an application context or via the constructor that takes a PortletContext (for standalone usage).

See Also

Summary

[Expand]
Inherited Fields
From class org.springframework.web.multipart.commons.CommonsFileUploadSupport
Public Constructors
CommonsPortletMultipartResolver()
Constructor for use as bean.
CommonsPortletMultipartResolver(PortletContext portletContext)
Constructor for standalone usage.
Public Methods
void cleanupMultipart(MultipartActionRequest request)
Cleanup any resources used for the multipart handling, such as storage for any uploaded file(s).
boolean isMultipart(ActionRequest request)
Determine if the given request contains multipart content.
MultipartActionRequest resolveMultipart(ActionRequest request)
Parse the given portlet request into multipart files and parameters, and wrap the request inside a MultipartActionRequest object that provides access to file descriptors and makes contained parameters accessible via the standard PortletRequest methods.
void setPortletContext(PortletContext portletContext)
Set the PortletContext that this object runs in.
void setResolveLazily(boolean resolveLazily)
Set whether to resolve the multipart request lazily at the time of file or parameter access.
Protected Methods
String determineEncoding(ActionRequest request)
Determine the encoding for the given request.
FileUpload newFileUpload(FileItemFactory fileItemFactory)
Initialize the underlying org.apache.commons.fileupload.portlet.PortletFileUpload instance.
CommonsFileUploadSupport.MultipartParsingResult parseRequest(ActionRequest request)
Parse the given portlet request, resolving its multipart elements.
[Expand]
Inherited Methods
From class org.springframework.web.multipart.commons.CommonsFileUploadSupport
From class java.lang.Object
From interface org.springframework.web.portlet.context.PortletContextAware
From interface org.springframework.web.portlet.multipart.PortletMultipartResolver

Public Constructors

public CommonsPortletMultipartResolver ()

Constructor for use as bean. Determines the portlet container's temporary directory via the PortletContext passed in as through the PortletContextAware interface (typically by an ApplicationContext).

public CommonsPortletMultipartResolver (PortletContext portletContext)

Constructor for standalone usage. Determines the portlet container's temporary directory via the given PortletContext.

Parameters
portletContext the PortletContext to use

Public Methods

public void cleanupMultipart (MultipartActionRequest request)

Cleanup any resources used for the multipart handling, such as storage for any uploaded file(s).

Parameters
request the request to cleanup resources for

public boolean isMultipart (ActionRequest request)

Determine if the given request contains multipart content.

Will typically check for content type "multipart/form-data", but the actually accepted requests might depend on the capabilities of the resolver implementation.

Parameters
request the portlet request to be evaluated
Returns
  • whether the request contains multipart content

public MultipartActionRequest resolveMultipart (ActionRequest request)

Parse the given portlet request into multipart files and parameters, and wrap the request inside a MultipartActionRequest object that provides access to file descriptors and makes contained parameters accessible via the standard PortletRequest methods.

Parameters
request the portlet request to wrap (must be of a multipart content type)
Returns
  • the wrapped portlet request

public void setPortletContext (PortletContext portletContext)

Set the PortletContext that this object runs in.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.

Parameters
portletContext PortletContext object to be used by this object

public void setResolveLazily (boolean resolveLazily)

Set whether to resolve the multipart request lazily at the time of file or parameter access.

Default is "false", resolving the multipart elements immediately, throwing corresponding exceptions at the time of the resolveMultipart(ActionRequest) call. Switch this to "true" for lazy multipart parsing, throwing parse exceptions once the application attempts to obtain multipart files or parameters.

Protected Methods

protected String determineEncoding (ActionRequest request)

Determine the encoding for the given request. Can be overridden in subclasses.

The default implementation checks the request encoding, falling back to the default encoding specified for this resolver.

Parameters
request current portlet request
Returns
  • the encoding for the request (never null)
See Also

protected FileUpload newFileUpload (FileItemFactory fileItemFactory)

Initialize the underlying org.apache.commons.fileupload.portlet.PortletFileUpload instance. Can be overridden to use a custom subclass, e.g. for testing purposes.

Parameters
fileItemFactory the Commons FileItemFactory to build upon
Returns
  • the new PortletFileUpload instance

protected CommonsFileUploadSupport.MultipartParsingResult parseRequest (ActionRequest request)

Parse the given portlet request, resolving its multipart elements.

Parameters
request the request to parse
Returns
  • the parsing result
Throws
MultipartException if multipart resolution failed.