Package com.artisol.teneo.engine.webapp
Class HttpEngineEnvironment
- Object
-
- AbstractEngineEnvironment
-
- ServletEngineEnvironment
-
- HttpEngineEnvironment
-
- All Implemented Interfaces:
EngineEnvironmentI
public class HttpEngineEnvironment extends ServletEngineEnvironment
Provides access to request data and cookie handling in a servlet container environment. Instances of this class are passed directly to solution scripts.- Version:
- 7.5.0
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTE_SESSION_TIMEOUTName of the servlet request attribute to store the session timeout value.
-
Constructor Summary
Constructors Constructor Description HttpEngineEnvironment(HttpServletRequest _request, Map<String,Object> _mRequestParameters, HttpServletResponse _response)Creates a new instance ofHttpEngineEnvironment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CookiecreateCookie(String _sName, String _sValue)Constructs aCookieobject for a specified name and value, to be used later as the parameter to methodsetCookie(Cookie).voiddeleteCookie(String _sName)Deletes the cookie with the given name.StringgetAuthType()CallsHttpServletRequest.getAuthType()on the request object.StringgetContextPath()CallsHttpServletRequest.getContextPath()on the request object.Cookie[]getCookies()Returns an array containing all theCookieobjects the client sent with the request.StringgetCookieValue(String _sName)Returns the same result as the following method invocation:StringgetCookieValue(String _sName, String _sDefault)Returns the value of the cookie (sent along with the request) with the given name.StringgetHeader(String _sHeaderName)CallsHttpServletRequest.getHeader(java.lang.String)on the request object.Enumeration<String>getHeaderNames()CallsHttpServletRequest.getHeaderNames()on the request object.Enumeration<String>getHeaders(String _sHeaderName)CallsHttpServletRequest.getHeaders(java.lang.String)on the request object.StringgetMethod()CallsHttpServletRequest.getMethod()on the request object.StringgetPathInfo()CallsHttpServletRequest.getPathInfo()on the request object.StringgetPathTranslated()CallsHttpServletRequest.getPathTranslated()on the request object.StringgetQueryString()CallsHttpServletRequest.getQueryString()on the request object.StringgetRemoteUser()CallsHttpServletRequest.getRemoteUser()on the request object.StringgetRequestedSessionId()CallsHttpServletRequest.getRequestedSessionId()on the request object.StringgetRequestURI()CallsHttpServletRequest.getRequestURI()on the request object.StringBuffergetRequestURL()CallsHttpServletRequest.getRequestURL()on the request object.StringgetServletPath()CallsHttpServletRequest.getServletPath()on the request object.intgetSessionTimeout()Returns how long the current session must be idle before it is terminated.booleanisInstanceOf(String _sTypeName)Checks whether this class or an ancestor is an instance of the given type name.booleanisRequestedSessionIdFromCookie()CallsHttpServletRequest.isRequestedSessionIdFromCookie()on the request object.booleanisRequestedSessionIdFromURL()CallsHttpServletRequest.isRequestedSessionIdFromURL()on the request object.booleanisRequestedSessionIdValid()CallsHttpServletRequest.isRequestedSessionIdValid()on the request object.booleanisUserInRole(String _sRole)CallsHttpServletRequest.isUserInRole(java.lang.String)on the request object.voidsetCookie(String _sName, String _sValue, int _iMaxAge)Sets a cookie with the given name, value, and maximum age.voidsetCookie(Cookie _cookie)Sets a cookie to the given cookie data.voidsetSessionTimeout(int _iTimeout)Sets how long the current session must be idle before it is terminated.-
Methods inherited from class ServletEngineEnvironment
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameters, getProtocol, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getServerName, getServerPort, isSecure
-
-
-
-
Field Detail
-
ATTRIBUTE_SESSION_TIMEOUT
public static final String ATTRIBUTE_SESSION_TIMEOUT
Name of the servlet request attribute to store the session timeout value.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpEngineEnvironment
public HttpEngineEnvironment(HttpServletRequest _request, Map<String,Object> _mRequestParameters, HttpServletResponse _response)Creates a new instance ofHttpEngineEnvironment.- Parameters:
_request- the servlet's request parameter_mRequestParameters- free typed request parameters_response- the servlet's response parameter
-
-
Method Detail
-
isInstanceOf
public boolean isInstanceOf(String _sTypeName)
Checks whether this class or an ancestor is an instance of the given type name.- Specified by:
isInstanceOfin interfaceEngineEnvironmentI- Overrides:
isInstanceOfin classServletEngineEnvironment- Returns:
trueif and only if the given type name equals"HttpEngineEnvironment"or one of the type names of the ancestor classes.- Since:
- 1.0
-
getCookieValue
public String getCookieValue(String _sName, String _sDefault)
Returns the value of the cookie (sent along with the request) with the given name. If no such cookie exists then the given default value is returned.This is a convenience method for accessing a cookie's value. In order to access all cookie data, an array containing all
Cookieobjects can be obtained by callinggetCookies().- Parameters:
_sName- name of the requested cookie_sDefault- default return value (default =null)- Returns:
- the value of the cookie with the given name if such cookie exists, otherwise the given default value
- Since:
- 1.0
- See Also:
HttpServletRequest.getCookies(),Cookie
-
getCookieValue
public String getCookieValue(String _sName)
Returns the same result as the following method invocation:getCookieValue(_sName, null)
- Since:
- 1.0
- See Also:
getCookieValue(String, String)
-
getCookies
public Cookie[] getCookies()
Returns an array containing all theCookieobjects the client sent with the request. If no cookies where sent the returned array is empty.- Returns:
- an array of all the
Cookies included with the request - Since:
- 1.0
-
createCookie
public Cookie createCookie(String _sName, String _sValue)
Constructs aCookieobject for a specified name and value, to be used later as the parameter to methodsetCookie(Cookie).Note: This method only creates a
Cookieobject but does not set the cookie in the engine environment.This is a factory method wrapped around the
Cookie(java.lang.String, java.lang.String)constructor.- Parameters:
_sName- the cookie's name. SeeCookie(java.lang.String, java.lang.String)on restrictions of the characters allowed for cookie names._sValue- the cookie's value SeeCookie.setValue(java.lang.String)on on restrictions of the characters allowed for cookie values.- Returns:
- a newly allocated
Cookieobject with the given name and value - Since:
- 1.1
- See Also:
Cookie(java.lang.String, java.lang.String)
-
setCookie
public void setCookie(String _sName, String _sValue, int _iMaxAge)
Sets a cookie with the given name, value, and maximum age. If a cookie with the given name already existed it is overwritten. The cookie data will be sent along the servlet reply to the client.This is a convenience method for setting a cookie's value. In order to set other attributes of a cookie it should be set by calling
setCookie(Cookie).- Parameters:
_sName- the cookie's name. SeeCookie(java.lang.String, java.lang.String)on restrictions of the characters allowed for cookie names._sValue- the cookie's value SeeCookie.setValue(java.lang.String)on on restrictions of the characters allowed for cookie values._iMaxAge- the cookie's maximum age in seconds. SeeCookie.setMaxAge(int)on a desciption of this value.- Since:
- 1.0
-
setCookie
public void setCookie(Cookie _cookie)
Sets a cookie to the given cookie data. If a cookie with the given name already existed it is overwritten. The cookie data will be sent along the servlet reply to the client.- Since:
- 1.0
-
deleteCookie
public void deleteCookie(String _sName)
Deletes the cookie with the given name. The cookie data will be sent along the servlet reply to the client.- Since:
- 1.0
-
getAuthType
public String getAuthType()
CallsHttpServletRequest.getAuthType()on the request object.- Since:
- 1.0
-
getContextPath
public String getContextPath()
CallsHttpServletRequest.getContextPath()on the request object.- Since:
- 1.0
-
getHeader
public String getHeader(String _sHeaderName)
CallsHttpServletRequest.getHeader(java.lang.String)on the request object.- Since:
- 1.0
-
getHeaderNames
public Enumeration<String> getHeaderNames()
CallsHttpServletRequest.getHeaderNames()on the request object.- Since:
- 1.0
-
getHeaders
public Enumeration<String> getHeaders(String _sHeaderName)
CallsHttpServletRequest.getHeaders(java.lang.String)on the request object.- Since:
- 1.0
-
getMethod
public String getMethod()
CallsHttpServletRequest.getMethod()on the request object.- Since:
- 1.0
-
getPathInfo
public String getPathInfo()
CallsHttpServletRequest.getPathInfo()on the request object.- Since:
- 1.0
-
getPathTranslated
public String getPathTranslated()
CallsHttpServletRequest.getPathTranslated()on the request object.- Since:
- 1.0
-
getQueryString
public String getQueryString()
CallsHttpServletRequest.getQueryString()on the request object.- Since:
- 1.0
-
getRemoteUser
public String getRemoteUser()
CallsHttpServletRequest.getRemoteUser()on the request object.- Since:
- 1.0
-
getRequestedSessionId
public String getRequestedSessionId()
CallsHttpServletRequest.getRequestedSessionId()on the request object.- Since:
- 1.0
-
getRequestURI
public String getRequestURI()
CallsHttpServletRequest.getRequestURI()on the request object.- Since:
- 1.0
-
getRequestURL
public StringBuffer getRequestURL()
CallsHttpServletRequest.getRequestURL()on the request object.- Since:
- 1.0
-
getServletPath
public String getServletPath()
CallsHttpServletRequest.getServletPath()on the request object.- Since:
- 1.0
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
CallsHttpServletRequest.isRequestedSessionIdFromCookie()on the request object.- Since:
- 1.0
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
CallsHttpServletRequest.isRequestedSessionIdFromURL()on the request object.- Since:
- 1.0
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
CallsHttpServletRequest.isRequestedSessionIdValid()on the request object.- Since:
- 1.0
-
isUserInRole
public boolean isUserInRole(String _sRole)
CallsHttpServletRequest.isUserInRole(java.lang.String)on the request object.- Since:
- 1.0
-
getSessionTimeout
public int getSessionTimeout()
Returns how long the current session must be idle before it is terminated.- Returns:
- the session timeout, in seconds
- Since:
- 1.1
-
setSessionTimeout
public void setSessionTimeout(int _iTimeout)
Sets how long the current session must be idle before it is terminated. Setting the timeout to 0 terminates the session after the current input request handling is completed.- Parameters:
_iTimeout- new session timeout, in seconds. May not be negative.- Since:
- 1.1
-
-