try {
MarinerServletRequestContext servletRequestContext =
new MarinerServletRequestContext(
filterConfig.getServletContext(),
requestWrapper,
response);
// Parse the contents of the response as Marlin markup.
// The processed page will be written to the response, so
// we don't need to do anything further.
XMLReader xmlReader = MarlinSAXHelper.getXMLReader(servletRequestContext, null);
// todo: The following baseURI initialisation code should be
// unnecessary if the system id is properly set on the InputSource.
// However, this needs to be tested properly before changing it as
// there were some problems with the pipeline.
EnvironmentContext environmentContext =
ContextInternals.getEnvironmentContext(servletRequestContext);
// The getXMLReader() call above will set up the pipelineContext in
// the environmentContext. See MarlinSAXHelper.setPipelineContext()
XMLPipelineContext pipelineContext = environmentContext.getPipelineContext();
// set the Base URI in the pipeline's context
try {
URL baseURI = filterConfig.getServletContext().getResource("/");
String baseURIAsString = baseURI.toExternalForm();
if (logger.isDebugEnabled()) {
logger.debug("Setting Base URI " + baseURIAsString);
}
pipelineContext.pushBaseURI(baseURIAsString);
} catch (MalformedURLException e) {
throw new ServletException(e);
}
// Treat the response wrapper as an InputSource for the XML parser.
Reader reader = responseWrapper.getReader();
InputSource inputSource = new InputSource(reader);
//inputSource.setSystemId(baseURIAsString);
// Parse the response and process it as XDIME.
xmlReader.parse(inputSource);
servletRequestContext.release();
} catch (MarinerContextException e) {
logger.error("portal-filter-exception",
new Object[]{responseWrapper.getContentsAsString()});
logger.error("mariner-context-exception", e);
throw new ServletException(