org.restlet.engine.local
Class DirectoryServerResource

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.UniformResource
          extended by org.restlet.resource.ServerResource
              extended by org.restlet.engine.local.DirectoryServerResource

public class DirectoryServerResource
extends ServerResource

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
DirectoryServerResource()
           
 
Method Summary
 Representation delete()
           
 void doInit()
          This initialization method 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.
protected  Representation get()
           
 String getBaseName()
          Returns the local base name of the file.
protected  Restlet getClientDispatcher()
          Returns a client dispatcher.
 Directory getDirectory()
          Returns the parent directory handler.
protected  ReferenceList getDirectoryContent()
          If the resource is a directory, this returns its content.
 String getDirectoryUri()
          Returns the context's directory URI (file, clap URI).
protected  Response getRepresentation(String resourceUri, MediaType acceptedMediaType)
          Returns a representation of the resource at the target URI.
 String getTargetUri()
          Returns the context's target URI (file, clap URI).
 List<Variant> getVariants()
           
protected  List<Variant> getVariants(Method method)
          Returns the list of variants for the given method.
 Representation handle()
           
 boolean isDirectoryTarget()
          Indicates if the target resource is a directory.
 boolean isFileTarget()
          Indicates if the target resource is a file.
 Representation put(Representation entity)
           
 void setTargetUri(String targetUri)
          Sets the context's target URI (file, clap URI).
 
Methods inherited from class org.restlet.resource.ServerResource
abort, commit, delete, describeVariants, doCatch, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, getAttribute, getInfo, getInfo, getOnSent, getPreferredVariant, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, options, post, post, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDimensions, setExisting, setLocationRef, setLocationRef, setNegotiated, setOnSent, setProxyChallengeRequests, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.Resource
doError, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponse, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, setRequest, setResponse, toObject, toRepresentation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryServerResource

public DirectoryServerResource()
Method Detail

delete

public Representation delete()
                      throws ResourceException
Overrides:
delete in class ServerResource
Throws:
ResourceException

doInit

public void doInit()
            throws ResourceException
This initialization method aims at answering the following questions:

The following constraints must be taken into account:

Overrides:
doInit in class Resource
Throws:
ResourceException

get

protected Representation get()
                      throws ResourceException
Overrides:
get in class ServerResource
Throws:
ResourceException

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.

getClientDispatcher

protected Restlet getClientDispatcher()
Returns a client dispatcher.

Returns:
A client dispatcher.

getDirectory

public Directory getDirectory()
Returns the parent directory handler.

Returns:
The parent directory handler.

getDirectoryContent

protected ReferenceList getDirectoryContent()
If the resource is a directory, this returns its content.

Returns:
The directory content.

getDirectoryUri

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

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

getRepresentation

protected Response getRepresentation(String resourceUri,
                                     MediaType acceptedMediaType)
Returns a representation of the resource at the target URI. Leverages the client dispatcher of the parent directory's context.

Parameters:
resourceUri - The URI of the target resource.
acceptedMediaType - The accepted media type or null.
Returns:
A response with the representation if success.

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()
Overrides:
getVariants in class ServerResource

getVariants

protected List<Variant> getVariants(Method method)
Returns the list of variants for the given method.

Overrides:
getVariants in class ServerResource
Parameters:
method - The related method.
Returns:
The list of variants for the given method.

handle

public Representation handle()
Overrides:
handle in class ServerResource

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.

put

public Representation put(Representation entity)
                   throws ResourceException
Overrides:
put in class ServerResource
Throws:
ResourceException

setTargetUri

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

Parameters:
targetUri - The context's target URI.


Copyright © 2005-2013 Restlet.