Example usage for org.apache.solr.response BinaryResponseWriter BinaryResponseWriter

List of usage examples for org.apache.solr.response BinaryResponseWriter BinaryResponseWriter

Introduction

In this page you can find the example usage for org.apache.solr.response BinaryResponseWriter BinaryResponseWriter.

Prototype

BinaryResponseWriter

Source Link

Usage

From source file:com.doculibre.constellio.wicket.servlet.SolrServletEmulator.java

License:Open Source License

/**
 * Parse the solr response to named list (need to create solrj query
 * respond).//  www .  jav a2  s  .c om
 * 
 * @param req
 *            The request.
 * @param rsp
 *            The response.
 * @return The named list.
 */
public NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
    try {
        BinaryResponseWriter writer = new BinaryResponseWriter();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        writer.write(bos, req, rsp);
        BinaryResponseParser parser = new BinaryResponseParser();
        return parser.processResponse(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}