Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

added query arg optional for getting optional content

William Au7ae4a26c5666
diff --git a/src/webapp/resources/admin/get-file.jsp b/src/webapp/resources/admin/get-file.jsp
index 64af33848a3..86d8b63bfb4 100644
--- a/src/webapp/resources/admin/get-file.jsp
+++ b/src/webapp/resources/admin/get-file.jsp
@@ -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);