Merge changes from old CONNECTORS-674 branch

git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/branches/CONNECTORS-674-2@1554202 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
index 5af995c..2d7306f 100644
--- a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
+++ b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
@@ -159,7 +159,7 @@
     
     try
     {
-      CloudSolrServer cloudSolrServer = new CloudSolrServer(zookeeperHosts, new ModifiedLBHttpSolrServer(HttpClientUtil.createClient(null)));
+      CloudSolrServer cloudSolrServer = new CloudSolrServer(zookeeperHosts/*, new ModifiedLBHttpSolrServer(HttpClientUtil.createClient(null))*/);
       cloudSolrServer.setZkClientTimeout(zkClientTimeout);
       cloudSolrServer.setZkConnectTimeout(zkConnectTimeout);
       cloudSolrServer.setDefaultCollection(collection);
@@ -270,7 +270,8 @@
     }
 
     String httpSolrServerUrl = protocol + "://" + server + ":" + port + location;
-    HttpSolrServer httpSolrServer = new ModifiedHttpSolrServer(httpSolrServerUrl, localClient, new XMLResponseParser());
+    HttpSolrServer httpSolrServer = new HttpSolrServer(httpSolrServerUrl, localClient, new XMLResponseParser());
+    httpSolrServer.setUseMultiPartPost(true);
     // Set the solrj instance we want to use
     solrServer = httpSolrServer;
   }
