org.w3c.jigsaw.frames
Class HTTPFrame

java.lang.Object
  extended by org.w3c.tools.resources.AttributeHolder
      extended by org.w3c.tools.resources.Resource
          extended by org.w3c.tools.resources.FramedResource
              extended by org.w3c.tools.resources.ResourceFrame
                  extended by org.w3c.tools.resources.ProtocolFrame
                      extended by org.w3c.jigsaw.frames.HTTPFrame
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, AttributeChangedListener, FrameEventListener
Direct Known Subclasses:
AsIsFrame, BrokerFrame, CgiFrame, CheckpointFrame, CvsFileFrame, DirectoryListerFrame, FancyFrame, ForwardFrame, GcStatFrame, HTTPExtFrame, JpegComFrame, JpegXMPFrame, LatestChildRedirectFrame, NegotiatedFrame, PageCompileFrame, PostableFrame, RedirecterFrame, RelocateFrame, ServletDirectoryFrame, ServletMapperFrame, ServletWrapperFrame, SSIFrame, StatisticsFrame, ThreadStatFrame, VirtualHostFrame, ZipFrame

public class HTTPFrame
extends ProtocolFrame

Default class to handle the HTTP protocol, manage FileResource and DirectoryResource.


Field Summary
protected  boolean acceptRanges
          Does this resource support byte ranges.
protected  HttpTokenList allowed
          Methods allowed by instances of that class in particular:
protected static int ATTR_ALLOW_DEL
          Attribute index - delete allowed for the associated resource ?
protected static int ATTR_BROWSABLE
          Attribute index - Allow the GNN browse method.
protected static int ATTR_CHARSET
          Attribute index - The index for the charset attribute.
protected static int ATTR_CONTENT_ENCODING
          Attribute index - The index for the content encodings attribute.
protected static int ATTR_CONTENT_LANGUAGE
          Attribute index - The index for the content languages attribute.
protected static int ATTR_CONTENT_LENGTH
          Attribute index - The index for the content length attribute.
protected static int ATTR_CONTENT_TYPE
          Attribute index - The index for the content type attribute.
protected static int ATTR_ICON
          Attribute index - The icon (if any) associated to the resource.
protected static int ATTR_ICONDIR
          Attribute index - The icon directory to use in dir listing.
protected static int ATTR_INDEX
          Attribute index - our index resource name.
protected static int ATTR_INDEXES
          Attribute index - our indexes resource name.
protected static int ATTR_MAXAGE
          Attribute index - Max age: the maximum drift allowed from reality.
protected static int ATTR_MD5
          Attribute index - Send MD5 Digest: the md5 digest of the resource sent
protected static int ATTR_PUTABLE
          Attribute index - Do we allow PUT method on this file.
protected static int ATTR_QUALITY
          Attributes index - The index for the quality attribute.
protected static int ATTR_RELOCATE
          Attribute index - The index for our relocate attribute.
protected static int ATTR_STYLE_LINK
          Attribute index - Style sheet for directory listing
protected static int ATTR_TITLE
          Attribute index - The index for the title attribute.
protected static MimeType browsetype
          The Browse Mime type.
static int COND_FAILED
          Condition check return code - Condition existed but failed.
static int COND_OK
          Condition check return code - Condition existed and succeeded.
static int COND_WEAK
          Condition check return code - Condition existed and succeeded but is a weak validation.
protected  DirectoryResource dresource
          The associated DirectoryResource (if any)
protected  FileResource fresource
          The associated FileResource (if any)
protected  HtmlGenerator listing
          Our current (cached) directory listing.
protected  long listing_stamp
          The time at which we generated the directory index.
static java.lang.String STATE_CONTENT_LOCATION
           
 
Fields inherited from class org.w3c.tools.resources.ResourceFrame
filterClass, frameListener, resource
 
Fields inherited from class org.w3c.tools.resources.FramedResource
ATTR_OID, attrListener, debugEvent, event_disabled, framesRef, structListener
 
