Search in sources :

Example 1 with ContentStreamHandlerBase

use of org.apache.solr.handler.ContentStreamHandlerBase in project lucene-solr by apache.

the class HttpSolrCall method extractHandlerFromURLPath.

/**
   * Extract handler from the URL path if not set.
   * This returns true if the action is set.
   * 
   */
protected void extractHandlerFromURLPath(SolrRequestParsers parser) throws Exception {
    if (handler == null && path.length() > 1) {
        // don't match "" or "/" as valid path
        handler = core.getRequestHandler(path);
        if (handler == null) {
            // Handle /schema/* paths via Restlet
            if (path.equals("/schema") || path.startsWith("/schema/")) {
                solrReq = parser.parse(core, path, req);
                SolrRequestInfo.setRequestInfo(new SolrRequestInfo(solrReq, new SolrQueryResponse()));
                if (path.equals(req.getServletPath())) {
                    // avoid endless loop - pass through to Restlet via webapp
                    action = PASSTHROUGH;
                    return;
                } else {
                    // forward rewritten URI (without path prefix and core/collection name) to Restlet
                    action = FORWARD;
                    return;
                }
            }
        }
        if (handler == null && parser.isHandleSelect()) {
            if ("/select".equals(path) || "/select/".equals(path)) {
                solrReq = parser.parse(core, path, req);
                invalidStates = checkStateIsValid(solrReq.getParams().get(CloudSolrClient.STATE_VERSION));
                String qt = solrReq.getParams().get(CommonParams.QT);
                handler = core.getRequestHandler(qt);
                if (handler == null) {
                    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "unknown handler: " + qt);
                }
                if (qt != null && qt.startsWith("/") && (handler instanceof ContentStreamHandlerBase)) {
                    //There was no restriction from Solr 1.4 thru 3.5 and it's not supported for update handlers.
                    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid Request Handler ('qt').  Do not use /select to access: " + qt);
                }
            }
        }
    }
}
Also used : SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) ContentStreamHandlerBase(org.apache.solr.handler.ContentStreamHandlerBase) SolrRequestInfo(org.apache.solr.request.SolrRequestInfo) SolrException(org.apache.solr.common.SolrException)

Aggregations

SolrException (org.apache.solr.common.SolrException)1 ContentStreamHandlerBase (org.apache.solr.handler.ContentStreamHandlerBase)1 SolrRequestInfo (org.apache.solr.request.SolrRequestInfo)1 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)1