throw new RuntimeException("Display target is not set for " + getClass().getName());
}
String xmlPath;
File xmlFile = null;
ModelAndView mv = new ModelAndView(getViewName());
if (TARGET_WEB_XML.equals(displayTarget)) {
ServletContext sctx = context.getServletContext();
xmlPath = sctx.getRealPath("/WEB-INF/web.xml");
xmlFile = new File(xmlPath);
mv.addObject("fileDesc", getMessageSourceAccessor().getMessage("probe.src.app.viewxmlconf.webxml.desc"));
} else if (TARGET_CONTEXT_XML.equals(displayTarget)) {
xmlFile = getContainerWrapper().getTomcatContainer().getConfigFile(context);
if (xmlFile != null) {
xmlPath = xmlFile.getPath();
} else {
xmlPath = null;
}
mv.addObject("fileDesc", getMessageSourceAccessor().getMessage("probe.src.app.viewxmlconf.contextxml.desc"));
} else {
throw new RuntimeException("Unknown display target " + getDisplayTarget());
}
mv.addObject("displayTarget", displayTarget);
mv.addObject("downloadUrl", downloadUrl);
if (xmlFile != null) {
mv.addObject("fileName", xmlFile.getName());
if (xmlFile.exists()) {
FileInputStream fis = new FileInputStream(xmlFile);
try {
String encoding = System.getProperty("file.encoding");
mv.addObject("content", Utils.highlightStream("web.xml", fis, "xml", encoding == null ? "ISO-8859-1" : encoding));
} finally {
fis.close();
}
} else {
logger.debug("File " + xmlPath + " of " + contextName + " application does not exists.");