org.apache.shindig.gadgets.servlet
Class MakeRequestHandler

java.lang.Object
  extended by org.apache.shindig.gadgets.servlet.MakeRequestHandler

public class MakeRequestHandler
extends Object

Handles gadgets.io.makeRequest requests. Unlike ProxyHandler, this may perform operations such as OAuth or signed fetch.


Field Summary
static String AUTHZ_PARAM
           
static String CONTENT_TYPE_PARAM
           
static String DEFAULT_NUM_ENTRIES
           
static String GET_FULL_HEADERS_PARAM
           
static String GET_SUMMARIES_PARAM
           
static String HEADERS_PARAM
           
static String METHOD_PARAM
           
static String NUM_ENTRIES_PARAM
           
static String POST_DATA_PARAM
           
static String UNPARSEABLE_CRUFT
           
 
Constructor Summary
MakeRequestHandler(RequestPipeline requestPipeline, ResponseRewriterRegistry contentRewriterRegistry)
           
 
Method Summary
protected  HttpRequest buildHttpRequest(javax.servlet.http.HttpServletRequest request)
          Generate a remote content request based on the parameters sent from the client.
protected  String convertResponseToJson(SecurityToken authToken, javax.servlet.http.HttpServletRequest request, HttpResponse results)
          Format a response as JSON, including additional JSON inserted by chained content fetchers.
 void fetch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Executes a request, returning the response as JSON to be handled by makeRequest.
protected static String getContainer(javax.servlet.http.HttpServletRequest request)
          Extracts the container name from the request.
protected static String getParameter(javax.servlet.http.HttpServletRequest request, String key, String defaultValue)
          getParameter helper method, returning default value if param not present.
protected  RequestPipeline getRequestPipeline()
           
protected  void setPostData(javax.servlet.http.HttpServletRequest request, HttpRequest req)
          Set http request post data according to servlet request.
protected static void setResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, HttpResponse results)
          Sets cache control headers for the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNPARSEABLE_CRUFT

public static final String UNPARSEABLE_CRUFT
See Also:
Constant Field Values

POST_DATA_PARAM

public static final String POST_DATA_PARAM
See Also:
Constant Field Values

METHOD_PARAM

public static final String METHOD_PARAM
See Also:
Constant Field Values

HEADERS_PARAM

public static final String HEADERS_PARAM
See Also:
Constant Field Values

CONTENT_TYPE_PARAM

public static final String CONTENT_TYPE_PARAM
See Also:
Constant Field Values

NUM_ENTRIES_PARAM

public static final String NUM_ENTRIES_PARAM
See Also:
Constant Field Values

DEFAULT_NUM_ENTRIES

public static final String DEFAULT_NUM_ENTRIES
See Also:
Constant Field Values

GET_SUMMARIES_PARAM

public static final String GET_SUMMARIES_PARAM
See Also:
Constant Field Values

GET_FULL_HEADERS_PARAM

public static final String GET_FULL_HEADERS_PARAM
See Also:
Constant Field Values

AUTHZ_PARAM

public static final String AUTHZ_PARAM
See Also:
Constant Field Values
Constructor Detail

MakeRequestHandler

@Inject
public MakeRequestHandler(RequestPipeline requestPipeline,
                                 ResponseRewriterRegistry contentRewriterRegistry)
Method Detail

fetch

public void fetch(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws GadgetException,
                  IOException
Executes a request, returning the response as JSON to be handled by makeRequest.

Throws:
GadgetException
IOException

buildHttpRequest

protected HttpRequest buildHttpRequest(javax.servlet.http.HttpServletRequest request)
                                throws GadgetException
Generate a remote content request based on the parameters sent from the client.

Throws:
GadgetException

setPostData

protected void setPostData(javax.servlet.http.HttpServletRequest request,
                           HttpRequest req)
                    throws GadgetException
Set http request post data according to servlet request. It uses header encoding if available, and defaulted to utf8 Override the function if different behavior is needed.

Throws:
GadgetException

convertResponseToJson

protected String convertResponseToJson(SecurityToken authToken,
                                       javax.servlet.http.HttpServletRequest request,
                                       HttpResponse results)
                                throws GadgetException
Format a response as JSON, including additional JSON inserted by chained content fetchers.

Throws:
GadgetException

getRequestPipeline

protected RequestPipeline getRequestPipeline()

getContainer

protected static String getContainer(javax.servlet.http.HttpServletRequest request)
Extracts the container name from the request.


getParameter

protected static String getParameter(javax.servlet.http.HttpServletRequest request,
                                     String key,
                                     String defaultValue)
getParameter helper method, returning default value if param not present.


setResponseHeaders

protected static void setResponseHeaders(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         HttpResponse results)
                                  throws GadgetException
Sets cache control headers for the response.

Throws:
GadgetException


Copyright © 2007-2012. All Rights Reserved.