SOLR-2263: Add ability for RawResponseWriter to stream binary files

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1064330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-01-27 22:00:14 +00:00
parent 4c62240087
commit 946dc5c68a
2 changed files with 25 additions and 1 deletions

View File

@ -419,6 +419,9 @@ New Features
* SOLR-2129: Added a Solr module for dynamic metadata extraction/indexing with Apache UIMA.
See contrib/uima/README.txt for more information. (Tommaso Teofili via rmuir)
* SOLR-1283: Add ability for RawResponseWriter to stream binary files as well as
text files. (Eric Pugh via yonik)
Optimizations
----------------------

View File

@ -18,6 +18,7 @@
package org.apache.solr.response;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
@ -44,7 +45,7 @@ import org.apache.solr.request.SolrQueryRequest;
* @version $Id$
* @since solr 1.3
*/
public class RawResponseWriter implements QueryResponseWriter
public class RawResponseWriter implements BinaryQueryResponseWriter
{
/**
* The key that should be used to add a ContentStream to the
@ -93,4 +94,24 @@ public class RawResponseWriter implements QueryResponseWriter
getBaseWriter( request ).write( writer, request, response );
}
}
public void write(OutputStream out, SolrQueryRequest request,
SolrQueryResponse response) throws IOException {
Object obj = response.getValues().get( CONTENT );
if( obj != null && (obj instanceof ContentStream ) ) {
// copy the contents to the writer...
ContentStream content = (ContentStream)obj;
java.io.InputStream in = content.getStream();
try {
IOUtils.copy( in, out );
} finally {
in.close();
}
}
else {
//getBaseWriter( request ).write( writer, request, response );
throw new IOException("did not find a CONTENT object");
}
}
}