org.exist.http
Class RESTServer

java.lang.Object
  extended byorg.exist.http.RESTServer

public class RESTServer
extends java.lang.Object

Author:
wolf

Field Summary
protected static java.util.Properties defaultProperties
           
protected static Logger LOG
           
protected static java.lang.String NS
           
protected static java.lang.String XUPDATE_NS
           
 
Constructor Summary
RESTServer(java.lang.String formEncoding, java.lang.String containerEncoding)
           
 
Method Summary
protected  void checkPragmas(XQueryContext context, java.util.Properties properties)
          Check if the XQuery contains pragmas that define serialization settings.
 void doDelete(DBBroker broker, java.lang.String path, HttpServletResponse response)
           
 void doGet(DBBroker broker, HttpServletRequest request, HttpServletResponse response, java.lang.String path)
          Handle GET request.
 void doHead(DBBroker broker, HttpServletRequest request, HttpServletResponse response, java.lang.String path)
           
 void doPost(DBBroker broker, HttpServletRequest request, HttpServletResponse response, java.lang.String path)
          Handles POST requests.
 void doPut(DBBroker broker, java.io.File tempFile, java.lang.String docPath, HttpServletRequest request, HttpServletResponse response)
          Handles PUT requests.
protected  java.lang.String printCollection(DBBroker broker, Collection collection)
           
protected  void printPermissions(org.xml.sax.helpers.AttributesImpl attrs, Permission perm)
           
protected  java.lang.String printResults(DBBroker broker, Sequence results, int howmany, int start, long queryTime, java.util.Properties outputProperties, boolean wrap)
           
protected  java.lang.String search(DBBroker broker, java.lang.String query, java.lang.String path, int howmany, int start, java.util.Properties outputProperties, boolean wrap, HttpServletRequest request, HttpServletResponse response)
          TODO: pass request and response objects to XQuery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NS

protected static final java.lang.String NS
See Also:
Constant Field Values

XUPDATE_NS

protected static final java.lang.String XUPDATE_NS
See Also:
Constant Field Values

LOG

protected static final Logger LOG

defaultProperties

protected static final java.util.Properties defaultProperties
Constructor Detail

RESTServer

public RESTServer(java.lang.String formEncoding,
                  java.lang.String containerEncoding)
Method Detail

doGet

public void doGet(DBBroker broker,
                  HttpServletRequest request,
                  HttpServletResponse response,
                  java.lang.String path)
           throws BadRequestException,
                  PermissionDeniedException,
                  NotFoundException,
                  java.io.IOException
Handle GET request. In the simplest case just returns the document or binary resource specified in the path. If the path leads to a collection, a listing of the collection contents is returned. If it resolves to a binary resource with mime-type "application/xquery", this resource will be loaded and executed by the XQuery engine. The method also recognizes a number of predefined parameters:

doHead

public void doHead(DBBroker broker,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   java.lang.String path)
            throws BadRequestException,
                   PermissionDeniedException,
                   NotFoundException,
                   java.io.IOException
Throws:
BadRequestException
PermissionDeniedException
NotFoundException
java.io.IOException

doPost

public void doPost(DBBroker broker,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   java.lang.String path)
            throws BadRequestException,
                   PermissionDeniedException,
                   java.io.IOException
Handles POST requests. If the path leads to a binary resource with mime-type "application/xquery", that resource will be read and executed by the XQuery engine. Otherwise, the request content is loaded and parsed as XML. It may either contain an XUpdate or a query request.

Parameters:
broker -
request -
response -
path -
Returns:
Throws:
BadRequestException
PermissionDeniedException
java.io.IOException

doPut

public void doPut(DBBroker broker,
                  java.io.File tempFile,
                  java.lang.String docPath,
                  HttpServletRequest request,
                  HttpServletResponse response)
           throws BadRequestException,
                  PermissionDeniedException,
                  java.io.IOException
Handles PUT requests. The request content is stored as a new resource at the specified location. If the resource already exists, it is overwritten if the user has write permissions. The resource type depends on the content type specified in the HTTP header. The content type will be looked up in the global mime table. If the corresponding mime type is not a know XML mime type, the resource will be stored as a binary resource.

Parameters:
broker -
tempFile -
docPath -
Returns:
Throws:
BadRequestException
PermissionDeniedException
java.io.IOException

doDelete

public void doDelete(DBBroker broker,
                     java.lang.String path,
                     HttpServletResponse response)
              throws PermissionDeniedException,
                     NotFoundException,
                     java.io.IOException
Throws:
PermissionDeniedException
NotFoundException
java.io.IOException

search

protected java.lang.String search(DBBroker broker,
                                  java.lang.String query,
                                  java.lang.String path,
                                  int howmany,
                                  int start,
                                  java.util.Properties outputProperties,
                                  boolean wrap,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
                           throws BadRequestException,
                                  PermissionDeniedException,
                                  XPathException
TODO: pass request and response objects to XQuery.

Throws:
XPathException
BadRequestException
PermissionDeniedException

checkPragmas

protected void checkPragmas(XQueryContext context,
                            java.util.Properties properties)
                     throws XPathException
Check if the XQuery contains pragmas that define serialization settings. If yes, copy the corresponding settings to the current set of output properties.

Parameters:
context -
Throws:
XPathException

printCollection

protected java.lang.String printCollection(DBBroker broker,
                                           Collection collection)

printPermissions

protected void printPermissions(org.xml.sax.helpers.AttributesImpl attrs,
                                Permission perm)

printResults

protected java.lang.String printResults(DBBroker broker,
                                        Sequence results,
                                        int howmany,
                                        int start,
                                        long queryTime,
                                        java.util.Properties outputProperties,
                                        boolean wrap)
                                 throws BadRequestException
Throws:
BadRequestException


<oXygen/> XML Editor provides support for editing and debugging XQuery expressions against the eXist XML Database.