org.apache.turbine.services.upload
Class TurbineUploadService

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitable
        |
        +--org.apache.turbine.services.BaseService
              |
              +--org.apache.turbine.services.TurbineBaseService
                    |
                    +--org.apache.turbine.services.upload.BaseUploadService
                          |
                          +--org.apache.turbine.services.upload.TurbineUploadService
All Implemented Interfaces:
Initable, Service, UploadService

public class TurbineUploadService
extends BaseUploadService

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 ParameterParser as FileItems.

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

Version:
$Id$
Author:
Rafal Krzewski, Daniel Rall

Fields inherited from class org.apache.turbine.services.upload.BaseUploadService
MAX_HEADER_SIZE
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.upload.UploadService
AUTOMATIC_DEFAULT, AUTOMATIC_KEY, CONTENT_DISPOSITION, CONTENT_TYPE, FORM_DATA, MIXED, MULTIPART, MULTIPART_FORM_DATA, MULTIPART_MIXED, REPOSITORY_DEFAULT, REPOSITORY_KEY, REPOSITORY_PARAMETER, SERVICE_NAME, SIZE_MAX_DEFAULT, SIZE_MAX_KEY, SIZE_THRESHOLD_DEFAULT, SIZE_THRESHOLD_KEY
 
Constructor Summary
TurbineUploadService()
           
 
Method Summary
protected  FileItem createItem(java.lang.String path, java.util.Map headers, int requestSize)
           Creates a new instance of FileItem.
protected  java.lang.String getFieldName(java.util.Map headers)
           Retrieves field name from Content-disposition header.
protected  java.lang.String getFileName(java.util.Map headers)
           Retrieves file name from Content-disposition header.
protected  java.lang.String getHeader(java.util.Map headers, java.lang.String name)
           Returns a header with specified name.
protected  java.util.Map parseHeaders(java.lang.String headerPart)
           Parses the header-part and returns as key/value pairs.
 void parseRequest(javax.servlet.http.HttpServletRequest req, ParameterParser params, java.lang.String path)
           Processes an RFC 1867 compliant multipart/form-data stream.
 
Methods inherited from class org.apache.turbine.services.upload.BaseUploadService
getRepository, getSizeMax, getSizeThreshold, init
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
 

Constructor Detail

TurbineUploadService

public TurbineUploadService()
Method Detail

parseRequest

public void parseRequest(javax.servlet.http.HttpServletRequest req,
                         ParameterParser params,
                         java.lang.String path)
                  throws TurbineException

Processes an RFC 1867 compliant multipart/form-data stream.

Overrides:
parseRequest in class BaseUploadService
Parameters:
req - The servlet request to be parsed.
params - The ParameterParser instance to insert form fields into.
path - The location where the files should be stored.
Throws:
TurbineException - If there are problems reading/parsing the request or storing files.

getFileName

protected java.lang.String getFileName(java.util.Map headers)

Retrieves file name from Content-disposition header.

Parameters:
headers - The HTTP request headers.
Returns:
A the file name for the current encapsulation.

getFieldName

protected java.lang.String getFieldName(java.util.Map headers)

Retrieves field name from Content-disposition header.

Parameters:
headers - The HTTP request headers.
Returns:
The field name for the current encapsulation.

createItem

protected FileItem createItem(java.lang.String path,
                              java.util.Map headers,
                              int requestSize)

Creates a new instance of FileItem.

Parameters:
path - The path for the FileItem.
headers - The HTTP request headers.
requestSize - The size of the request.
Returns:
A newly created FileItem.

parseHeaders

protected java.util.Map parseHeaders(java.lang.String headerPart)

Parses the header-part and returns as key/value pairs.

If there are multiple headers of the same names, the name will map to a comma-separated list containing the values.

Parameters:
headerPart - The header-part of the current encapsulation.
Returns:
The parsed HTTP request headers.

getHeader

protected final java.lang.String getHeader(java.util.Map headers,
                                           java.lang.String name)

Returns a header with specified name.

Parameters:
headers - The HTTP request headers.
name - The name of the header to fetch.
Returns:
The value of specified header, or a comma-separated list if there were multiple headers of that name.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.