com.elasticpath.cmweb.util.impl
Class RequestHelperImpl

java.lang.Object
  extended by com.elasticpath.cmweb.util.impl.RequestHelperImpl
All Implemented Interfaces:
RequestHelper

public class RequestHelperImpl
extends java.lang.Object
implements RequestHelper

The default implementation of RequestHelper.


Constructor Summary
RequestHelperImpl()
           
 
Method Summary
 CmUserSession getCmUserSession(javax.servlet.http.HttpServletRequest request)
          Return a CmUserSession 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestHelperImpl

public RequestHelperImpl()
Method Detail

getCmUserSession

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

Specified by:
getCmUserSession in interface RequestHelper
Parameters:
request - the http request
Returns:
a CmUserSession instance
Throws:
EpCmWebException - when request is null

getElasticPath

public ElasticPath getElasticPath()
Get the ElasticPath singleton.

Specified by:
getElasticPath in interface RequestHelper
Returns:
elasticpath the ElasticPath singleton.

getIntParameterOrAttribute

public 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.

Specified by:
getIntParameterOrAttribute in interface RequestHelper
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

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

Specified by:
getUrl in interface RequestHelper
Parameters:
request - the request
Returns:
the absolute url

setCmUserSession

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

Specified by:
setCmUserSession in interface RequestHelper
Parameters:
request - the http request
cmUserSession - the cm user session to save
Throws:
EpCmWebException - when request or cm user session is null

setElasticPath

public void setElasticPath(ElasticPath elasticpath)
Inject the ElasticPath singleton.

Specified by:
setElasticPath in interface RequestHelper
Parameters:
elasticpath - the ElasticPath singleton.