diff --git a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpMultipart.java b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpMultipart.java
deleted file mode 100644
index 2f97323..0000000
--- a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpMultipart.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.manifoldcf.agents.output.solr;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.entity.mime.content.ContentBody;
-import org.apache.http.entity.mime.MinimalField;
-import org.apache.http.entity.mime.FormBodyPart;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MIME;
-import org.apache.http.entity.mime.Header;
-import org.apache.http.util.ByteArrayBuffer;
-
-/**
- * HttpMultipart represents a collection of MIME multipart encoded content bodies. This class is
- * capable of operating either in the strict (RFC 822, RFC 2045, RFC 2046 compliant) or
- * the browser compatible modes.
- *
- * @since 4.0
- */
-public class ModifiedHttpMultipart {
-
-    private static ByteArrayBuffer encode(
-            final Charset charset, final String string) {
-        ByteBuffer encoded = charset.encode(CharBuffer.wrap(string));
-        ByteArrayBuffer bab = new ByteArrayBuffer(encoded.remaining());
-        bab.append(encoded.array(), encoded.position(), encoded.remaining());
-        return bab;
-    }
-
-    private static void writeBytes(
-            final ByteArrayBuffer b, final OutputStream out) throws IOException {
-        out.write(b.buffer(), 0, b.length());
-    }
-
-    private static void writeBytes(
-            final String s, final Charset charset, final OutputStream out) throws IOException {
-        ByteArrayBuffer b = encode(charset, s);
-        writeBytes(b, out);
-    }
-
-    private static void writeBytes(
-            final String s, final OutputStream out) throws IOException {
-        ByteArrayBuffer b = encode(MIME.DEFAULT_CHARSET, s);
-        writeBytes(b, out);
-    }
-
-    private static void writeField(
-            final MinimalField field, final OutputStream out) throws IOException {
-        writeBytes(field.getName(), out);
-        writeBytes(FIELD_SEP, out);
-        writeBytes(field.getBody(), out);
-        writeBytes(CR_LF, out);
-    }
-
-    private static void writeField(
-            final MinimalField field, final Charset charset, final OutputStream out) throws IOException {
-        writeBytes(field.getName(), charset, out);
-        writeBytes(FIELD_SEP, out);
-        writeBytes(field.getBody(), charset, out);
-        writeBytes(CR_LF, out);
-    }
-
-    private static final ByteArrayBuffer FIELD_SEP = encode(MIME.DEFAULT_CHARSET, ": ");
-    private static final ByteArrayBuffer CR_LF = encode(MIME.DEFAULT_CHARSET, "\r\n");
-    private static final ByteArrayBuffer TWO_DASHES = encode(MIME.DEFAULT_CHARSET, "--");
-
-
-    private final String subType;
-    private final Charset charset;
-    private final String boundary;
-    private final List<FormBodyPart> parts;
-
-    private final HttpMultipartMode mode;
-
-    /**
-     * Creates an instance with the specified settings.
-     *
-     * @param subType mime subtype - must not be {@code null}
-     * @param charset the character set to use. May be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
-     * @param boundary to use  - must not be {@code null}
-     * @param mode the mode to use
-     * @throws IllegalArgumentException if charset is null or boundary is null
-     */
-    public ModifiedHttpMultipart(final String subType, final Charset charset, final String boundary, HttpMultipartMode mode) {
-        super();
-        if (subType == null) {
-            throw new IllegalArgumentException("Multipart subtype may not be null");
-        }
-        if (boundary == null) {
-            throw new IllegalArgumentException("Multipart boundary may not be null");
-        }
-        this.subType = subType;
-        this.charset = charset != null ? charset : MIME.DEFAULT_CHARSET;
-        this.boundary = boundary;
-        this.parts = new ArrayList<FormBodyPart>();
-        this.mode = mode;
-    }
-
-    /**
-     * Creates an instance with the specified settings.
-     * Mode is set to {@link HttpMultipartMode#STRICT}
-     *
-     * @param subType mime subtype - must not be {@code null}
-     * @param charset the character set to use. May be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
-     * @param boundary to use  - must not be {@code null}
-     * @throws IllegalArgumentException if charset is null or boundary is null
-     */
-    public ModifiedHttpMultipart(final String subType, final Charset charset, final String boundary) {
-        this(subType, charset, boundary, HttpMultipartMode.STRICT);
-    }
-
-    public ModifiedHttpMultipart(final String subType, final String boundary) {
-        this(subType, null, boundary);
-    }
-
-    public String getSubType() {
-        return this.subType;
-    }
-
-    public Charset getCharset() {
-        return this.charset;
-    }
-
-    public HttpMultipartMode getMode() {
-        return this.mode;
-    }
-
-    public List<FormBodyPart> getBodyParts() {
-        return this.parts;
-    }
-
-    public void addBodyPart(final FormBodyPart part) {
-        if (part == null) {
-            return;
-        }
-        this.parts.add(part);
-    }
-
-    public String getBoundary() {
-        return this.boundary;
-    }
-
-    private void doWriteTo(
-        final HttpMultipartMode mode,
-        final OutputStream out,
-        boolean writeContent) throws IOException {
-
-        ByteArrayBuffer boundary = encode(this.charset, getBoundary());
-        for (FormBodyPart part: this.parts) {
-            writeBytes(TWO_DASHES, out);
-            writeBytes(boundary, out);
-            writeBytes(CR_LF, out);
-
-            Header header = part.getHeader();
-
-            switch (mode) {
-            case STRICT:
-                for (MinimalField field: header) {
-                    writeField(field, this.charset, out);
-                }
-                break;
-            case BROWSER_COMPATIBLE:
-                // Only write Content-Disposition
-                // Use content charset
-                MinimalField cd = part.getHeader().getField(MIME.CONTENT_DISPOSITION);
-                writeField(cd, this.charset, out);
-                String filename = part.getBody().getFilename();
-                if (filename != null) {
-                    MinimalField ct = part.getHeader().getField(MIME.CONTENT_TYPE);
-                    writeField(ct, this.charset, out);
-                }
-                break;
-            }
-            writeBytes(CR_LF, out);
-
-            if (writeContent) {
-                part.getBody().writeTo(out);
-            }
-            writeBytes(CR_LF, out);
-        }
-        writeBytes(TWO_DASHES, out);
-        writeBytes(boundary, out);
-        writeBytes(TWO_DASHES, out);
-        writeBytes(CR_LF, out);
-    }
-
-    /**
-     * Writes out the content in the multipart/form encoding. This method
-     * produces slightly different formatting depending on its compatibility
-     * mode.
-     *
-     * @see #getMode()
-     */
-    public void writeTo(final OutputStream out) throws IOException {
-        doWriteTo(this.mode, out, true);
-    }
-
-    /**
-     * Determines the total length of the multipart content (content length of
-     * individual parts plus that of extra elements required to delimit the parts
-     * from one another). If any of the @{link BodyPart}s contained in this object
-     * is of a streaming entity of unknown length the total length is also unknown.
-     * <p/>
-     * This method buffers only a small amount of data in order to determine the
-     * total length of the entire entity. The content of individual parts is not
-     * buffered.
-     *
-     * @return total length of the multipart entity if known, <code>-1</code>
-     *   otherwise.
-     */
-    public long getTotalLength() {
-        long contentLen = 0;
-        for (FormBodyPart part: this.parts) {
-            ContentBody body = part.getBody();
-            long len = body.getContentLength();
-            if (len >= 0) {
-                contentLen += len;
-            } else {
-                return -1;
-            }
-        }
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        try {
-            doWriteTo(this.mode, out, false);
-            byte[] extra = out.toByteArray();
-            return contentLen + extra.length;
-        } catch (IOException ex) {
-            // Should never happen
-            return -1;
-        }
-    }
-
-}
diff --git a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java
deleted file mode 100644
index fa0a8ca..0000000
--- a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.manifoldcf.agents.output.solr;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.ConnectException;
-import java.net.SocketTimeoutException;
-import java.nio.charset.Charset;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.NoHttpResponseException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.mime.FormBodyPart;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.content.InputStreamBody;
-import org.apache.http.entity.mime.content.StringBody;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.request.RequestWriter;
-import org.apache.solr.client.solrj.request.UpdateRequest;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.client.solrj.util.ClientUtils;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.ContentStream;
-import org.apache.solr.common.util.NamedList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.nio.charset.Charset;
-
-/** This class overrides and somewhat changes the behavior of the
-* SolrJ HttpSolrServer class.  The point of all this is simply to get
-* the right information to Tika.  When SolrJ uses GET or POST but not
-* multipart-post, it does not include multipart headers that Tika uses -
-* specifically, the name of the document and the length of the document.
-* Patches have been submitted to the SOLR ticket queue to address this
-* problem in a method-insensitive way, but so far there has been no sign that
-* the Solr team is interested in committing them.
-*/
-public class ModifiedHttpSolrServer extends HttpSolrServer
-{
-  // Here we duplicate all the private fields we need
-  
-  private static final String UTF_8 = "UTF-8";
-  private static final String DEFAULT_PATH = "/select";
-
-  private static Charset UTF8_CHARSET;
-  static
-  {
-    try
-    {
-      UTF8_CHARSET = Charset.forName(UTF_8);
-    }
-    catch (Exception e)
-    {
-      e.printStackTrace();
-      System.exit(-100);
-      UTF8_CHARSET = null;
-    }
-  }
-  
-  private final HttpClient httpClient;
-  private boolean followRedirects = false;
-  private int maxRetries = 0;
-  private boolean useMultiPartPost = true;
-
-  public ModifiedHttpSolrServer(String baseURL, HttpClient client, ResponseParser parser) {
-    super(baseURL, client, parser);
-    httpClient = client;
-  }
-  
-  @Override
-  public NamedList<Object> request(final SolrRequest request,
-      final ResponseParser processor) throws SolrServerException, IOException {
-    HttpRequestBase method = null;
-    InputStream is = null;
-    SolrParams params = request.getParams();
-    Collection<ContentStream> streams = requestWriter.getContentStreams(request);
-    String path = requestWriter.getPath(request);
-    if (path == null || !path.startsWith("/")) {
-      path = DEFAULT_PATH;
-    }
-    
-    ResponseParser parser = request.getResponseParser();
-    if (parser == null) {
-      parser = this.parser;
-    }
-    
-    // The parser 'wt=' and 'version=' params are used instead of the original
-    // params
-    ModifiableSolrParams wparams = new ModifiableSolrParams(params);
-    if (parser != null) {
-      wparams.set(CommonParams.WT, parser.getWriterType());
-      wparams.set(CommonParams.VERSION, parser.getVersion());
-    }
-    if (invariantParams != null) {
-      wparams.add(invariantParams);
-    }
-    params = wparams;
-    
-    int tries = maxRetries + 1;
-    try {
-      while( tries-- > 0 ) {
-        // Note: since we aren't do intermittent time keeping
-        // ourselves, the potential non-timeout latency could be as
-        // much as tries-times (plus scheduling effects) the given
-        // timeAllowed.
-        try {
-          if( SolrRequest.METHOD.GET == request.getMethod() ) {
-            if( streams != null ) {
-              throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "GET can't send streams!" );
-            }
-            method = new HttpGet( baseUrl + path + ClientUtils.toQueryString( params, false ) );
-          }
-          else if( SolrRequest.METHOD.POST == request.getMethod() ) {
-
-            String url = baseUrl + path;
-            boolean hasNullStreamName = false;
-            if (streams != null) {
-              for (ContentStream cs : streams) {
-                if (cs.getName() == null) {
-                  hasNullStreamName = true;
-                  break;
-                }
-              }
-            }
-            boolean isMultipart = (this.useMultiPartPost || ( streams != null && streams.size() > 1 )) && !hasNullStreamName;
-            
-            LinkedList<NameValuePair> postParams = new LinkedList<NameValuePair>();
-            if (streams == null || isMultipart) {
-              HttpPost post = new HttpPost(url);
-              post.setHeader("Content-Charset", "UTF-8");
-              if (!isMultipart) {
-                post.addHeader("Content-Type",
-                    "application/x-www-form-urlencoded; charset=UTF-8");
-              }
-
-              List<FormBodyPart> parts = new LinkedList<FormBodyPart>();
-              Iterator<String> iter = params.getParameterNamesIterator();
-              while (iter.hasNext()) {
-                String p = iter.next();
-                String[] vals = params.getParams(p);
-                if (vals != null) {
-                  for (String v : vals) {
-                    if (isMultipart) {
-                      parts.add(new FormBodyPart(p, new StringBody(v, Charset.forName("UTF-8"))));
-                    } else {
-                      postParams.add(new BasicNameValuePair(p, v));
-                    }
-                  }
-                }
-              }
-
-              if (isMultipart && streams != null) {
-                for (ContentStream content : streams) {
-                  String contentType = content.getContentType();
-                  if(contentType==null) {
-                    contentType = "application/octet-stream"; // default
-                  }
-                  String contentName = content.getName();
-                  parts.add(new FormBodyPart(contentName, 
-                       new InputStreamBody(
-                           content.getStream(), 
-                           contentType, 
-                           content.getName())));
-                }
-              }
-              
-              if (parts.size() > 0) {
-                ModifiedMultipartEntity entity = new ModifiedMultipartEntity(HttpMultipartMode.STRICT, null, UTF8_CHARSET);
-                for(FormBodyPart p: parts) {
-                  entity.addPart(p);
-                }
-                post.setEntity(entity);
-              } else {
-                //not using multipart
-                post.setEntity(new UrlEncodedFormEntity(postParams, "UTF-8"));
-              }
-
-              method = post;
-            }
-            // It is has one stream, it is the post body, put the params in the URL
-            else {
-              String pstr = ClientUtils.toQueryString(params, false);
-              HttpPost post = new HttpPost(url + pstr);
-
-              // Single stream as body
-              // Using a loop just to get the first one
-              final ContentStream[] contentStream = new ContentStream[1];
-              for (ContentStream content : streams) {
-                contentStream[0] = content;
-                break;
-              }
-              if (contentStream[0] instanceof RequestWriter.LazyContentStream) {
-                post.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
-                  @Override
-                  public Header getContentType() {
-                    return new BasicHeader("Content-Type", contentStream[0].getContentType());
-                  }
-                  
-                  @Override
-                  public boolean isRepeatable() {
-                    return false;
-                  }
-                  
-                });
-              } else {
-                post.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
-                  @Override
-                  public Header getContentType() {
-                    return new BasicHeader("Content-Type", contentStream[0].getContentType());
-                  }
-                  
-                  @Override
-                  public boolean isRepeatable() {
-                    return false;
-                  }
-                });
-              }
-              method = post;
-            }
-          }
-          else {
-            throw new SolrServerException("Unsupported method: "+request.getMethod() );
-          }
-        }
-        catch( NoHttpResponseException r ) {
-          method = null;
-          if(is != null) {
-            is.close();
-          }
-          // If out of tries then just rethrow (as normal error).
-          if (tries < 1) {
-            throw r;
-          }
-        }
-      }
-    } catch (IOException ex) {
-      throw new SolrServerException("error reading streams", ex);
-    }
-    
-    // XXX client already has this set, is this needed?
-    method.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
-        followRedirects);
-    method.addHeader("User-Agent", AGENT);
-    
-    InputStream respBody = null;
-    boolean shouldClose = true;
-    
-    try {
-      // Execute the method.
-      final HttpResponse response = httpClient.execute(method);
-      int httpStatus = response.getStatusLine().getStatusCode();
-      
-      // Read the contents
-      respBody = response.getEntity().getContent();
-      
-      // handle some http level checks before trying to parse the response
-      switch (httpStatus) {
-        case HttpStatus.SC_OK:
-        case HttpStatus.SC_BAD_REQUEST:
-        case HttpStatus.SC_CONFLICT:  // 409
-          break;
-        case HttpStatus.SC_MOVED_PERMANENTLY:
-        case HttpStatus.SC_MOVED_TEMPORARILY:
-          if (!followRedirects) {
-            throw new SolrServerException("Server at " + getBaseURL()
-                + " sent back a redirect (" + httpStatus + ").");
-          }
-          break;
-        default:
-          throw new SolrException(SolrException.ErrorCode.getErrorCode(httpStatus), "Server at " + getBaseURL()
-              + " returned non ok status:" + httpStatus + ", message:"
-              + response.getStatusLine().getReasonPhrase());
-          
-      }
-      if (processor == null) {
-        // no processor specified, return raw stream
-        NamedList<Object> rsp = new NamedList<Object>();
-        rsp.add("stream", respBody);
-        // Only case where stream should not be closed
-        shouldClose = false;
-        return rsp;
-      }
-      String charset = EntityUtils.getContentCharSet(response.getEntity());
-      NamedList<Object> rsp = processor.processResponse(respBody, charset);
-      if (httpStatus != HttpStatus.SC_OK) {
-        String reason = null;
-        try {
-          NamedList err = (NamedList) rsp.get("error");
-          if (err != null) {
-            reason = (String) err.get("msg");
-            // TODO? get the trace?
-          }
-        } catch (Exception ex) {}
-        if (reason == null) {
-          StringBuilder msg = new StringBuilder();
-          msg.append(response.getStatusLine().getReasonPhrase());
-          msg.append("\n\n");
-          msg.append("request: " + method.getURI());
-          reason = java.net.URLDecoder.decode(msg.toString(), UTF_8);
-        }
-        throw new SolrException(
-            SolrException.ErrorCode.getErrorCode(httpStatus), reason);
-      }
-      return rsp;
-    } catch (ConnectException e) {
-      throw new SolrServerException("Server refused connection at: "
-          + getBaseURL(), e);
-    } catch (SocketTimeoutException e) {
-      throw new SolrServerException(
-          "Timeout occured while waiting response from server at: "
-              + getBaseURL(), e);
-    } catch (IOException e) {
-      throw new SolrServerException(
-          "IOException occured when talking to server at: " + getBaseURL(), e);
-    } finally {
-      if (respBody != null && shouldClose) {
-        try {
-          respBody.close();
-        } catch (Throwable t) {} // ignore
-      }
-    }
-  }
-
-  @Override
-  public void setFollowRedirects(boolean followRedirects) {
-    super.setFollowRedirects(followRedirects);
-    this.followRedirects = followRedirects;
-  }
-
-}
diff --git a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedLBHttpSolrServer.java b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedLBHttpSolrServer.java
deleted file mode 100644
index a8b728f..0000000
--- a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedLBHttpSolrServer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.manifoldcf.agents.output.solr;
-
-import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.client.solrj.impl.BinaryResponseParser;
-import org.apache.solr.client.solrj.*;
-import java.net.MalformedURLException;
-import org.apache.http.client.HttpClient;
-
-
-/** This class overrides and somewhat changes the behavior of the
-* SolrJ LBHttpSolrServer class.  This is so it instantiates our modified
-* HttpSolrServer class, so that multipart forms work.
-*/
-public class ModifiedLBHttpSolrServer extends LBHttpSolrServer
-{
-  private final HttpClient httpClient;
-  private final ResponseParser parser;
-  
-  public ModifiedLBHttpSolrServer(String... solrServerUrls) throws MalformedURLException {
-    this(null, solrServerUrls);
-  }
-  
-  /** The provided httpClient should use a multi-threaded connection manager */ 
-  public ModifiedLBHttpSolrServer(HttpClient httpClient, String... solrServerUrl)
-          throws MalformedURLException {
-    this(httpClient, new BinaryResponseParser(), solrServerUrl);
-  }
-
-  /** The provided httpClient should use a multi-threaded connection manager */  
-  public ModifiedLBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl)
-          throws MalformedURLException {
-    super(httpClient, parser, solrServerUrl);
-    this.httpClient = httpClient;
-    this.parser = parser;
-  }
-  
-  @Override
-  protected HttpSolrServer makeServer(String server) throws MalformedURLException {
-    return new ModifiedHttpSolrServer(server, httpClient, parser);
-  }
-
-}
diff --git a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedMultipartEntity.java b/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedMultipartEntity.java
deleted file mode 100644
index f14243d..0000000
--- a/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedMultipartEntity.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.manifoldcf.agents.output.solr;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-import java.util.Random;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.mime.content.ContentBody;
-import org.apache.http.entity.mime.FormBodyPart;
-import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MIME;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Multipart/form coded HTTP entity consisting of multiple body parts.
- *
- * @since 4.0
- */
-public class ModifiedMultipartEntity implements HttpEntity {
-
-    /**
-     * The pool of ASCII chars to be used for generating a multipart boundary.
-     */
-    private final static char[] MULTIPART_CHARS =
-        "-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-            .toCharArray();
-
-    private final ModifiedHttpMultipart multipart;
-    private final Header contentType;
-
-    // @GuardedBy("dirty") // we always read dirty before accessing length
-    private long length;
-    private volatile boolean dirty; // used to decide whether to recalculate length
-
-    /**
-     * Creates an instance using the specified parameters
-     * @param mode the mode to use, may be {@code null}, in which case {@link HttpMultipartMode#STRICT} is used
-     * @param boundary the boundary string, may be {@code null}, in which case {@link #generateBoundary()} is invoked to create the string
-     * @param charset the character set to use, may be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
-     */
-    public ModifiedMultipartEntity(
-            HttpMultipartMode mode,
-            String boundary,
-            Charset charset) {
-        super();
-        if (boundary == null) {
-            boundary = generateBoundary();
-        }
-        if (mode == null) {
-            mode = HttpMultipartMode.STRICT;
-        }
-        this.multipart = new ModifiedHttpMultipart("form-data", charset, boundary, mode);
-        this.contentType = new BasicHeader(
-                HTTP.CONTENT_TYPE,
-                generateContentType(boundary, charset));
-        this.dirty = true;
-    }
-
-    /**
-     * Creates an instance using the specified {@link HttpMultipartMode} mode.
-     * Boundary and charset are set to {@code null}.
-     * @param mode the desired mode
-     */
-    public ModifiedMultipartEntity(final HttpMultipartMode mode) {
-        this(mode, null, null);
-    }
-
-    /**
-     * Creates an instance using mode {@link HttpMultipartMode#STRICT}
-     */
-    public ModifiedMultipartEntity() {
-        this(HttpMultipartMode.STRICT, null, null);
-    }
-
-    protected String generateContentType(
-            final String boundary,
-            final Charset charset) {
-        StringBuilder buffer = new StringBuilder();
-        buffer.append("multipart/form-data; boundary=");
-        buffer.append(boundary);
-        if (charset != null) {
-            buffer.append("; charset=");
-            buffer.append(charset.name());
-        }
-        return buffer.toString();
-    }
-
-    protected String generateBoundary() {
-        StringBuilder buffer = new StringBuilder();
-        Random rand = new Random();
-        int count = rand.nextInt(11) + 30; // a random size from 30 to 40
-        for (int i = 0; i < count; i++) {
-            buffer.append(MULTIPART_CHARS[rand.nextInt(MULTIPART_CHARS.length)]);
-        }
-        return buffer.toString();
-    }
-
-    public void addPart(final FormBodyPart bodyPart) {
-        this.multipart.addBodyPart(bodyPart);
-        this.dirty = true;
-    }
-
-    public void addPart(final String name, final ContentBody contentBody) {
-        addPart(new FormBodyPart(name, contentBody));
-    }
-
-    public boolean isRepeatable() {
-        for (FormBodyPart part: this.multipart.getBodyParts()) {
-            ContentBody body = part.getBody();
-            if (body.getContentLength() < 0) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public boolean isChunked() {
-        return !isRepeatable();
-    }
-
-    public boolean isStreaming() {
-        return !isRepeatable();
-    }
-
-    public long getContentLength() {
-        if (this.dirty) {
-            this.length = this.multipart.getTotalLength();
-            this.dirty = false;
-        }
-        return this.length;
-    }
-
-    public Header getContentType() {
-        return this.contentType;
-    }
-
-    public Header getContentEncoding() {
-        return null;
-    }
-
-    public void consumeContent()
-        throws IOException, UnsupportedOperationException{
-        if (isStreaming()) {
-            throw new UnsupportedOperationException(
-                    "Streaming entity does not implement #consumeContent()");
-        }
-    }
-
-    public InputStream getContent() throws IOException, UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                    "Multipart form entity does not implement #getContent()");
-    }
-
-    public void writeTo(final OutputStream outstream) throws IOException {
-        this.multipart.writeTo(outstream);
-    }
-
-}