Fields inherited from class org.w3c.tools.resources.Resource
ATTR_CONTEXT, ATTR_HELP_URL, ATTR_IDENTIFIER, ATTR_LAST_MODIFIED, ATTR_PARENT, ATTR_RESOURCE_FRAMES, ATTR_STORE_ENTRY, ATTR_URL, co, id
 
Fields inherited from class org.w3c.tools.resources.AttributeHolder
attributes, values
 
Constructor Summary
HTTPFrame()
           
 
Method Summary
 void addStyleSheet(HtmlGenerator g)
          Add our own Style Sheet to the HtmlGenerator.
 void attributeChanged(AttributeChangedEvent evt)
          Listen its resource.
 Reply browse(Request request)
          A present to GNNPress users ! This method implements the BROWSE method that AOL press (or GNN press, or whatever its last name is) expects.
 boolean checkExpect(Request request)
          Check the Expect condition of that request
 int checkIfMatch(Request request)
          Check the If-Match condition of that request.
 int checkIfModifiedSince(Request request)
          Check the If-Modified-Since condition of that request.
 int checkIfNoneMatch(Request request)
          Check the If-None-Match condition of that request.
 int checkIfUnmodifiedSince(Request request)
          Check the If-Unmodified-Since condition of that request.
 boolean checkRequest(RequestInterface request)
          Check the request.
 int checkValidators(Request request)
          check the validators namely LMT/Etags according to rfc2616 rules
 boolean computeContainerListing(boolean refresh)
          Get ContainerResource listing
 java.lang.String computeETag()
          Compute the ETag string
protected  java.io.File computeTrashDir(java.io.File dir)
           
protected  java.io.File computeTrashFile(java.io.File file)
           
 Reply createDefaultReply(Request request, int status)
          Create a reply to answer to request on this file.
protected  Reply createFileReply(Request request)
          Create the reply relative to the given file.
 Reply delete(Request request)
          The default DELETE method, actually the resource (file, directory) is moved into the trash directory which is not accessible via HTTP.
protected  Reply deleteDirectoryResource(Request request)
          Perform a DELETE for the associated DirectoryResource.
protected  Reply deleteFileResource(Request request)
          Perform a DELETE for the associated FileResource.
protected  Reply deleteMe(Request request)
          Alway throws an HTTPException
protected  Reply deleteOtherResource(Request request)
          Perform a DELETE for the associated resource.
 Reply extended(Request request)
           
 Reply get(Request request)
          The default GET method.
protected  HttpTokenList getAllow()
          get the Allowed methods for this resource
 boolean getAllowDeleteFlag()
          delete allowed for the associated resource ?
 boolean getBrowsableFlag()
          Get this class browsable flag.
protected  MimeType getBrowseType()
          Get the Browse Mime type.
 java.lang.String getCharset()
          Get this resource charset.
 java.lang.String getContentEncoding()
          Get this resource content encoding.
 java.lang.String getContentLanguage()
          Get this resource content language.
 int getContentLength()
          Get this resource content length.
 MimeType getContentType()
          Get this resource content type.
 Reply getDirectoryListing(Request request)
          Reply with an HTML doc listing the resources of this container.
 DirectoryResource getDirectoryResource()
          Get the associated DirectoryResource (if any)
protected  Reply getDirectoryResource(Request request)
          Perform a GET for the associated DirectoryResource.
 HttpEntityTag getETag()
          Get this resource Etag
 FileResource getFileResource()
          Get the associated FileResource (if any)
protected  Reply getFileResource(Request request)
          Get for FileResource
 java.lang.String getHelpURL()
          Get this resource's help url.
 java.lang.String getHelpURL(java.lang.String topic)
          Get the help URL for that resource's attribute.
 java.lang.String getIcon()
          Get this resource's icon.
 java.lang.String getIconDirectory()
          Get the optional icon directory.
 java.lang.String getIndex()
          Get the optional main index name for this directory listing.
 java.lang.String[] getIndexes()
          Get the optional index name array for this directory listing.
 long getMaxAge()
          Get this resource's max age.
 boolean getMD5Flag()
          Do we send the MD5 digest?
