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:
William Au 2006-05-02 17:40:14 +00:00
parent 6945bc6dc9
commit 7ae4a26c56
1 changed files with 12 additions and 0 deletions

View File

@ -7,17 +7,23 @@
<%@ page contentType="text/plain;charset=UTF-8" language="java" %>
<%
String fname = request.getParameter("file");
String optional = request.getParameter("optional");
String gettableFiles = SolrConfig.config.get("admin/gettableFiles","");
StringTokenizer st = new StringTokenizer(gettableFiles);
InputStream is;
boolean isValid = false;
boolean isOptional = false;
if (fname != null) {
// Validate fname
while(st.hasMoreTokens()) {
if (st.nextToken().compareTo(fname) == 0) isValid = true;
}
}
if (optional!=null && optional.equalsIgnoreCase("y")) {
isOptional=true;
}
if (isValid) {
try {
is= Config.openResource(fname);
Reader input = new InputStreamReader(is);
char[] buf = new char[4096];
@ -26,6 +32,12 @@
if (len<=0) break;
out.write(buf,0,len);
}
}
catch (RuntimeException re) {
if (!isOptional) {
throw re;
}
}
} else {
out.println("<ERROR>");
out.println("Permission denied for file "+ fname);