org.xiruss.xirussrepository.server.jetty.apiserver
Class XirussHttpApiHandler

java.lang.Object
  extended by org.mortbay.http.handler.AbstractHttpHandler
      extended by org.xiruss.xirussrepository.server.jetty.XirussHttpHandlerBase
          extended by org.xiruss.xirussrepository.server.jetty.apiserver.XirussHttpApiHandler
All Implemented Interfaces:
java.io.Serializable, org.mortbay.http.HttpHandler, org.mortbay.util.LifeCycle

public class XirussHttpApiHandler
extends XirussHttpHandlerBase

Handles HTTP requests for repository resources. This handler returns results in a form usable by client programs, i.e., the XirussHttpClientHelper. All results are returned as XML documents.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xiruss.xirussrepository.server.jetty.XirussHttpHandlerBase
_acceptRanges, _dirAllowed, baseResHandler, logger, rep
 
Constructor Summary
XirussHttpApiHandler(XirussRepository rep)
           
 
Method Summary
 org.mortbay.util.Resource getResource(XirussRepository rep, org.mortbay.http.HttpRequest request)
          get Resource to serve.
 void handle(java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response)
           
protected  void handleCreateBranch(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, java.util.Vector pathTokens)
          Creates a new branch in the repository.
protected  void handleCreateMutableSnapshot(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, java.util.Vector pathTokens)
          Creates a new mutable snapshot on the branch addressed by the URL.
protected  void handleCreateResource(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, java.util.Vector pathTokens)
           
protected  void handleCreateUser(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, java.util.Vector pathTokens)
           
protected  void handleCreateVersion(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, java.util.Vector pathTokens)
           
 void handleGet(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, java.lang.String pathInContext, java.lang.String pathParams, org.mortbay.util.Resource resource)
           
 void handlePost(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, java.lang.String pathInContext, org.mortbay.util.Resource resource)
           
 void handlePut(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, java.lang.String pathInContext, org.mortbay.util.Resource resource)
          Handles PUT requests to create new versions of existing resources.
 void sendDirectory(org.mortbay.http.HttpRequest request, org.mortbay.http.HttpResponse response, org.mortbay.util.Resource resource, boolean parent)
           
 
Methods inherited from class org.xiruss.xirussrepository.server.jetty.XirussHttpHandlerBase
sendData, setAllowHeader, tokenizePath, writeHeaders
 
Methods inherited from class org.mortbay.http.handler.AbstractHttpHandler
getHttpContext, getName, handleTrace, initialize, isStarted, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XirussHttpApiHandler

public XirussHttpApiHandler(XirussRepository rep)
Method Detail

handle

public void handle(java.lang.String pathInContext,
                   java.lang.String pathParams,
                   org.mortbay.http.HttpRequest request,
                   org.mortbay.http.HttpResponse response)
            throws org.mortbay.http.HttpException,
                   java.io.IOException
Throws:
org.mortbay.http.HttpException
java.io.IOException

handlePut

public void handlePut(org.mortbay.http.HttpRequest request,
                      org.mortbay.http.HttpResponse response,
                      java.lang.String pathInContext,
                      org.mortbay.util.Resource resource)
               throws java.io.IOException
Handles PUT requests to create new versions of existing resources. Note that all other objects are created by POST requests because they don't contain data directly nor do they have a notion of being versioned. By contrast, versions can contain data (and most version types exist in order to contain data) and therefore the semantic of "posting to a resource" is the best match for creating a new version of a resource. This also reflects the distinction made in the HTTP spec between POST being handled by one object that then changes the data state of the server, possibly by creating new objects, while PUT is applied directly to a resource in order to change that resource's state (i.e., to set its content). Thus, while "posting to a resource" results in a new version object, conceptually the (SnapCM) resource is the union of its versions so, semantically, creating a new version of a resource is identical to creating a new version of a file where the new file has the same URL as the old file.

Parameters:
request - The HTTP request. The following request parameters have special semantics. All other parameters are taken as property/value pairs to be set on the created version. - userid The objId of the user who is creating the version. If not specified, a new user object is created (reflecting the fact that Xirrus-T, as a toy, has no security features). If specified and the user does not exist, the create wil be failed.
response - The HTTP response. For success responses, the response message will be the object ID of the created version.
pathInContext - URL path to the resource for which a new version is to be created.
resource -
Throws:
java.io.IOException

handlePost

public void handlePost(org.mortbay.http.HttpRequest request,
                       org.mortbay.http.HttpResponse response,
                       java.lang.String pathInContext,
                       org.mortbay.util.Resource resource)
                throws java.io.IOException
Throws:
java.io.IOException

handleCreateUser

protected void handleCreateUser(org.mortbay.http.HttpRequest request,
                                org.mortbay.http.HttpResponse response,
                                org.mortbay.util.Resource resource,
                                java.util.Vector pathTokens)
                         throws java.io.IOException
Throws:
java.io.IOException

handleCreateResource

protected void handleCreateResource(org.mortbay.http.HttpRequest request,
                                    org.mortbay.http.HttpResponse response,
                                    org.mortbay.util.Resource resource,
                                    java.util.Vector pathTokens)
                             throws java.io.IOException
Throws:
java.io.IOException

handleCreateVersion

protected void handleCreateVersion(org.mortbay.http.HttpRequest request,
                                   org.mortbay.http.HttpResponse response,
                                   org.mortbay.util.Resource resource,
                                   java.util.Vector pathTokens)
                            throws java.io.IOException
Throws:
java.io.IOException

handleCreateMutableSnapshot

protected void handleCreateMutableSnapshot(org.mortbay.http.HttpRequest request,
                                           org.mortbay.http.HttpResponse response,
                                           org.mortbay.util.Resource resource,
                                           java.util.Vector pathTokens)
                                    throws java.io.IOException
Creates a new mutable snapshot on the branch addressed by the URL. Optional name parameter specifies the name for snapshot. Snapshot names need not be unique within a branch.

Parameters:
request -
response -
resource -
pathTokens -
Throws:
java.io.IOException

handleCreateBranch

protected void handleCreateBranch(org.mortbay.http.HttpRequest request,
                                  org.mortbay.http.HttpResponse response,
                                  org.mortbay.util.Resource resource,
                                  java.util.Vector pathTokens)
                           throws java.io.IOException
Creates a new branch in the repository.

Parameters:
request -
response -
resource -
pathTokens -
Throws:
java.io.IOException

handleGet

public void handleGet(org.mortbay.http.HttpRequest request,
                      org.mortbay.http.HttpResponse response,
                      java.lang.String pathInContext,
                      java.lang.String pathParams,
                      org.mortbay.util.Resource resource)
               throws java.io.IOException
Throws:
java.io.IOException

sendDirectory

public void sendDirectory(org.mortbay.http.HttpRequest request,
                          org.mortbay.http.HttpResponse response,
                          org.mortbay.util.Resource resource,
                          boolean parent)
                   throws java.io.IOException
Throws:
java.io.IOException

getResource

public org.mortbay.util.Resource getResource(XirussRepository rep,
                                             org.mortbay.http.HttpRequest request)
                                      throws java.io.IOException
get Resource to serve. Map a path to a resource.

Parameters:
pathInContext - The path to find a resource for.
Returns:
The resource to serve.
Throws:
java.io.IOException