com.noelios.restlet.local
Class DirectoryResource

java.lang.Object
  extended by org.restlet.Handler
      extended by org.restlet.resource.Resource
          extended by com.noelios.restlet.local.DirectoryResource

public class DirectoryResource
extends Resource

Resource supported by a set of context representations (from file system, class loaders and webapp context). A content negotiation mechanism (similar to Apache HTTP server) is available. It is based on path extensions to detect variants (languages, media types or character sets).

Author:
Jerome Louvel, Thierry Boileau
See Also:
Apache mod_negotiation module

Constructor Summary
DirectoryResource(Directory directory, Request request, Response response)
          This constructor aims at answering the following questions:
does this request target a directory? does this request target a directory, with an index file? should this request be redirected (target is a directory with no trailing "/")? does this request target a file?
The following constraints must be taken into account:
the underlying helper may not support content negotiation and be able to return the list of possible variants of the target file (e.g.
 
Method Summary
 java.lang.String getBaseName()
          Returns the local base name of the file.
 Directory getDirectory()
          Returns the parent directory handler.
 java.lang.String getDirectoryUri()
          Returns the context's directory URI (file, clap URI).
static java.util.Set<java.lang.String> getExtensions(java.lang.String entryName)
          Returns the set of extensions contained in a given directory entry name.
 java.lang.String getTargetUri()
          Returns the context's target URI (file, clap URI).
 java.util.List<Variant> getVariants()
          Returns the representation variants.
 void handleGet()
           
 boolean isDirectoryTarget()
          Indicates if the target resource is a directory.
 boolean isFileTarget()
          Indicates if the target resource is a file.
 void removeRepresentations()
           
 void setTargetUri(java.lang.String targetUri)
          Sets the context's target URI (file, clap URI).
 void storeRepresentation(Representation entity)
           
 
Methods inherited from class org.restlet.resource.Resource
acceptRepresentation, allowDelete, allowGet, allowPost, allowPut, delete, getPreferredRepresentation, getPreferredVariant, getRepresentation, handleDelete, handlePost, handlePut, init, isAvailable, isModifiable, isNegotiateContent, isReadable, post, put, represent, represent, setAvailable, setModifiable, setNegotiateContent, setReadable, setVariants
 
Methods inherited from class org.restlet.Handler
allowHead, allowOptions, generateRef, getAllowedMethods, getApplication, getContext, getLogger, getMatrix, getQuery, getRequest, getResponse, handleHead, handleOptions, setContext, setRequest, setResponse, updateAllowedMethods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryResource

public DirectoryResource(Directory directory,
                         Request request,
                         Response response)
                  throws java.io.IOException
This constructor aims at answering the following questions:

The following constraints must be taken into account:

Parameters:
directory - The parent directory handler.
request - The handled call.
Throws:
java.io.IOException
Method Detail

getExtensions

public static java.util.Set<java.lang.String> getExtensions(java.lang.String entryName)
Returns the set of extensions contained in a given directory entry name.

Parameters:
entryName - The directory entry name.
Returns:
The set of extensions.

getBaseName

public java.lang.String getBaseName()
Returns the local base name of the file. For example, "foo.en" and "foo.en-GB.html" return "foo".

Returns:
The local name of the file.

getDirectory

public Directory getDirectory()
Returns the parent directory handler.

Returns:
The parent directory handler.

getDirectoryUri

public java.lang.String getDirectoryUri()
Returns the context's directory URI (file, clap URI).

Returns:
The context's directory URI (file, clap URI).

getTargetUri

public java.lang.String getTargetUri()
Returns the context's target URI (file, clap URI).

Returns:
The context's target URI (file, clap URI).

getVariants

public java.util.List<Variant> getVariants()
Returns the representation variants.

Overrides:
getVariants in class Resource
Returns:
The representation variants.

handleGet

public void handleGet()
Overrides:
handleGet in class Resource

isDirectoryTarget

public boolean isDirectoryTarget()
Indicates if the target resource is a directory.

Returns:
True if the target resource is a directory.

isFileTarget

public boolean isFileTarget()
Indicates if the target resource is a file.

Returns:
True if the target resource is a file.

removeRepresentations

public void removeRepresentations()
                           throws ResourceException
Overrides:
removeRepresentations in class Resource
Throws:
ResourceException

setTargetUri

public void setTargetUri(java.lang.String targetUri)
Sets the context's target URI (file, clap URI).

Parameters:
targetUri - The context's target URI.

storeRepresentation

public void storeRepresentation(Representation entity)
                         throws ResourceException
Overrides:
storeRepresentation in class Resource
Throws:
ResourceException


Copyright © 2005-2008 Noelios Technologies.