com.atlassian.bamboo.filter
Class AccessLogFilter

java.lang.Object
  extended by com.atlassian.bamboo.filter.AccessLogFilter
All Implemented Interfaces:
javax.servlet.Filter

public class AccessLogFilter
extends java.lang.Object
implements javax.servlet.Filter

Logs JIRA username and request URL via log4j. See http://confluence.atlassian.com/display/JIRA/User+access+logging


Constructor Summary
AccessLogFilter()
           
 
Method Summary
 void destroy()
          Does nothing
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain chain)
          Creates logs if INFO logging level is set and URL is "interesting" according to isInterestingUrl(String).
protected  java.lang.String getEndText(java.lang.String startText, long memDiff, long timeDiff)
           
protected  java.lang.String getStartText(java.lang.String url, javax.servlet.http.HttpServletRequest request, long startMem)
           
 void init(javax.servlet.FilterConfig filterConfig)
          Does nothing but prints INFO log message
protected  boolean isInterestingUrl(java.lang.String url)
          Returns true if the given URL is of our interest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessLogFilter

public AccessLogFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Does nothing but prints INFO log message

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - not used
Throws:
javax.servlet.ServletException - not thrown

doFilter

public void doFilter(javax.servlet.ServletRequest servletRequest,
                     javax.servlet.ServletResponse servletResponse,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Creates logs if INFO logging level is set and URL is "interesting" according to isInterestingUrl(String).

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
servletRequest - request
servletResponse - response
chain - filter chain
Throws:
java.io.IOException - if another filter in the filter chain throws it
javax.servlet.ServletException - if another filter in the filter chain throws it

getStartText

protected java.lang.String getStartText(java.lang.String url,
                                        javax.servlet.http.HttpServletRequest request,
                                        long startMem)

getEndText

protected java.lang.String getEndText(java.lang.String startText,
                                      long memDiff,
                                      long timeDiff)

isInterestingUrl

protected boolean isInterestingUrl(java.lang.String url)
Returns true if the given URL is of our interest. Images (.gif, .png, .jpg, .ico), CSS (.css) and JavaScript (.js) are out of interest and if url ends with one of these extentions false is returned.

Parameters:
url - url to check
Returns:
true if interesting

destroy

public void destroy()
Does nothing

Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2010 Atlassian. All Rights Reserved.