From 2504985445bcd0e81e478a577018edfe6912ff57 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sat, 14 Jan 2012 15:21:42 +0000 Subject: [PATCH] SOLR-3036: Ability to specify overwrite=false on the URL for XML updates. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1231514 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 5 +++++ solr/core/src/java/org/apache/solr/handler/XMLLoader.java | 1 + .../apache/solr/handler/XmlUpdateRequestHandlerTest.java | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 250b191f110..1e25fbab718 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -427,6 +427,10 @@ New Features * SOLR-2906: Added LFU cache options to Solr. (Shawn Heisey via Erick Erickson) +* SOLR-3036: Ability to specify overwrite=false on the URL for XML updates. + (Sami Siren via yonik) + + Optimizations ---------------------- * SOLR-1931: Speedup for LukeRequestHandler and admin/schema browser. New parameter @@ -436,6 +440,7 @@ Optimizations * SOLR-3012: Move System.getProperty("type") in postData() to main() and add type argument so that the client applications of SimplePostTool can set content type via method argument. (koji) + Bug Fixes ---------------------- * SOLR-2912: Fixed File descriptor leak in ShowFileRequestHandler (Michael Ryan, shalin) diff --git a/solr/core/src/java/org/apache/solr/handler/XMLLoader.java b/solr/core/src/java/org/apache/solr/handler/XMLLoader.java index 59817acdbc0..7102f093f32 100644 --- a/solr/core/src/java/org/apache/solr/handler/XMLLoader.java +++ b/solr/core/src/java/org/apache/solr/handler/XMLLoader.java @@ -112,6 +112,7 @@ class XMLLoader extends ContentStreamLoader { // First look for commitWithin parameter on the request, will be overwritten for individual 's addCmd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1); + addCmd.overwrite = params.getBool(UpdateParams.OVERWRITE, true); for (int i = 0; i < parser.getAttributeCount(); i++) { String attrName = parser.getAttributeLocalName(i); diff --git a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java index 51fd7d02ea5..086912ca5c9 100644 --- a/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/XmlUpdateRequestHandlerTest.java @@ -80,7 +80,7 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { } @Test - public void testCommitWithin() throws Exception + public void testRequestParams() throws Exception { String xml = "" + @@ -90,7 +90,7 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { " " + ""; - SolrQueryRequest req = req("commitWithin","100"); + SolrQueryRequest req = req("commitWithin","100","overwrite","false"); SolrQueryResponse rsp = new SolrQueryResponse(); BufferingRequestProcessor p = new BufferingRequestProcessor(null); @@ -98,8 +98,8 @@ public class XmlUpdateRequestHandlerTest extends SolrTestCaseJ4 { loader.load(req, rsp, new ContentStreamBase.StringStream(xml)); AddUpdateCommand add = p.addCommands.get(0); - assertEquals(add.commitWithin, 100); - + assertEquals(100, add.commitWithin); + assertEquals(false, add.overwrite); req.close(); }