protected  Reply getOtherResource(Request request)
          The default GET method for other king of associated resource
 boolean getPutableFlag()
          Get the PUT'able flag (are we allow to PUT to the resource ?)
 double getQuality()
          Get this resource quality.
 boolean getRelocateFlag()
          Should we relocate invalid requests to this directory.
 java.lang.String getStyleSheetURL()
          Get this frame style sheet link
 java.lang.String getTitle()
          Get this resource title.
 java.net.URL getURL(Request request)
          Get the full URL for that resource.
 Reply handleRangeRequest(Request request, HttpRange r)
          handles a Range Request
 Reply head(Request request)
          The default HEAD method replies does a GET and removes entity.
protected  Reply headDirectoryResource(Request request)
          Perform a HEAD request for the associated DirectoryResource.
protected  Reply headFileResource(Request request)
          Perform a HEAD request for the associated FileResource.
protected  Reply headOtherResource(Request request)
          Perform a HEAD request for the associated resource.
 void initialize(java.util.Hashtable defs)
          Initialization method for attribute holders.
 Reply link(Request request)
          The default LINK method replies with a not implemented.
 boolean lookup(LookupState ls, LookupResult lr)
          Lookup the target resource.
protected  boolean lookupDirectory(LookupState ls, LookupResult lr)
          Lookup the target resource when associated with a DirectoryResource.
protected  boolean lookupFile(LookupState ls, LookupResult lr)
          Lookup the target resource when associated with a FileResource.
protected  boolean lookupOther(LookupState ls, LookupResult lr)
          Lookup the target resource when associated with an unknown resource.
protected  boolean lookupResource(LookupState ls, LookupResult lr)
          Lookup the target resource (dispath to more specific lookup methods).
 Reply options(Request request)
          The default OPTIONS method replies with a not implemented.
 ReplyInterface perform(RequestInterface req)
          Perform the request
protected  ReplyInterface performFrames(RequestInterface request)
          Perform the request on all the frames of that resource.
 void pickleValues(java.util.Hashtable defs)
          Set the values.
 Reply post(Request request)
          The default POST method replies with a not implemented.
 Reply put(Request request)
          The default PUT method.
protected  Reply putFileResource(Request request)
          Change the content of the associated FileResource.
protected  Reply putOtherResource(Request request)
          Always throw a ProtocolException.
 void registerOtherResource(FramedResource resource)
          use this one instead of registerResource if the resource type doesn't matter or if this is not a file or a directory resource.
 void registerResource(FramedResource resource)
          Register this frame to the given resource.
 void setValue(int idx, java.lang.Object value)
          Catch setValue, to maintain cached header values correctness.
 Reply trace(Request request)
          The default TRACE method replies with a not implemented
 Reply unlink(Request request)
          The default UNLINK method replies with a not implemented.
 double unsafeGetQuality()
          Get this resource quality.
protected  void updateCachedHeaders()
          Update the cached headers value.
 
Methods inherited from class org.w3c.tools.resources.ResourceFrame
addFrameEventListener, eventDisabled, fireFrameEvent, frameModified, getFilters, getFilters, getFrameReference, getResource, getResourceReference, getSpaceEntry, getURLPath, lookupFilters, lookupFrames, postFrameEvent, processEvent, removeFrameEventListener, unregisterResource, updateDefaultChildAttributes
 
Methods inherited from class org.w3c.tools.resources.FramedResource
addAttributeChangedListener, addStructureChangedListener, collectFramesReference, delete, disableEvent, displayEvent, enableEvent, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameRemoved, getClone, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, initialize, markModified, notifyUnload, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setSilentValue, setSilentValue, unregisterFrame
 
