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

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

Introduction

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

Prototype

@Override
    public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse response) throws IOException 

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).//w  ww.j a v a2 s . c  o m
 * 
 * @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);
    }
}