com.noelios.restlet.local
Class DirectoryResource

java.lang.Object
  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 (contact@noelios.com), Thierry Boileau
See Also:
Apache mod_negotiation module

Constructor Summary
DirectoryResource(Directory directory, Request request, Response response)
          Constructor.
 
Method Summary
 boolean allowDelete()
          Indicates if it is allowed to delete the resource.
 boolean allowPut()
          Indicates if it is allowed to put to the resource.
 void delete()
          Asks the resource to delete itself and all its representations.
 String getBaseName()
          Returns the local base name of the file.
 Directory getDirectory()
          Returns the parent directory handler.
 String getDirectoryUri()
          Returns the context's directory URI (file, clap URI).
static Set<String> getExtensions(String entryName)
          Returns the set of extensions contained in a given directory entry name.
 String getTargetUri()
          Returns the context's target URI (file, clap URI).
 List<Variant> getVariants()
          Returns the representation variants.
 void handleGet()
           
 void put(Representation variant)
          Puts a variant representation in the resource.
 void setTargetUri(String targetUri)
          Sets the context's target URI (file, clap URI).
 
Methods inherited from class org.restlet.resource.Resource
allowGet, allowPost, generateRef, getContext, getLogger, getPreferredRepresentation, getPreferredVariant, getRepresentation, getRequest, getResponse, handleDelete, handleHead, handleOptions, handlePost, handlePut, init, isNegotiateContent, post, setContext, setNegotiateContent, setRequest, setResponse
 
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 IOException
Constructor.

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

getExtensions

public static Set<String> getExtensions(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.

allowDelete

public boolean allowDelete()
Indicates if it is allowed to delete the resource. The default value is false.

Overrides:
allowDelete in class Resource
Returns:
True if the method is allowed.

allowPut

public boolean allowPut()
Indicates if it is allowed to put to the resource. The default value is false.

Overrides:
allowPut in class Resource
Returns:
True if the method is allowed.

handleGet

public void handleGet()
Overrides:
handleGet in class Resource

delete

public void delete()
Asks the resource to delete itself and all its representations.

Overrides:
delete in class Resource

put

public void put(Representation variant)
Puts a variant representation in the resource.

Overrides:
put in class Resource
Parameters:
variant - A new or updated variant representation.

getBaseName

public 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 String getDirectoryUri()
Returns the context's directory URI (file, clap URI).

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

getTargetUri

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

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

getVariants

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

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

setTargetUri

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

Parameters:
targetUri - The context's target URI.


Copyright © 2005-2007 Noelios Consulting.