mirror of https://github.com/apache/lucene.git
added query arg optional for getting optional content
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@398977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6945bc6dc9
commit
7ae4a26c56
|
@ -7,17 +7,23 @@
|
||||||
<%@ page contentType="text/plain;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/plain;charset=UTF-8" language="java" %>
|
||||||
<%
|
<%
|
||||||
String fname = request.getParameter("file");
|
String fname = request.getParameter("file");
|
||||||
|
String optional = request.getParameter("optional");
|
||||||
String gettableFiles = SolrConfig.config.get("admin/gettableFiles","");
|
String gettableFiles = SolrConfig.config.get("admin/gettableFiles","");
|
||||||
StringTokenizer st = new StringTokenizer(gettableFiles);
|
StringTokenizer st = new StringTokenizer(gettableFiles);
|
||||||
InputStream is;
|
InputStream is;
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
|
boolean isOptional = false;
|
||||||
if (fname != null) {
|
if (fname != null) {
|
||||||
// Validate fname
|
// Validate fname
|
||||||
while(st.hasMoreTokens()) {
|
while(st.hasMoreTokens()) {
|
||||||
if (st.nextToken().compareTo(fname) == 0) isValid = true;
|
if (st.nextToken().compareTo(fname) == 0) isValid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (optional!=null && optional.equalsIgnoreCase("y")) {
|
||||||
|
isOptional=true;
|
||||||
|
}
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
|
try {
|
||||||
is= Config.openResource(fname);
|
is= Config.openResource(fname);
|
||||||
Reader input = new InputStreamReader(is);
|
Reader input = new InputStreamReader(is);
|
||||||
char[] buf = new char[4096];
|
char[] buf = new char[4096];
|
||||||
|
@ -26,6 +32,12 @@
|
||||||
if (len<=0) break;
|
if (len<=0) break;
|
||||||
out.write(buf,0,len);
|
out.write(buf,0,len);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (RuntimeException re) {
|
||||||
|
if (!isOptional) {
|
||||||
|
throw re;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
out.println("<ERROR>");
|
out.println("<ERROR>");
|
||||||
out.println("Permission denied for file "+ fname);
|
out.println("Permission denied for file "+ fname);
|
||||||
|
|
Loading…
Reference in New Issue