Methods inherited from class org.w3c.tools.resources.Resource
acceptUnload, checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getIdentifier, getLastModified, getParent, getServer, getSpace, getStoreEntry, getValue, getValue, isInitialized, isUnloaded, setContext, setContext, setValue, unsafeGetContext, unsafeGetFrame, unsafeGetFrames, unsafeGetIdentifier, unsafeGetResourceReference, unsafeGetURLPath, unsafeGetValue, updateAttributes
 
Methods inherited from class org.w3c.tools.resources.AttributeHolder
definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, lookupAttribute, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unsafeDefinesAttribute, unsafeGetDouble, unsafeGetString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_CONTENT_LOCATION

public static final java.lang.String STATE_CONTENT_LOCATION
See Also:
Constant Field Values

COND_FAILED

public static final int COND_FAILED
Condition check return code - Condition existed but failed.

See Also:
Constant Field Values

COND_OK

public static final int COND_OK
Condition check return code - Condition existed and succeeded.

See Also:
Constant Field Values

COND_WEAK

public static final int COND_WEAK
Condition check return code - Condition existed and succeeded but is a weak validation.

See Also:
Constant Field Values

allowed

protected HttpTokenList allowed
Methods allowed by instances of that class in particular:


ATTR_QUALITY

protected static int ATTR_QUALITY
Attributes index - The index for the quality attribute.


ATTR_TITLE

protected static int ATTR_TITLE
Attribute index - The index for the title attribute.


ATTR_CONTENT_LANGUAGE

protected static int ATTR_CONTENT_LANGUAGE
Attribute index - The index for the content languages attribute.


ATTR_CONTENT_ENCODING

protected static int ATTR_CONTENT_ENCODING
Attribute index - The index for the content encodings attribute.


ATTR_CONTENT_TYPE

protected static int ATTR_CONTENT_TYPE
Attribute index - The index for the content type attribute.


ATTR_CHARSET

protected static int ATTR_CHARSET
Attribute index - The index for the charset attribute.


ATTR_CONTENT_LENGTH

protected static int ATTR_CONTENT_LENGTH
Attribute index - The index for the content length attribute.


ATTR_ICON

protected static int ATTR_ICON
Attribute index - The icon (if any) associated to the resource.


ATTR_MAXAGE

protected static int ATTR_MAXAGE
Attribute index - Max age: the maximum drift allowed from reality.


ATTR_MD5

protected static int ATTR_MD5
Attribute index - Send MD5 Digest: the md5 digest of the resource sent


ATTR_ALLOW_DEL

protected static int ATTR_ALLOW_DEL
Attribute index - delete allowed for the associated resource ?


ATTR_PUTABLE

protected static int ATTR_PUTABLE
Attribute index - Do we allow PUT method on this file.


ATTR_RELOCATE

protected static int ATTR_RELOCATE
Attribute index - The index for our relocate attribute.


ATTR_INDEX

protected static int ATTR_INDEX
Attribute index - our index resource name.


ATTR_INDEXES

protected static int ATTR_INDEXES
Attribute index - our indexes resource name.


ATTR_ICONDIR

protected static int ATTR_ICONDIR
Attribute index - The icon directory to use in dir listing.


ATTR_BROWSABLE

protected static int ATTR_BROWSABLE
Attribute index - Allow the GNN browse method.


ATTR_STYLE_LINK

protected static int ATTR_STYLE_LINK
Attribute index - Style sheet for directory listing


dresource

protected DirectoryResource dresource
The associated DirectoryResource (if any)


fresource

protected FileResource fresource
The associated FileResource (if any)


acceptRanges

protected boolean acceptRanges
Does this resource support byte ranges.


listing

protected HtmlGenerator listing
Our current (cached) directory listing.


listing_stamp

protected long listing_stamp
The time at which we generated the directory index.


browsetype

protected static MimeType browsetype
The Browse Mime type.

Constructor Detail

HTTPFrame

public HTTPFrame()
Method Detail

registerResource

public void registerResource(FramedResource resource)
Register this frame to the given resource.

Overrides:
registerResource in class ResourceFrame
Parameters:
resource - The resource associated with this frame.

getFileResource

public FileResource getFileResource()
Get the associated FileResource (if any)

