incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r946090 - in /incubator/lcf/trunk/modules/connectors/solr: connector/org/apache/lcf/agents/output/solr/HttpPoster.java connector/org/apache/lcf/agents/output/solr/SolrConnector.java crawler-ui/output/solr/editconfig.jsp
Date Wed, 19 May 2010 09:08:45 GMT
Author: kwright
Date: Wed May 19 09:08:45 2010
New Revision: 946090

URL: http://svn.apache.org/viewvc?rev=946090&view=rev
Log:
Fix for ticket CONNECTORS-36.  Revamp the Solr connector argument handling to be completely
general.

Modified:
    incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
    incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
    incubator/lcf/trunk/modules/connectors/solr/crawler-ui/output/solr/editconfig.jsp

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java?rev=946090&r1=946089&r2=946090&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
(original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
Wed May 19 09:08:45 2010
@@ -164,7 +164,7 @@ public class HttpPoster
   * Post the input stream to ingest
   * @param documentURI is the document's uri.
   * @param document is the document structure to ingest.
-  * @param arguments are the configuration arguments to pass in the post.
+  * @param arguments are the configuration arguments to pass in the post.  Key is argument
name, value is a list of the argument values.
   * @param authorityNameString is the name of the governing authority for this document's
acls, or null if none.
   * @param activities is the activities object, so we can report what's happening.
   * @return true if the ingestion was successful, or false if the ingestion is illegal.
@@ -893,9 +893,6 @@ public class HttpPoster
 
       try
       {
-        // Build the URL in question.
-        // MHL
-
         // Do the operation!
         long fullStartTime = System.currentTimeMillis();
 
@@ -944,8 +941,13 @@ public class HttpPoster
                 while (iter.hasNext())
                 {
                   String name = (String)iter.next();
-                  String value = (String)arguments.get(name);
-                  totalLength += lengthField(name,value);
+                  List values = (List)arguments.get(name);
+                  int j = 0;
+                  while (j < values.size())
+                  {
+                    String value = (String)values.get(j++);
+                    totalLength += lengthField(name,value);
+                  }
                 }
                 // Count the metadata.
                 iter = document.getFields();
@@ -994,8 +996,13 @@ public class HttpPoster
                 while (iter.hasNext())
                 {
                   String name = (String)iter.next();
-                  String value = (String)arguments.get(name);
-                  writeField(out,name,value);
+                  List values = (List)arguments.get(name);
+                  int j = 0;
+                  while (j < values.size())
+                  {
+                    String value = (String)values.get(j++);
+                    writeField(out,name,value);
+                  }
                 }
 
                 // Write the metadata, each in a field by itself

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java?rev=946090&r1=946089&r2=946090&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
(original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
Wed May 19 09:08:45 2010
@@ -174,7 +174,16 @@ public class SolrConnector extends org.a
     {
       ConfigNode node = params.getChild(i++);
       if (node.getType().equals(SolrConfig.NODE_ARGUMENT))
-        args.put(node.getAttributeValue(SolrConfig.ATTRIBUTE_NAME),node.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE));
+      {
+        String attrName = node.getAttributeValue(SolrConfig.ATTRIBUTE_NAME);
+        ArrayList list = (ArrayList)args.get(attrName);
+        if (list == null)
+        {
+          list = new ArrayList();
+          args.put(attrName,list);
+        }
+        list.add(node.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE));
+      }
     }
     
     String[] sortArray = new String[args.size()];
@@ -194,12 +203,17 @@ public class SolrConnector extends org.a
     while (i < sortArray.length)
     {
       String name = sortArray[i++];
-      String value = (String)args.get(name);
-      fixedList[0] = name;
-      fixedList[1] = value;
-      StringBuffer pairBuffer = new StringBuffer();
-      packFixedList(pairBuffer,fixedList,'=');
-      nameValues.add(pairBuffer.toString());
+      ArrayList values = (ArrayList)args.get(name);
+      int j = 0;
+      while (j < values.size())
+      {
+        String value = (String)values.get(j++);
+        fixedList[0] = name;
+        fixedList[1] = value;
+        StringBuffer pairBuffer = new StringBuffer();
+        packFixedList(pairBuffer,fixedList,'=');
+        nameValues.add(pairBuffer.toString());
+      }
     }
     
     StringBuffer sb = new StringBuffer();
@@ -233,7 +247,16 @@ public class SolrConnector extends org.a
     {
       ConfigNode node = params.getChild(i++);
       if (node.getType().equals(SolrConfig.NODE_ARGUMENT))
-        args.put(node.getAttributeValue(SolrConfig.ATTRIBUTE_NAME),node.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE));
+      {
+        String attrName = node.getAttributeValue(SolrConfig.ATTRIBUTE_NAME);
+        ArrayList list = (ArrayList)args.get(attrName);
+        if (list == null)
+        {
+          list = new ArrayList();
+          args.put(attrName,list);
+        }
+        list.add(node.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE));
+      }
     }
 
     // Establish a session

