com.ibm.wbi.http.beans
Class PutGenerator

com.ibm.wbi.plugin.Meg
  |
  +--com.ibm.wbi.plugin.Generator
        |
        +--com.ibm.wbi.http.plugin.HttpGenerator
              |
              +--com.ibm.wbi.http.beans.PutGenerator

public class PutGenerator
extends HttpGenerator

A Generator that handles HTTP 'PUT' requests and stores the results in a file on the local file system.

It has three properties: Directory, UrlPrefix, and CreateNeededDirectories.

Directory
Specifies the directory in the local file system where files are to be stored.
UrlPrefix
specifies a path prefix that will be expected to be part of the requested URL that will be ignored. For example, if the Directory is "c:\putfiles" and the UrlPrefix is "home/data" and the 'PUT' URL is: "http://myserver/home/data/foo/a.html" then the Generator will store the file "c:\putfiles\foo\a.html".
CreateNeededDirectories
a boolean that specifies whether subdirectories should be automatically created if a PUT request attempts to store a file in a non-existant child of Directory. If false and the subdirectory does not exist, a 400 error is returned to the browser.

The PUT request must contain a content-length header entry. It may also optionally contain a content-range header entry. Use of content-range allows a client to PUT portions of a file in separate PUT requests.

Upon successful completion of the PUT operation, the Generator sends a brief message back to the browser, with an HTTP response code of 200. Upon an error condition, the Generator sends a brief explanation with an HTTP response code of 400. The possible error conditions are:


Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information
 
Fields inherited from class com.ibm.wbi.http.plugin.HttpGenerator
COPYRIGHT, http
 
Fields inherited from class com.ibm.wbi.plugin.Generator
COPYRIGHT
 
Fields inherited from class com.ibm.wbi.plugin.Meg
COPYRIGHT, EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED
 
Constructor Summary
PutGenerator()
          The default constructor.
 
Method Summary
 java.lang.String getDirectory()
          Access the Directory property.
 java.lang.String getUrlPrefix()
          Access the UrlPrefix property.
 void handleRequest(RequestEvent e)
          The method used by WBI to handle the PUT request.
 boolean isCreateNeededDirectories()
          Access the CreateNeededDirectories property.
 void setCreateNeededDirectories(boolean cnd)
          Set the CreateNeededDirectories property.
 void setDirectory(java.lang.String dir)
          Set the Directory property.
 void setUrlPrefix(java.lang.String up)
          Set the UrlPrefix property.
 
Methods inherited from class com.ibm.wbi.http.plugin.HttpGenerator
add, addCookie, getContentType, getHttpResponse, getHttpResponseString, getResponseCode, getResponseText, isCache, produceHeader, set, setCache, setContentLength, setContentType, setResponseCode, setResponseText, setServer, writeHeader
 
Methods inherited from class com.ibm.wbi.plugin.Generator
getMegType
 
Methods inherited from class com.ibm.wbi.plugin.Meg
forwardRequest, getCondition, getEnabled, getName, getPlugin, getPriority, isEnabled, processRejectedRequest, setCondition, setEnabled, setName, setPriority, setup, setup, setup, setup, threadManagerRun
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
IBM copyright information
Constructor Detail

PutGenerator

public PutGenerator()
The default constructor. Directory defaults to "../data"; UrlPrefix defaults to null; CreateNeededDirectories defaults to true.
Method Detail

setDirectory

public void setDirectory(java.lang.String dir)
Set the Directory property. This is the directory in which files will be stored. For example, "C:\data"
Parameters:
dir - The Directory.

getDirectory

public java.lang.String getDirectory()
Access the Directory property.
Returns:
The Directory

setCreateNeededDirectories

public void setCreateNeededDirectories(boolean cnd)
Set the CreateNeededDirectories property. This property determines whether a PUT request is allowed to specify a non-existent directory, in which case it will automatically be created. If this property is false, such a request will generate an error.
Parameters:
cnd - Create directories?

isCreateNeededDirectories

public boolean isCreateNeededDirectories()
Access the CreateNeededDirectories property.
Returns:
Create directories?

setUrlPrefix

public void setUrlPrefix(java.lang.String up)
Set the UrlPrefix property. This property specifies what leading characters of the URL path should be ignored when determining where to store the file in the local file system. For example, if urlPrefix=="/wbi" and directory=="../data" and the URL Path="/wbi/foo/bar.baz" then the file "bar.baz" will be stored in the "../data/foo" directory.
Parameters:
up - The UrlPrefix

getUrlPrefix

public java.lang.String getUrlPrefix()
Access the UrlPrefix property.
Returns:
The UrlPrefix

handleRequest

public void handleRequest(RequestEvent e)
                   throws RequestRejectedException,
                          java.io.IOException
The method used by WBI to handle the PUT request.
Parameters:
e - The request event.
Throws:
RequestRejectedException - To reject request.
Overrides:
handleRequest in class HttpGenerator