Coverage Report - org.kuali.student.common.util.filter.GWTCacheControlFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
GWTCacheControlFilter
0%
0/14
0%
0/2
1.333
 
 1  
 package org.kuali.student.common.util.filter;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.util.Date;
 5  
 
 6  
 import javax.servlet.Filter;
 7  
 import javax.servlet.FilterChain;
 8  
 import javax.servlet.FilterConfig;
 9  
 import javax.servlet.ServletException;
 10  
 import javax.servlet.ServletRequest;
 11  
 import javax.servlet.ServletResponse;
 12  
 import javax.servlet.http.HttpServletRequest;
 13  
 import javax.servlet.http.HttpServletResponse;
 14  
 
 15  
 /**
 16  
  * 
 17  
  * This class ensures that the nochache.js files are in fact, not cached. It seems that the file was getting 
 18  
  * cached and this was causing odd UI errors to appear. 
 19  
  *
 20  
  */
 21  0
 public class GWTCacheControlFilter implements Filter {
 22  
 
 23  
         public void destroy() {
 24  0
         }
 25  
 
 26  
         public void init(FilterConfig config) throws ServletException {
 27  0
         }
 28  
 
 29  
         public void doFilter(ServletRequest request, ServletResponse response,
 30  
                         FilterChain filterChain) throws IOException, ServletException {
 31  
 
 32  0
                 HttpServletRequest httpRequest = (HttpServletRequest) request;
 33  0
                 String requestURI = httpRequest.getRequestURI();
 34  
 
 35  0
                 if (requestURI.contains(".nocache.")) {
 36  0
                         Date now = new Date();
 37  0
                         HttpServletResponse httpResponse = (HttpServletResponse) response;
 38  0
                         httpResponse.setDateHeader("Date", now.getTime());
 39  
                         // one day old
 40  0
                         httpResponse.setDateHeader("Expires", now.getTime() - 86400000L);
 41  0
                         httpResponse.setHeader("Pragma", "no-cache");
 42  0
                         httpResponse.setHeader("Cache-control", "no-cache, no-store, must-revalidate");
 43  
                 }
 44  
 
 45  0
                 filterChain.doFilter(request, response);
 46  0
         }
 47  
 }