mirror of https://github.com/apache/lucene.git
factor out commit param parsing: SOLR-185
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@524611 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
55ee8f2305
commit
32d95f5c89
|
@ -46,7 +46,10 @@ public class CSVRequestHandler extends RequestHandlerBase {
|
|||
|
||||
Iterable<ContentStream> streams = req.getContentStreams();
|
||||
if (streams == null) {
|
||||
throw new SolrException(400, "missing content stream");
|
||||
if(!RequestHandlerUtils.handleCommit(req, rsp, false)) {
|
||||
throw new SolrException( 400, "missing content stream" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for(ContentStream stream : streams) {
|
||||
|
@ -58,6 +61,9 @@ public class CSVRequestHandler extends RequestHandlerBase {
|
|||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
|
||||
// perhaps commit when we are done
|
||||
RequestHandlerUtils.handleCommit(req, rsp, false);
|
||||
}
|
||||
|
||||
//////////////////////// SolrInfoMBeans methods //////////////////////
|
||||
|
@ -94,7 +100,6 @@ abstract class CSVLoader {
|
|||
static String EMPTY="keepEmpty";
|
||||
static String SPLIT="split";
|
||||
static String ENCAPSULATOR="encapsulator";
|
||||
static String COMMIT="commit";
|
||||
static String OVERWRITE="overwrite";
|
||||
|
||||
private static Pattern colonSplit = Pattern.compile(":");
|
||||
|
@ -345,10 +350,6 @@ abstract class CSVLoader {
|
|||
|
||||
addDoc(line,vals);
|
||||
}
|
||||
|
||||
if (params.getBool(COMMIT,false)) {
|
||||
handler.commit(new CommitUpdateCommand(false));
|
||||
}
|
||||
}
|
||||
|
||||
/** called for each line of values (document) */
|
||||
|
|
|
@ -25,26 +25,21 @@ import org.apache.solr.request.SolrQueryRequest;
|
|||
import org.apache.solr.request.SolrQueryResponse;
|
||||
import org.apache.solr.update.CommitUpdateCommand;
|
||||
|
||||
/**
|
||||
* This handler could be replace with the standard XmlUpdateHandler with
|
||||
* a default parameter set to commit=true
|
||||
*
|
||||
* TODO? -- Delete it now, while it is not in mainstream use yet...
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class CommitRequestHandler extends RequestHandlerBase
|
||||
{
|
||||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException
|
||||
{
|
||||
SolrParams params = req.getParams();
|
||||
|
||||
boolean optimize = params.getBool( UpdateParams.OPTIMIZE, false );
|
||||
CommitUpdateCommand cmd = new CommitUpdateCommand( optimize );
|
||||
cmd.waitFlush = params.getBool( UpdateParams.WAIT_FLUSH, cmd.waitFlush );
|
||||
cmd.waitSearcher = params.getBool( UpdateParams.WAIT_SEARCHER, cmd.waitSearcher );
|
||||
|
||||
SolrCore.getSolrCore().getUpdateHandler().commit( cmd );
|
||||
|
||||
if( optimize ) {
|
||||
rsp.add( "optimize", "true" );
|
||||
}
|
||||
else {
|
||||
rsp.add( "commit", "true" );
|
||||
}
|
||||
// common parameters
|
||||
RequestHandlerUtils.handleCommit(req, rsp, true);
|
||||
}
|
||||
|
||||
//////////////////////// SolrInfoMBeans methods //////////////////////
|
||||
|
@ -56,16 +51,16 @@ public class CommitRequestHandler extends RequestHandlerBase
|
|||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "$Revision:$";
|
||||
return "$Revision$";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceId() {
|
||||
return "$Id:$";
|
||||
return "$Id$";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSource() {
|
||||
return "$URL:$";
|
||||
return "$URL$";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,11 @@ public class XmlUpdateRequestHandler extends RequestHandlerBase
|
|||
{
|
||||
Iterable<ContentStream> streams = req.getContentStreams();
|
||||
if( streams == null ) {
|
||||
if( !RequestHandlerUtils.handleCommit(req, rsp, false) ) {
|
||||
throw new SolrException( 400, "missing content stream" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Cycle through each stream
|
||||
for( ContentStream stream : req.getContentStreams() ) {
|
||||
|
@ -86,6 +89,9 @@ public class XmlUpdateRequestHandler extends RequestHandlerBase
|
|||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
}
|
||||
|
||||
// perhaps commit when we are done
|
||||
RequestHandlerUtils.handleCommit(req, rsp, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue