/** * Checks if the current (HTTP) request contains a valid body. * * @param request the Solr request. * @return true if the current (HTTP) request contains a valid body, false otherwise. */ boolean isBodyNotEmpty(final SolrQueryRequest request) { return request.getContentStreams() != null && request.getContentStreams().iterator().hasNext(); }
private Reader getContentStreamReader(SolrQueryRequest req, Reader reader) throws IOException { Iterable<ContentStream> streams = req.getContentStreams(); if (streams != null) { Iterator<ContentStream> iter = streams.iterator(); if (iter.hasNext()) { reader = iter.next().getReader(); } if (iter.hasNext()) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "MoreLikeThis does not support multiple ContentStreams"); } } return reader; }
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); Iterable<ContentStream> streams = req.getContentStreams(); if (streams != null) { for (ContentStream stream : req.getContentStreams()) { Reader reader = stream.getReader(); try { XMLStreamReader parser = inputFactory.createXMLStreamReader(reader); NamedList<Object> result = processContent(parser, req.getSchema()); rsp.add("response", result); } finally { IOUtils.closeQuietly(reader); } } } }
/** * Extracts the only content stream from the request. {@link org.apache.solr.common.SolrException.ErrorCode#BAD_REQUEST} * error is thrown if the request doesn't hold any content stream or holds more than one. * * @param req The solr request. * * @return The single content stream which holds the documents to be analyzed. */ private ContentStream extractSingleContentStream(SolrQueryRequest req) { Iterable<ContentStream> streams = req.getContentStreams(); if (streams == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "DocumentAnlysisRequestHandler expects a single content stream with documents to analyze"); } Iterator<ContentStream> iter = streams.iterator(); if (!iter.hasNext()) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "DocumentAnlysisRequestHandler expects a single content stream with documents to analyze"); } ContentStream stream = iter.next(); if (iter.hasNext()) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "DocumentAnlysisRequestHandler expects a single content stream with documents to analyze"); } return stream; } }
if (request.getContentStreams() == null || !request.getContentStreams().iterator().hasNext()) { throw new SolrException(ErrorCode.BAD_REQUEST, "Empty RDF Payload"); } else if ("PUT".equals(method)) { if (request.getContentStreams() == null || !request.getContentStreams().iterator().hasNext()) { throw new SolrException(ErrorCode.BAD_REQUEST, "Emtpty RDF Payload");
formatResponseAsJson(req); if (req.getContentStreams() == null) { LOGGER.warn("no content stream"); rsp.add("error", "No content stream"); InputStream stream = req.getContentStreams().iterator().next().getStream(); stream = detectGzip(stream);
@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()); }
private void handleContentStreams (LinkedTreeBuilder builder, SolrQueryRequest req, ArrayList<XdmItem> result, Evaluator evaluator) throws XPathException { for (ContentStream stream : req.getContentStreams()) { String contentType = stream.getContentType();
if (req.getContentStreams() != null) { resultSequence = new ArrayList<XdmItem>(); handleContentStreams (builder, req, resultSequence, evaluator);
Iterable<ContentStream> streams = req.getContentStreams(); if (streams != null) {
Iterable<ContentStream> streams = req.getContentStreams(); if (streams != null) { Iterator<ContentStream> iter = streams.iterator();
Iterable<ContentStream> streams = req.getContentStreams(); if (streams != null) { Iterator<ContentStream> iter = streams.iterator();
String q = params.get( CommonParams.Q ); if( q == null || q.trim().length() <1 ) { Iterable<ContentStream> streams = req.getContentStreams(); if( streams != null ) { Iterator<ContentStream> iter = streams.iterator();
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try { ContentStreamLoader documentLoader = newLoader(req, processor); Iterable<ContentStream> streams = req.getContentStreams(); if (streams == null) { if (!RequestHandlerUtils.handleCommit(processor, params, false) && !RequestHandlerUtils.handleRollback(processor, params, false)) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream"); } } else { for (ContentStream stream : streams) { documentLoader.load(req, rsp, stream); } // Perhaps commit from the parameters RequestHandlerUtils.handleCommit(processor, params, false); RequestHandlerUtils.handleRollback(processor, params, false); } } finally { // finish the request processor.finish(); } }
Iterable<ContentStream> streams = req.getContentStreams(); if(streams != null){ for (ContentStream stream : streams) {
request.setParams(new ModifiableSolrParams(parameters).set(Names.QUERY, readCommandFromIncomingStream(request.getContentStreams().iterator().next()))); requestHandler( request,