org.apache.fulcrum.upload
Class DefaultUploadService

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.fulcrum.upload.DefaultUploadService
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, UploadService

public class DefaultUploadService
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements UploadService, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable

This class is an implementation of UploadService.

Files will be stored in temporary disk storage on in memory, depending on request size, and will be available from the org.apache.fulcrum.util.parser.ParameterParser as org.apache.fulcrum.upload.FileItems.

This implementation of UploadService handles multiple files per single html widget, sent using multipar/mixed encoding type, as specified by RFC 1867. Use org.apache.fulcrum.util.parser.ParameterParser#getFileItems(String) to acquire an array of org.apache.fulcrum.upload.FileItems associated with given html widget.

Version:
$Id: DefaultUploadService.java 732085 2009-01-06 19:58:22Z tv $
Author:
Rafal Krzewski, Daniel Rall, Jason van Zyl

Field Summary
 
Fields inherited from interface org.apache.fulcrum.upload.UploadService
CONTENT_DISPOSITION, CONTENT_TYPE, FORM_DATA, HEADER_ENCODING_DEFAULT, HEADER_ENCODING_KEY, MIXED, MULTIPART, MULTIPART_FORM_DATA, MULTIPART_MIXED, REPOSITORY_DEFAULT, REPOSITORY_KEY, REPOSITORY_PARAMETER, ROLE, SIZE_MAX_DEFAULT, SIZE_MAX_KEY, SIZE_THRESHOLD_DEFAULT, SIZE_THRESHOLD_KEY
 
Constructor Summary
DefaultUploadService()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Avalon component lifecycle method
 void contextualize(org.apache.avalon.framework.context.Context context)
           
 String getHeaderEncoding()
           Retrieves the value of the headerEncoding property of UploadService.
 String getRepository()
          The location used to temporarily store files that are larger than the size threshold.
 long getSizeMax()
          The maximum allowed upload size
 long getSizeThreshold()
          The threshold beyond which files are written directly to disk.
 void initialize()
          Initializes the service.
 List parseRequest(javax.servlet.http.HttpServletRequest req)
          Parses a RFC 1867 compliant multipart/form-data stream.
 List parseRequest(javax.servlet.http.HttpServletRequest req, int sizeThreshold, int sizeMax, String path)
          Parses a RFC 1867 compliant multipart/form-data stream.
 List parseRequest(javax.servlet.http.HttpServletRequest req, String path)
          Parses a RFC 1867 compliant multipart/form-data stream.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUploadService

public DefaultUploadService()
Method Detail

getSizeMax

public long getSizeMax()
The maximum allowed upload size

Specified by:
getSizeMax in interface UploadService
Returns:
The maximum upload size.

getSizeThreshold

public long getSizeThreshold()
The threshold beyond which files are written directly to disk.

Specified by:
getSizeThreshold in interface UploadService
Returns:
The threshold beyond which files are written directly to disk.

getRepository

public String getRepository()
The location used to temporarily store files that are larger than the size threshold.

Specified by:
getRepository in interface UploadService
Returns:
The repository.

getHeaderEncoding

public String getHeaderEncoding()
Description copied from interface: UploadService

Retrieves the value of the headerEncoding property of UploadService.

Specified by:
getHeaderEncoding in interface UploadService
Returns:
Returns the headerEncoding.

parseRequest

public List parseRequest(javax.servlet.http.HttpServletRequest req)
                  throws org.apache.avalon.framework.service.ServiceException

Parses a RFC 1867 compliant multipart/form-data stream.

Specified by:
parseRequest in interface UploadService
Parameters:
req - The servlet request to be parsed.
Throws:
org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).

parseRequest

public List parseRequest(javax.servlet.http.HttpServletRequest req,
                         String path)
                  throws org.apache.avalon.framework.service.ServiceException

Parses a RFC 1867 compliant multipart/form-data stream.

Specified by:
parseRequest in interface UploadService
Parameters:
req - The servlet request to be parsed.
path - The location where the files should be stored.
Throws:
org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).

parseRequest

public List parseRequest(javax.servlet.http.HttpServletRequest req,
                         int sizeThreshold,
                         int sizeMax,
                         String path)
                  throws org.apache.avalon.framework.service.ServiceException

Parses a RFC 1867 compliant multipart/form-data stream.

Specified by:
parseRequest in interface UploadService
Parameters:
req - The servlet request to be parsed.
sizeThreshold - the max size in bytes to be stored in memory
sizeMax - the maximum allowed upload size in bytes
path - The location where the files should be stored.
Throws:
org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
Avalon component lifecycle method

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable

initialize

public void initialize()
                throws Exception
Initializes the service. This method processes the repository path, to make it relative to the web application root, if necessary

Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
Exception

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Throws:
org.apache.avalon.framework.context.ContextException


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.