wt.httpgw
Class URLFactory

java.lang.Object
  extended bywt.httpgw.URLFactory

public final class URLFactory
extends Object

A URL and HREF factory for Windchill application resources.

Instances are capable of generating URL objects or HREF strings to resources in a particular Windchill system. Each instance corresponds to one Windchill system from which URL mappings are obtained. Each factory instance has an optional request URI from which relative HREF strings are generated. If no request URI is set, only absolute HREFs are returned. Each system has a base URL corresponding to the application's virtual directory root. Resources are requested using paths relative to this base URL (e.g. wt/clients/images/myimage.jpg).

Instances are constructed given a codebase URL for a Windchill system. This URL is any URL that can be used to download configuration files corresponding to the desired system. Configuration files (e.g. wt.properties, urlmap.properties) from the server codebase are used to determine the system's base URL and any URL mappings that may apply to certain resources. The base URL for a system may be different than the server codebase URL used to construct the factory.

URL mappings allow Windchill administrators to override the location of specific resources such as files, directories, or servlets which are otherwise located relative to the system's base URL. Mappings may override the entire URL or just specific components such as protocol, host, port, or path.

Typiccal usage in a JSP is to instantiate using the no-arg constructor, set the requestURI property from the servlet request, generate a HTML tag in the response to the application root using the getBaseHREF() method, then reset the factory's request URI to the application root using the setRequestUri method with the same value.

Resource-specific helper methods can be created which encapsulate the URL and HREF generating methods within methods that are more meaningful to the target resource. For example, a servlet that uses path info elements and/or query string parameters in a well defined way can be exposed factory methods that have more meaningful arguments. These helper methods should accept an instance of a URL factory as input along with the resource-specific arguments.

NOTE: Instances of a URL factory are not thread safe. Each instance contains buffers that may be reused when encoding URLs.

Mapping File

(UL)The mapping file will consist of a series of key/value pairs separated by the '=' character. Further '=' characters will be left as part of the value part of the pair. Comments may be inserted into the file by using the '#' character and blank lines will be ignored. The default Windchill file for URL Mappings is the file urlmap.properties located in the Windchill codebase directory.

Mapping Rules



Supported API: true
Extendable: false


Field Summary
private static ThreadLocal alt_local_server
          Thread localized list for the current alt server configuration
static String ALT_SERVER_CODEBASE_PROPERTY
           
private static Hashtable cvMappings
          Static hashmap of Mapped Properties
private  boolean isMapCodebase
          cache and use the vailability of alt codebase
private  URL ivAltBaseURL
          Alternate BaseURL.
private  URLData ivAltRefData
          The Alternate URLData to the codebase
private  URL ivBaseURL
          BaseURL.
private  boolean ivbFullyQualified
          flag for the fully qualified URL setting
private  boolean ivbMapped
          Whether this URLFactory has mapped settings.
private  EncodingConverter ivEncoder
           
private  String ivEncoding
          The string encoding for the URLFactory
private  ArrayList ivList
          The List of mappings for a particular codebase
private  URLData ivRefData
          The reference URLData to the codebase
private  URLData ivRequestURI
          The request URI object
private static ThreadLocal local_encoder
          Thread localized encoder
private static ThreadLocal local_server
          Thread localized list for the current server configuration
private static ThreadLocal local_servers
          Thread localized list of server configurations
static String MAPPING_FILENAME
           
private  boolean noAltProtocol
          whether the Request URL protocol takes precedence
private static int STRINGBUFFER_SIZE
           
 
Constructor Summary
URLFactory()
          Construct a URL factory for the default (local) server system.
URLFactory(URL server_codebase)
          Construct a URL factory for a specified server system.
 
Method Summary
private  URLData buildServerURLData(URL aServerCodebase)
          Will create a URLData object for the server codebase which is defined by the URL.
private  URLData buildURLData(String tvKey, String tvValue, URLData aRefData)
          This will build an URLData object based on the Mapping String and it's key in coordination with a Reference Object.
private  String determineRelativeHREF(URLData aReference, String aResource)
          This method will determine the relative difference between a Reference URLData and a String resource
 String determineResource(String aRequestPath)
          This method will take a request resource path which may start with a '/' and determine from this the Windchill resource path based on the Windchill codebase being common between the URLFactory, and the requested resource path.
