Esri Geoportal Server
1.0

com.esri.gpt.control.georss
Class RestQueryServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.esri.gpt.framework.context.BaseServlet
              extended by com.esri.gpt.control.georss.RestQueryServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
DistributedSearchServlet

public class RestQueryServlet
extends BaseServlet

Servlet end-point for rest based catalog query requests.

See Also:
Serialized Form

Nested Class Summary
protected static class RestQueryServlet.ResponseFormat
          Enumeration of response formats.
 
Constructor Summary
RestQueryServlet()
          Default constructor.
 
Method Summary
protected  void execute(HttpServletRequest request, HttpServletResponse response, RequestContext context)
          Processes the HTTP request.
protected  SearchResultRecords executeQuery(HttpServletRequest request, RequestContext context, MessageBroker messageBroker, RestQuery query)
          Executes the query.
protected  SearchResult executeQuery1(HttpServletRequest request, RequestContext context, MessageBroker messageBroker, RestQuery query)
          Execute Query that returns a SearchResult object (SearchResult as opposed to the SearchResultRecord which executeQuery does).
protected  String getRequestParameter(HttpServletRequest request, String parameterKey)
          Gets the HTTP request parameter value associated with a key.
protected  RestQueryServlet.ResponseFormat getResponseFormat(HttpServletRequest request, RestQuery query)
          Determines the response format.
 void init(ServletConfig config)
          Initializes the servlet.
protected  FeedWriter makeFeedWriter(HttpServletRequest request, RequestContext context, PrintWriter printWriter, MessageBroker messageBroker, RestQuery query)
          Makes a writer capable of generating an appropriate response based upon the requested response format.
protected  RestQuery parseRequest(HttpServletRequest request, RequestContext context)
          Parses the request and generates a populated query suitable for execution.
protected  void setResponseContentType(HttpServletRequest request, HttpServletResponse response, RestQuery query)
          Sets the HTTP content type for the response.
protected  SearchCriteria toSearchCriteria(HttpServletRequest request, RequestContext context, RestQuery query)
          Generates a search critera object from the request.
 
Methods inherited from class com.esri.gpt.framework.context.BaseServlet
authenticate, doGet, doPost, getCredentials, getLogger, getParameterValue, getRealm, readInputCharacters, writeCharacterResponse, writeHtmlResponse, writeXmlResponse
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestQueryServlet

public RestQueryServlet()
Default constructor.

Method Detail

execute

protected void execute(HttpServletRequest request,
                       HttpServletResponse response,
                       RequestContext context)
                throws Exception
Processes the HTTP request.

Specified by:
execute in class BaseServlet
Parameters:
request - the HTTP request.
response - HTTP response.
context - request context
Throws:
Exception - if an exception occurs

executeQuery1

protected SearchResult executeQuery1(HttpServletRequest request,
                                     RequestContext context,
                                     MessageBroker messageBroker,
                                     RestQuery query)
                              throws SearchException
Execute Query that returns a SearchResult object (SearchResult as opposed to the SearchResultRecord which executeQuery does).

Parameters:
request - the request
context - the context
messageBroker - the message broker
query - the query
Returns:
the search result
Throws:
SearchException - the search exception

executeQuery

protected SearchResultRecords executeQuery(HttpServletRequest request,
                                           RequestContext context,
                                           MessageBroker messageBroker,
                                           RestQuery query)
                                    throws SearchException
Executes the query.

Parameters:
request - the HTTP request
context - the request context
messageBroker - the resource message broker
query - the query to execute
Returns:
the resultant records
Throws:
SearchException - if an exception occurs

getRequestParameter

protected String getRequestParameter(HttpServletRequest request,
                                     String parameterKey)
Gets the HTTP request parameter value associated with a key.

Parameters:
request - the HTTP request
parameterKey - the parameter key
Returns:
parameter value (empty string if not found, trimmed never null)

setResponseContentType

protected void setResponseContentType(HttpServletRequest request,
                                      HttpServletResponse response,
                                      RestQuery query)
Sets the HTTP content type for the response.

Parameters:
request - the HTTP request
response - the HTTP response
query - the rest query

getResponseFormat

protected RestQueryServlet.ResponseFormat getResponseFormat(HttpServletRequest request,
                                                            RestQuery query)
Determines the response format.

Parameters:
request - the HTTP request
query - the rest query
Returns:
the response format

init

public void init(ServletConfig config)
          throws ServletException
Initializes the servlet.
Init parameter "bundleBaseName" is read for message configuration.

Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Parameters:
config - the servlet configuration
Throws:
ServletException - if an exception occurs

makeFeedWriter

protected FeedWriter makeFeedWriter(HttpServletRequest request,
                                    RequestContext context,
                                    PrintWriter printWriter,
                                    MessageBroker messageBroker,
                                    RestQuery query)
Makes a writer capable of generating an appropriate response based upon the requested response format.

Parameters:
request - the HTTP request
context - the request context
printWriter - the underlying print writer
messageBroker - the message broker
query - the query
Returns:
the appropriate writer

parseRequest

protected RestQuery parseRequest(HttpServletRequest request,
                                 RequestContext context)
Parses the request and generates a populated query suitable for execution.

This method essentially uses URL key-value pairs to generate filter and response components for a rest based query.

This method is the primary extensibility point for the rest API. Code example for this method given below for reference during extension.

RestQuery query = new RestQuery();
    RestQueryParser parser = new RestQueryParser(request,context,query);

    parser.parseRepositoryId("rid");
    parser.parseResponseFormat("f");
    parser.parseResponseGeometry("geometryType");
    parser.parseResponseStyle("style");
    parser.parseResponseTarget("target");
    parser.parseStartRecord("start",1);
    parser.parseMaxRecords("max",10);
    parser.parsePropertyIsEqualTo("uuid","uuid");
    parser.parsePropertyIsLike("searchText","anytext");
    parser.parsePropertyList("contentType","dc:type",",",true);
    parser.parsePropertyList("dataCategory","dc:subject",",",true);
    parser.parsePropertyRange("after","before","dct:modified");
    parser.parseSpatialClause("bbox","spatialRel","geometry");
    parser.parseSortables("orderBy");
    return query;
    

Parameters:
request - the HTTP request
context - the request context
Returns:
the populated rest query

toSearchCriteria

protected SearchCriteria toSearchCriteria(HttpServletRequest request,
                                          RequestContext context,
                                          RestQuery query)
Generates a search critera object from the request.

Parameters:
request - the HTTP request
context - the request context
query - the pre-populated rest query
Returns:
the search criteria object

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.