public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream) throws Exception { parseAndLoadDocs(req, rsp, stream.getStream(), processor); } };
@Override public InputStream getStream() throws IOException { return stream.getStream(); }
@Override public void write(OutputStream os) throws IOException { IOUtils.copy(stream.getStream(), os); }
@Override public void close() { if (contentStream != null) { try { if (in == null) in = contentStream.getStream(); in.close(); } catch (IOException e) { /*no op*/ } } } }
public InputStream getStream() throws IOException { return getDelegate().getStream(); }
@Override public InputStream getStream() throws IOException { return getDelegate().getStream(); }
private void fillSingleContentStream(Collection<ContentStream> streams, HttpEntityEnclosingRequestBase postOrPut) throws IOException { // Single stream as body // Using a loop just to get the first one final ContentStream[] contentStream = new ContentStream[1]; for (ContentStream content : streams) { contentStream[0] = content; break; } Long size = contentStream[0].getSize(); postOrPut.setEntity(new InputStreamEntity(contentStream[0].getStream(), size == null ? -1 : size) { @Override public Header getContentType() { return new BasicHeader("Content-Type", contentStream[0].getContentType()); } @Override public boolean isRepeatable() { return false; } }); }
private String quietlyReadContentStreams() { StringBuilder sb = new StringBuilder(); if (contentStream != null) { for (ContentStream stream : this.contentStream) { InputStream ioStream = null; try { ioStream = stream.getStream(); sb.append(StreamUtils.copyToString(ioStream, Charset.forName("UTF-8"))); } catch (IOException e) {} finally { if (ioStream != null) { try { ioStream.close(); } catch (IOException e) {} } } } } return sb.toString(); }
/** * Read commands from request streams * * @param streams the streams * @param resp solr query response * @param singletonCommands , commands that cannot be repeated * @return parsed list of commands * @throws IOException if there is an error while parsing the stream */ public static List<CommandOperation> readCommands(Iterable<ContentStream> streams, NamedList resp, Set<String> singletonCommands) throws IOException { if (streams == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream"); } ArrayList<CommandOperation> ops = new ArrayList<>(); for (ContentStream stream : streams) { if ("application/javabin".equals(stream.getContentType())) { ops.addAll(parse(stream.getStream(), singletonCommands)); } else { ops.addAll(parse(stream.getReader(), singletonCommands)); } } List<Map> errList = CommandOperation.captureErrors(ops); if (!errList.isEmpty()) { resp.add(CommandOperation.ERR_MSGS, errList); return null; } return ops; }
@Override public InputStream getData(String query) { contentStream = context.getDocBuilder().getReqParams().getContentStream(); if (contentStream == null) throw new DataImportHandlerException(SEVERE, "No stream available. The request has no body"); try { return in = contentStream.getStream(); } catch (IOException e) { DataImportHandlerException.wrapAndThrow(SEVERE, e); return null; } }
content.getStream(), ContentType.parse(contentType), content.getName())));
InputStream stream = req.getContentStreams().iterator().next().getStream(); stream = detectGzip(stream);
partBytes = IOUtils.toByteArray(stream.getStream(), stream.getSize()); } catch (IOException e) { throw new LuxException (e);
@Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException { // Show params rsp.add( "params", req.getParams().toNamedList() ); // Write the streams... if( req.getContentStreams() != null ) { ArrayList streams = new ArrayList(); // Cycle through each stream for( ContentStream content : req.getContentStreams() ) { NamedList<Object> stream = new SimpleOrderedMap<Object>(); stream.add( "name", content.getName() ); stream.add( "sourceInfo", content.getSourceInfo() ); stream.add( "size", content.getSize() ); stream.add( "contentType", content.getContentType() ); stream.add( "stream", IOUtils.toString( content.getStream() ) ); streams.add( stream ); } rsp.add( "streams", streams ); } rsp.add("context", req.getContext()); }
post.setRequestEntity(new InputStreamRequestEntity(contentStream[0].getStream(), contentStream[0].getContentType()));
inputStream = stream.getStream(); metadata.add(ExtractingMetadataConstants.STREAM_NAME, stream.getName()); metadata.add(ExtractingMetadataConstants.STREAM_SOURCE_INFO, stream.getSourceInfo());
InputStream inputStream = null; try { inputStream = stream.getStream(); String xpathExpr = params.get(ExtractingParams.XPATH_EXPRESSION); boolean extractOnly = params.getBool(ExtractingParams.EXTRACT_ONLY, false);