com.cafesoft.cams.access.url
Class UrlResourceRequest

java.lang.Object
  |
  +--com.cafesoft.cams.access.AbstractResourceRequest
        |
        +--com.cafesoft.cams.access.url.UrlResourceRequest
All Implemented Interfaces:
ResourceRequest

public class UrlResourceRequest
extends AbstractResourceRequest

UrlResourceRequest represents a request for resource identified by a Uniform Resource Locator (URL).

An UrlResourceRequest is uniquely identified by:

  1. it's type, which is specified by a String token
  2. it's resource identifier (a fully-qualified URL)
  3. the action being requested on the Resource (e.g. "GET", "POST", etc).

URLs have the general form:

 scheme://host[:port]/uri
 
but actions are generally specific to the scheme. For example, if the scheme is "http" or "https", then actions: GET, PUT, POST, DELETE, etc. are appropriate. If the scheme is "ftp" or "ftps", the actions: READ, WRITE, MKDIR, etc. are appropriate.

This class is configurable for use with many different type resources available via URL.

Since:
7/22/03

Field Summary
 
Fields inherited from class com.cafesoft.cams.access.AbstractResourceRequest
actions, actionsMask, id, type
 
Constructor Summary
UrlResourceRequest(Map schemeMap, ResourceType type, String id, String actions)
          Create a new UrlResourceRequest object.
 
Method Summary
 String getHost()
          Get the URL Resource host.
 int getPort()
          Get the URI Resource port.
 String getScheme()
          Get the URL Resource scheme.
 String getUri()
          Get the Uniform Resource Indicator.
protected  void parseActions(String actions)
          Parse the actions.
protected  void parseId(String id)
          Parse the id.
 
Methods inherited from class com.cafesoft.cams.access.AbstractResourceRequest
getActions, getActionsMask, getId, getResourceType, setActions, setId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UrlResourceRequest

public UrlResourceRequest(Map schemeMap,
                          ResourceType type,
                          String id,
                          String actions)
                   throws InvalidResourceException
Create a new UrlResourceRequest object.

Parameters:
schemeMap - a Map containing all defaultPorts for all supported Url schemes.
type - the ResourceType of the ResourceRequest.
id - the colloquial id of the ResourceRequest.
actions - the colloquial actions of the ResourceRequest.
Throws:
InvalidResourceException - if any errors occur while creating the AbstractResourceRequest.
Method Detail

getScheme

public String getScheme()
Get the URL Resource scheme.

Returns:
the scheme (e.g. "http", "https", "ftp", etc).

getHost

public String getHost()
Get the URL Resource host.

Returns:
the host

getPort

public int getPort()
Get the URI Resource port.

Returns:
the port

getUri

public String getUri()
Get the Uniform Resource Indicator.

Returns:
the URI

parseId

protected void parseId(String id)
                throws InvalidResourceException
Parse the id.

This method parses a URL of the following general form:

scheme://host:port/uri

where the scheme might include: "http" or "https" and the port may or may not be specified. The result of parsing will always be a "Fully Qualified Resource Identifier" (FQRI), in which all components of the URL are represented. For example, if the identifier passed to this method is:

http://www.myhost.com/secure/index.html

the resulting FQRI will be:

http://www.myhost.com:80/secure/index.html

The default ports for particular schemes are defined by the schemeMap that is passed into the constructor via the Factory. This schemeMap contains all supported schemes and their default ports. For example if the scheme is https the default port maybe 8443. If a valid port cannot be determined for a particular id a InvalidResourceException is thrown.

Because Resource identifiers are case-sensitive and part of a URL is not, the following component of a URL rsesource identifier is converted to lower case:

scheme://host

The Uniform Resource Identifier portion may be case-sensitive depending on the Web Server, so it's case is preserved. For example, for:

HTTPS://WWW.MYHOST.COM/secure/index.html

the resulting FQRI will be:

https://www.myhost.com:443/secure/index.html

Overrides:
parseId in class AbstractResourceRequest
Parameters:
id - the id to parse.
Throws:
InvalidResourceException - if the id is invalid.

parseActions

protected void parseActions(String actions)
                     throws InvalidResourceException
Parse the actions.

This method expects actions to be separated by either a comma, space, or tab character. For each parsed action it's actionMask is added to the the ResourceRequest's action mask.

Overrides:
parseActions in class AbstractResourceRequest
Parameters:
actions - the actions to parse.
Throws:
InvalidResourceException - if the actions is invalid.


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.