return;
}
HttpSession httpSession = safeGetSession( httpRequest, forceEagerSessionCreation );
boolean httpSessionExistedAtStartOfRequest = httpSession != null;
IPentahoSession pentahoSessionBeforeChainExecution = readPentahoSessionFromHttpSession( httpSession );
// Make the HttpSession null, as we don't want to keep a reference to it lying
// around in case chain.doFilter() invalidates it.
httpSession = null;
localeLeftovers( httpRequest );
if ( pentahoSessionBeforeChainExecution == null ) {
pentahoSessionBeforeChainExecution = generatePentahoSession( httpRequest );
if ( logger.isDebugEnabled() ) {
logger.debug( "Found no IPentahoSession in HTTP session; created new IPentahoSession" );
}
} else {
if ( logger.isDebugEnabled() ) {
logger.debug( "Obtained a valid IPentahoSession from HTTP session to "
+ "associate with PentahoSessionHolder: '" + pentahoSessionBeforeChainExecution + "'" );
}
}
httpRequest.setAttribute( FILTER_APPLIED, Boolean.TRUE );
// Create a wrapper that will eagerly update the session with the Pentaho session
// if anything in the chain does a sendError() or sendRedirect().
OnRedirectUpdateSessionResponseWrapper responseWrapper =
new OnRedirectUpdateSessionResponseWrapper( httpResponse, httpRequest, httpSessionExistedAtStartOfRequest );
// Proceed with chain
try {
// This is the only place in this class where PentahoSessionHolder.setSession() is called
PentahoSessionHolder.setSession( pentahoSessionBeforeChainExecution );
chain.doFilter( httpRequest, responseWrapper );
} finally {
// This is the only place in this class where PentahoSessionHolder.getSession() is called
IPentahoSession pentahoSessionAfterChainExecution = PentahoSessionHolder.getSession();
// Crucial removal of PentahoSessionHolder contents - do this before anything else.
PentahoSessionHolder.removeSession();
httpRequest.removeAttribute( FILTER_APPLIED );