Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jcorporate.expresso.core.misc.upload
Class Uploader  view Uploader download Uploader.java

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.upload.Uploader
All Implemented Interfaces:
org.apache.struts.upload.MultipartRequestHandler

public class Uploader
extends java.lang.Object
implements org.apache.struts.upload.MultipartRequestHandler

Files will be stored in temporary disk storage

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


Field Summary
private  java.util.Hashtable headers
          Stores parsed headers as key - value pairs.
private static org.apache.log4j.Logger log
           
static int MAX_HEADER_SIZE
          A maximum lenght of a single header line that will be parsed.
private  org.apache.struts.action.ActionServlet myActionServlet
           
private  org.apache.struts.action.ActionMapping myMapping
           
private  DefaultParameterParser myParser
           
 
Fields inherited from interface org.apache.struts.upload.MultipartRequestHandler
ATTRIBUTE_MAX_LENGTH_EXCEEDED
 
Constructor Summary
Uploader()
           
 
Method Summary
protected  FileItem createItem(java.lang.String path, int requestSize, boolean storeAsFile)
           Creates a new instance of a FileItem.
 void finish()
          This method is called on when a successful form post has been made.
 java.util.Hashtable getAllElements()
          This method returns all elements of a multipart request.
protected  java.lang.String getFieldName()
           Retrieves field name from 'Content-disposition' header.
 java.util.Hashtable getFileElements()
          This method is called on to retrieve all the FormFile input elements of the request.
protected  java.lang.String getFileName()
           Retrieves file name from 'Content-disposition' header.
protected  java.lang.String getHeader(java.lang.String name)
           Returns a header with specified name.
 org.apache.struts.action.ActionMapping getMapping()
          Get the ActionMapping instance for this request
 org.apache.struts.action.ActionServlet getServlet()
          Get the ActionServlet instance
 java.util.Hashtable getTextElements()
          This method is called on to retrieve all the text input elements of the request.
 void handleRequest(javax.servlet.http.HttpServletRequest request)
          After constructed, this is the first method called on by ActionServlet.
protected  void parseHeaders(java.lang.String headerPart)
           Parses the header-part and stores 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.
 void rollback()
          This method is called on when there's some sort of problem and the form post needs to be rolled back.
 void setMapping(org.apache.struts.action.ActionMapping mapping)
          Convienience method to set a reference to a working ActionMapping instance.
 void setServlet(org.apache.struts.action.ActionServlet servlet)
          Convienience method to set a reference to a working ActionServlet instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_HEADER_SIZE

public static final int MAX_HEADER_SIZE
A maximum lenght of a single header line that will be parsed. (1024 bytes).

See Also:
Constant Field Values

headers

private java.util.Hashtable headers
Stores parsed headers as key - value pairs.


myParser

private DefaultParameterParser myParser

myMapping

private org.apache.struts.action.ActionMapping myMapping

myActionServlet

private org.apache.struts.action.ActionServlet myActionServlet

log

private static org.apache.log4j.Logger log
Constructor Detail

Uploader

public Uploader()
Method Detail

parseRequest

public void parseRequest(javax.servlet.http.HttpServletRequest req,
                         ParameterParser params,
                         java.lang.String path)
                  throws com.jcorporate.expresso.core.controller.ControllerException
Processes an RFC 1867 compliant multipart/form-data stream.


getFieldName

protected java.lang.String getFieldName()

Retrieves field name from 'Content-disposition' header.


getFileName

protected java.lang.String getFileName()

Retrieves file name from 'Content-disposition' header.


createItem

protected FileItem createItem(java.lang.String path,
                              int requestSize,
                              boolean storeAsFile)

Creates a new instance of a FileItem.


parseHeaders

protected void parseHeaders(java.lang.String headerPart)

Parses the header-part and stores 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.


getHeader

protected java.lang.String getHeader(java.lang.String name)

Returns a header with specified name.


setServlet

public void setServlet(org.apache.struts.action.ActionServlet servlet)
Convienience method to set a reference to a working ActionServlet instance.

Specified by:
setServlet in interface org.apache.struts.upload.MultipartRequestHandler

setMapping

public void setMapping(org.apache.struts.action.ActionMapping mapping)
Convienience method to set a reference to a working ActionMapping instance.

Specified by:
setMapping in interface org.apache.struts.upload.MultipartRequestHandler

getServlet

public org.apache.struts.action.ActionServlet getServlet()
Get the ActionServlet instance

Specified by:
getServlet in interface org.apache.struts.upload.MultipartRequestHandler

getMapping

public org.apache.struts.action.ActionMapping getMapping()
Get the ActionMapping instance for this request

Specified by:
getMapping in interface org.apache.struts.upload.MultipartRequestHandler

handleRequest

public void handleRequest(javax.servlet.http.HttpServletRequest request)
                   throws javax.servlet.ServletException
After constructed, this is the first method called on by ActionServlet. Use this method for all your data-parsing of the ServletInputStream in the request

Specified by:
handleRequest in interface org.apache.struts.upload.MultipartRequestHandler

getTextElements

public java.util.Hashtable getTextElements()
This method is called on to retrieve all the text input elements of the request.

Specified by:
getTextElements in interface org.apache.struts.upload.MultipartRequestHandler

getFileElements

public java.util.Hashtable getFileElements()
This method is called on to retrieve all the FormFile input elements of the request.

Specified by:
getFileElements in interface org.apache.struts.upload.MultipartRequestHandler

getAllElements

public java.util.Hashtable getAllElements()
This method returns all elements of a multipart request.

Specified by:
getAllElements in interface org.apache.struts.upload.MultipartRequestHandler

rollback

public void rollback()
This method is called on when there's some sort of problem and the form post needs to be rolled back. Providers should remove any FormFiles used to hold information by setting them to null and also physically delete them if the implementation calls for writing directly to disk. NOTE: Currently implemented but not automatically supported, ActionForm implementors must call rollback() manually for rolling back file uploads.

Specified by:
rollback in interface org.apache.struts.upload.MultipartRequestHandler

finish

public void finish()
This method is called on when a successful form post has been made. Some implementations will use this to destroy temporary files or write to a database or something of that nature

Specified by:
finish in interface org.apache.struts.upload.MultipartRequestHandler