org.apache.turbine.util.upload
Class FileHandler

java.lang.Object
  |
  +--org.apache.turbine.util.upload.FileHandler

Deprecated. Use TurbineUploadService counterpart FileItem.

public class FileHandler
extends java.lang.Object

This class is used to upload files from a client to the server (any types and any number of fields is supported) and download files from the server to the client.

Author:
Oleg M. Podolsky, Neeme Praks

Field Summary
private  byte[] boundary
          Deprecated.  
private  int boundarysize
          Deprecated. Place for boundary that separates field data.
private  java.lang.String contenttype
          Deprecated.  
private static byte[] CRLF2
          Deprecated. Carriage return - line feed two times.
private  java.lang.String fieldname
          Deprecated.  
private  java.lang.String filename
          Deprecated.  
private  long maxdata
          Deprecated. Maximum number of bytes accepted, if zero then no limit.
static java.lang.String PARAMETER_NAME_CONTENT_TYPE
          Deprecated.  
static java.lang.String PARAMETER_NAME_ENCODING
          Deprecated.  
static java.lang.String PARAMETER_NAME_FILENAME
          Deprecated.  
static java.lang.String PARAMETER_NAME_FILENAME_SAVED
          Deprecated.  
static java.lang.String PARAMETER_NAME_FILESIZE
          Deprecated.  
private  ParameterParser pp
          Deprecated.  
private  byte[] readbuffer
          Deprecated.  
private static int readbuffersize
          Deprecated. Buffer for reading/writing data and buffer for storing all data.
private  javax.servlet.http.HttpServletRequest req
          Deprecated.  
private  javax.servlet.http.HttpServletResponse res
          Deprecated.  
private  java.lang.String root
          Deprecated.  
private  byte[] storebuffer
          Deprecated.  
private  int storebuffersize
          Deprecated.  
private  byte[] writebuffer
          Deprecated.  
private static int writebuffersize
          Deprecated. Buffer for sending data back to browser.
 
Constructor Summary
FileHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, ParameterParser pp)
          Deprecated. Use TurbineUploadService counterpart FileItem.
FileHandler(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, ParameterParser pp, java.lang.String root)
          Deprecated. Use TurbineUploadService counterpart FileItem.
FileHandler(javax.servlet.http.HttpServletRequest req, ParameterParser pp, java.lang.String root)
          Deprecated. Use TurbineUploadService counterpart FileItem.
FileHandler(RunData data)
          Deprecated. Use TurbineUploadService counterpart FileItem.
FileHandler(RunData data, java.lang.String root)
          Deprecated. Use TurbineUploadService counterpart FileItem.
 
Method Summary
private  void copyStream(java.io.InputStream ins, java.io.OutputStream outs)
          Deprecated. Copies stream ins to stream outs.
 boolean deleteFile(java.lang.String filename)
          Deprecated. Use TurbineUploadService counterpart FileItem.
private  int findByte(byte b, int pos)
          Deprecated. Finds the first position of B in StoreBuffer beginning with position number Pos, or -1 if not found.
private  int findSubArray(byte[] subarray, int pos)
          Deprecated. Finds the first position of SubArray in StoreBuffer beginning with position number Pos, or -1 if not found.
private  java.lang.String getChunkAsText(int start, int end)
          Deprecated. Returns the given chunk of StoreBuffer as a String.
 java.lang.String getFileRepository()
          Deprecated. Use TurbineUploadService counterpart FileItem.
private  void getHeaderInfo(int start, int end)
          Deprecated. Finds values of Fieldname and Filename variables from the given chunk of StoreBuffer.
private  java.lang.String getRandomName()
          Deprecated. Finds random name in the ROOT directory.
private  java.lang.String getShortName(java.lang.String fullname)
          Deprecated. Cuts short name of a file from its fully qualified name.
static boolean isSimpleForm(javax.servlet.http.HttpServletRequest req)
          Deprecated. Use TurbineUploadService counterpart FileItem.
private  void readToStoreBuffer(java.io.InputStream instream)
          Deprecated. Reads the data from the given inputstream to StoreBuffer.
 void saveStream()
          Deprecated. Use TurbineUploadService counterpart FileItem.
 void setFileRepository(java.lang.String root)
          Deprecated. Use TurbineUploadService counterpart FileItem.
 void setMaxSize(long size)
          Deprecated. Use TurbineUploadService counterpart FileItem.