Returns:
a FileResource instance or null if no FileResource is associated with this frame.

getDirectoryResource

public DirectoryResource getDirectoryResource()
Get the associated DirectoryResource (if any)

Returns:
a DirectoryResource instance or null if no DirectoryResource is associated with this frame.

registerOtherResource

public void registerOtherResource(FramedResource resource)
use this one instead of registerResource if the resource type doesn't matter or if this is not a file or a directory resource. In subclasses you should have to do that:
  public void registerResource(FramedResource resource) {
   super.registerOtherResource(resource);
  }
 

Parameters:
the - resource to register.

getHelpURL

public java.lang.String getHelpURL()
Get this resource's help url.

Overrides:
getHelpURL in class Resource
Returns:
An URL, encoded as a String, or null if not available.

getHelpURL

public java.lang.String getHelpURL(java.lang.String topic)
Get the help URL for that resource's attribute.

Overrides:
getHelpURL in class Resource
Parameters:
topic - The topic (can be an attribute name, or a property, etc).
Returns:
A String encoded URL, or null.

attributeChanged

public void attributeChanged(AttributeChangedEvent evt)
Listen its resource.

Specified by:
attributeChanged in interface AttributeChangedListener
Overrides:
attributeChanged in class ResourceFrame
Parameters:
evt - The AttributeChangeEvent describing the change.

setValue

public void setValue(int idx,
                     java.lang.Object value)
Catch setValue, to maintain cached header values correctness.

Overrides:
setValue in class ResourceFrame
Parameters:
idx - The index of the attribute to be set.
value - The new value for the attribute.

getURL

public java.net.URL getURL(Request request)
Get the full URL for that resource.

Returns:
An URL instance.

getQuality

public double getQuality()
Get this resource quality.

Returns:
The resource quality, or some negative value if not defined.

unsafeGetQuality

public double unsafeGetQuality()
Get this resource quality.

Returns:
The resource quality, or some negative value if not defined.

getTitle

public java.lang.String getTitle()
Get this resource title.

Returns:
This resource's title, or null if not defined.

getContentLanguage

public java.lang.String getContentLanguage()
Get this resource content language. Language are stored as a comma separated String of tokens.

Returns:
A comma separated string of language tokens, or null if undefined.

getContentEncoding

public java.lang.String getContentEncoding()
Get this resource content encoding. The content encoding of a resource is stored as a comma separated list of tokens (as decribed in the Content_encoding header of the HTTP specification, and in the order they should appear in the header).

Returns:
A string of comma separated encoding tokens, or null if not defined.

getCharset

public java.lang.String getCharset()
Get this resource charset.

Returns:
A String, or null if not defined.

getContentType

public MimeType getContentType()
Get this resource content type.

Returns:
An instance of MIMEType, or null if not defined.

computeETag

public java.lang.String computeETag()
Compute the ETag string

Returns:
a string or null if not applicable

getETag

public HttpEntityTag getETag()
Get this resource Etag

Returns:
an instance of HttpEntityTag, or null if not defined.

getContentLength

public int getContentLength()
Get this resource content length.

Returns:
The resource content length, or -1 if not defined.

getIcon

public java.lang.String getIcon()
Get this resource's icon.


getMaxAge

public long getMaxAge()
Get this resource's max age. The max age of a resource indicates how much drift is allowed between the physicall version of the resource, and any in-memory cached version of it.

The max age attribute is a long number giving the number of milliseconds of allowed drift.


getPutableFlag

public boolean getPutableFlag()
Get the PUT'able flag (are we allow to PUT to the resource ?)


getMD5Flag

public boolean getMD5Flag()
Do we send the MD5 digest?


getAllowDeleteFlag

public boolean getAllowDeleteFlag()
delete allowed for the associated resource ?


getAllow

protected HttpTokenList getAllow()
get the Allowed methods for this resource

Returns:
an HttpTokenList

handleRangeRequest

public Reply handleRangeRequest(Request request,
                                HttpRange r)
                         throws ProtocolException
