org.jasig.portlet.newsreader.mvc.filter
Class ShallowEtagHeaderPortletFilter

java.lang.Object
  extended by org.jasig.portlet.newsreader.mvc.filter.ShallowEtagHeaderPortletFilter
All Implemented Interfaces:
javax.portlet.filter.PortletFilter, javax.portlet.filter.ResourceFilter

public class ShallowEtagHeaderPortletFilter
extends Object
implements javax.portlet.filter.ResourceFilter

ETag filter code copied from org.springframework.web.filter.ShallowEtagHeaderFilter.

Version:
$Revision: 22044 $

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
ShallowEtagHeaderPortletFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response, javax.portlet.filter.FilterChain filterChain)
           
protected  String generateETagHeaderValue(byte[] bytes)
          Generate the ETag header value from the given response body byte array.
 void init(javax.portlet.filter.FilterConfig filterConfig)
           
protected  boolean isEligibleForEtag(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response, int responseStatusCode, byte[] responseBody)
          Indicates whether the given request and response are eligible for ETag generation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

ShallowEtagHeaderPortletFilter

public ShallowEtagHeaderPortletFilter()
Method Detail

destroy

public void destroy()
Specified by:
destroy in interface javax.portlet.filter.PortletFilter

init

public void init(javax.portlet.filter.FilterConfig filterConfig)
          throws javax.portlet.PortletException
Specified by:
init in interface javax.portlet.filter.PortletFilter
Throws:
javax.portlet.PortletException

doFilter

public void doFilter(javax.portlet.ResourceRequest request,
                     javax.portlet.ResourceResponse response,
                     javax.portlet.filter.FilterChain filterChain)
              throws IOException,
                     javax.portlet.PortletException
Specified by:
doFilter in interface javax.portlet.filter.ResourceFilter
Throws:
IOException
javax.portlet.PortletException

isEligibleForEtag

protected boolean isEligibleForEtag(javax.portlet.ResourceRequest request,
                                    javax.portlet.ResourceResponse response,
                                    int responseStatusCode,
                                    byte[] responseBody)
Indicates whether the given request and response are eligible for ETag generation.

Default implementation returns true for response status codes in the 2xx series.

Parameters:
request - the HTTP request
response - the HTTP response
responseStatusCode - the HTTP response status code
responseBody - the response body
Returns:
true if eligible for ETag generation; false otherwise

generateETagHeaderValue

protected String generateETagHeaderValue(byte[] bytes)
Generate the ETag header value from the given response body byte array.

The default implementation generates an MD5 hash.

Parameters:
bytes - the response bdoy as byte array
Returns:
the ETag header value
See Also:
DigestUtils


Copyright © 2009-2010 Jasig. All Rights Reserved.