diff --git a/.classpath b/.classpath index f930763c6..2391cf3cd 100644 --- a/.classpath +++ b/.classpath @@ -38,7 +38,6 @@ - diff --git a/addon/YaCy.app/Contents/Info.plist b/addon/YaCy.app/Contents/Info.plist index 1db3e9bc3..8254f2ce0 100644 --- a/addon/YaCy.app/Contents/Info.plist +++ b/addon/YaCy.app/Contents/Info.plist @@ -39,13 +39,12 @@ $JAVAROOT/htroot $JAVAROOT/lib/activation.jar $JAVAROOT/lib/apache-mime4j-0.6.jar - $JAVAROOT/lib/apache-solr-solrj-3.5.0.jar + $JAVAROOT/lib/apache-solr-solrj-3.6.0.jar $JAVAROOT/lib/bcmail-jdk15-145.jar $JAVAROOT/lib/bcprov-jdk15-145.jar $JAVAROOT/lib/bzip2.jar $JAVAROOT/lib/commons-codec-1.6.jar $JAVAROOT/lib/commons-fileupload-1.2.2.jar - $JAVAROOT/lib/commons-httpclient-3.1.jar $JAVAROOT/lib/commons-io-2.1.jar $JAVAROOT/lib/commons-jxpath-1.3.jar $JAVAROOT/lib/commons-logging-1.1.1.jar diff --git a/build.xml b/build.xml index 5700450c3..1085a62f4 100644 --- a/build.xml +++ b/build.xml @@ -157,13 +157,12 @@ - + - diff --git a/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1.jar deleted file mode 100644 index 7c59774ae..000000000 Binary files a/lib/commons-httpclient-3.1.jar and /dev/null differ diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java index fc1819c45..ef0e96183 100644 --- a/source/net/yacy/cora/protocol/http/HTTPClient.java +++ b/source/net/yacy/cora/protocol/http/HTTPClient.java @@ -49,7 +49,6 @@ import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.ConnectionInfo; import net.yacy.cora.protocol.HeaderFramework; -import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; @@ -64,6 +63,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.params.CookiePolicy; import org.apache.http.client.params.HttpClientParams; import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.ClientConnectionManager; @@ -178,7 +178,7 @@ public class HTTPClient { HttpConnectionParams.setTcpNoDelay(httpParams, false); // Defines whether the socket can be bound even though a previous connection is still in a timeout state. HttpConnectionParams.setSoReuseaddr(httpParams, true); - + /** * HTTP client settings */ @@ -673,14 +673,17 @@ public class HTTPClient { private static SSLSocketFactory getSSLSocketFactory() { final TrustManager trustManager = new X509TrustManager() { + @Override public void checkClientTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { } + @Override public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException { } + @Override public X509Certificate[] getAcceptedIssuers() { return null; } diff --git a/source/net/yacy/cora/services/federated/solr/SolrHTTPClient.java b/source/net/yacy/cora/services/federated/solr/SolrHTTPClient.java index e3b78039e..efc11ae82 100644 --- a/source/net/yacy/cora/services/federated/solr/SolrHTTPClient.java +++ b/source/net/yacy/cora/services/federated/solr/SolrHTTPClient.java @@ -51,7 +51,6 @@ import org.apache.solr.client.solrj.response.UpdateResponse; import org.apache.solr.client.solrj.util.ClientUtils; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; -import org.apache.solr.common.params.DefaultSolrParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.ContentStream; @@ -208,11 +207,11 @@ public class SolrHTTPClient extends SolrServer { params = wparams; } else { - params = new DefaultSolrParams( wparams, params ); + params = SolrParams.wrapDefaults(wparams, params); } if( this._invariantParams != null ) { - params = new DefaultSolrParams( this._invariantParams, params ); + params = SolrParams.wrapDefaults( this._invariantParams, params ); } @@ -599,17 +598,20 @@ public class SolrHTTPClient extends SolrServer { final UpdateRequest req = new UpdateRequest(); req.setDocIterator(new Iterator() { - public boolean hasNext() { + @Override + public boolean hasNext() { return beanIterator.hasNext(); } - public SolrInputDocument next() { + @Override + public SolrInputDocument next() { final Object o = beanIterator.next(); if (o == null) return null; return getBinder().toSolrInputDocument(o); } - public void remove() { + @Override + public void remove() { beanIterator.remove(); } }); diff --git a/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java b/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java index f23f939e6..25f02f74e 100644 --- a/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java +++ b/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java @@ -27,7 +27,6 @@ package net.yacy.cora.services.federated.solr; import java.io.File; import java.io.IOException; import java.net.InetAddress; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -42,12 +41,16 @@ import net.yacy.document.Document; import net.yacy.kelondro.data.meta.DigestURI; import net.yacy.kelondro.logging.Log; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthPolicy; -import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.http.HttpHost; +import org.apache.http.client.AuthCache; +import org.apache.http.client.HttpClient; +import org.apache.http.client.protocol.ClientContext; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.BasicAuthCache; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.protocol.HttpContext; import org.apache.solr.client.solrj.SolrQuery; -import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; +import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrDocumentList; @@ -59,7 +62,7 @@ public class SolrSingleConnector implements SolrConnector { private final String solrurl, host, solrpath, solraccount, solrpw; private final int port; - private CommonsHttpSolrServer server; + private HttpSolrServer server; private final SolrScheme scheme; private final static int transmissionQueueCount = 4; // allow concurrent http sessions to solr @@ -101,26 +104,21 @@ public class SolrSingleConnector implements SolrConnector { } } if (this.solraccount.length() > 0) { - final HttpClient client = new HttpClient(); - final AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, null, null); - client.getState().setCredentials(scope,new UsernamePasswordCredentials(this.solraccount, this.solrpw)); - final List authPrefs = new ArrayList(2); - authPrefs.add(AuthPolicy.DIGEST); - authPrefs.add(AuthPolicy.BASIC); - // This will exclude the NTLM authentication scheme - client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); - client.getParams().setAuthenticationPreemptive(true); - try { - this.server = new CommonsHttpSolrServer("http://" + this.host + ":" + this.port + this.solrpath, client); - } catch (final MalformedURLException e) { - throw new IOException("bad auth connector url: " + this.solrurl); - } + final HttpClient client = new DefaultHttpClient() { + @Override + protected HttpContext createHttpContext() { + HttpContext context = super.createHttpContext(); + AuthCache authCache = new BasicAuthCache(); + BasicScheme basicAuth = new BasicScheme(); + HttpHost targetHost = new HttpHost(u.getHost(), u.getPort(), u.getProtocol()); + authCache.put(targetHost, basicAuth); + context.setAttribute(ClientContext.AUTH_CACHE, authCache); + return context; + } + }; + this.server = new HttpSolrServer("http://" + this.host + ":" + this.port + this.solrpath, client); } else { - try { - this.server = new CommonsHttpSolrServer(this.solrurl); - } catch (final MalformedURLException e) { - throw new IOException("bad connector url: " + this.solrurl); - } + this.server = new HttpSolrServer(this.solrurl); } this.server.setDefaultMaxConnectionsPerHost( 128 ); this.server.setMaxTotalConnections( 256 );