Java Code Examples for org.apache.solr.client.solrj.util.ClientUtils#TEXT_XML

The following examples show how to use org.apache.solr.client.solrj.util.ClientUtils#TEXT_XML . 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: DocumentAnalysisRequest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public RequestWriter.ContentWriter getContentWriter(String expectedType) {

  return new RequestWriter.ContentWriter() {
    @Override
    public void write(OutputStream os) throws IOException {
      OutputStreamWriter outputStreamWriter = new OutputStreamWriter(os, UTF_8);
      try {
        getXML(outputStreamWriter);
      } finally {
        outputStreamWriter.flush();
      }
    }

    @Override
    public String getContentType() {
      return ClientUtils.TEXT_XML;
    }
  };

}
 
Example 2
Source File: RequestWriter.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Use this to do a push writing instead of pull. If this method returns null
 * {@link org.apache.solr.client.solrj.request.RequestWriter#getContentStreams(SolrRequest)} is
 * invoked to do a pull write.
 */
public ContentWriter getContentWriter(@SuppressWarnings({"rawtypes"})SolrRequest req) {
  if (req instanceof UpdateRequest) {
    UpdateRequest updateRequest = (UpdateRequest) req;
    if (isEmpty(updateRequest)) return null;
    return new ContentWriter() {
      @Override
      public void write(OutputStream os) throws IOException {
        OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8);
        updateRequest.writeXML(writer);
        writer.flush();
      }

      @Override
      public String getContentType() {
        return ClientUtils.TEXT_XML;
      }
    };
  }
  return req.getContentWriter(ClientUtils.TEXT_XML);
}
 
Example 3
Source File: RequestWriter.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public String getUpdateContentType() {
  return ClientUtils.TEXT_XML;
}
 
Example 4
Source File: DirectXmlRequest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
  return new StringPayloadContentWriter(xml, ClientUtils.TEXT_XML);
}