private  void storeChunk(int start, int end, java.io.OutputStream outstream)
          Deprecated. Writes the given chunk of StoreBuffer to given OutputStream.
private  void writeChunks()
          Deprecated. Divides StoreBuffer into simple fields and binary fields (files) and writes them to files (simple fields - to a text file, files - to files with random names, providing name mappings in the file for simple fields).
 void writeFileToResponse(java.lang.String savedname, java.lang.String filename, java.lang.String contenttype)
          Deprecated. Use TurbineUploadService counterpart FileItem.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PARAMETER_NAME_FILENAME

public static java.lang.String PARAMETER_NAME_FILENAME
Deprecated. 

PARAMETER_NAME_FILESIZE

public static java.lang.String PARAMETER_NAME_FILESIZE
Deprecated. 

PARAMETER_NAME_FILENAME_SAVED

public static java.lang.String PARAMETER_NAME_FILENAME_SAVED
Deprecated. 

PARAMETER_NAME_ENCODING

public static java.lang.String PARAMETER_NAME_ENCODING
Deprecated. 

PARAMETER_NAME_CONTENT_TYPE

public static java.lang.String PARAMETER_NAME_CONTENT_TYPE
Deprecated. 

CRLF2

private static final byte[] CRLF2
Deprecated. 
Carriage return - line feed two times.

readbuffersize

private static int readbuffersize
Deprecated. 
Buffer for reading/writing data and buffer for storing all data.

readbuffer

private byte[] readbuffer
Deprecated. 

storebuffersize

private int storebuffersize
Deprecated. 

storebuffer

private byte[] storebuffer
Deprecated. 

writebuffersize

private static int writebuffersize
Deprecated. 
Buffer for sending data back to browser.

writebuffer

private byte[] writebuffer
Deprecated. 

maxdata

private long maxdata
Deprecated. 
Maximum number of bytes accepted, if zero then no limit.

boundarysize

private int boundarysize
Deprecated. 
Place for boundary that separates field data.

boundary

private byte[] boundary
Deprecated. 

fieldname

private java.lang.String fieldname
Deprecated. 

filename

private java.lang.String filename
Deprecated. 

contenttype

private java.lang.String contenttype
Deprecated. 

req

private javax.servlet.http.HttpServletRequest req
Deprecated. 

res

private javax.servlet.http.HttpServletResponse res
Deprecated. 

pp

private ParameterParser pp
Deprecated. 

root

private java.lang.String root
Deprecated. 
Constructor Detail

FileHandler

public FileHandler(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res,
                   ParameterParser pp)
Deprecated. Use TurbineUploadService counterpart FileItem.

Performs initialization.
Parameters:
req - An HttpServletRequest.
res - An HttpServletResponse.
pp - A ParameterParser.

FileHandler

public FileHandler(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res,
                   ParameterParser pp,
                   java.lang.String root)
Deprecated. Use TurbineUploadService counterpart FileItem.

Performs initialization.
Parameters:
req - An HttpServletRequest.
res - An HttpServletResponse.
pp - A ParameterParser.
root - A String.

FileHandler

public FileHandler(javax.servlet.http.HttpServletRequest req,
                   ParameterParser pp,
                   java.lang.String root)
Deprecated. Use TurbineUploadService counterpart FileItem.

Performs initialization.
Parameters:
req - An HttpServletRequest.
res - An HttpServletResponse.
root - A String.

FileHandler

public FileHandler(RunData data,
                   java.lang.String root)
Deprecated. Use TurbineUploadService counterpart FileItem.

Performs initialization.
Parameters:
data - A Turbine RunData object.
root - A String.

FileHandler

public FileHandler(RunData data)
Deprecated. Use TurbineUploadService counterpart FileItem.

Performs initialization.
Parameters:
data - A Turbine RunData object.
Method Detail

isSimpleForm

public static boolean isSimpleForm(javax.servlet.http.HttpServletRequest req)
Deprecated. Use TurbineUploadService counterpart FileItem.

If the form data is non-multipart (simple), it returns true, otherwise returns false.
Parameters:
req - An HttpServletRequest.
Returns:
True if the form data is non-multipart (simple).

copyStream

