List of usage examples for org.apache.solr.response QueryResponseWriterUtil writeQueryResponse
public static void writeQueryResponse(OutputStream outputStream, QueryResponseWriter responseWriter, SolrQueryRequest solrRequest, SolrQueryResponse solrResponse, String contentType) throws IOException
From source file:org.vootoo.server.RequestProcesser.java
License:Apache License
protected void writeResponse(SolrQueryResponse solrRsp, QueryResponseWriter responseWriter, SolrQueryRequest solrReq) throws IOException { Object invalidStates = solrReq.getContext().get(CloudSolrClient.STATE_VERSION); //This is the last item added to the applyResult and the client would expect it that way. //If that assumption is changed , it would fail. This is done to avoid an O(n) scan on // the applyResult for each request if (invalidStates != null) solrRsp.add(CloudSolrClient.STATE_VERSION, invalidStates); // Now write it out final String ct = responseWriter.getContentType(solrReq, solrRsp); // don't call setContentType on null if (null != ct) { responseSetter.setContentType(ct); }/*from ww w . j a v a 2 s. c om*/ if (solrRsp.getException() != null) { NamedList info = new SimpleOrderedMap(); int code = ResponseUtils.getErrorInfo(solrRsp.getException(), info, logger); //solrRsp.add("error", info); // use protocol response exception instead of set 'error' response return to client, responseSetter.setSolrResponseException(code, info); } QueryResponseWriterUtil.writeQueryResponse(responseSetter.getResponseOutputStream(), responseWriter, solrReq, solrRsp, ct); //fire QueryResponse write Complete responseSetter.writeQueryResponseComplete(solrRsp); }