com.elasticpath.cmweb.util
Interface RequestHelper

All Known Implementing Classes:
RequestHelperImpl

public interface RequestHelper

RequestHelper represents a helper instance for http requests.


Method Summary
 CmUserSession getCmUserSession(javax.servlet.http.HttpServletRequest request)
          Return a ShoppingCart instance if there is one stored in http session.
 ElasticPath getElasticPath()
          Get the ElasticPath singleton.
 int getIntParameterOrAttribute(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultVal)
          Get an int parameter or attribute, with a fallback value.
 java.lang.String getUrl(javax.servlet.http.HttpServletRequest request)
          Retrive the absolute url from the given request.
 void setCmUserSession(javax.servlet.http.HttpServletRequest request, CmUserSession cmUserSession)
          Sets a CmUserSession into http session.
 void setElasticPath(ElasticPath elasticpath)
          Inject the ElasticPath singleton.
 

Method Detail

getCmUserSession

CmUserSession getCmUserSession(javax.servlet.http.HttpServletRequest request)
Return a ShoppingCart instance if there is one stored in http session. Otherwise, create a new one and return it.

Parameters:
request - the http request
Returns:
a CmUserSession instance

getElasticPath

ElasticPath getElasticPath()
Get the ElasticPath singleton.

Returns:
elasticpath the ElasticPath singleton.

getIntParameterOrAttribute

int getIntParameterOrAttribute(javax.servlet.http.HttpServletRequest request,
                               java.lang.String name,
                               int defaultVal)
Get an int parameter or attribute, with a fallback value. Never throws an exception. Can pass a distinguished value as default to enable checks of whether it was supplied.

Parameters:
request - current HTTP request
name - the name of the parameter
defaultVal - the default value to use as fallback
Returns:
the int value of parameter or attribute if it exists, otherwise, returns a fallback value

getUrl

java.lang.String getUrl(javax.servlet.http.HttpServletRequest request)
Retrive the absolute url from the given request.

Parameters:
request - the request
Returns:
the absolute url

setCmUserSession

void setCmUserSession(javax.servlet.http.HttpServletRequest request,
                      CmUserSession cmUserSession)
Sets a CmUserSession into http session.

Parameters:
request - the http request
cmUserSession - the cm user session to save

setElasticPath

void setElasticPath(ElasticPath elasticpath)
Inject the ElasticPath singleton.

Parameters:
elasticpath - the ElasticPath singleton.