org.apache.turbine.services.upload
Class TurbineUpload

java.lang.Object
  extended byorg.apache.turbine.services.upload.TurbineUpload

public abstract class TurbineUpload
extends java.lang.Object

This is a facade class for UploadService.

This class provides static methods that retrieve the configured (in TurbineResource.properties) implementation of UploadService and perform certain operations on it. It uses constants defined in UploadService interface for accessing the service's properties and default values for them.

Version:
$Id: TurbineUpload.java 534527 2007-05-02 16:10:59Z tv $
Author:
Rafal Krzewski

Constructor Summary
TurbineUpload()
           
 
Method Summary
static boolean getAutomatic()
          Retrieves the value of the 'automatic' property of UploadService.
static java.lang.String getRepository()
           Retrieves the value of the repository property of UploadService.
static UploadService getService()
           Retrieves an instance of system's configured implementation of UploadService
static long getSizeMax()
           Retrieves the value of 'size.max' property of UploadService.
static int getSizeThreshold()
           Retrieves the value of size.threshold property of UploadService.
static boolean isAvailable()
          Checks whether an Upload Service is configured.
static void parseRequest(javax.servlet.http.HttpServletRequest req, ParameterParser params)
           Performs parsing the request and storing files and form fields.
static void parseRequest(javax.servlet.http.HttpServletRequest req, ParameterParser params, java.lang.String path)
           Performs parsing the request and storing files and form fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurbineUpload

public TurbineUpload()
Method Detail

getService

public static UploadService getService()

Retrieves an instance of system's configured implementation of UploadService

Returns:
An instance of UploadService

isAvailable

public static boolean isAvailable()
Checks whether an Upload Service is configured. This method is safe to call even with no Upload service installed.

Returns:
True if an upload Service is configured

getAutomatic

public static boolean getAutomatic()
Retrieves the value of the 'automatic' property of UploadService. This reports whether the Upload Service is available and (if yes), the Parameter parser should allow "automatic" uploads if it is submitted to Turbine. This method is safe to call even with no Upload Service configured.

Returns:
The value of 'automatic' property of UploadService.

getSizeMax

public static long getSizeMax()

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

Returns:
The value of 'size.max' property of UploadService.

getSizeThreshold

public static int getSizeThreshold()

Retrieves the value of size.threshold property of UploadService.

Returns:
The threshold beyond which files are written directly to disk.

getRepository

public static java.lang.String getRepository()

Retrieves the value of the repository property of UploadService.

Returns:
The repository.

parseRequest

public static void parseRequest(javax.servlet.http.HttpServletRequest req,
                                ParameterParser params)
                         throws TurbineException

Performs parsing the request and storing files and form fields. Default file repository is used. This method is called by the ParameterParser if automatic upload is enabled.

Parameters:
req - The servlet request to be parsed.
params - The ParameterParser instance to insert form fields into.
Throws:
TurbineException - If there are problems reading/parsing the request or storing files.

parseRequest

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

Performs parsing the request and storing files and form fields. Custom file repository may be specified. You can call this method in your file upload Action to if you need to specify a custom directory for storing files.

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.


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