|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.tools.resources.AttributeHolder org.w3c.tools.resources.Resource org.w3c.tools.resources.FramedResource org.w3c.tools.resources.ResourceFrame org.w3c.tools.resources.ProtocolFrame org.w3c.jigsaw.frames.HTTPFrame
public class HTTPFrame
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.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 |
---|
public static final java.lang.String STATE_CONTENT_LOCATION
public static final int COND_FAILED
public static final int COND_OK
public static final int COND_WEAK
protected HttpTokenList allowed
protected static int ATTR_QUALITY
protected static int ATTR_TITLE
protected static int ATTR_CONTENT_LANGUAGE
protected static int ATTR_CONTENT_ENCODING
protected static int ATTR_CONTENT_TYPE
protected static int ATTR_CHARSET
protected static int ATTR_CONTENT_LENGTH
protected static int ATTR_ICON
protected static int ATTR_MAXAGE
protected static int ATTR_MD5
protected static int ATTR_ALLOW_DEL
protected static int ATTR_PUTABLE
protected static int ATTR_RELOCATE
protected static int ATTR_INDEX
protected static int ATTR_INDEXES
protected static int ATTR_ICONDIR
protected static int ATTR_BROWSABLE
protected static int ATTR_STYLE_LINK
protected DirectoryResource dresource
protected FileResource fresource
protected boolean acceptRanges
protected HtmlGenerator listing
protected long listing_stamp
protected static MimeType browsetype
Constructor Detail |
---|
public HTTPFrame()
Method Detail |
---|
public void registerResource(FramedResource resource)
registerResource
in class ResourceFrame
resource
- The resource associated with this frame.public FileResource getFileResource()
public DirectoryResource getDirectoryResource()
public void registerOtherResource(FramedResource resource)
public void registerResource(FramedResource resource) { super.registerOtherResource(resource); }
the
- resource to register.public java.lang.String getHelpURL()
getHelpURL
in class Resource
public java.lang.String getHelpURL(java.lang.String topic)
getHelpURL
in class Resource
topic
- The topic (can be an attribute name, or a property, etc).
public void attributeChanged(AttributeChangedEvent evt)
attributeChanged
in interface AttributeChangedListener
attributeChanged
in class ResourceFrame
evt
- The AttributeChangeEvent describing the change.public void setValue(int idx, java.lang.Object value)
setValue
in class ResourceFrame
idx
- The index of the attribute to be set.value
- The new value for the attribute.public java.net.URL getURL(Request request)
public double getQuality()
public double unsafeGetQuality()
public java.lang.String getTitle()
public java.lang.String getContentLanguage()
public java.lang.String getContentEncoding()
public java.lang.String getCharset()
public MimeType getContentType()
public java.lang.String computeETag()
public HttpEntityTag getETag()
public int getContentLength()
public java.lang.String getIcon()
public long getMaxAge()
The max age attribute is a long number giving the number of milliseconds of allowed drift.
public boolean getPutableFlag()
public boolean getMD5Flag()
public boolean getAllowDeleteFlag()
protected HttpTokenList getAllow()
public Reply handleRangeRequest(Request request, HttpRange r) throws ProtocolException
request,
- the requestr,
- the HttpRange
ProtocolException
- If processsing the request failed.public boolean getBrowsableFlag()
public java.lang.String getStyleSheetURL()
public java.lang.String getIconDirectory()
public boolean getRelocateFlag()
public java.lang.String getIndex()
public java.lang.String[] getIndexes()
getIndex()
public void addStyleSheet(HtmlGenerator g)
g
- The HtmlGenerator.public boolean computeContainerListing(boolean refresh)
refresh
- should we refresh the listing?
public Reply getDirectoryListing(Request request) throws ProtocolException, ResourceException
Using a modem, I know that each place I can reply with an NOT_MODIFIED, is a big win.
request
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected void updateCachedHeaders()
public Reply createDefaultReply(Request request, int status)
request
- The request to make a reply for.
public int checkIfMatch(Request request)
If-Match
condition of that request.
request
- The request to check.
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).
public int checkIfNoneMatch(Request request)
If-None-Match
condition of that request.
request
- The request to check.
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).
public int checkIfModifiedSince(Request request)
If-Modified-Since
condition of that request.
request
- The request to check.
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).
public int checkIfUnmodifiedSince(Request request)
If-Unmodified-Since
condition of that request.
request
- The request to check.
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).
public boolean checkExpect(Request request)
Expect
condition of that request
request
- The request to check.
true
if the requirement is knownpublic int checkValidators(Request request)
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).
public boolean lookup(LookupState ls, LookupResult lr) throws ProtocolException
lookup
in class ResourceFrame
ls
- The current lookup statelr
- The result
ProtocolException
- If an error relative to the protocol occursResourceFrame.lookupFilters(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult)
,
lookupResource(org.w3c.tools.resources.LookupState, org.w3c.tools.resources.LookupResult)
protected boolean lookupResource(LookupState ls, LookupResult lr) throws ProtocolException
ls
- The current lookup statelr
- The result
ProtocolException
- If an error relative to the protocol occurslookupDirectory(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)
protected boolean lookupDirectory(LookupState ls, LookupResult lr) throws ProtocolException
ls
- The current lookup statelr
- The result
ProtocolException
- If an error relative to the protocol
occursprotected boolean lookupFile(LookupState ls, LookupResult lr) throws ProtocolException
ls
- The current lookup statelr
- The result
ProtocolException
- If an error relative to the protocol occursprotected boolean lookupOther(LookupState ls, LookupResult lr) throws ProtocolException
ls
- The current lookup statelr
- The result
ProtocolException
- If an error relative to the protocol occurspublic boolean checkRequest(RequestInterface request)
checkRequest
in class ResourceFrame
request
- the incomming request.
protected ReplyInterface performFrames(RequestInterface request) throws ProtocolException, ResourceException
performFrames
in class FramedResource
request
- A RequestInterface instance.
ProtocolException
- If an error relative to the protocol occurs
ResourceException
- If an error not relative to the
protocol occurspublic ReplyInterface perform(RequestInterface req) throws ProtocolException, ResourceException
perform
in class ResourceFrame
req
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.public Reply get(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply getOtherResource(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply createFileReply(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply deleteMe(Request request) throws HTTPException
HTTPException
protected Reply getFileResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply getDirectoryResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- if request processing failed.
ResourceException
- If the resource got a fatal error.public Reply head(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- Always thrown, to return a NOT_IMPLEMENTED
error.
ResourceException
- If the resource got a fatal error.protected Reply headOtherResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply headDirectoryResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply headFileResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.public Reply post(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- Always thrown, to return a NOT_IMPLEMENTED
error.
ResourceException
- If the resource got a fatal error.public Reply put(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected Reply putOtherResource(Request request) throws ProtocolException
request
- The incmming request.
ProtocolException
- (Always thrown).protected Reply putFileResource(Request request) throws ProtocolException, ResourceException
request
- The incomming request.
ProtocolException
- if a protocol
error occurs
ResourceException
- If the resource got a fatal error.public Reply options(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- In case of errors.
ResourceException
- If the resource got a fatal error.public Reply delete(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- If processsing the request failed.
ResourceException
- If the resource got a fatal error.protected java.io.File computeTrashFile(java.io.File file)
protected java.io.File computeTrashDir(java.io.File dir)
protected Reply deleteDirectoryResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- if request processing failed.
ResourceException
- If the resource got a fatal error.protected Reply deleteFileResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- if request processing failed.
ResourceException
- If the resource got a fatal error.protected Reply deleteOtherResource(Request request) throws ProtocolException, ResourceException
request
- the incomming request.
ProtocolException
- if request processing failed.
ResourceException
- If the resource got a fatal error.public Reply link(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- Always thrown, to return a NOT_IMPLEMENTED
error.
ResourceException
- If the resource got a fatal error.public Reply unlink(Request request) throws ProtocolException, ResourceException
request
- The request to handle.
ProtocolException
- Always thrown, to return a NOT_IMPLEMENTED
error.
ResourceException
- If the resource got a fatal error.public Reply trace(Request request) throws HTTPException, ClientException
request
- The request to handle.
HTTPException
- In case of errors.
ClientException
- If the client instance controling the
request processing got a fatal error.public Reply extended(Request request) throws ProtocolException, ResourceException
ProtocolException
ResourceException
protected MimeType getBrowseType()
public Reply browse(Request request) throws ProtocolException
BROWSE
method that
AOL press (or GNN press, or whatever its last name is) expects.
request
- The request to process.
ProtocolException
- If some error occurs.public void pickleValues(java.util.Hashtable defs)
pickleValues
in class Resource
defs
- The Hashtable containing the values.public void initialize(java.util.Hashtable defs)
initialize
in class Resource
defs
- The Hashtable containing the default values.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |