PageRenderTime 60ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/jetty/work/Jetty_0_0_0_0_8983_solr.war__solr__k1kf17/jsp/org/apache/jsp/admin/index_jsp.java

https://github.com/jronallo/northwest-digital-archives
Java | 388 lines | 343 code | 39 blank | 6 comment | 30 complexity | 330f089dd6002d2ce28d904602707b92 MD5 | raw file
Possible License(s): Apache-2.0, MIT
  1. package org.apache.jsp.admin;
  2. import javax.servlet.*;
  3. import javax.servlet.http.*;
  4. import javax.servlet.jsp.*;
  5. import java.util.Date;
  6. import java.util.List;
  7. import java.util.Collection;
  8. import org.apache.solr.request.SolrRequestHandler;
  9. import org.apache.solr.core.SolrConfig;
  10. import org.apache.solr.core.SolrCore;
  11. import org.apache.solr.schema.IndexSchema;
  12. import java.io.File;
  13. import java.net.InetAddress;
  14. import java.io.StringWriter;
  15. import org.apache.solr.core.Config;
  16. import org.apache.solr.common.util.XML;
  17. import org.apache.solr.common.SolrException;
  18. import org.apache.lucene.LucenePackage;
  19. import java.net.UnknownHostException;
  20. public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
  21. implements org.apache.jasper.runtime.JspSourceDependent {
  22. private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
  23. private static java.util.Vector _jspx_dependants;
  24. static {
  25. _jspx_dependants = new java.util.Vector(2);
  26. _jspx_dependants.add("/admin/header.jsp");
  27. _jspx_dependants.add("/admin/_info.jsp");
  28. }
  29. private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;
  30. public Object getDependants() {
  31. return _jspx_dependants;
  32. }
  33. public void _jspService(HttpServletRequest request, HttpServletResponse response)
  34. throws java.io.IOException, ServletException {
  35. PageContext pageContext = null;
  36. HttpSession session = null;
  37. ServletContext application = null;
  38. ServletConfig config = null;
  39. JspWriter out = null;
  40. Object page = this;
  41. JspWriter _jspx_out = null;
  42. PageContext _jspx_page_context = null;
  43. try {
  44. response.setContentType("text/html; charset=utf-8");
  45. pageContext = _jspxFactory.getPageContext(this, request, response,
  46. null, true, 8192, true);
  47. _jspx_page_context = pageContext;
  48. application = pageContext.getServletContext();
  49. config = pageContext.getServletConfig();
  50. session = pageContext.getSession();
  51. out = pageContext.getOut();
  52. _jspx_out = out;
  53. _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
  54. out.write('\n');
  55. out.write('\n');
  56. out.write('\n');
  57. out.write('\n');
  58. out.write('\n');
  59. out.write("\n");
  60. out.write("\n");
  61. out.write("\n");
  62. out.write("\n");
  63. out.write("\n");
  64. out.write("\n");
  65. out.write("\n");
  66. out.write('\n');
  67. out.write('\n');
  68. out.write('\n');
  69. out.write("\n");
  70. out.write("<html>\n");
  71. out.write("<head>\n");
  72. request.setCharacterEncoding("UTF-8");
  73. out.write('\n');
  74. out.write("\n");
  75. out.write("\n");
  76. out.write("\n");
  77. out.write("\n");
  78. out.write("\n");
  79. out.write("\n");
  80. out.write("\n");
  81. out.write("\n");
  82. out.write("\n");
  83. //
  84. SolrCore core = (SolrCore) request.getAttribute("org.apache.solr.SolrCore");
  85. if (core == null) {
  86. response.sendError( 404, "missing core name in path" );
  87. return;
  88. }
  89. SolrConfig solrConfig = core.getSolrConfig();
  90. int port = request.getServerPort();
  91. IndexSchema schema = core.getSchema();
  92. // enabled/disabled is purely from the point of a load-balancer
  93. // and has no effect on local server function. If there is no healthcheck
  94. // configured, don't put any status on the admin pages.
  95. String enabledStatus = null;
  96. String enabledFile = solrConfig.get("admin/healthcheck/text()",null);
  97. boolean isEnabled = false;
  98. if (enabledFile!=null) {
  99. isEnabled = new File(enabledFile).exists();
  100. }
  101. String collectionName = schema!=null ? schema.getName():"unknown";
  102. InetAddress addr = null;
  103. String hostname = "unknown";
  104. try {
  105. addr = InetAddress.getLocalHost();
  106. hostname = addr.getCanonicalHostName();
  107. } catch (UnknownHostException e) {
  108. //default to unknown
  109. }
  110. String defaultSearch = "";
  111. {
  112. StringWriter tmp = new StringWriter();
  113. XML.escapeCharData
  114. (solrConfig.get("admin/defaultQuery/text()", null), tmp);
  115. defaultSearch = tmp.toString();
  116. }
  117. String solrImplVersion = "";
  118. String solrSpecVersion = "";
  119. String luceneImplVersion = "";
  120. String luceneSpecVersion = "";
  121. {
  122. Package p;
  123. StringWriter tmp;
  124. p = SolrCore.class.getPackage();
  125. tmp = new StringWriter();
  126. solrImplVersion = p.getImplementationVersion();
  127. if (null != solrImplVersion) {
  128. XML.escapeCharData(solrImplVersion, tmp);
  129. solrImplVersion = tmp.toString();
  130. }
  131. tmp = new StringWriter();
  132. solrSpecVersion = p.getSpecificationVersion() ;
  133. if (null != solrSpecVersion) {
  134. XML.escapeCharData(solrSpecVersion, tmp);
  135. solrSpecVersion = tmp.toString();
  136. }
  137. p = LucenePackage.class.getPackage();
  138. tmp = new StringWriter();
  139. luceneImplVersion = p.getImplementationVersion();
  140. if (null != luceneImplVersion) {
  141. XML.escapeCharData(luceneImplVersion, tmp);
  142. luceneImplVersion = tmp.toString();
  143. }
  144. tmp = new StringWriter();
  145. luceneSpecVersion = p.getSpecificationVersion() ;
  146. if (null != luceneSpecVersion) {
  147. XML.escapeCharData(luceneSpecVersion, tmp);
  148. luceneSpecVersion = tmp.toString();
  149. }
  150. }
  151. String cwd=System.getProperty("user.dir");
  152. String solrHome= solrConfig.getInstanceDir();
  153. out.write("\n");
  154. out.write("<script>\n");
  155. out.write("var host_name=\"");
  156. out.print( hostname );
  157. out.write("\"\n");
  158. out.write("</script>\n");
  159. out.write("\n");
  160. out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
  161. out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"solr-admin.css\">\n");
  162. out.write("<link rel=\"icon\" href=\"favicon.ico\" type=\"image/ico\"></link>\n");
  163. out.write("<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/ico\"></link>\n");
  164. out.write("<title>Solr admin page</title>\n");
  165. out.write("</head>\n");
  166. out.write("\n");
  167. out.write("<body>\n");
  168. out.write("<a href=\".\"><img border=\"0\" align=\"right\" height=\"78\" width=\"142\" src=\"solr_small.png\" alt=\"Solr\"></a>\n");
  169. out.write("<h1>Solr Admin (");
  170. out.print( collectionName );
  171. out.write(')');
  172. out.write('\n');
  173. out.print( enabledStatus==null ? "" : (isEnabled ? " - Enabled" : " - Disabled") );
  174. out.write(" </h1>\n");
  175. out.write("\n");
  176. out.print( hostname );
  177. out.write(':');
  178. out.print( port );
  179. out.write("<br/>\n");
  180. out.write("cwd=");
  181. out.print( cwd );
  182. out.write(" SolrHome=");
  183. out.print( solrHome );
  184. out.write('\n');
  185. out.write('\n');
  186. SolrRequestHandler replicationhandler = core.getRequestHandler("/replication");
  187. out.write("\n");
  188. out.write("<br clear=\"all\">\n");
  189. out.write("<table>\n");
  190. out.write("\n");
  191. out.write("<tr>\n");
  192. out.write(" <td>\n");
  193. out.write("\t<h3>Solr</h3>\n");
  194. out.write(" </td>\n");
  195. out.write(" <td>\n");
  196. out.write(" ");
  197. if (null != core.getSchemaResource()) {
  198. out.write("\n");
  199. out.write(" [<a href=\"file/?file=");
  200. out.print(core.getSchemaResource());
  201. out.write("\">Schema</a>]\n");
  202. out.write(" ");
  203. }
  204. if (null != core.getConfigResource()) {
  205. out.write("\n");
  206. out.write(" [<a href=\"file/?file=");
  207. out.print(core.getConfigResource());
  208. out.write("\">Config</a>]\n");
  209. out.write(" ");
  210. }
  211. out.write("\n");
  212. out.write(" [<a href=\"analysis.jsp?highlight=on\">Analysis</a>]\n");
  213. out.write(" [<a href=\"schema.jsp\">Schema Browser</a>] ");
  214. if(replicationhandler != null ){
  215. out.write("[<a href=\"replication\">Replication</a>]");
  216. }
  217. out.write("\n");
  218. out.write(" <br>\n");
  219. out.write(" [<a href=\"stats.jsp\">Statistics</a>]\n");
  220. out.write(" [<a href=\"registry.jsp\">Info</a>]\n");
  221. out.write(" [<a href=\"distributiondump.jsp\">Distribution</a>]\n");
  222. out.write(" [<a href=\"ping\">Ping</a>]\n");
  223. out.write(" [<a href=\"logging\">Logging</a>]\n");
  224. out.write(" </td>\n");
  225. out.write("</tr>\n");
  226. out.write("\n");
  227. out.write('\n');
  228. org.apache.solr.core.CoreContainer cores = (org.apache.solr.core.CoreContainer)request.getAttribute("org.apache.solr.CoreContainer");
  229. if (cores!=null) {
  230. Collection<String> names = cores.getCoreNames();
  231. if (names.size() > 1) {
  232. out.write("<tr><td><strong>Cores:</strong><br></td><td>");
  233. for (String name : names) {
  234. out.write("[<a href=\"../../");
  235. out.print(name);
  236. out.write("/admin/\">");
  237. out.print(name);
  238. out.write("</a>]");
  239. }
  240. out.write("</td></tr>");
  241. }}
  242. out.write("\n");
  243. out.write("\n");
  244. out.write("<tr>\n");
  245. out.write(" <td>\n");
  246. out.write(" <strong>App server:</strong><br>\n");
  247. out.write(" </td>\n");
  248. out.write(" <td>\n");
  249. out.write(" [<a href=\"get-properties.jsp\">Java Properties</a>]\n");
  250. out.write(" [<a href=\"threaddump.jsp\">Thread Dump</a>]\n");
  251. out.write(" ");
  252. if (enabledFile!=null)
  253. if (isEnabled) {
  254. out.write("\n");
  255. out.write(" [<a href=\"action.jsp?action=Disable\">Disable</a>]\n");
  256. out.write(" ");
  257. } else {
  258. out.write("\n");
  259. out.write(" [<a href=\"action.jsp?action=Enable\">Enable</a>]\n");
  260. out.write(" ");
  261. }
  262. out.write("\n");
  263. out.write(" </td>\n");
  264. out.write("</tr>\n");
  265. out.write("\n");
  266. out.write("\n");
  267. // a quick hack to get rid of get-file.jsp -- note this still spits out invalid HTML
  268. out.write( org.apache.solr.handler.admin.ShowFileRequestHandler.getFileContents( "admin-extra.html" ) );
  269. out.write("\n");
  270. out.write("\n");
  271. out.write("</table><P>\n");
  272. out.write("\n");
  273. out.write("\n");
  274. out.write("<table>\n");
  275. out.write("<tr>\n");
  276. out.write(" <td>\n");
  277. out.write("\t<h3>Make a Query</h3>\n");
  278. out.write(" </td>\n");
  279. out.write(" <td>\n");
  280. out.write("[<a href=\"form.jsp\">Full Interface</a>]\n");
  281. out.write(" </td>\n");
  282. out.write(" \n");
  283. out.write("</tr>\n");
  284. out.write("<tr>\n");
  285. out.write(" <td>\n");
  286. out.write(" Query String:\n");
  287. out.write(" </td>\n");
  288. out.write(" <td colspan=2>\n");
  289. out.write("\t<form name=queryForm method=\"GET\" action=\"../select/\" accept-charset=\"UTF-8\">\n");
  290. out.write(" <textarea class=\"std\" rows=\"4\" cols=\"40\" name=\"q\">");
  291. out.print( defaultSearch );
  292. out.write("</textarea>\n");
  293. out.write(" <input name=\"version\" type=\"hidden\" value=\"2.2\">\n");
  294. out.write("\t<input name=\"start\" type=\"hidden\" value=\"0\">\n");
  295. out.write("\t<input name=\"rows\" type=\"hidden\" value=\"10\">\n");
  296. out.write("\t<input name=\"indent\" type=\"hidden\" value=\"on\">\n");
  297. out.write(" <br><input class=\"stdbutton\" type=\"submit\" value=\"search\" \n");
  298. out.write(" \tonclick=\"if (queryForm.q.value.length==0) { alert('no empty queries, please'); return false; } else { queryForm.submit(); } \">\n");
  299. out.write("\t</form>\n");
  300. out.write(" </td>\n");
  301. out.write("</tr>\n");
  302. out.write("</table><p>\n");
  303. out.write("\n");
  304. out.write("<table>\n");
  305. out.write("<tr>\n");
  306. out.write(" <td>\n");
  307. out.write("\t<h3>Assistance</h3>\n");
  308. out.write(" </td>\n");
  309. out.write(" <td>\n");
  310. out.write("\t[<a href=\"http://lucene.apache.org/solr/\">Documentation</a>]\n");
  311. out.write("\t[<a href=\"http://issues.apache.org/jira/browse/SOLR\">Issue Tracker</a>]\n");
  312. out.write("\t[<a href=\"mailto:solr-user@lucene.apache.org\">Send Email</a>]\n");
  313. out.write("\t<br>\n");
  314. out.write(" [<a href=\"http://wiki.apache.org/solr/SolrQuerySyntax\">Solr Query Syntax</a>]\n");
  315. out.write(" </td>\n");
  316. out.write("</tr>\n");
  317. out.write("<tr>\n");
  318. out.write(" <td>\n");
  319. out.write(" </td>\n");
  320. out.write(" <td>\n");
  321. out.write(" Current Time: ");
  322. out.print( new Date() );
  323. out.write("\n");
  324. out.write(" </td>\n");
  325. out.write("</tr>\n");
  326. out.write("<tr>\n");
  327. out.write(" <td>\n");
  328. out.write(" </td>\n");
  329. out.write(" <td>\n");
  330. out.write(" Server Start At: ");
  331. out.print( new Date(core.getStartTime()) );
  332. out.write("\n");
  333. out.write(" </td>\n");
  334. out.write("</tr>\n");
  335. out.write("</table>\n");
  336. out.write("</body>\n");
  337. out.write("</html>\n");
  338. } catch (Throwable t) {
  339. if (!(t instanceof SkipPageException)){
  340. out = _jspx_out;
  341. if (out != null && out.getBufferSize() != 0)
  342. out.clearBuffer();
  343. if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
  344. }
  345. } finally {
  346. _jspxFactory.releasePageContext(_jspx_page_context);
  347. }
  348. }
  349. }