Java Code Examples for org.apache.solr.core.SolrCore#postDecorateResponse()

The following examples show how to use org.apache.solr.core.SolrCore#postDecorateResponse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpSolrCall.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void handleAdminRequest() throws IOException {
  SolrQueryResponse solrResp = new SolrQueryResponse();
  SolrCore.preDecorateResponse(solrReq, solrResp);
  handleAdmin(solrResp);
  SolrCore.postDecorateResponse(handler, solrReq, solrResp);
  if (solrResp.getToLog().size() > 0) {
    if (log.isInfoEnabled()) { // has to come second and in it's own if to keep ./gradlew check happy.
      log.info(handler != null ? MarkerFactory.getMarker(handler.getClass().getName()) : MarkerFactory.getMarker(HttpSolrCall.class.getName()), solrResp.getToLogAsString("[admin]"));
    }
  }
  QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT));
  if (respWriter == null) respWriter = getResponseWriter();
  writeResponse(solrResp, respWriter, Method.getMethod(req.getMethod()));
  if (shouldAudit()) {
    EventType eventType = solrResp.getException() == null ? EventType.COMPLETED : EventType.ERROR;
    if (shouldAudit(eventType)) {
      cores.getAuditLoggerPlugin().doAudit(
          new AuditEvent(eventType, req, getAuthCtx(), solrReq.getRequestTimer().getTime(), solrResp.getException()));
    }
  }
}
 
Example 2
Source File: V2HttpCall.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
protected void execute(SolrQueryResponse rsp) {
  SolrCore.preDecorateResponse(solrReq, rsp);
  if (api == null) {
    rsp.setException(new SolrException(SolrException.ErrorCode.NOT_FOUND,
        "Cannot find correspond api for the path : " + solrReq.getContext().get(CommonParams.PATH)));
  } else {
    try {
      api.call(solrReq, rsp);
    } catch (Exception e) {
      rsp.setException(e);
    }
  }

  SolrCore.postDecorateResponse(handler, solrReq, rsp);
}
 
Example 3
Source File: BaseSolrResource.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Deal with an exception on the SolrResponse, fill in response header info,
 * and log the accumulated messages on the SolrResponse.
 */
protected void handlePostExecution(Logger log) {
  
  handleException(log);
  
  // TODO: should status=0 (success?) be left as-is in the response header?
  SolrCore.postDecorateResponse(null, solrRequest, solrResponse);
  addDeprecatedWarning();

  if (log.isInfoEnabled() && solrResponse.getToLog().size() > 0) {
    log.info(solrResponse.getToLogAsString(solrCore.getLogId()));
  }
}