private  URLData findMapping(ArrayList aList, String aKey)
          Will return an URLData object that maps to a given key if the key or a partial key is found in the mapping list.
private  URLData findPartialMapping(ArrayList aList, String aKey, int anIndex)
          This method will attempt to find a partial mapping for the given key by searching up the list toward the beginning looking for the first partial match.
 String getBaseHREF()
          This method will return the fully qualified path to the Windchill Codebase.
 String getBaseHREFFromRequestURI()
          Get the HREF which represents the path from the current Request URI to the Windchill codebase.
 URL getBaseURL()
          Get base URL for the referenced Windchill system as a URL object.
 String getEncoding()
          Get the character encoding used to encode character to octets before the are hex escaped into generated URLs or HREFs.
 String getFullyQualifiedRequestURI()
          This method will get the Fully Qualified Request URI returning the Protocol://Hostname[:Port]/[PackagePath/][Resource][?QueryString] .
 String getHREF(String resource)
          Generate a HREF string to the identified resource.
 String getHREF(String resource, boolean fullyQualified)
          Generate a HREF string to the identified resource.
 String getHREF(String resource, HashMap Params)
          Generate a HREF string to the identified resource.
 String getHREF(String resource, HashMap params, boolean fullyQualified)
          Generate a HREF string to the identified resource.
 String getHREF(String resource, String query_string)
          Generate a HREF string to the identified resource.
 String getHREF(String resource, String params, boolean fullyQualified)
          Generate a HREF string to the identified resource.
 String getRequestURI()
          Get the request URI of this factory.
 URL getURL(String resource)
          Generate a URL to the identified resource.
 URL getURL(String resource, HashMap params)
          Generate a URL object to the identified resource.
 URL getURL(String resource, String query_string)
          Generate a URL to the identified resource.
private  TreeMap getURLMappings(TreeMap aMap, URL CodebaseURL, String aMappingFile)
          This method will take a Properties Mapping (the server properties) along with an optional codebase and the napping file name to retrieve the mappings from the server (or local codebase) and add the mappings to the Properties Map.
 HashMap parseFormData(InputStream in)
          Parses data from an HTML form that the client sends to the server using the HTTP POST method and the application/x-www-form-urlencoded MIME type.
 HashMap parseFormData(int len, InputStream in)
          Parses data from an HTML form that the client sends to the server using the HTTP POST method and the application/x-www-form-urlencoded MIME type.
 HashMap parseQueryString(String query_string)
          Parses a query string passed from the client to the server and builds a HashMap object with key-value pairs.
private  String[] reverseTransform(String[] aData)
          Reverse of the Above Will return the String[] input by replacing the packagepath elements of wt.server.codebase with packagepath elements from the wt.httpgw.mapCodebase
 void setEncoding(String encoding)
          Set the character encoding used to encode characters to octets before they are hex escaped into generated URLs or HREFs.
 void setRequestURI(String request_uri)
          Set the request URI of this factory.
 void setRequestURIFromURL(URL request_uri)
          Set the request URI of this factory.
 String setRequestURItoBase()
          Set the request URI for this factory to the Windchill Codebase of the URLFactory's Windchill system.
 void setRequestURL(String aScheme, String aHostname, String aRequest_URI)
          Set the request URL for this factory.
private  String transform(String aData)
          Will return the URI input by replacing the packagepath with packagepath from the wt.server.codebase
private  String[] transform(String[] aData)
          Will return the String[] input by replacing the packagepath elements of wt.httpgw.mapCodebase with packagepath elements from the wt.server.codebase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvMappings

private static Hashtable cvMappings
Static hashmap of Mapped Properties


ivEncoding

private String ivEncoding
The string encoding for the URLFactory


local_encoder

private static ThreadLocal local_encoder
Thread localized encoder


local_server

private static ThreadLocal local_server
Thread localized list for the current server configuration


local_servers

private static ThreadLocal local_servers
Thread localized list of server configurations


alt_local_server

private static ThreadLocal alt_local_server
Thread localized list for the current alt server configuration


ivList

private ArrayList ivList
The List of mappings for a particular codebase


ivBaseURL