handles a Range Request

Parameters:
request, - the request
r, - the HttpRange
Returns:
a Reply if range is valid, or null if there is a change in the resource, or if the HttpRange is not valid ( 4-2, for example).
Throws:
ProtocolException - If processsing the request failed.

getBrowsableFlag

public boolean getBrowsableFlag()
Get this class browsable flag.


getStyleSheetURL

public java.lang.String getStyleSheetURL()
Get this frame style sheet link


getIconDirectory

public java.lang.String getIconDirectory()
Get the optional icon directory.


getRelocateFlag

public boolean getRelocateFlag()
Should we relocate invalid requests to this directory.

Returns:
A boolean true if we should relocate.

getIndex

public java.lang.String getIndex()
Get the optional main index name for this directory listing.

Returns:
The name of the resource responsible to list that container.

getIndexes

public java.lang.String[] getIndexes()
Get the optional index name array for this directory listing.

Returns:
The index name array (including the main index)
See Also:
getIndex()

addStyleSheet

public void addStyleSheet(HtmlGenerator g)
Add our own Style Sheet to the HtmlGenerator.

Parameters:
g - The HtmlGenerator.

computeContainerListing

public boolean computeContainerListing(boolean refresh)
Get ContainerResource listing

Parameters:
refresh - should we refresh the listing?
Returns:
a boolean (true if refreshed)

getDirectoryListing

public Reply getDirectoryListing(Request request)
                          throws ProtocolException,
                                 ResourceException
Reply with an HTML doc listing the resources of this container. This function takes special care not to regenerate a listing when one is available. It also caches the date of the listing, so that it can win big with NOT_MODIFIED.

Using a modem, I know that each place I can reply with an NOT_MODIFIED, is a big win.

Parameters:
request - The request to handle.
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

updateCachedHeaders

protected void updateCachedHeaders()
Update the cached headers value. Each resource maintains a set of cached values for headers, this allows for a nice sped-up in headers marshalling, which - as the complexity of the protocol increases - becomes a bottleneck.


createDefaultReply

public Reply createDefaultReply(Request request,
                                int status)
Create a reply to answer to request on this file. This method will create a suitable reply (matching the given request) and will set all its default header values to the appropriate values.

Parameters:
request - The request to make a reply for.
Returns:
An instance of Reply, suited to answer this request.

checkIfMatch

public int checkIfMatch(Request request)
Check the If-Match condition of that request.

Parameters:
request - The request to check.
Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).

checkIfNoneMatch

public int checkIfNoneMatch(Request request)
Check the If-None-Match condition of that request.

Parameters:
request - The request to check.
Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).

checkIfModifiedSince

public int checkIfModifiedSince(Request request)
Check the If-Modified-Since condition of that request.

Parameters:
request - The request to check.
Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).

checkIfUnmodifiedSince

public int checkIfUnmodifiedSince(Request request)
Check the If-Unmodified-Since condition of that request.

Parameters:
request - The request to check.
Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).

checkExpect

public boolean checkExpect(Request request)
Check the Expect condition of that request

Parameters:
request - The request to check.
Returns:
A boolean true if the requirement is known

checkValidators

public int checkValidators(Request request)
check the validators namely LMT/Etags according to rfc2616 rules

Returns:
An integer, either COND_FAILED if condition was checked, but failed, COND_OK if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).

lookup

public boolean lookup(LookupState ls,
                      LookupResult lr)
               throws ProtocolException
Lookup the target resource. Lookup filters and then resource.

Overrides:
lookup in class ResourceFrame
Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws:
ProtocolException - If an error relative to the protocol occurs
See Also:
ResourceFrame.lookupFilters(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult), lookupResource(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult)

lookupResource

protected boolean lookupResource(LookupState ls,
                                 LookupResult lr)
                          throws ProtocolException
Lookup the target resource (dispath to more specific lookup methods).

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws:
ProtocolException - If an error relative to the protocol occurs
See Also:
lookupDirectory(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult), lookupFile(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult), lookupOther(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult)

