2N/A<%@ page contentType="text/plain; charset=utf-8" pageEncoding="UTF-8" %>
2N/A<%--
2N/A Licensed to the Apache Software Foundation (ASF) under one or more
2N/A contributor license agreements. See the NOTICE file distributed with
2N/A this work for additional information regarding copyright ownership.
2N/A The ASF licenses this file to You under the Apache License, Version 2.0
2N/A (the "License"); you may not use this file except in compliance with
2N/A the License. You may obtain a copy of the License at
2N/A
2N/A http://www.apache.org/licenses/LICENSE-2.0
2N/A
2N/A Unless required by applicable law or agreed to in writing, software
2N/A distributed under the License is distributed on an "AS IS" BASIS,
2N/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2N/A See the License for the specific language governing permissions and
2N/A limitations under the License.
2N/A--%>
2N/A<%@ page import="org.apache.solr.core.Config,
2N/A org.apache.solr.core.SolrCore,
2N/A org.apache.solr.core.SolrConfig,
2N/A java.io.InputStream,
2N/A java.io.InputStreamReader,
2N/A java.io.Reader,
2N/A java.util.StringTokenizer,
2N/A java.util.logging.Logger"%>
2N/A<%!
2N/A static Logger log = Logger.getLogger(SolrCore.class.getName());
2N/A%>
2N/A<%
2N/A // NOTE -- this file will be removed in a future release
2N/A log.warning("Using deprecated JSP: " + request.getRequestURL().append("?").append(request.getQueryString()) + " -- check the ShowFileRequestHandler" );
2N/A
2N/A Object ocore = request.getAttribute("org.apache.solr.SolrCore");
2N/A SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
2N/A String fname = request.getParameter("file");
2N/A String optional = request.getParameter("optional");
2N/A String gettableFiles = core.getSolrConfig().get("admin/gettableFiles","");
2N/A StringTokenizer st = new StringTokenizer(gettableFiles);
2N/A InputStream is;
2N/A boolean isValid = false;
2N/A boolean isOptional = false;
2N/A if (fname != null) {
2N/A // Validate fname
2N/A while(st.hasMoreTokens()) {
2N/A if (st.nextToken().compareTo(fname) == 0) isValid = true;
2N/A }
2N/A }
2N/A if (optional!=null && optional.equalsIgnoreCase("y")) {
2N/A isOptional=true;
2N/A }
2N/A if (isValid) {
2N/A try {
2N/A is= core.getSolrConfig().openResource(fname);
2N/A Reader input = new InputStreamReader(is);
2N/A char[] buf = new char[4096];
2N/A while (true) {
2N/A int len = input.read(buf);
2N/A if (len<=0) break;
2N/A out.write(buf,0,len);
2N/A }
2N/A }
2N/A catch (RuntimeException re) {
2N/A if (!isOptional) {
2N/A throw re;
2N/A }
2N/A }
2N/A } else {
2N/A out.println("<ERROR>");
2N/A out.println("Permission denied for file "+ fname);
2N/A out.println("</ERROR>");
2N/A }
2N/A%>
2N/A