Search in sources :

Example 1 with RequestHandlerBase

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

the class InfoHandler method handle.

private void handle(SolrQueryRequest req, SolrQueryResponse rsp, String path) {
    int i = path.lastIndexOf('/');
    String name = path.substring(i + 1, path.length());
    RequestHandlerBase handler = handlers.get(name.toLowerCase(Locale.ROOT));
    if (handler == null) {
        throw new SolrException(SolrException.ErrorCode.NOT_FOUND, "No handler by name " + name + " available names are " + handlers.keySet());
    }
    handler.handleRequest(req, rsp);
    rsp.setHttpCaching(false);
}
Also used : RequestHandlerBase(org.apache.solr.handler.RequestHandlerBase) SolrException(org.apache.solr.common.SolrException)

Example 2 with RequestHandlerBase

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

the class BasicFunctionalityTest method testRequestHandlerBaseException.

@Test
public void testRequestHandlerBaseException() {
    final String tmp = "BOO! ignore_exception";
    SolrRequestHandler handler = new RequestHandlerBase() {

        @Override
        public String getDescription() {
            return tmp;
        }

        @Override
        public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) {
            throw new RuntimeException(tmp);
        }
    };
    handler.init(new NamedList());
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrQueryRequest req = req();
    h.getCore().execute(handler, req, rsp);
    assertNotNull("should have found an exception", rsp.getException());
    req.close();
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) RequestHandlerBase(org.apache.solr.handler.RequestHandlerBase) NamedList(org.apache.solr.common.util.NamedList) SolrRequestHandler(org.apache.solr.request.SolrRequestHandler) Test(org.junit.Test)

Aggregations

RequestHandlerBase (org.apache.solr.handler.RequestHandlerBase)2 SolrException (org.apache.solr.common.SolrException)1 NamedList (org.apache.solr.common.util.NamedList)1 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)1 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)1 SolrRequestHandler (org.apache.solr.request.SolrRequestHandler)1 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)1 Test (org.junit.Test)1