private URL ivBaseURL
BaseURL. The URL object representing the Codebase.


ivAltBaseURL

private URL ivAltBaseURL
Alternate BaseURL. The URL object representing the Codebase.


ivRefData

private URLData ivRefData
The reference URLData to the codebase


ivAltRefData

private URLData ivAltRefData
The Alternate URLData to the codebase


ivRequestURI

private URLData ivRequestURI
The request URI object


ivbFullyQualified

private boolean ivbFullyQualified
flag for the fully qualified URL setting


ivbMapped

private boolean ivbMapped
Whether this URLFactory has mapped settings.


isMapCodebase

private boolean isMapCodebase
cache and use the vailability of alt codebase


noAltProtocol

private boolean noAltProtocol
whether the Request URL protocol takes precedence


ivEncoder

private EncodingConverter ivEncoder

MAPPING_FILENAME

public static final String MAPPING_FILENAME
See Also:
Constant Field Values

ALT_SERVER_CODEBASE_PROPERTY

public static final String ALT_SERVER_CODEBASE_PROPERTY
See Also:
Constant Field Values

STRINGBUFFER_SIZE

private static final int STRINGBUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

URLFactory

public URLFactory()
           throws WTException
Construct a URL factory for the default (local) server system. The Windchill codebase will be the codebase of the local server.



Supported API: true


URLFactory

public URLFactory(URL server_codebase)
           throws WTException
Construct a URL factory for a specified server system. The URL should point the URLFactory to the codebase of the desired Windchill system.

For example:



Supported API: true

Parameters:
server_codebase - codebase URL corresponding to the desired system.
Method Detail

buildServerURLData

private final URLData buildServerURLData(URL aServerCodebase)
Will create a URLData object for the server codebase which is defined by the URL. The URL should be of the form protocol://host:port/Document-Root/

Parameters:
aServerCodebase - an URL to the codebase to reference
Returns:
The URLData for the server codebase.

buildURLData

private final URLData buildURLData(String tvKey,
                                   String tvValue,
                                   URLData aRefData)
This will build an URLData object based on the Mapping String and it's key in coordination with a Reference Object. If the mapping does not explicitly define a parameter of an URL (for example protocol) the value will be taken from the Reference object or the key (package Path and resource).

Parameters:
tvKey - The key to map.
tvValue - The mapping value to map to the key
aRefData - The reference data object.
Returns:
The mapped URLData object.

getURLMappings

private TreeMap getURLMappings(TreeMap aMap,
                               URL CodebaseURL,
                               String aMappingFile)
                        throws IOException
This method will take a Properties Mapping (the server properties) along with an optional codebase and the napping file name to retrieve the mappings from the server (or local codebase) and add the mappings to the Properties Map. If the properties were already mapped previously by the URLFactory this method will not be called.

Parameters:
aMap - The properties map to add the properties too.
aMappingFile - The mapping file name.
Returns:
Properties The updated properties
Throws:
IOException - If there was a problem obtaining the properties

setRequestURIFromURL

public void setRequestURIFromURL(URL request_uri)
Set the request URI of this factory. Generated HREF strings for resources will be relative to this base URI.

Setting to a request URI will cause all generated HREFs to be relative to the given request URI. Setting to null will force all generated HREFs to be fully qualified.

Supported API: true

Parameters:
request_uri - request URI

setRequestURL

public void setRequestURL(String aScheme,
                          String aHostname,
                          String aRequest_URI)
Set the request URL for this factory. If the request URI includes a host and and protocol (scheme), the specified scheme and hostname passed in will overwrite the requested URI. This method therefore supports absolute URIs and relative URIs.

Supported API: true

Parameters:
aScheme - The scheme for the URL ( for example https )
aHostname - The hostname of the request. Some browsers may include the port in this string. This method will accept this form and parse the port successfully.
aRequest_URI - The request uri for the request. This may be relative or absolute.

setRequestURItoBase

public String setRequestURItoBase()
Set the request URI for this factory to the Windchill Codebase of the URLFactory's Windchill system. The base HREF will be returned to the Windchill codebase.

Supported API: true

Returns:
String The HREF to the windchill codebase.

setRequestURI

public void setRequestURI(String request_uri)
                   throws NullPointerException
