Enhydra 5.1 API

org.enhydra.servlet.debug
Class RequestRecord

java.lang.Object
  |
  +--org.enhydra.servlet.filter.RequestFilter
        |
        +--org.enhydra.servlet.debug.RequestRecord
All Implemented Interfaces:
DebugRequest, javax.servlet.http.HttpServletRequest, org.apache.tomcat.core.RequestAdapter, javax.servlet.ServletRequest

public class RequestRecord
extends RequestFilter
implements javax.servlet.http.HttpServletRequest, DebugRequest

HttpServletRequest filter that generate a record of the request that was made. Once the request is complete, this object contains the information and is used as the record of the request's content.

Version:
$Revision: 1.1 $
Author:
Mark Diekhans
See Also:
com.lutris.filter.TransactionFilter, ServletRequest, HttpServletRequest

Field Summary
protected  ServletTransactionRecord transactionRecord
          Transaction record that this object is associated with.
 
Fields inherited from class org.enhydra.servlet.filter.RequestFilter
adapter, myRequest
 
Constructor Summary
protected RequestRecord(javax.servlet.http.HttpServletRequest originalRequest)
          Constructor.
 
Method Summary
 void addTrace(java.lang.String str)
          Add a string to the trace buffer.
protected  void completed()
          Flag the request as completed.
 java.lang.Object getAttribute(java.lang.String name)
          Record call and pass on to actual request object.
 java.util.Enumeration getAttributeNames()
           
 java.lang.String getAuthType()
          Record call and return cached value.
 java.lang.String getCharacterEncoding()
          Returns the character set encoding for the input of this request.
 int getContentLength()
          Record call and return cached value.
 java.lang.String getContentType()
          Record call and return cached value.
 java.lang.String getContextPath()
           
 javax.servlet.http.Cookie[] getCookies()
          Gets the array of cookies found in this request.
 long getDateHeader(java.lang.String name)
          Record call and return cached value.
 java.lang.String getHeader(java.lang.String name)
          Record call and return cached value.
 java.util.Enumeration getHeaderNames()
          Record call and return cached value.
 java.util.Enumeration getHeaders(java.lang.String name)
           
 javax.servlet.ServletInputStream getInputStream()
          Returns a wrapper around the real input stream.
 int getIntHeader(java.lang.String name)
          Record call and return cached value.
 java.util.Locale getLocale()
           
 java.util.Enumeration getLocales()
           
 java.lang.String getMethod()
          Record call and return cached value.
 java.lang.String getParameter(java.lang.String name)
          Record call and return cached value.
 java.util.Enumeration getParameterNames()
          Record call and return cached value.
 java.lang.String[] getParameterValues(java.lang.String name)
          Record call and return cached value.
 java.lang.String getPathInfo()
          Record call and return cached value.
 java.lang.String getPathTranslated()
          Record call and return cached value.
 java.lang.String getProtocol()
          Record call and return cached value.
 java.lang.String getQueryString()
          Record call and return cached value.
 java.io.BufferedReader getReader()
          Returns a buffered reader for reading text in the request body.
 java.lang.String getRealPath(java.lang.String path)
          Pass on to actual request object.
 java.lang.String getRemoteAddr()
          Record call and return cached value.
 java.lang.String getRemoteHost()
          Record call and return cached value.
 java.lang.String getRemoteUser()
          Record call and return cached value.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String name)
           
 java.lang.String getRequestedSessionId()
          Gets the session id specified with this request.
 java.lang.String getRequestURI()
          Record call and return cached value.
 java.lang.String getScheme()
          Record call and return cached value.
 java.lang.String getServerName()
          Record call and return cached value.
 int getServerPort()
          Record call and return cached value.
 java.lang.String getServletPath()
          Record call and return cached value.
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.http.HttpSession getSession(boolean create)
          Get or create a session.
 int getTotalBytes()
          Returns the number of bytes associated with the response.
 java.security.Principal getUserPrincipal()
           
 boolean isRequestedSessionIdFromCookie()
          Checks whether the session id specified by this request came in as a cookie.
 boolean isRequestedSessionIdFromUrl()
          Checks whether the session id specified by this request came in as part of the URL.
 boolean isRequestedSessionIdFromURL()
           
 boolean isRequestedSessionIdValid()
          Checks whether this request is associated with a session that is valid in the current session context.
 boolean isSecure()
           
 boolean isUserInRole(java.lang.String role)
           
 void removeAttribute(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class org.enhydra.servlet.filter.RequestFilter
doRead, doRead, getCookieHeaders, getMimeHeaders, getServletName, getServletPrefix, recycle, setQueryString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionRecord

protected ServletTransactionRecord transactionRecord
Transaction record that this object is associated with.

Constructor Detail

RequestRecord

protected RequestRecord(javax.servlet.http.HttpServletRequest originalRequest)
Constructor. Wrap the object around a single request and record infomation about it. The information is stored in this object for future access.

Parameters:
originalRequest - The real HttpServletRequest, which all calls will be passed on to.
See Also:
ServletRequest, HttpServletRequest
Method Detail

completed

protected void completed()
Flag the request as completed. This any summarization to occur and the object to disassociated with the original request object to help catch errors.


addTrace

public void addTrace(java.lang.String str)
Add a string to the trace buffer. InputStreamRecords will also call this.


getContentLength

public int getContentLength()
Record call and return cached value.

Specified by:
getContentLength in interface javax.servlet.ServletRequest
Overrides:
getContentLength in class RequestFilter
See Also:
ServletRequest.getContentLength()

getContentType

public java.lang.String getContentType()
Record call and return cached value.

Specified by:
getContentType in interface javax.servlet.ServletRequest
Overrides:
getContentType in class RequestFilter
See Also:
ServletRequest.getContentType()

getProtocol

public java.lang.String getProtocol()
Record call and return cached value.

Specified by:
getProtocol in interface javax.servlet.ServletRequest
Overrides:
getProtocol in class RequestFilter
See Also:
ServletRequest.getProtocol()

getScheme

public java.lang.String getScheme()
Record call and return cached value.

Specified by:
getScheme in interface javax.servlet.ServletRequest
Overrides:
getScheme in class RequestFilter
See Also:
ServletRequest.getScheme()

getServerName

public java.lang.String getServerName()
Record call and return cached value.

Specified by:
getServerName in interface javax.servlet.ServletRequest
Overrides:
getServerName in class RequestFilter
See Also:
ServletRequest.getServerName()

getServerPort

public int getServerPort()
Record call and return cached value.

Specified by:
getServerPort in interface javax.servlet.ServletRequest
Overrides:
getServerPort in class RequestFilter
See Also:
ServletRequest.getServerPort()

getRemoteAddr

public java.lang.String getRemoteAddr()
Record call and return cached value.

Specified by:
getRemoteAddr in interface javax.servlet.ServletRequest
Overrides:
getRemoteAddr in class RequestFilter
See Also:
ServletRequest.getRemoteAddr()

getRemoteHost

public java.lang.String getRemoteHost()
Record call and return cached value.

Specified by:
getRemoteHost in interface javax.servlet.ServletRequest
Overrides:
getRemoteHost in class RequestFilter
See Also:
ServletRequest.getRemoteHost()

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Pass on to actual request object. Will generate an error if used after request has completed.

Specified by:
getRealPath in interface javax.servlet.ServletRequest
Overrides:
getRealPath in class RequestFilter
See Also:
ServletRequest.getRealPath(java.lang.String)

getInputStream

public javax.servlet.ServletInputStream getInputStream()
                                                throws java.io.IOException
Returns a wrapper around the real input stream. All read calls will be logged via this object's addTrace() method.

Specified by:
getInputStream in interface javax.servlet.ServletRequest
Overrides:
getInputStream in class RequestFilter
java.io.IOException
See Also:
ServletRequest.getInputStream()

getParameter

public java.lang.String getParameter(java.lang.String name)
Record call and return cached value.

Specified by:
getParameter in interface javax.servlet.ServletRequest
Overrides:
getParameter in class RequestFilter
See Also:
ServletRequest.getParameter(java.lang.String)

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Record call and return cached value.

Specified by:
getParameterValues in interface javax.servlet.ServletRequest
Overrides:
getParameterValues in class RequestFilter
Parameters:
name - the name of the parameter whose value is required.
See Also:
ServletRequest.getParameterValues(java.lang.String)

getParameterNames

public java.util.Enumeration getParameterNames()
Record call and return cached value.

Specified by:
getParameterNames in interface javax.servlet.ServletRequest
Overrides:
getParameterNames in class RequestFilter
See Also:
ServletRequest.getParameterNames()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Record call and pass on to actual request object. Will return null if used after request is complete.

Specified by:
getAttribute in interface javax.servlet.ServletRequest
Overrides:
getAttribute in class RequestFilter
See Also:
ServletRequest.getAttribute(java.lang.String)

getMethod

public java.lang.String getMethod()
Record call and return cached value.

Specified by:
getMethod in interface javax.servlet.http.HttpServletRequest
Overrides:
getMethod in class RequestFilter
See Also:
HttpServletRequest.getMethod()

getRequestURI

public java.lang.String getRequestURI()
Record call and return cached value.

Specified by:
getRequestURI in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestURI in class RequestFilter
See Also:
HttpServletRequest.getRequestURI()

getServletPath

public java.lang.String getServletPath()
Record call and return cached value.

Specified by:
getServletPath in interface javax.servlet.http.HttpServletRequest
Overrides:
getServletPath in class RequestFilter
See Also:
HttpServletRequest.getServletPath()

getPathInfo

public java.lang.String getPathInfo()
Record call and return cached value.

Specified by:
getPathInfo in interface javax.servlet.http.HttpServletRequest
Overrides:
getPathInfo in class RequestFilter
See Also:
HttpServletRequest.getPathInfo()

getPathTranslated

public java.lang.String getPathTranslated()
Record call and return cached value.

Specified by:
getPathTranslated in interface javax.servlet.http.HttpServletRequest
Overrides:
getPathTranslated in class RequestFilter
See Also:
HttpServletRequest.getPathTranslated()

getQueryString

public java.lang.String getQueryString()
Record call and return cached value.

Specified by:
getQueryString in interface javax.servlet.http.HttpServletRequest
Overrides:
getQueryString in class RequestFilter
See Also:
HttpServletRequest.getQueryString()

getRemoteUser

public java.lang.String getRemoteUser()
Record call and return cached value.

Specified by:
getRemoteUser in interface javax.servlet.http.HttpServletRequest
Overrides:
getRemoteUser in class RequestFilter
See Also:
HttpServletRequest.getRemoteUser()

getAuthType

public java.lang.String getAuthType()
Record call and return cached value.

Specified by:
getAuthType in interface javax.servlet.http.HttpServletRequest
Overrides:
getAuthType in class RequestFilter
See Also:
HttpServletRequest.getAuthType()

getHeader

public java.lang.String getHeader(java.lang.String name)
Record call and return cached value.

Specified by:
getHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getHeader in class RequestFilter
Parameters:
name - the case-insensitive header field name
See Also:
HttpServletRequest.getHeader(java.lang.String)

getIntHeader

public int getIntHeader(java.lang.String name)
Record call and return cached value.

Specified by:
getIntHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getIntHeader in class RequestFilter
See Also:
HttpServletRequest.getIntHeader(java.lang.String)

getDateHeader

public long getDateHeader(java.lang.String name)
Record call and return cached value.

Specified by:
getDateHeader in interface javax.servlet.http.HttpServletRequest
Overrides:
getDateHeader in class RequestFilter
See Also:
HttpServletRequest.getDateHeader(java.lang.String)

getHeaderNames

public java.util.Enumeration getHeaderNames()
Record call and return cached value.

Specified by:
getHeaderNames in interface javax.servlet.http.HttpServletRequest
Overrides:
getHeaderNames in class RequestFilter
See Also:
HttpServletRequest.getHeaderNames()

getCookies

public javax.servlet.http.Cookie[] getCookies()
Gets the array of cookies found in this request.

Specified by:
getCookies in interface javax.servlet.http.HttpServletRequest
Overrides:
getCookies in class RequestFilter
Returns:
The array of cookies found in this request.
See Also:
HttpServletRequest.getCookies()

getTotalBytes

public int getTotalBytes()
Returns the number of bytes associated with the response.

Specified by:
getTotalBytes in interface DebugRequest

getSession

public javax.servlet.http.HttpSession getSession(boolean create)
Get or create a session.

Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
Overrides:
getSession in class RequestFilter
Returns:
The session associated with this request or null if create was false and no valid session is associated with this request.
See Also:
HttpServletRequest.getSession()

getRequestedSessionId

public java.lang.String getRequestedSessionId()
Gets the session id specified with this request.

Specified by:
getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
Overrides:
getRequestedSessionId in class RequestFilter
Returns:
The session id specified by this request, or null if the request did not specify a session id
See Also:
isRequestedSessionIdValid, HttpServletRequest.getRequestedSessionId()

isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()
Checks whether this request is associated with a session that is valid in the current session context.

Specified by:
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
Overrides:
isRequestedSessionIdValid in class RequestFilter
Returns:
True if this request is assocated with a session that is valid in the current session context.
See Also:
HttpServletRequest.isRequestedSessionIdValid()

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Checks whether the session id specified by this request came in as a cookie.

Specified by:
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
Overrides:
isRequestedSessionIdFromCookie in class RequestFilter
Returns:
True if the session id specified by this request came in as a cookie; false otherwise
See Also:
javax.servlet.http.HttpServletResponse#isRequestedSessionIdFromCookie

isRequestedSessionIdFromUrl

public boolean isRequestedSessionIdFromUrl()
Checks whether the session id specified by this request came in as part of the URL. (The requested session may not be the one returned by the getSession method.)

Specified by:
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
Overrides:
isRequestedSessionIdFromUrl in class RequestFilter
Returns:
True if the session id specified by the request for this session came in as part of the URL; false otherwise
See Also:
javax.servlet.http.HttpServletResponse#isRequestedSessionIdFromUrl

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Returns a buffered reader for reading text in the request body.

Specified by:
getReader in interface javax.servlet.ServletRequest
Overrides:
getReader in class RequestFilter
Throws:
java.io.IOException - On other I/O related errors.
See Also:
ServletRequest.getReader()

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the character set encoding for the input of this request.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletRequest
Overrides:
getCharacterEncoding in class RequestFilter
See Also:
ServletRequest.getCharacterEncoding()

isUserInRole

public boolean isUserInRole(java.lang.String role)
Specified by:
isUserInRole in interface javax.servlet.http.HttpServletRequest
Overrides:
isUserInRole in class RequestFilter

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface javax.servlet.ServletRequest
Overrides:
getLocale in class RequestFilter

getUserPrincipal

public java.security.Principal getUserPrincipal()
Specified by:
getUserPrincipal in interface javax.servlet.http.HttpServletRequest
Overrides:
getUserPrincipal in class RequestFilter

getLocales

public java.util.Enumeration getLocales()
Specified by:
getLocales in interface javax.servlet.ServletRequest
Overrides:
getLocales in class RequestFilter

getContextPath

public java.lang.String getContextPath()
Specified by:
getContextPath in interface javax.servlet.http.HttpServletRequest
Overrides:
getContextPath in class RequestFilter

getHeaders

public java.util.Enumeration getHeaders(java.lang.String name)
Specified by:
getHeaders in interface javax.servlet.http.HttpServletRequest
Overrides:
getHeaders in class RequestFilter

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.servlet.ServletRequest
Overrides:
removeAttribute in class RequestFilter

isSecure

public boolean isSecure()
Specified by:
isSecure in interface javax.servlet.ServletRequest
Overrides:
isSecure in class RequestFilter

isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()
Specified by:
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
Overrides:
isRequestedSessionIdFromURL in class RequestFilter

getSession

public javax.servlet.http.HttpSession getSession()
Specified by:
getSession in interface javax.servlet.http.HttpServletRequest
Overrides:
getSession in class RequestFilter

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletRequest
Overrides:
getAttributeNames in class RequestFilter

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in interface javax.servlet.ServletRequest
Overrides:
setAttribute in class RequestFilter

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String name)
Specified by:
getRequestDispatcher in interface javax.servlet.ServletRequest
Overrides:
getRequestDispatcher in class RequestFilter

Enhydra 5.1 API