org.apache.turbine.services.upload
Class TurbineUploadService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.turbine.services.upload.TurbineUploadService
All Implemented Interfaces:
Initable, Service, UploadService

public class TurbineUploadService
extends TurbineBaseService
implements UploadService

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: TurbineUploadService.java 534527 2007-05-02 16:10:59Z tv $
Author:
Rafal Krzewski, Daniel Rall, Henning P. Schmiedehausen

Field Summary
protected  org.apache.commons.fileupload.servlet.ServletFileUpload fileUpload
          A File Upload object for the actual uploading
protected  org.apache.commons.fileupload.disk.DiskFileItemFactory itemFactory
          A File Item Factory object for the actual uploading
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, 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
 boolean getAutomatic()
          Retrieves the value of the 'automatic' property of UploadService.
 java.lang.String getRepository()
           Retrieves the value of the repository property of UploadService.
 long getSizeMax()
           Retrieves the value of size.max property of the UploadService.
 int getSizeThreshold()
           Retrieves the value of size.threshold property of UploadService.
 void init()
          Initializes the service.
 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.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, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
 

Field Detail

fileUpload

protected org.apache.commons.fileupload.servlet.ServletFileUpload fileUpload
A File Upload object for the actual uploading


itemFactory

protected org.apache.commons.fileupload.disk.DiskFileItemFactory itemFactory
A File Item Factory object for the actual uploading

Constructor Detail

TurbineUploadService

public TurbineUploadService()
Method Detail

init

public void init()
          throws InitializationException
Initializes the service. This method processes the repository path, to make it relative to the web application root, if neccessary

Specified by:
init in interface Initable
Overrides:
init in class TurbineBaseService
Throws:
InitializationException

getSizeMax

public long getSizeMax()

Retrieves the value of size.max property of the UploadService.

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

getSizeThreshold

public int getSizeThreshold()

Retrieves the value of size.threshold property of UploadService.

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

getAutomatic

public boolean getAutomatic()
Retrieves the value of the 'automatic' property of UploadService. This reports whether the Parameter parser should allow "automatic" uploads if it is submitted to Turbine.

Specified by:
getAutomatic in interface UploadService
Returns:
The value of 'automatic' property of UploadService.

getRepository

public java.lang.String getRepository()

Retrieves the value of the repository property of UploadService.

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

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.

Specified by:
parseRequest in interface UploadService
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 - Problems reading/parsing the request or storing the uploaded file(s).


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.