Set the request URI of this factory. Generated HREF strings for resources will be relative to this base URI.

Setting to a request URI will cause all generated HREFs to be relative to the given request URI. Setting to null will force all generated HREFs to be fully qualified. The specified request URI may be fully qualified or relative to the current request URI. The rules follow those which are defined in the HTTP Specification for valid HREF formats. If there is no current request URI, relative URIs will be interpreted relative to the Windhcill codebase URL.

Notes: If a relative request_uri is passed in as an argument to this method with the form ../[../]newpath/[resource][?query_string] the ../ much be a valid pathing relative to the current Request URI. For example, if the current Request URI is equal to /Windchill/wt/httpgw and this method is called with ../../../../directory this would be invalid and the Request URI will not be changed. A NullPointerException will be thrown by the method which can be used in the client to trap this exception.

Supported API: true

Parameters:
request_uri - request URI in string form to allow relative URI syntax
Throws:
NullPointerException - Optional exception used to catch invalid relative Request URI paths, or if a relative Request URI is desired and the current Request URI is null.

getRequestURI

public String getRequestURI()
Get the request URI of this factory. This method will not return any resource or query strings associated with the request URI. For a fully qualified requestURI, use getFullyQualifiedRequestURI( )

Supported API: true

Returns:
request URI string (null if not set)
See Also:
getFullyQualifiedRequestURI()

getFullyQualifiedRequestURI

public String getFullyQualifiedRequestURI()
This method will get the Fully Qualified Request URI returning the Protocol://Hostname[:Port]/[PackagePath/][Resource][?QueryString] . If the Request URI is null, null will be returned.

Supported API: true

Returns:
The fully qualified Request URI (null if not set)
See Also:
getRequestURI()

setEncoding

public void setEncoding(String encoding)
Set the character encoding used to encode characters to octets before they are hex escaped into generated URLs or HREFs. The default encoding is UTF8 as recommended in RFC 2718. Setting to null restores the default encoding.

Supported API: true

Parameters:
encoding - character encoding name

getEncoding

public String getEncoding()
Get the character encoding used to encode character to octets before the are hex escaped into generated URLs or HREFs.

Supported API: true

Returns:
character encoding name

getBaseURL

public final URL getBaseURL()
Get base URL for the referenced Windchill system as a URL object. This normally corresponds to the Windchill application virtual directory root, but the value returned should only be assumed to refer to the application's static document root. URL mappings may apply to any dynamic resources, including JSPs, so the factory should be used to contruct references to all resources.

Supported API: true

Returns:
base URL

getBaseHREF

public final String getBaseHREF()
This method will return the fully qualified path to the Windchill Codebase. If this is the String that is desired for the <BASE> tag, it may be used, however getFullyQualifiedRequestURI() should be used where possible to set the base tag relative to the current Request URI and not the Windchill codebase.

Supported API: true

@return The fully qualified base to the Windchill codebase.


getBaseHREFFromRequestURI

public final String getBaseHREFFromRequestURI()
Get the HREF which represents the path from the current Request URI to the Windchill codebase. If the current RequestURI is null, the fully qualified HREF to the Windchill codebase will be returned.

Note: This value should NOT be used to set HTML <BASE> tags. Use getFullyQualifiedRequestURI() to get a fully qualified base tag for the current Request URI.



Supported API: true

Returns:
base HREF to the Windchill Codebase

@see getFullyQualifiedRequestURI()


getURL

public final URL getURL(String resource)
Generate a URL to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will not be ignored, and will return the URL using the current URLFactory hostname, protocol and port. Generate a URL to the identified resource.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

Parameters:
resource - The resource path
Returns:
resource URL

determineResource

public String determineResource(String aRequestPath)
This method will take a request resource path which may start with a '/' and determine from this the Windchill resource path based on the Windchill codebase being common between the URLFactory, and the requested resource path. This is useful, if there is a need to use request.getRequestURI( ) which will return an absolute resource path, but there is a need to utilize the mapping file on the system.

Supported API: true

