@Override protected void execute(HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) { String path = req.getServletPath(); if (req.getPathInfo() != null) { // this lets you handle /update/commit when /update is a servlet path += req.getPathInfo(); } if (pathPrefix != null && path.startsWith(pathPrefix)) { path = path.substring(pathPrefix.length()); } int idx = path.indexOf("/", 1); if (idx > 1) { // try to get the corename as a request parameter first sreq.getContext().put("solandra-index", path.substring(1, idx)); } super.execute(req, handler, sreq, rsp); }
String indexName = (String) rb.req.getContext().get("solandra-index"); String indexName = (String) rb.req.getContext().get("solandra-index");
@Override public Map<Object, Object> getContext() { return request.getContext(); }
@Override public Map<Object, Object> getContext() { return request.getContext(); }
public SolrQueryContext(XQueryComponent xQueryComponent, SolrQueryRequest req) { this.queryComponent = xQueryComponent; this.req = req; servletRequest = (HttpServletRequest) req.getContext().get(LUX_HTTP_SERVLET_REQUEST); }
/** * Returns the character encoding that will be used to decode the incoming request. * * @param request the current Solr request. * @return the character encoding that will be used to decode the incoming request. */ String characterEncoding(final SolrQueryRequest request) { final HttpServletRequest httpRequest = (HttpServletRequest) request.getContext().get(Names.HTTP_REQUEST_KEY); return httpRequest.getCharacterEncoding() != null ? httpRequest.getCharacterEncoding() : "UTF-8"; }
/** * Returns true if the method associated with the current HTTP request is GET. * * @param request the current Solr request. * @return true if the method associated with the current HTTP request is GET. */ boolean isUsingGET(final SolrQueryRequest request) { return "GET".equals(((HttpServletRequest) request.getContext().get(Names.HTTP_REQUEST_KEY)).getMethod()); }
private String getImpersonatorName(SolrQueryRequest req) { HttpServletRequest httpServletRequest = (HttpServletRequest)req.getContext().get("httpRequest"); if (httpServletRequest != null) { return (String)httpServletRequest.getAttribute(DO_AS_USER_NAME); } return null; }
/** * Returns true if the method associated with the current HTTP request is POST. * * @param request the current Solr request. * @return true if the method associated with the current HTTP request is POST. */ boolean isUsingPOST(final SolrQueryRequest request) { return "POST".equals(((HttpServletRequest) request.getContext().get(Names.HTTP_REQUEST_KEY)).getMethod()); }
@Override protected void execute(HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) { // Make the raw request available to the XQueryComponent and // LuxResponseWriter sreq.getContext().put(SolrQueryContext.LUX_HTTP_SERVLET_REQUEST, req); super.execute(req, handler, sreq, rsp); }
/** * Returns the content type associated with the current request. * * @param request the current request. * @return the content type associated with the current request or an empty string. */ String contentType(final SolrQueryRequest request) { final String incomingContentType = ((HttpServletRequest) request.getContext().get(Names.HTTP_REQUEST_KEY)).getContentType(); return isNotNullOrEmptyString(incomingContentType) ? incomingContentType : EMPTY_STRING; }
public SolrQueryRequest parse( SolrCore core, String path, HttpServletRequest req ) throws Exception { SolrRequestParser parser = standard; // TODO -- in the future, we could pick a different parser based on the request // Pick the parser from the request... ArrayList<ContentStream> streams = new ArrayList<ContentStream>(1); SolrParams params = parser.parseParamsAndFillStreams( req, streams ); SolrQueryRequest sreq = buildRequestFrom( core, params, streams ); // Handlers and login will want to know the path. If it contains a ':' // the handler could use it for RESTful URLs sreq.getContext().put( "path", path ); return sreq; }
@Override public String getContentType(final SolrQueryRequest request, final SolrQueryResponse response) { final boolean isHybridMode = Boolean.TRUE.equals(request.getContext().get(Names.HYBRID_MODE)); return isHybridMode ? contentTypeRewrites.get(getContentType(request, true)) : getContentType(request, true); }
/** * Actually run the query */ @Override public void process(ResponseBuilder rb) throws IOException { CollapseRequest collapseRequest = (CollapseRequest) rb.req.getContext().remove("collapseRequest"); if (collapseRequest == null) { super.process(rb); return; } doProcess(rb, collapseRequest); }
protected void execute( HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) { // a custom filter could add more stuff to the request before passing it on. // for example: sreq.getContext().put( "HttpServletRequest", req ); // used for logging query stats in SolrCore.execute() sreq.getContext().put( "webapp", req.getContextPath() ); sreq.getCore().execute( handler, sreq, rsp ); }
/** * Parses some parameters from the request in preparation for the collapsing when collapsing is enabled otherwise * behaves like {@link super#prepare(ResponseBuilder)}. * * @param rb The response builder of the current search request * @throws IOException When index search problems occur */ @Override public void prepare(ResponseBuilder rb) throws IOException { super.prepare(rb); rb.req.getContext().put("collapseRequest", resolveCollapseRequest(rb)); }
@Override public String getContentType(SolrQueryRequest request, SolrQueryResponse response) { String contentType = (String) request.getContext().get ("lux.contentType"); if (contentType == null) { contentType= request.getParams().get("lux.contentType"); } if (contentType != null) { return contentType; } else { return "text/html; charset=UTF-8"; } }
private Template getTemplate(VelocityEngine engine, SolrQueryRequest request) throws IOException { Template template; String templateName = request.getParams().get(TEMPLATE); String qt = request.getParams().get(CommonParams.QT); String path = (String) request.getContext().get("path"); if (templateName == null && path != null) { templateName = path; } // TODO: path is never null, so qt won't get picked up maybe special case for '/select' to use qt, otherwise use path? if (templateName == null && qt != null) { templateName = qt; } if (templateName == null) templateName = "index"; try { template = engine.getTemplate(templateName + TEMPLATE_EXTENSION); } catch (Exception e) { throw new IOException(e.getMessage()); } return template; }
private Template getTemplate(VelocityEngine engine, SolrQueryRequest request) throws IOException { Template template; String template_name = request.getParams().get("v.template"); String qt = request.getParams().get("qt"); String path = (String) request.getContext().get("path"); if (template_name == null && path != null) { template_name = path; } // TODO: path is never null, so qt won't get picked up maybe special case for '/select' to use qt, otherwise use path? if (template_name == null && qt != null) { template_name = qt; } if (template_name == null) template_name = "index"; try { template = engine.getTemplate(template_name + ".vm"); } catch (Exception e) { throw new IOException(e.getMessage()); } return template; }
private void handleAdminRequest(HttpServletRequest req, ServletResponse response, SolrRequestHandler handler, SolrQueryRequest solrReq) throws IOException { SolrQueryResponse solrResp = new SolrQueryResponse(); final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>(); solrResp.add("responseHeader", responseHeader); NamedList toLog = solrResp.getToLog(); toLog.add("webapp", req.getContextPath()); toLog.add("path", solrReq.getContext().get("path")); toLog.add("params", "{" + solrReq.getParamString() + "}"); handler.handleRequest(solrReq, solrResp); SolrCore.setResponseHeaderValues(handler, solrReq, solrResp); StringBuilder sb = new StringBuilder(); for (int i = 0; i < toLog.size(); i++) { String name = toLog.getName(i); Object val = toLog.getVal(i); sb.append(name).append("=").append(val).append(" "); } QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT)); if (respWriter == null) respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard"); writeResponse(solrResp, response, respWriter, solrReq, Method.getMethod(req.getMethod())); }