nextapp.echo2.webcontainer.filetransfer
Class AbstractFileUploadProvider

java.lang.Object
  extended by nextapp.echo2.webcontainer.filetransfer.AbstractFileUploadProvider
All Implemented Interfaces:
java.io.Serializable, MultipartUploadSPI, WebRenderAction.MultipartRequestWrapper
Direct Known Subclasses:
JakartaCommonsFileUploadProvider

public abstract class AbstractFileUploadProvider
extends java.lang.Object
implements MultipartUploadSPI, java.io.Serializable

Base abstract class containing common implementations

See Also:
Serialized Form

Field Summary
protected static java.io.File TEMPDIR_FILE
           
protected static java.lang.String TEMPDIR_PATH
           
 
Fields inherited from interface nextapp.echo2.webcontainer.filetransfer.MultipartUploadSPI
SYSTEM_PROPERTY_NAME
 
Constructor Summary
AbstractFileUploadProvider()
           
 
Method Summary
 java.io.File getDiskCacheLocation()
          Gets the directory to be used for storing file uploads that exceed the memory cache threshold.
 int getFileUploadSizeLimit()
          Gets the maximum size, in bytes, of file uploads to be accepted.
 int getMemoryCacheThreshold()
          Gets the size, in bytes, that the file upload must exceed before being cached to disk.
 HttpServletRequest getWrappedRequest(HttpServletRequest request)
          Returns a replacement HttpServletRequest object that may be used to handle a multipart/form-data encoded HTTP request.
 boolean supportsDiskCaching()
          Implementations return true if they support caching the uploaded file to disk.
 boolean supportsFileUploadSizeLimit()
          Implementations return true if they support limiting the size of the upload.
protected  java.io.File writeTempFile(java.io.InputStream in, UploadSelect uploadSelect)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nextapp.echo2.webcontainer.filetransfer.MultipartUploadSPI
updateComponent
 

Field Detail

TEMPDIR_PATH

protected static final java.lang.String TEMPDIR_PATH

TEMPDIR_FILE

protected static final java.io.File TEMPDIR_FILE
Constructor Detail

AbstractFileUploadProvider

public AbstractFileUploadProvider()
Method Detail

supportsDiskCaching

public boolean supportsDiskCaching()
Description copied from interface: MultipartUploadSPI
Implementations return true if they support caching the uploaded file to disk. Implementations that return true must not throw UnsupportedOperationExceptions for the methods setMemoryCacheThreshold() and setDiskCacheLocation().

Specified by:
supportsDiskCaching in interface MultipartUploadSPI
Returns:
true if the implementation is able to conserve memory by storing the uploaded file to disk
See Also:
MultipartUploadSPI.supportsDiskCaching()

supportsFileUploadSizeLimit

public boolean supportsFileUploadSizeLimit()
Description copied from interface: MultipartUploadSPI
Implementations return true if they support limiting the size of the upload. Implementations that return true must not throw an UnsupportedOperationException for the method setFileUploadSizeLimit().

Specified by:
supportsFileUploadSizeLimit in interface MultipartUploadSPI
Returns:
true if the implmentation is able to terminate uploads larger than a specified size
See Also:
MultipartUploadSPI.supportsFileUploadSizeLimit()

getDiskCacheLocation

public java.io.File getDiskCacheLocation()
                                  throws java.io.IOException,
                                         java.lang.UnsupportedOperationException
Description copied from interface: MultipartUploadSPI
Gets the directory to be used for storing file uploads that exceed the memory cache threshold.

Specified by:
getDiskCacheLocation in interface MultipartUploadSPI
Returns:
location to store uploaded files
Throws:
java.io.IOException - if the directory does not exist or the File throws an IOException during this operation
java.lang.UnsupportedOperationException - if this implementation does not support disk caching
See Also:
MultipartUploadSPI.getDiskCacheLocation()

getFileUploadSizeLimit

public int getFileUploadSizeLimit()
                           throws java.lang.UnsupportedOperationException
Description copied from interface: MultipartUploadSPI
Gets the maximum size, in bytes, of file uploads to be accepted. Uploads that exceed the specified size are terminated or handled in a manner that minimizes the risk of a Denial of Service attack against the application.

Specified by:
getFileUploadSizeLimit in interface MultipartUploadSPI
Returns:
the size threshold after which a file upload is rejected
Throws:
java.lang.UnsupportedOperationException - if this implementation does not support limiting file upload sizes
See Also:
MultipartUploadSPI.getFileUploadSizeLimit()

getMemoryCacheThreshold

public int getMemoryCacheThreshold()
                            throws java.lang.UnsupportedOperationException
Description copied from interface: MultipartUploadSPI
Gets the size, in bytes, that the file upload must exceed before being cached to disk. Some implementations that support disk caching may not support the storing of small uploads in memory. Such implementations should ignore calls to this method and not throw an UnsupportedOperationException.

Specified by:
getMemoryCacheThreshold in interface MultipartUploadSPI
Returns:
bytes maximum size of the file upload before it will be cached to disk
Throws:
java.lang.UnsupportedOperationException - if this implementation does not support disk caching
See Also:
MultipartUploadSPI.getMemoryCacheThreshold()

getWrappedRequest

public HttpServletRequest getWrappedRequest(HttpServletRequest request)
                                     throws java.io.IOException,
                                            ServletException
Description copied from interface: WebRenderAction.MultipartRequestWrapper
Returns a replacement HttpServletRequest object that may be used to handle a multipart/form-data encoded HTTP request.

Specified by:
getWrappedRequest in interface WebRenderAction.MultipartRequestWrapper
Parameters:
request - The HTTP request provided from the servlet container that has multipart/form-data encoding.
Returns:
An HTTP request that is capable of handling multipart/form-data encoding.
Throws:
java.io.IOException
ServletException

writeTempFile

protected java.io.File writeTempFile(java.io.InputStream in,
                                     UploadSelect uploadSelect)
                              throws java.io.IOException
Throws:
java.io.IOException