    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class w3c.jigsaw.resources.FileResource

    java.lang.Object
       |
       +----w3c.jigsaw.resources.AttributeHolder
               |
               +----w3c.jigsaw.resources.Resource
                       |
                       +----w3c.jigsaw.resources.HTTPResource
                               |
                               +----w3c.jigsaw.resources.FilteredResource
                                       |
                                       +----w3c.jigsaw.resources.FileResource

public class FileResource
extends FilteredResource

##

ATTR_FILENAME
  Attributes index - The filename attribute.
ATTR_FILESTAMP
  Attribute index - The date at which we last checked the file content.
ATTR_PUTABLE
  Attribute index - Do we allow PUT method on this file.
file
  The file we refer to.

##

FileResource()

##

checkContent()
  Check this file content, and update attributes if needed.
checkIfMatch(Request)
  Check the `If-Match` condition of that request.
checkIfModifiedSince(Request)
  Check the `If-Modified-Since` condition of that request.
checkIfNoneMatch(Request)
  Check the `If-None-Match` condition of that request.
checkIfUnmodifiedSince(Request)
  Check the `If-Unmodified-Since` condition of that request.
createDefaultReply(Request, int)
  Create a reply to answer to request on this file.
get(Request)
  The GET method on files.
getBackupFile()
  Get the name of the backup file for this resource.
getFile()
  Get this file resource file name.
getFilename()
  Get this resource filename attribute.
getFileStamp()
  Get the date at which we last examined the file.
getPutableFlag()
  Get the PUT'able flag (are we allow to PUT to the resource ?)
head(Request)
  The HEAD method on files, and their sub-classes.
initialize(Object[])
  Initialize the FileResource instance.
newContent(InputStream)
  Save the given stream as the underlying file content.
put(Request)
  Put a new entity in this resource.
setValue(int, Object)
  Set some of this resource attribute.
updateAttributes()
  Update our computed attributes.
updateCachedHeaders()
  Uupdate the cached headers for this resource.
updateFileAttributes()
  Update the file related attributes.

##

ATTR_FILENAME

      protected static int ATTR_FILENAME

  Attributes index - The filename attribute.

ATTR_PUTABLE

      protected static int ATTR_PUTABLE

  Attribute index - Do we allow PUT method on this file.

ATTR_FILESTAMP

      protected static int ATTR_FILESTAMP

  Attribute index - The date at which we last checked the file content.

file

      protected File file

  The file we refer to. This is a cached version of some attributes, so we need to override the setValue method in order to be able to catch any changes to it.

##

FileResource

      public FileResource()

##

getFilename

      public String getFilename()

  Get this resource filename attribute.

getPutableFlag

      public boolean getPutableFlag()

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

getFileStamp

      public long getFileStamp()

  Get the date at which we last examined the file.

getBackupFile

      public File getBackupFile()

  Get the name of the backup file for this resource.
  Returns:
    A File object suitable to receive the backup version of this file.

newContent

      protected synchronized boolean newContent(InputStream in) throws IOException

  Save the given stream as the underlying file content. This method preserve the old file version in a `~` file.
  Parameters:
    in - The input stream to use as the resource entity.
  Returns:
    A boolean, true if the resource was just created, false otherwise.
  Throws: IOException
    If dumping the content failed.

checkContent

      protected long checkContent()

  Check this file content, and update attributes if needed. This method is normally called before any perform request is done, so that we make sure that all meta-informations is up to date before handling a request.
  Returns:
    The time of the last update to the resource.

updateCachedHeaders

      protected void updateCachedHeaders()

  Uupdate the cached headers for this resource.
  Overrides:
    updateCachedHeaders in class HTTPResource

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.
  Overrides:
    createDefaultReply in class HTTPResource

setValue

      public synchronized void setValue(int idx,
                                        Object value)

  Set some of this resource attribute. We just catch here any write access to the filename's, to update our cache file object.
  Overrides:
    setValue in class HTTPResource

getFile

      public synchronized File getFile()

  Get this file resource file name.

checkIfMatch

      public int checkIfMatch(Request request)

  Check the `If-Match` condition of that request.
  Overrides:
    checkIfMatch in class HTTPResource

checkIfNoneMatch

      public int checkIfNoneMatch(Request request)

  Check the `If-None-Match` condition of that request.
  Overrides:
    checkIfNoneMatch in class HTTPResource

checkIfModifiedSince

      public int checkIfModifiedSince(Request request)

  Check the `If-Modified-Since` condition of that request.
  Overrides:
    checkIfModifiedSince in class HTTPResource

checkIfUnmodifiedSince

      public int checkIfUnmodifiedSince(Request request)

  Check the `If-Unmodified-Since` condition of that request.
  Overrides:
    checkIfUnmodifiedSince in class HTTPResource

head

      public Reply head(Request request)

  The HEAD method on files, and their sub-classes.
  Returns:
    A Reply instance.
  Overrides:
    head in class HTTPResource

get

      public Reply get(Request request) throws HTTPException

  The GET method on files. Check for the last modified time against the IMS if any. If OK, emit a not modified reply, otherwise, emit the whole file.
  Parameters:
    request - The request to handle.
  Throws: HTTPException
    If some error occured.
  Overrides:
    get in class HTTPResource

put

      public synchronized Reply put(Request request) throws HTTPException, ClientException

  Put a new entity in this resource.
  Parameters:
    request - The request to handle.
  Overrides:
    put in class HTTPResource

updateFileAttributes

      public void updateFileAttributes()

  Update the file related attributes. The file we serve has changed since the last time we checked it, if any of the attribute values depend on the file content, this is the appropriate place to recompute them.

updateAttributes

      public void updateAttributes()

  Update our computed attributes.
  Overrides:
    updateAttributes in class Resource

initialize

      public void initialize(Object values[])

  Initialize the FileResource instance.
  Overrides:
    initialize in class AttributeHolder

    All Packages  Class Hierarchy  This Package  Previous  Next  Index