[ 
https://issues.apache.org/jira/browse/CONNECTORS-674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13633885#comment-13633885
 ] 

Karl Wright commented on CONNECTORS-674:
----------------------------------------

Hi Ryan,

I've looked at the diff of what was added to ModifiedHttpSolrServer, and the 
following was done just to make the multipart feature actually work again (it 
was broken when I turned it back on):

{code}
Index: ModifiedHttpSolrServer.java
===================================================================
--- ModifiedHttpSolrServer.java (.../trunk/connectors/solr/connector/src/main/ja
va/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrServer.java)
(revision 1446153)
+++ ModifiedHttpSolrServer.java (.../branches/CONNECTORS-674/connectors/solr/con
nector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrSe
rver.java)      (revision 1468792)
@@ -140,13 +140,22 @@
           else if( SolrRequest.METHOD.POST == request.getMethod() ) {

             String url = baseUrl + path;
-            boolean isMultipart = ( streams != null && streams.size() > 1 );
-
+            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 (!this.useMultiPartPost && !isMultipart) {
+              if (!isMultipart) {
                 post.addHeader("Content-Type",
                     "application/x-www-form-urlencoded; charset=UTF-8");
               }
@@ -158,7 +167,7 @@
                 String[] vals = params.getParams(p);
                 if (vals != null) {
                   for (String v : vals) {
-                    if (this.useMultiPartPost || isMultipart) {
+                    if (isMultipart) {
                       parts.add(new FormBodyPart(p, new StringBody(v, Charset.f
orName("UTF-8"))));
                     } else {
                       postParams.add(new BasicNameValuePair(p, v));
@@ -167,13 +176,14 @@
                 }
               }

-              if (isMultipart) {
+              if (isMultipart && streams != null) {
                 for (ContentStream content : streams) {
                   String contentType = content.getContentType();
                   if(contentType==null) {
                     contentType = "application/octet-stream"; // default
                   }
-                  parts.add(new FormBodyPart(content.getName(),
+                  String contentName = content.getName();
+                  parts.add(new FormBodyPart(contentName,
                        new InputStreamBody(
                            content.getStream(),
                            contentType,

{code}

None of these changes seem to have made it into the patch for the SOLR ticket.  
I will attach them to that ticket, though.


                
> Send metadata to Solr using multipart request
> ---------------------------------------------
>
>                 Key: CONNECTORS-674
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-674
>             Project: ManifoldCF
>          Issue Type: Improvement
>          Components: Lucene/SOLR connector
>    Affects Versions: ManifoldCF 1.3
>            Reporter: Ryan McKinley
>            Assignee: Karl Wright
>             Fix For: ManifoldCF 1.3
>
>
> In Solrj 4.3, setUserMultipartRequest is exposed.  Rather then encoding the 
> metadata in the URL string, we should send it in the request body

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to