Browse files

add support for 0.10.x

  • Loading branch information...
1 parent cd8f20b commit fc8e42cd1103fb326de8ea9a76ec59456fc7bfd0 Robert Newson committed Dec 21, 2009
View
2 README.md
@@ -10,7 +10,7 @@ This branch (master) contains the development version of the next release (0.5).
<tr><th>CouchDB</th><th>couchdb-lucene</th></tr>
<tr><td>0.9.1, 0.10</td><td>0.4</td></tr>
<tr><td>0.11 (not yet released)</td><td>0.4-maint (0.4 with patch for trunk compatibility)</td></tr>
-<tr><td>0.11+</td><td>0.5 (not yet released)</td></tr>
+<tr><td>0.10+</td><td>0.5 (not yet released)</td></tr>
</table>
<h1>Issue Tracking</h1>
View
13 src/main/java/com/github/rnewson/couchdb/lucene/HttpClientFactory.java
@@ -2,7 +2,12 @@
import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
@@ -12,7 +17,7 @@
* HttpClient instances just the way we like them.
*
* @author robertnewson
- *
+ *
*/
public final class HttpClientFactory {
@@ -25,7 +30,11 @@ public static HttpClient getInstance() {
HttpConnectionParams.setTcpNoDelay(params, true);
HttpConnectionParams.setStaleCheckingEnabled(params, false);
- return new DefaultHttpClient(params);
+ final SchemeRegistry schemeRegistry = new SchemeRegistry();
+ schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 5984));
+ final ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
+
+ return new DefaultHttpClient(cm, params);
}
}
View
9 src/main/java/com/github/rnewson/couchdb/lucene/ViewIndexer.java
@@ -106,7 +106,14 @@ public Void handleResponse(final HttpResponse response) throws IOException {
break loop;
}
- final JSONObject doc = json.getJSONObject("doc");
+ final JSONObject doc;
+ if (json.has("doc")) {
+ doc = json.getJSONObject("doc");
+ } else {
+ // include_docs=true doesn't work prior to 0.11.
+ doc = database.getDocument(json.getString("id"));
+ }
+
final String id = doc.getString("_id");
if (id.equals("_design/" + Utils.getDesignDocumentName(path))) {
if (doc.optBoolean("_deleted")) {
View
2 src/main/java/com/github/rnewson/couchdb/lucene/couchdb/Couch.java
@@ -21,7 +21,7 @@
public static Couch getInstance(final HttpClient httpClient, final String url) throws IOException {
final Couch result = new Couch(httpClient, url);
final JSONObject info = result.getInfo();
- if (info.getString("version").compareTo("0.11") < 0) {
+ if (info.getString("version").compareTo("0.10") < 0) {
throw new IllegalStateException("Incompatible version found: " + info);
}
return result;

0 comments on commit fc8e42c

Please sign in to comment.