lookupDirectory

protected boolean lookupDirectory(LookupState ls,
                                  LookupResult lr)
                           throws ProtocolException
Lookup the target resource when associated with a DirectoryResource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws:
ProtocolException - If an error relative to the protocol occurs

lookupFile

protected boolean lookupFile(LookupState ls,
                             LookupResult lr)
                      throws ProtocolException
Lookup the target resource when associated with a FileResource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws:
ProtocolException - If an error relative to the protocol occurs

lookupOther

protected boolean lookupOther(LookupState ls,
                              LookupResult lr)
                       throws ProtocolException
Lookup the target resource when associated with an unknown resource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws:
ProtocolException - If an error relative to the protocol occurs

checkRequest

public boolean checkRequest(RequestInterface request)
Check the request.

Overrides:
checkRequest in class ResourceFrame
Parameters:
request - the incomming request.
Returns:
true if the request is an HTTP Request.

performFrames

protected ReplyInterface performFrames(RequestInterface request)
                                throws ProtocolException,
                                       ResourceException
Perform the request on all the frames of that resource. The Reply returned is the first non-null reply.

Overrides:
performFrames in class FramedResource
Parameters:
request - A RequestInterface instance.
Returns:
A ReplyInterface instance.
Throws:
ProtocolException - If an error relative to the protocol occurs
ResourceException - If an error not relative to the protocol occurs

perform

public ReplyInterface perform(RequestInterface req)
                       throws ProtocolException,
                              ResourceException
Perform the request

Overrides:
perform in class ResourceFrame
Parameters:
req - The request to handle.
Returns:
a ReplyInterface instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

get

public Reply get(Request request)
          throws ProtocolException,
                 ResourceException
The default GET method.

Parameters:
request - The request to handle.
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

getOtherResource

protected Reply getOtherResource(Request request)
                          throws ProtocolException,
                                 ResourceException
The default GET method for other king of associated resource

Parameters:
request - The request to handle.
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

createFileReply

protected Reply createFileReply(Request request)
                         throws ProtocolException,
                                ResourceException
Create the reply relative to the given file.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

deleteMe

protected Reply deleteMe(Request request)
                  throws HTTPException
Alway throws an HTTPException

Throws:
HTTPException

getFileResource

protected Reply getFileResource(Request request)
                         throws ProtocolException,
                                ResourceException
Get for FileResource

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

getDirectoryResource

protected Reply getDirectoryResource(Request request)
                              throws ProtocolException,
                                     ResourceException
Perform a GET for the associated DirectoryResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance.
Throws:
ProtocolException - if request processing failed.
ResourceException - If the resource got a fatal error.

head

public Reply head(Request request)
           throws ProtocolException,
                  ResourceException
The default HEAD method replies does a GET and removes entity.

Parameters:
request - The request to handle.
Throws:
ProtocolException - Always thrown, to return a NOT_IMPLEMENTED error.
ResourceException - If the resource got a fatal error.

headOtherResource

protected Reply headOtherResource(Request request)
                           throws ProtocolException,
                                  ResourceException
Perform a HEAD request for the associated resource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

headDirectoryResource

protected Reply headDirectoryResource(Request request)
                               throws ProtocolException,
                                      ResourceException
Perform a HEAD request for the associated DirectoryResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

headFileResource

protected Reply headFileResource(Request request)
                          throws ProtocolException,
                                 ResourceException
Perform a HEAD request for the associated FileResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

post

public Reply post(Request request)
           throws ProtocolException,
                  ResourceException
The default POST method replies with a not implemented.

Parameters:
request - The request to handle.
Throws:
ProtocolException - Always thrown, to return a NOT_IMPLEMENTED error.
ResourceException - If the resource got a fatal error.

put

public Reply put(Request request)
          throws ProtocolException,
                 ResourceException
The default PUT method.

Parameters:
request - The request to handle.
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

putOtherResource

