add read queryparameter in gsaservlet

pull/1/head
reger 11 years ago
parent 1e94719084
commit b75e92aac3

@ -24,6 +24,8 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -75,7 +77,7 @@ public class GSAsearchServlet extends HttpServlet {
throws ServletException, IOException {
response.setContentType(QueryResponseWriter.CONTENT_TYPE_XML_UTF8);
response.setStatus(HttpServletResponse.SC_OK);
respond(request, new serverObjects(), Switchboard.getSwitchboard(), response.getOutputStream());
respond(request, Switchboard.getSwitchboard(), response.getOutputStream());
}
// ------------------------------------------
@ -85,7 +87,7 @@ public class GSAsearchServlet extends HttpServlet {
*/
public static serverObjects respond(final HttpServletRequest header, serverObjects post, final Switchboard sb, final OutputStream out) {
public static void respond(final HttpServletRequest header, final Switchboard sb, final OutputStream out) {
// remember the peer contact for peer statistics
String clientip = header.getHeader(HeaderFramework.CONNECTION_PROP_CLIENTIP);
@ -100,8 +102,17 @@ public class GSAsearchServlet extends HttpServlet {
// final boolean searchAllowed = authenticated || sb.getConfigBool("publicSearchpage", true);
// if (!searchAllowed) return null;
// check post
if (post == null) {post = new serverObjects(); post.put("q", ""); post.put("num", "0");}
// create post
serverObjects post = new serverObjects();
post.put("q", ""); post.put("num", "0");
// convert servletrequest parameter to old style serverObjects map
Map<String, String[]> map = header.getParameterMap();
Iterator<Map.Entry<String, String[]>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String[]> param = it.next();
post.put(param.getKey(), param.getValue()); // hint: post.put uses String[] for String value anyways
}
ConcurrentLog.info("GSA Query", post.toString());
sb.intermissionAllThreads(3000); // tell all threads to do nothing for a specific time
@ -186,7 +197,7 @@ public class GSAsearchServlet extends HttpServlet {
// get the embedded connector
EmbeddedSolrConnector connector = sb.index.fulltext().getDefaultEmbeddedConnector();
if (connector == null) return null;
if (connector == null) return;
// do the solr request
SolrQueryRequest req = connector.request(post.toSolrParams(null));
@ -198,7 +209,7 @@ public class GSAsearchServlet extends HttpServlet {
ConcurrentLog.logException(e);
if (req != null) req.close();
SolrRequestInfo.clearRequestInfo();
return null;
return;
}
// set some context for the writer
@ -234,7 +245,5 @@ public class GSAsearchServlet extends HttpServlet {
}
AccessTracker.addToDump(originalQuery, Integer.toString(matches));
ConcurrentLog.info("GSA Query", "results: " + matches + ", for query:" + post.toString());
return null;
}
}

@ -48,7 +48,6 @@ import org.eclipse.jetty.server.HttpOutput;
import org.eclipse.jetty.server.InclusiveByteRange;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.util.MultiPartOutputStream;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.resource.Resource;
@ -82,9 +81,6 @@ import org.eclipse.jetty.util.resource.Resource;
*
* pathInfoOnly If true, only the path info will be applied to the resourceBase
*
*
* etags If True, weak etags will be generated and handled.
*
* </PRE>
*
*/

@ -106,9 +106,6 @@ import org.eclipse.jetty.util.resource.Resource;
*
* pathInfoOnly If true, only the path info will be applied to the resourceBase
*
*
* etags If True, weak etags will be generated and handled.
*
* </PRE>
*/
public abstract class YaCyDefaultServlet extends HttpServlet {

Loading…
Cancel
Save