private void copyStream(java.io.InputStream ins,
                        java.io.OutputStream outs)
                 throws java.io.IOException
Deprecated. 
Copies stream ins to stream outs.
Parameters:
ins - An InputStream.
outs - An OutputStream.
Throws:
IOException. -  

writeFileToResponse

public void writeFileToResponse(java.lang.String savedname,
                                java.lang.String filename,
                                java.lang.String contenttype)
                         throws java.lang.Exception
Deprecated. Use TurbineUploadService counterpart FileItem.

Writes HTTP headers and the file data to the response.
Parameters:
savedname - A String.
filename - A String.
contenttype - A String.
Throws:
Exception, - a generic exception.

getRandomName

private java.lang.String getRandomName()
Deprecated. 
Finds random name in the ROOT directory. For example, if ROOT="c:/temp", name="c:/temp/upload23967879053.dat". ROOT cannot finish with '/' or '\'.
Returns:
A String with a random name in the given directory.

getShortName

private java.lang.String getShortName(java.lang.String fullname)
Deprecated. 
Cuts short name of a file from its fully qualified name. For example, "c:\a\b\info.txt" -> "info.txt".
Parameters:
fullname - Full name of a file.
Returns:
A String with the short name.

findByte

private int findByte(byte b,
                     int pos)
Deprecated. 
Finds the first position of B in StoreBuffer beginning with position number Pos, or -1 if not found.
Parameters:
b - Byte to find.
pos - Position to start from.
Returns:
The first occurence of B from Pos.

findSubArray

private int findSubArray(byte[] subarray,
                         int pos)
Deprecated. 
Finds the first position of SubArray in StoreBuffer beginning with position number Pos, or -1 if not found.
Parameters:
subarray - Subarray to find.
pos - Position to start from.
Returns:
The first occurence of Subarray from Pos.

readToStoreBuffer

private void readToStoreBuffer(java.io.InputStream instream)
                        throws java.io.IOException
Deprecated. 
Reads the data from the given inputstream to StoreBuffer.
Parameters:
instream - InputStream to use.
Throws:
IOException. -  

getHeaderInfo

private void getHeaderInfo(int start,
                           int end)
Deprecated. 
Finds values of Fieldname and Filename variables from the given chunk of StoreBuffer.
Parameters:
start - Starting position in StoreBuffer.
end - Ending position in StoreBuffer.

getChunkAsText

private java.lang.String getChunkAsText(int start,
                                        int end)
Deprecated. 
Returns the given chunk of StoreBuffer as a String.
Parameters:
start - Starting position in StoreBuffer.
end - Ending position in StoreBuffer.
Returns:
Given chunk's representation as a String.

storeChunk

private void storeChunk(int start,
                        int end,
                        java.io.OutputStream outstream)
                 throws java.io.IOException
Deprecated. 
Writes the given chunk of StoreBuffer to given OutputStream.
Parameters:
start - Starting position in StoreBuffer.
end - Ending position in StoreBuffer.
outstream - OutputStream to write to.
Throws:
IOException. -  

writeChunks

private void writeChunks()
                  throws java.io.IOException
Deprecated. 
Divides StoreBuffer into simple fields and binary fields (files) and writes them to files (simple fields - to a text file, files - to files with random names, providing name mappings in the file for simple fields).
Throws:
IOException. -  

saveStream

public void saveStream()
                throws javax.servlet.ServletException,
                       java.io.IOException
Deprecated. Use TurbineUploadService counterpart FileItem.

Stores all data.
Throws:
ServletException. -  
IOException. -  

setFileRepository

public void setFileRepository(java.lang.String root)
Deprecated. Use TurbineUploadService counterpart FileItem.

Sets the root file repository.
Parameters:
root - A String.

getFileRepository

public java.lang.String getFileRepository()
Deprecated. Use TurbineUploadService counterpart FileItem.

Gets the root file repository.
Returns:
A String.

setMaxSize

public void setMaxSize(long size)
Deprecated. Use TurbineUploadService counterpart FileItem.

Sets the maximum size.
Parameters:
size - A long.

deleteFile

public boolean deleteFile(java.lang.String filename)
Deprecated. Use TurbineUploadService counterpart FileItem.

Deletes the file.
Parameters:
filename - A String.
Returns:
True if file was deleted.


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