SOLR-3244: Fix new admin UI for Tomcat

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1300710 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-03-14 20:29:42 +00:00
parent dba31ba5a5
commit 8bcbd04454
2 changed files with 25 additions and 21 deletions

View File

@ -439,7 +439,8 @@ Other Changes
* SOLR-2607: Removed obsolete client/ folder (ehatcher, Eric Pugh, janhoy)
* SOLR-3202: Dropping Support for JSP. New Admin UI is all client side (ryan)
* SOLR-3202, SOLR-3244: Dropping Support for JSP. New Admin UI is all client side
(ryan, Aliaksandr Zhuhrou, Uwe Schindler)
* SOLR-3159: Upgrade example and tests to run with Jetty 8 (ryan)

View File

@ -17,8 +17,7 @@
package org.apache.solr.servlet;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
@ -29,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.solr.core.CoreContainer;
@ -47,25 +47,28 @@ public final class LoadAdminUiServlet extends HttpServlet {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
File f = new File(getServletContext().getRealPath("admin.html"));
if(f.exists()) {
InputStream in = getServletContext().getResourceAsStream("/admin.html");
if(in != null) {
try {
// This attribute is set by the SolrDispatchFilter
CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
String html = IOUtils.toString(new FileInputStream(f), "UTF-8");
String html = IOUtils.toString(in, "UTF-8");
String[] search = new String[] {
"${contextPath}",
"${adminPath}"
};
String[] replace = new String[] {
request.getContextPath(),
cores.getAdminPath()
StringEscapeUtils.escapeJavaScript(request.getContextPath()),
StringEscapeUtils.escapeJavaScript(cores.getAdminPath())
};
out.println( StringUtils.replaceEach(html, search, replace) );
} finally {
IOUtils.closeQuietly(in);
}
else {
} else {
out.println("solr");
}
}