protected Reply putOtherResource(Request request)
                          throws ProtocolException
Always throw a ProtocolException.

Parameters:
request - The incmming request.
Returns:
a Reply instance.
Throws:
ProtocolException - (Always thrown).

putFileResource

protected Reply putFileResource(Request request)
                         throws ProtocolException,
                                ResourceException
Change the content of the associated FileResource.

Parameters:
request - The incomming request.
Throws:
ProtocolException - if a protocol error occurs
ResourceException - If the resource got a fatal error.

options

public Reply options(Request request)
              throws ProtocolException,
                     ResourceException
The default OPTIONS method replies with a not implemented.

Parameters:
request - The request to handle.
Throws:
ProtocolException - In case of errors.
ResourceException - If the resource got a fatal error.

delete

public Reply delete(Request request)
             throws ProtocolException,
                    ResourceException
The default DELETE method, actually the resource (file, directory) is moved into the trash directory which is not accessible via HTTP.

Parameters:
request - The request to handle.
Throws:
ProtocolException - If processsing the request failed.
ResourceException - If the resource got a fatal error.

computeTrashFile

protected java.io.File computeTrashFile(java.io.File file)

computeTrashDir

protected java.io.File computeTrashDir(java.io.File dir)

deleteDirectoryResource

protected Reply deleteDirectoryResource(Request request)
                                 throws ProtocolException,
                                        ResourceException
Perform a DELETE for the associated DirectoryResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance.
Throws:
ProtocolException - if request processing failed.
ResourceException - If the resource got a fatal error.

deleteFileResource

protected Reply deleteFileResource(Request request)
                            throws ProtocolException,
                                   ResourceException
Perform a DELETE for the associated FileResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance.
Throws:
ProtocolException - if request processing failed.
ResourceException - If the resource got a fatal error.

deleteOtherResource

protected Reply deleteOtherResource(Request request)
                             throws ProtocolException,
                                    ResourceException
Perform a DELETE for the associated resource.

Parameters:
request - the incomming request.
Returns:
A Reply instance.
Throws:
ProtocolException - if request processing failed.
ResourceException - If the resource got a fatal error.

link

public Reply link(Request request)
           throws ProtocolException,
                  ResourceException
The default LINK method replies with a not implemented.

Parameters:
request - The request to handle.
Throws:
ProtocolException - Always thrown, to return a NOT_IMPLEMENTED error.
ResourceException - If the resource got a fatal error.

unlink

public Reply unlink(Request request)
             throws ProtocolException,
                    ResourceException
The default UNLINK method replies with a not implemented.

Parameters:
request - The request to handle.
Throws:
ProtocolException - Always thrown, to return a NOT_IMPLEMENTED error.
ResourceException - If the resource got a fatal error.

trace

public Reply trace(Request request)
            throws HTTPException,
                   ClientException
The default TRACE method replies with a not implemented

Parameters:
request - The request to handle.
Throws:
HTTPException - In case of errors.
ClientException - If the client instance controling the request processing got a fatal error.

extended

public Reply extended(Request request)
               throws ProtocolException,
                      ResourceException
Throws:
ProtocolException
ResourceException

getBrowseType

protected MimeType getBrowseType()
Get the Browse Mime type.


browse

public Reply browse(Request request)
             throws ProtocolException
A present to GNNPress users ! This method implements the BROWSE method that AOL press (or GNN press, or whatever its last name is) expects.

Parameters:
request - The request to process.
Returns:
A Reply instance.
Throws:
ProtocolException - If some error occurs.

pickleValues

public void pickleValues(java.util.Hashtable defs)
Set the values. (MUST be called before initialize).

Overrides:
pickleValues in class Resource
Parameters:
defs - The Hashtable containing the values.

initialize

public void initialize(java.util.Hashtable defs)
Initialization method for attribute holders. This method allows to initialize an attribute holder by providing its attributes values through a Hashtable mapping attribute names to attribute values.

Overrides:
initialize in class Resource
Parameters:
defs - The Hashtable containing the default values.