HDIV API 2.0.4

org.hdiv.config.multipart
Class AbstractMultipartConfig

java.lang.Object
  extended by org.hdiv.config.multipart.AbstractMultipartConfig
All Implemented Interfaces:
IMultipartConfig
Direct Known Subclasses:
Struts2MultipartConfig, StrutsMultipartConfig

public abstract class AbstractMultipartConfig
extends java.lang.Object
implements IMultipartConfig

Class containing multipart request configuration and methods initialized from Spring Factory.

Author:
Gorka Vicente

Field Summary
protected  java.lang.String maxFileSize
          The maximum allowable size, in bytes, of an uploaded file.
protected  java.lang.String tempDir
          The temporary working directory to use for file uploads.
 
Fields inherited from interface org.hdiv.config.multipart.IMultipartConfig
ATTRIBUTE_MAX_LENGTH_EXCEEDED, DEFAULT_SIZE_MAX, DEFAULT_SIZE_THRESHOLD, FILEUPLOAD_EXCEPTION
 
Constructor Summary
AbstractMultipartConfig()
           
 
Method Summary
 void addFileParameter(RequestWrapper request, org.apache.commons.fileupload.FileItem item)
          Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.
 long convertSizeToBytes(java.lang.String sizeString, long defaultSize)
          Converts a size value from a string representation to its numeric value.
 java.lang.String getRepositoryPath(javax.servlet.ServletContext servletContext)
          Returns the path to the temporary directory to be used for uploaded files which are written to disk.
protected  long getSizeMax()
          Returns the maximum allowable size, in bytes, of an uploaded file.
 void setMaxFileSize(java.lang.String maxFileSize)
           
 void setTempDir(java.lang.String tempDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hdiv.config.multipart.IMultipartConfig
addTextParameter, handleMultipartRequest
 

Field Detail

maxFileSize

protected java.lang.String maxFileSize
The maximum allowable size, in bytes, of an uploaded file.


tempDir

protected java.lang.String tempDir
The temporary working directory to use for file uploads.

Constructor Detail

AbstractMultipartConfig

public AbstractMultipartConfig()
Method Detail

convertSizeToBytes

public long convertSizeToBytes(java.lang.String sizeString,
                               long defaultSize)
Converts a size value from a string representation to its numeric value. The string must be of the form nnnm, where nnn is an arbitrary decimal value, and m is a multiplier. The multiplier must be one of 'K', 'M' and 'G', representing kilobytes, megabytes and gigabytes respectively. If the size value cannot be converted, for example due to invalid syntax, the supplied default is returned instead.

Parameters:
sizeString - The string representation of the size to be converted.
defaultSize - The value to be returned if the string is invalid.
Returns:
The actual size in bytes.

getRepositoryPath

public java.lang.String getRepositoryPath(javax.servlet.ServletContext servletContext)
Returns the path to the temporary directory to be used for uploaded files which are written to disk. The directory used is determined from the first of the following to be non-empty.
  1. A temp dir explicitly defined using the saveDir attribute of the <multipartConfig> element in the Spring config file.
  2. The temp dir specified by the javax.servlet.context.tempdir attribute.

Specified by:
getRepositoryPath in interface IMultipartConfig
Parameters:
servletContext - servlet context
Returns:
The path to the directory to be used to store uploaded files.

addFileParameter

public void addFileParameter(RequestWrapper request,
                             org.apache.commons.fileupload.FileItem item)
Adds a file parameter to the set of file parameters for this request and also to the list of all parameters.

Specified by:
addFileParameter in interface IMultipartConfig
Parameters:
request - The request in which the parameter was specified.
item - The file item for the parameter to add.

setMaxFileSize

public void setMaxFileSize(java.lang.String maxFileSize)
Parameters:
maxFileSize - The maximum size to set.

setTempDir

public void setTempDir(java.lang.String tempDir)
Parameters:
tempDir - The tempDir to set.

getSizeMax

protected long getSizeMax()
Returns the maximum allowable size, in bytes, of an uploaded file. The value is obtained from the Spring configuration.

Returns:
The maximum allowable file size, in bytes.

HDIV 2.0.4

Copyright © 2008 hdiv.org. All Rights Reserved.