use of org.apache.wiki.WatchDog in project jspwiki by apache.
the class WikiJSPFilter method doFilter.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
WatchDog w = m_engine.getCurrentWatchDog();
try {
NDC.push(m_engine.getApplicationName() + ":" + ((HttpServletRequest) request).getRequestURI());
w.enterState("Filtering for URL " + ((HttpServletRequest) request).getRequestURI(), 90);
HttpServletResponseWrapper responseWrapper;
responseWrapper = new MyServletResponseWrapper((HttpServletResponse) response, m_wiki_encoding, useEncoding);
// fire PAGE_REQUESTED event
String pagename = DefaultURLConstructor.parsePageFromURL((HttpServletRequest) request, response.getCharacterEncoding());
fireEvent(WikiPageEvent.PAGE_REQUESTED, pagename);
super.doFilter(request, responseWrapper, chain);
try {
w.enterState("Delivering response", 30);
WikiContext wikiContext = getWikiContext(request);
String r = filter(wikiContext, responseWrapper);
if (useEncoding) {
OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream(), response.getCharacterEncoding());
out.write(r);
out.flush();
out.close();
} else {
response.getWriter().write(r);
}
// Clean up the UI messages and loggers
if (wikiContext != null) {
wikiContext.getWikiSession().clearMessages();
}
// fire PAGE_DELIVERED event
fireEvent(WikiPageEvent.PAGE_DELIVERED, pagename);
} finally {
w.exitState();
}
} finally {
w.exitState();
NDC.pop();
NDC.remove();
}
}
Aggregations