Modified: incubator/lcf/trunk/modules/connectors/solr/crawler-ui/output/solr/editconfig.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/crawler-ui/output/solr/editconfig.jsp?rev=946090&r1=946089&r2=946090&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/crawler-ui/output/solr/editconfig.jsp (original)
+++ incubator/lcf/trunk/modules/connectors/solr/crawler-ui/output/solr/editconfig.jsp Wed
May 19 09:08:45 2010
@@ -178,7 +178,13 @@
 		{
 			String name = sn.getAttributeValue(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_NAME);
 			String value = sn.getAttributeValue(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_VALUE);
-			argumentMap.put(name,value);
+			ArrayList values = (ArrayList)argumentMap.get(name);
+			if (values == null)
+			{
+				values = new ArrayList();
+				argumentMap.put(name,values);
+			}
+			values.add(value);
 		}
 	}
 	// "Arguments" tab
@@ -207,29 +213,34 @@
 				</tr>
 <%
 		i = 0;
-		while (i < sortArray.length)
+		int k = 0;
+		while (k < sortArray.length)
 		{
-			String name = sortArray[i];
-			String value = (String)argumentMap.get(name);
-			// It's prefix will be...
-			String prefix = "argument_" + Integer.toString(i);
+			String name = sortArray[k++];
+			ArrayList values = (ArrayList)argumentMap.get(name);
+			int j = 0;
+			while (j < values.size())
+			{
+				String value = (String)values.get(j++);
+				// Its prefix will be...
+				String prefix = "argument_" + Integer.toString(i);
 %>
 				<tr class='<%=((i % 2)==0)?"evenformrow":"oddformrow"%>'>
 					<td class="formcolumncell">
 						<a name='<%=prefix%>'><input type="button" value="Delete" alt='<%="Delete
argument #"+Integer.toString(i+1)%>' onclick='<%="javascript:deleteArgument("+Integer.toString(i)+");"%>'/>
 						<input type="hidden" name='<%=prefix+"_op"%>' value="Continue"/>
 						<input type="hidden" name='<%=prefix+"_name"%>' value='<%=org.apache.lcf.ui.util.Encoder.attributeEscape(name)%>'/>
-						<input type="hidden" name='<%=prefix+"_value"%>' value='<%=org.apache.lcf.ui.util.Encoder.attributeEscape(value)%>'/>
 					</td>
 					<td class="formcolumncell">
 						<nobr><%=org.apache.lcf.ui.util.Encoder.bodyEscape(name)%></nobr>
 					</td>
 					<td class="formcolumncell">
-						<nobr><%=org.apache.lcf.ui.util.Encoder.bodyEscape(value)%></nobr>
+						<nobr><input type="text" size="30" name='<%=prefix+"_value"%>' value='<%=org.apache.lcf.ui.util.Encoder.attributeEscape(value)%>'</nobr>
 					</td>
 				</tr>
 <%
-			i++;
+				i++;
+			}
 		}
 		if (i == 0)
 		{
@@ -266,13 +277,19 @@
 		while (iter.hasNext())
 		{
 			String name = (String)iter.next();
-			String value = (String)argumentMap.get(name);
-			// It's prefix will be...
-			String prefix = "argument_" + Integer.toString(i++);
+			ArrayList values = (ArrayList)argumentMap.get(name);
+			int j = 0;
+			while (j < values.size())
+			{
+				String value = (String)values.get(j++);
+				// It's prefix will be...
+				String prefix = "argument_" + Integer.toString(i++);
 %>
 <input type="hidden" name='<%=prefix+"_name"%>' value='<%=org.apache.lcf.ui.util.Encoder.attributeEscape(name)%>'/>
 <input type="hidden" name='<%=prefix+"_value"%>' value='<%=org.apache.lcf.ui.util.Encoder.attributeEscape(value)%>'/>
 <%
+
+			}
 		}
 %>
 <input type="hidden" name="argument_count" value='<%=i%>'/>



Mime
View raw message