Parameters:
aRequestPath - The request URI to resolve. If it does not start with a '/' the the String will be returned.
Returns:
The transformed String containing either the original string (if a fully qualified string was passed in, or the path to the resource within the current codebase. If the path can not be resolved to the current Windchill system, the string passed in is returned.

getHREF

public String getHREF(String resource,
                      boolean fullyQualified)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.


Path elements containing non-ASCII characters are encoded into bytes and then URL encoded. If request URI is set, this may return a relative HREF.

This method will return a fully qualified HREF. This should only is cases where a fully qualified HREF is required. For example, opening a new window using javascript.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param path resource path

Parameters:
fullyQualified - whether the HREF is to be fully qualified (independent of URLFactory configuration)
Returns:
resource HREF string

getHREF

public String getHREF(String resource)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.
Path elements containing non-ASCII characters are encoded into bytes and then URL encoded. If request URI is set, this may return a relative HREF.

NOTE: This method is not thread safe. Do not share factory instances between threads.

Supported API: true

@param path resource path

Returns:
resource HREF string

determineRelativeHREF

private final String determineRelativeHREF(URLData aReference,
                                           String aResource)
This method will determine the relative difference between a Reference URLData and a String resource

Parameters:
aReference - The reference URLData object.
aResource - The resource to look for.
Returns:
The relative HREF path.

getURL

public URL getURL(String resource,
                  String query_string)
Generate a URL to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the URL using the current URLFactory hostname, protocol and port. Path elements and query strings containing non-ASCII characters are encoded into bytes and then URL encoded.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param resource The resource path

Parameters:
query_string - The query string to add to the URL
Returns:
resource URL

getHREF

public String getHREF(String resource,
                      String params,
                      boolean fullyQualified)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.


Path elements and request parameters containing non-ASCII characters that are already encoded. If request URI is set, this may return a relative HREF.

This method will return a fully qualified HREF if the flag is true. This should only is cases where a fully qualified HREF is required. For example, opening a new window using javascript.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param path resource path

Parameters:
params - The list of Parameters already encoded
fullyQualified - whether the HREF is to be fully qualified (independent of URLFactory configuration)
Returns:
resource HREF string

getHREF

public String getHREF(String resource,
                      String query_string)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.


Path elements and request parameters containing non-ASCII characters that are already encoded. If request URI is set, this may return a relative HREF.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param path resource path

Parameters:
query_string - The list of Parameters already encoded
Returns:
resource HREF string

getURL

public URL getURL(String resource,
                  HashMap params)
Generate a URL object to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the URL using the current URLFactory hostname, protocol and port.


Path elements and request parameters containing non-ASCII characters that are encoded within this method before returning.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param resource resource path

Parameters:
params - The hashmap on un-encoded parameters.
Returns:
URL to the resource

getHREF

public String getHREF(String resource,
                      HashMap params,
                      boolean fullyQualified)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.


Path elements and request parameters containing non-ASCII characters are encoded into bytes and then URL encoded. Parameter values should be strings or arrays of strings for multi-valued parameters. If request URI is set, this may return a relative HREF.

This method will return a fully qualified HREF if the flag is true. This should only is cases where a fully qualified HREF is required. For example, opening a new window using javascript.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param path resource path

Parameters:
params - The Hashmap of Parameters
fullyQualified - whether the HREF is to be fully qualified (independent of URLFactory configuration)
Returns:
resource HREF string

getHREF

public String getHREF(String resource,
                      HashMap Params)
Generate a HREF string to the identified resource. The resource path is a full path starting at the application root directory. The path is relative to the Windchill application root. A leading '/' will be ignored, and will return the string if HREFs are not fully qualified, or the fully qualified HREF using the current URLFactory hostname, protocol and port.


Path elements and request parameters containing non-ASCII characters are encoded into bytes and then URL encoded. Parameter values should be strings or arrays of strings for multi-valued parameters. If request URI is set, this may return a relative HREF.

NOTE: If usage of request.getRequestURI( ) is required, make sure to pass the request through determineResource(request.getRequestURI()); first, so that the resource path relative to the Windchill System can be determined. Failure to do so will not allow proper usage of the mapping file.

Thread Safe: true (Do not share factory instances between threads)

Supported API: true

@param path resource path

Parameters:
Params - The hashmap of parameters.

parseQueryString

public HashMap parseQueryString(String query_string)
Parses a query string passed from the client to the server and builds a HashMap object with key-value pairs. The query string should be in the form of a string packaged by the GET or POST method, that is, it should have key-value pairs in the form key=value, with each pair separated from the next by a & character. This is the format produced by the getURL and getHREF methods.

A key can appear more than once in the query string with different values. However, the key appears only once in the hashtable, with its value being an array of strings containing the multiple values sent by the query string.

The keys and values in the hashtable are stored in their decoded form, so an + characters are converted to spaces and any hex escaped octets are converted to bytes before the octet sequence is decoded into characters using the factory's current character encoding.

NOTE: This method is not thread safe. Do not share factory instances between threads.

Supported API: true

Parameters:
query_string - string containing encoded query string
Returns:
a HashTable object built from the parsed key-value pairs. If query_string is null, an empty HashMap will be returned.

parseFormData

public HashMap parseFormData(int len,
                             InputStream in)
Parses data from an HTML form that the client sends to the server using the HTTP POST method and the application/x-www-form-urlencoded MIME type.

The data sent by the POST method contains key-value pairs. A key can appear more than once in the POST data with different values. However, the key appears only once in the hashmap, with its value being an array of strings containing the multiple values sent by the POST method.

The keys and values in the hashmap are stored in their decoded form, so an + characters are converted to spaces and any hex escaped octets are converted to bytes before the octet sequence is decoded into characters using the factory's current character encoding.

NOTE: This method is not thread safe. Do not share factory instances between threads.

Supported API: false

Parameters:
len - length of the input stream (-1 causes read to EOF or newline)
in - input stream to read
Returns:
A HashMap of form data parameters or an empty HashMap if the InputStream of the stream length was empty.

parseFormData

public HashMap parseFormData(InputStream in)
Parses data from an HTML form that the client sends to the server using the HTTP POST method and the application/x-www-form-urlencoded MIME type.

The data sent by the POST method contains key-value pairs. A key can appear more than once in the POST data with different values. However, the key appears only once in the hashmap, with its value being an array of strings containing the multiple values sent by the POST method.

The keys and values in the hashmap are stored in their decoded form, so an + characters are converted to spaces and any hex escaped octets are converted to bytes before the octet sequence is decoded into characters using the factory's current character encoding.

NOTE: This method is not thread safe. Do not share factory instances between threads.

Supported API: false

Parameters:
in - input stream to read
Returns:
A HashMap of form data parameters or an empty HashMap if the InputStream of the stream length was empty.

findPartialMapping

private URLData findPartialMapping(ArrayList aList,
                                   String aKey,
                                   int anIndex)
This method will attempt to find a partial mapping for the given key by searching up the list toward the beginning looking for the first partial match. If found, the URLData object will be returned, in which the partial mapping has been applied to the original key and a complete URLData object, representing the combination of the mapping and key will be returned.

NOTE: As the search is backing off, any element that is a resource, ie. it ends without a '/' will be ignored, as an absolute mapping does not constitute a subset of the desired mapping.

Parameters:
aList - The list of mappings
aKey - The key to search for
anIndex - The starting index.
Returns:
The matching mapping if found. null if not.

findMapping

private URLData findMapping(ArrayList aList,
                            String aKey)
Will return an URLData object that maps to a given key if the key or a partial key is found in the mapping list. A binary search will attempt to locate the key in the list. If the key is not found, a partial search backoff algorithm is used to locate any possible partial keys in the listing. If no match is found, null will be returned

Parameters:
aList - The list of mapped items.
aKey - The key representing the item to search for
Returns:
URLData The structure for the matched item. null if not found

transform

private String transform(String aData)
Will return the URI input by replacing the packagepath with packagepath from the wt.server.codebase

Parameters:
aData - The input URI.
Returns:
String The transformed String

transform

private String[] transform(String[] aData)
Will return the String[] input by replacing the packagepath elements of wt.httpgw.mapCodebase with packagepath elements from the wt.server.codebase

Parameters:
aData - The input String[].
Returns:
String[] The transformed String[]

reverseTransform

private String[] reverseTransform(String[] aData)
Reverse of the Above Will return the String[] input by replacing the packagepath elements of wt.server.codebase with packagepath elements from the wt.httpgw.mapCodebase

Parameters:
aData - The input String[].
Returns:
String[] The transformed String[]