You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2010/06/16 12:18:26 UTC
svn commit: r955181 - in
/incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr: build.xml
connector/org/apache/lcf/agents/output/solr/SolrConnector.java
crawler-ui/output/
Author: kwright
Date: Wed Jun 16 10:18:25 2010
New Revision: 955181
URL: http://svn.apache.org/viewvc?rev=955181&view=rev
Log:
Complete the conversion of the solr output connector to the new method of handling connector UI's.
Removed:
incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/crawler-ui/output/
Modified:
incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/build.xml
incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
Modified: incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/build.xml?rev=955181&r1=955180&r2=955181&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/build.xml Wed Jun 16 10:18:25 2010
@@ -25,71 +25,12 @@
</javac>
</target>
- <target name="compile-crawler-ui" depends="compile-connector">
- <!-- Unpack the crawler war -->
- <mkdir dir="build/crawler-ui-war"/>
- <unwar src="war/lcf-crawler-ui.war" dest="build/crawler-ui-war"/>
- <!-- Create a copy of everything in the proper environment -->
- <mkdir dir="build/jsp-environment/WEB-INF/lib"/>
- <mkdir dir="build/jsp-environment/WEB-INF/jsp"/>
- <copy todir="build/jsp-environment/WEB-INF" file="build/crawler-ui-war/WEB-INF/web.xml"/>
- <copy todir="build/jsp-environment" file="build/crawler-ui-war/adminHeaders.jsp"/>
- <copy todir="build/jsp-environment" file="build/crawler-ui-war/adminDefaults.jsp"/>
- <copy todir="build/jsp-environment" file="build/crawler-ui-war/error.jsp"/>
- <copy todir="build/jsp-environment" file="build/crawler-ui-war/checkAdminLogin.jsp"/>
-
- <copy todir="build/jsp-environment">
- <fileset dir="crawler-ui" includes="**/*.jsp,**/*.css,**/*.png,**/*.html"/>
- </copy>
- <copy todir="build/jsp-environment/WEB-INF/lib">
- <fileset dir="build/crawler-ui-war/WEB-INF/lib">
- <include name="*.jar"/>
- </fileset>
- </copy>
- <copy todir="build/jsp-environment/WEB-INF/jsp">
- <fileset dir="build/crawler-ui-war/WEB-INF/jsp">
- <include name="*.tld"/>
- </fileset>
- </copy>
- <copy todir="build/jsp-environment/WEB-INF/classes">
- <fileset dir="build/connector/classes"/>
- </copy>
- <!-- Compile to java, as a check -->
- <mkdir dir="build/crawler-ui/java"/>
- <!-- Define the jsp compilation task using web libraries -->
- <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
- <classpath id="jspc.classpath">
- <pathelement location="${java.home}/../lib/tools.jar"/>
- <fileset dir="lib">
- <include name="*.jar"/>
- </fileset>
- <pathelement location="build/crawler-ui-war/WEB-INF/lib/jstl.jar"/>
- <pathelement location="build/crawler-ui-war/WEB-INF/lib/standard.jar"/>
- <pathelement location="build/connector/classes"/>
- </classpath>
- </taskdef>
- <jasper2 validateXml="false" uriroot="build/jsp-environment" webXmlFragment="build/jsp-environment/WEB-INF/web-generated.xml" outputDir="build/crawler-ui/java" />
- <!-- Compile java classes -->
- <mkdir dir="build/crawler-ui/classes"/>
- <javac srcdir="build/crawler-ui/java" destdir="build/crawler-ui/classes" target="1.5" source="1.4" debug="true" debuglevel="lines,vars,source">
- <classpath id="classpath">
- <pathelement location="${java.home}/../lib/tools.jar"/>
- <fileset dir="lib">
- <include name="*.jar"/>
- </fileset>
- <pathelement location="build/crawler-ui-war/WEB-INF/lib/jstl.jar"/>
- <pathelement location="build/crawler-ui-war/WEB-INF/lib/standard.jar"/>
- <pathelement location="build/connector/classes"/>
- </classpath>
- </javac>
- </target>
-
<target name="jar-connector" depends="compile-connector">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/lcf-solr-connector.jar" basedir="build/connector/classes"/>
</target>
- <target name="webapp-crawler-ui" depends="compile-crawler-ui,jar-connector">
+ <target name="webapp-crawler-ui" depends="jar-connector">
<mkdir dir="build/webapp/crawler-ui/WEB-INF/lib"/>
<copy todir="build/webapp/crawler-ui/WEB-INF/lib" file="build/jar/lcf-solr-connector.jar"/>
<mkdir dir="build/webapp/crawler-ui"/>
Modified: incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java?rev=955181&r1=955180&r2=955181&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java (original)
+++ incubator/lcf/branches/CONNECTORS-40/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/SolrConnector.java Wed Jun 16 10:18:25 2010
@@ -22,6 +22,7 @@ import org.apache.lcf.core.interfaces.*;
import org.apache.lcf.agents.interfaces.*;
import java.util.*;
+import java.io.*;
/** This is the output connector for SOLR. Currently, no frills.
*/
@@ -285,6 +286,673 @@ public class SolrConnector extends org.a
poster.deletePost(documentURI,activities);
}
+ // UI support methods.
+ //
+ // These support methods come in two varieties. The first bunch is involved in setting up connection configuration information. The second bunch
+ // is involved in presenting and editing output specification information for a job. The two kinds of methods are accordingly treated differently,
+ // in that the first bunch cannot assume that the current connector object is connected, while the second bunch can. That is why the first bunch
+ // receives a thread context argument for all UI methods, while the second bunch does not need one (since it has already been applied via the connect()
+ // method, above).
+
+ /** Output the configuration header section.
+ * This method is called in the head section of the connector's configuration page. Its purpose is to add the required tabs to the list, and to output any
+ * javascript methods that might be needed by the configuration editing HTML.
+ *@param threadContext is the local thread context.
+ *@param out is the output to which any HTML should be sent.
+ *@param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+ *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector.
+ */
+ public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, ArrayList tabsArray)
+ throws LCFException, IOException
+ {
+ tabsArray.add("Server");
+ tabsArray.add("Arguments");
+
+ out.print(
+"<script type=\"text/javascript\">\n"+
+"<!--\n"+
+"function checkConfig()\n"+
+"{\n"+
+" if (editconnection.servername.value == \"\")\n"+
+" {\n"+
+" alert(\"Please supply a valid Solr server name\");\n"+
+" editconnection.servername.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+
+" {\n"+
+" alert(\"Solr server port must be a valid integer\");\n"+
+" editconnection.serverport.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n"+
+" {\n"+
+" alert(\"Web application name cannot have '/' characters\");\n"+
+" editconnection.webappname.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Update path must start with a '/' character\");\n"+
+" editconnection.updatepath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Remove path must start with a '/' character\");\n"+
+" editconnection.removepath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Status path must start with a '/' character\");\n"+
+" editconnection.statuspath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" return true;\n"+
+"}\n"+
+"\n"+
+"function checkConfigForSave()\n"+
+"{\n"+
+" if (editconnection.servername.value == \"\")\n"+
+" {\n"+
+" alert(\"Please supply a valid Solr server name\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.servername.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.serverport.value != \"\" && !isInteger(editconnection.serverport.value))\n"+
+" {\n"+
+" alert(\"Solr server port must be a valid integer\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.serverport.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.webappname.value != \"\" && editconnection.webappname.value.indexOf(\"/\") != -1)\n"+
+" {\n"+
+" alert(\"Web application name cannot have '/' characters\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.webappname.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.updatepath.value != \"\" && editconnection.updatepath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Update path must start with a '/' character\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.updatepath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.removepath.value != \"\" && editconnection.removepath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Remove path must start with a '/' character\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.removepath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" if (editconnection.statuspath.value != \"\" && editconnection.statuspath.value.substring(0,1) != \"/\")\n"+
+" {\n"+
+" alert(\"Status path must start with a '/' character\");\n"+
+" SelectTab(\"Server\");\n"+
+" editconnection.statuspath.focus();\n"+
+" return false;\n"+
+" }\n"+
+" return true;\n"+
+"}\n"+
+"\n"+
+"function deleteArgument(i)\n"+
+"{\n"+
+" // Set the operation\n"+
+" eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Delete\\\"\");\n"+
+" // Submit\n"+
+" if (editconnection.argument_count.value==i)\n"+
+" postFormSetAnchor(\"argument\");\n"+
+" else\n"+
+" postFormSetAnchor(\"argument_\"+i)\n"+
+" // Undo, so we won't get two deletes next time\n"+
+" eval(\"editconnection.argument_\"+i+\"_op.value=\\\"Continue\\\"\");\n"+
+"}\n"+
+"\n"+
+"function addArgument()\n"+
+"{\n"+
+" if (editconnection.argument_name.value == \"\")\n"+
+" {\n"+
+" alert(\"Argument name cannot be an empty string\");\n"+
+" editconnection.argument_name.focus();\n"+
+" return;\n"+
+" }\n"+
+" editconnection.argument_op.value=\"Add\";\n"+
+" postFormSetAnchor(\"argument\");\n"+
+"}\n"+
+"\n"+
+"//-->\n"+
+"</script>\n"
+ );
+
+ }
+
+ /** Output the configuration body section.
+ * This method is called in the body section of the connector's configuration page. Its purpose is to present the required form elements for editing.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html>, <body>, and <form> tags. The name of the
+ * form is "editconnection".
+ *@param threadContext is the local thread context.
+ *@param out is the output to which any HTML should be sent.
+ *@param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+ *@param tabName is the current tab name.
+ */
+ public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, String tabName)
+ throws LCFException, IOException
+ {
+ String protocol = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PROTOCOL);
+ if (protocol == null)
+ protocol = "http";
+
+ String server = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_SERVER);
+ if (server == null)
+ server = "localhost";
+
+ String port = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PORT);
+ if (port == null)
+ port = "8983";
+
+ String webapp = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_WEBAPPNAME);
+ if (webapp == null)
+ webapp = "solr";
+
+ String updatePath = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_UPDATEPATH);
+ if (updatePath == null)
+ updatePath = "/update/extract";
+
+ String removePath = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REMOVEPATH);
+ if (removePath == null)
+ removePath = "/update";
+
+ String statusPath = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_STATUSPATH);
+ if (statusPath == null)
+ statusPath = "/admin/ping";
+
+ String realm = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REALM);
+ if (realm == null)
+ realm = "";
+
+ String userID = parameters.getParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_USERID);
+ if (userID == null)
+ userID = "";
+
+ String password = parameters.getObfuscatedParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PASSWORD);
+ if (password == null)
+ password = "";
+
+ // "Appliance" tab
+ if (tabName.equals("Server"))
+ {
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Protocol:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <select name=\"serverprotocol\">\n"+
+" <option value=\"http\""+(protocol.equals("http")?" selected=\"true\"":"")+">http</option>\n"+
+" <option value=\"https\""+(protocol.equals("https")?" selected=\"true\"":"")+">https</option>\n"+
+" </select>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Server name:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"servername\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(server)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Port:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"serverport\" type=\"text\" size=\"5\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(port)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Web application name:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"webappname\" type=\"text\" size=\"16\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(webapp)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Update handler:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"updatepath\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(updatePath)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Remove handler:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"removepath\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(removePath)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Status handler:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"statuspath\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(statusPath)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Realm:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"realm\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(realm)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>User ID:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input name=\"userid\" type=\"text\" size=\"32\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(userID)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Password:</nobr></td>\n"+
+" <td class=\"value\">\n"+
+" <input type=\"password\" size=\"32\" name=\"password\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(password)+"\"/>\n"+
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+ }
+ else
+ {
+ // Server tab hiddens
+ out.print(
+"<input type=\"hidden\" name=\"serverprotocol\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(protocol)+"\"/>\n"+
+"<input type=\"hidden\" name=\"servername\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(server)+"\"/>\n"+
+"<input type=\"hidden\" name=\"serverport\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(port)+"\"/>\n"+
+"<input type=\"hidden\" name=\"webappname\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(webapp)+"\"/>\n"+
+"<input type=\"hidden\" name=\"updatepath\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(updatePath)+"\"/>\n"+
+"<input type=\"hidden\" name=\"removepath\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(removePath)+"\"/>\n"+
+"<input type=\"hidden\" name=\"statuspath\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(statusPath)+"\"/>\n"+
+"<input type=\"hidden\" name=\"realm\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(realm)+"\"/>\n"+
+"<input type=\"hidden\" name=\"userid\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(userID)+"\"/>\n"+
+"<input type=\"hidden\" name=\"password\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(password)+"\"/>\n"
+ );
+ }
+
+ // Prepare for the argument tab
+ Map argumentMap = new HashMap();
+ int i = 0;
+ while (i < parameters.getChildCount())
+ {
+ ConfigNode sn = parameters.getChild(i++);
+ if (sn.getType().equals(org.apache.lcf.agents.output.solr.SolrConfig.NODE_ARGUMENT))
+ {
+ 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);
+ ArrayList values = (ArrayList)argumentMap.get(name);
+ if (values == null)
+ {
+ values = new ArrayList();
+ argumentMap.put(name,values);
+ }
+ values.add(value);
+ }
+ }
+ // "Arguments" tab
+ if (tabName.equals("Arguments"))
+ {
+ // For the display, sort the arguments into alphabetic order
+ String[] sortArray = new String[argumentMap.size()];
+ i = 0;
+ Iterator iter = argumentMap.keySet().iterator();
+ while (iter.hasNext())
+ {
+ sortArray[i++] = (String)iter.next();
+ }
+ java.util.Arrays.sort(sortArray);
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+" <tr>\n"+
+" <td class=\"description\"><nobr>Arguments:</nobr></td>\n"+
+" <td class=\"boxcell\">\n"+
+" <table class=\"formtable\">\n"+
+" <tr class=\"formheaderrow\">\n"+
+" <td class=\"formcolumnheader\"></td>\n"+
+" <td class=\"formcolumnheader\"><nobr>Name</nobr></td>\n"+
+" <td class=\"formcolumnheader\"><nobr>Value</nobr></td>\n"+
+" </tr>\n"
+ );
+ i = 0;
+ int k = 0;
+ while (k < sortArray.length)
+ {
+ 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);
+ out.print(
+" <tr class=\""+(((i % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
+" <td class=\"formcolumncell\">\n"+
+" <a name=\""+prefix+"\"><input type=\"button\" value=\"Delete\" alt=\"Delete argument #"+Integer.toString(i+1)+"\" onclick=\"javascript:deleteArgument("+Integer.toString(i)+");"+"\"/>\n"+
+" <input type=\"hidden\" name=\""+prefix+"_op"+"\" value=\"Continue\"/>\n"+
+" <input type=\"hidden\" name=\""+prefix+"_name"+"\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(name)+"\"/>\n"+
+" </a>\n"+
+" </td>\n"+
+" <td class=\"formcolumncell\">\n"+
+" <nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(name)+"</nobr>\n"+
+" </td>\n"+
+" <td class=\"formcolumncell\">\n"+
+" <nobr><input type=\"text\" size=\"30\" name=\""+prefix+"_value"+"\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(value)+"\"</nobr>\n"+
+" </td>\n"+
+" </tr>\n"
+ );
+ i++;
+ }
+ }
+ if (i == 0)
+ {
+ out.print(
+" <tr class=\"formrow\"><td class=\"formmessage\" colspan=\"3\">No arguments specified</td></tr>\n"
+ );
+ }
+ out.print(
+" <tr class=\"formrow\"><td class=\"formseparator\" colspan=\"3\"><hr/></td></tr>\n"+
+" <tr class=\"formrow\">\n"+
+" <td class=\"formcolumncell\">\n"+
+" <a name=\"argument\"><input type=\"button\" value=\"Add\" alt=\"Add argument\" onclick=\"javascript:addArgument();\"/></a>\n"+
+" <input type=\"hidden\" name=\"argument_count\" value=\""+Integer.toString(i)+"\"/>\n"+
+" <input type=\"hidden\" name=\"argument_op\" value=\"Continue\"/>\n"+
+" </a>\n"+
+" </td>\n"+
+" <td class=\"formcolumncell\">\n"+
+" <nobr><input type=\"text\" size=\"30\" name=\"argument_name\" value=\"\"/></nobr>\n"+
+" </td>\n"+
+" <td class=\"formcolumncell\">\n"+
+" <nobr><input type=\"text\" size=\"30\" name=\"argument_value\" value=\"\"/></nobr>\n"+
+" </td>\n"+
+" </tr>\n"+
+" </table>\n"+
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+ }
+ else
+ {
+ // Emit hiddens for argument tab
+ i = 0;
+ Iterator iter = argumentMap.keySet().iterator();
+ while (iter.hasNext())
+ {
+ String name = (String)iter.next();
+ 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++);
+ out.print(
+"<input type=\"hidden\" name=\""+prefix+"_name\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(name)+"\"/>\n"+
+"<input type=\"hidden\" name=\""+prefix+"_value\" value=\""+org.apache.lcf.ui.util.Encoder.attributeEscape(value)+"\"/>\n"
+ );
+ }
+ }
+ out.print(
+"<input type=\"hidden\" name=\"argument_count\" value=\""+Integer.toString(i)+"\"/>\n"
+ );
+ }
+ }
+
+ /** Process a configuration post.
+ * This method is called at the start of the connector's configuration page, whenever there is a possibility that form data for a connection has been
+ * posted. Its purpose is to gather form information and modify the configuration parameters accordingly.
+ * The name of the posted form is "editconnection".
+ *@param threadContext is the local thread context.
+ *@param variableContext is the set of variables available from the post, including binary file post information.
+ *@param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+ *@return null if all is well, or a string error message if there is an error that should prevent saving of the connection (and cause a redirection to an error page).
+ */
+ public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext, ConfigParams parameters)
+ throws LCFException
+ {
+ String protocol = variableContext.getParameter("serverprotocol");
+ if (protocol != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PROTOCOL,protocol);
+
+ String server = variableContext.getParameter("servername");
+ if (server != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_SERVER,server);
+
+ String port = variableContext.getParameter("serverport");
+ if (port != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PORT,port);
+
+ String webapp = variableContext.getParameter("webappname");
+ if (webapp != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_WEBAPPNAME,webapp);
+
+ String updatePath = variableContext.getParameter("updatepath");
+ if (updatePath != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_UPDATEPATH,updatePath);
+
+ String removePath = variableContext.getParameter("removepath");
+ if (removePath != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REMOVEPATH,removePath);
+
+ String statusPath = variableContext.getParameter("statuspath");
+ if (statusPath != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_STATUSPATH,statusPath);
+
+ String realm = variableContext.getParameter("realm");
+ if (realm != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REALM,realm);
+
+ String userID = variableContext.getParameter("userid");
+ if (userID != null)
+ parameters.setParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_USERID,userID);
+
+ String password = variableContext.getParameter("password");
+ if (password != null)
+ parameters.setObfuscatedParameter(org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PASSWORD,password);
+
+ String x = variableContext.getParameter("argument_count");
+ if (x != null && x.length() > 0)
+ {
+ // About to gather the argument nodes, so get rid of the old ones.
+ int i = 0;
+ while (i < parameters.getChildCount())
+ {
+ ConfigNode node = parameters.getChild(i);
+ if (node.getType().equals(org.apache.lcf.agents.output.solr.SolrConfig.NODE_ARGUMENT))
+ parameters.removeChild(i);
+ else
+ i++;
+ }
+ int count = Integer.parseInt(x);
+ i = 0;
+ while (i < count)
+ {
+ String prefix = "argument_"+Integer.toString(i);
+ String op = variableContext.getParameter(prefix+"_op");
+ if (op == null || !op.equals("Delete"))
+ {
+ // Gather the name and value.
+ String name = variableContext.getParameter(prefix+"_name");
+ String value = variableContext.getParameter(prefix+"_value");
+ ConfigNode node = new ConfigNode(org.apache.lcf.agents.output.solr.SolrConfig.NODE_ARGUMENT);
+ node.setAttribute(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_NAME,name);
+ node.setAttribute(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_VALUE,value);
+ parameters.addChild(parameters.getChildCount(),node);
+ }
+ i++;
+ }
+ String addop = variableContext.getParameter("argument_op");
+ if (addop != null && addop.equals("Add"))
+ {
+ String name = variableContext.getParameter("argument_name");
+ String value = variableContext.getParameter("argument_value");
+ ConfigNode node = new ConfigNode(org.apache.lcf.agents.output.solr.SolrConfig.NODE_ARGUMENT);
+ node.setAttribute(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_NAME,name);
+ node.setAttribute(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_VALUE,value);
+ parameters.addChild(parameters.getChildCount(),node);
+ }
+ }
+ return null;
+ }
+
+ /** View configuration.
+ * This method is called in the body section of the connector's view configuration page. Its purpose is to present the connection information to the user.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html> and <body> tags.
+ *@param threadContext is the local thread context.
+ *@param out is the output to which any HTML should be sent.
+ *@param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+ */
+ public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters)
+ throws LCFException, IOException
+ {
+ out.print(
+"<table class=\"displaytable\">\n"+
+" <tr>\n"+
+" <td class=\"description\" colspan=\"1\"><nobr>Parameters:</nobr></td>\n"+
+" <td class=\"value\" colspan=\"3\">\n"
+ );
+ Iterator iter = parameters.listParameters();
+ while (iter.hasNext())
+ {
+ String param = (String)iter.next();
+ String value = parameters.getParameter(param);
+ if (param.length() >= "password".length() && param.substring(param.length()-"password".length()).equalsIgnoreCase("password"))
+ {
+ out.print(
+" <nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"=********</nobr><br/>\n"
+ );
+ }
+ else if (param.length() >="keystore".length() && param.substring(param.length()-"keystore".length()).equalsIgnoreCase("keystore"))
+ {
+ IKeystoreManager kmanager = KeystoreManagerFactory.make("",value);
+ out.print(
+" <nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"=<"+Integer.toString(kmanager.getContents().length)+" certificate(s)></nobr><br/>\n"
+ );
+ }
+ else
+ {
+ out.print(
+" <nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"="+org.apache.lcf.ui.util.Encoder.bodyEscape(value)+"</nobr><br/>\n"
+ );
+ }
+ }
+
+ out.print(
+" </td>\n"+
+" </tr>\n"+
+"\n"+
+" <tr>\n"+
+" <td class=\"description\" colspan=\"1\"><nobr>Arguments:</nobr></td>\n"+
+" <td class=\"boxcell\" colspan=\"3\">\n"+
+" <table class=\"formtable\">\n"+
+" <tr class=\"formheaderrow\">\n"+
+" <td class=\"formcolumnheader\"><nobr>Name</nobr></td>\n"+
+" <td class=\"formcolumnheader\"><nobr>Value</nobr></td>\n"+
+" </tr>\n"
+ );
+
+ int i = 0;
+ int instanceNumber = 0;
+ while (i < parameters.getChildCount())
+ {
+ ConfigNode cn = parameters.getChild(i++);
+ if (cn.getType().equals(org.apache.lcf.agents.output.solr.SolrConfig.NODE_ARGUMENT))
+ {
+ // An argument node! Look for all its parameters.
+ String name = cn.getAttributeValue(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_NAME);
+ String value = cn.getAttributeValue(org.apache.lcf.agents.output.solr.SolrConfig.ATTRIBUTE_VALUE);
+
+ out.print(
+" <tr class=\""+(((instanceNumber % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
+" <td class=\"formcolumncell\"><nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(name)+"</nobr></td>\n"+
+" <td class=\"formcolumncell\"><nobr>"+org.apache.lcf.ui.util.Encoder.bodyEscape(value)+"</nobr></td>\n"+
+" </tr>\n"
+ );
+
+ instanceNumber++;
+ }
+ }
+ if (instanceNumber == 0)
+ {
+ out.print(
+" <tr class=\"formrow\"><td class=\"formmessage\" colspan=\"5\">No arguments</td></tr>\n"
+ );
+ }
+
+ out.print(
+" </table>\n"+
+" </td>\n"+
+" </tr>\n"+
+"</table>\n"
+ );
+ }
+
+ /** Output the specification header section.
+ * This method is called in the head section of a job page which has selected an output connection of the current type. Its purpose is to add the required tabs
+ * to the list, and to output any javascript methods that might be needed by the job editing HTML.
+ *@param out is the output to which any HTML should be sent.
+ *@param os is the current output specification for this job.
+ *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector.
+ */
+ public void outputSpecificationHeader(IHTTPOutput out, OutputSpecification os, ArrayList tabsArray)
+ throws LCFException, IOException
+ {
+ out.print(
+"<script type=\"text/javascript\">\n"+
+"<!--\n"+
+"\n"+
+"function checkOutputSpecification()\n"+
+"{\n"+
+" return true;\n"+
+"}\n"+
+"\n"+
+"//-->\n"+
+"</script>\n"
+ );
+ }
+
+ /** Output the specification body section.
+ * This method is called in the body section of a job page which has selected an output connection of the current type. Its purpose is to present the required form elements for editing.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html>, <body>, and <form> tags. The name of the
+ * form is "editjob".
+ *@param out is the output to which any HTML should be sent.
+ *@param os is the current output specification for this job.
+ *@param tabName is the current tab name.
+ */
+ public void outputSpecificationBody(IHTTPOutput out, OutputSpecification os, String tabName)
+ throws LCFException, IOException
+ {
+ }
+
+ /** Process a specification post.
+ * This method is called at the start of job's edit or view page, whenever there is a possibility that form data for a connection has been
+ * posted. Its purpose is to gather form information and modify the output specification accordingly.
+ * The name of the posted form is "editjob".
+ *@param variableContext contains the post data, including binary file-upload information.
+ *@param os is the current output specification for this job.
+ *@return null if all is well, or a string error message if there is an error that should prevent saving of the job (and cause a redirection to an error page).
+ */
+ public String processSpecificationPost(IPostParameters variableContext, OutputSpecification os)
+ throws LCFException
+ {
+ return null;
+ }
+
+ /** View specification.
+ * This method is called in the body section of a job's view page. Its purpose is to present the output specification information to the user.
+ * The coder can presume that the HTML that is output from this configuration will be within appropriate <html> and <body> tags.
+ *@param out is the output to which any HTML should be sent.
+ *@param os is the current output specification for this job.
+ */
+ public void viewSpecification(IHTTPOutput out, OutputSpecification os)
+ throws LCFException, IOException
+ {
+ }
+
// Protected methods
/** Stuffer for packing a single string with an end delimiter */
LCF and Solr multicore
Posted by Erik Hatcher <er...@gmail.com>.
That commit, Karl, reminded me... LCF's Solr configuration doesn't
have a spot for putting in an optional core name. When using Solr,
URLs are of the form: http://localhost:8983/solr[/<corename>]...
I imagine one could simply add that to the webapp name field so
instead of "solr" it'd be "solr/corename", but that seems like a bit
of a hack.
Why even break all these pieces of the Solr URL down? Why not simply
have a "Solr URL" field where the user would put in the entire string "http://localhost:8983/solr/mycore
"?
Erik
Begin forwarded message:
> + public void outputConfigurationBody(IThreadContext threadContext,
> IHTTPOutput out, ConfigParams parameters, String tabName)
> + throws LCFException, IOException
> + {
> + String protocol =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PROTOCOL);
> + if (protocol == null)
> + protocol = "http";
> +
> + String server =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_SERVER);
> + if (server == null)
> + server = "localhost";
> +
> + String port =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PORT);
> + if (port == null)
> + port = "8983";
> +
> + String webapp =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_WEBAPPNAME);
> + if (webapp == null)
> + webapp = "solr";
> +
> + String updatePath =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_UPDATEPATH);
> + if (updatePath == null)
> + updatePath = "/update/extract";
> +
> + String removePath =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REMOVEPATH);
> + if (removePath == null)
> + removePath = "/update";
> +
> + String statusPath =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_STATUSPATH);
> + if (statusPath == null)
> + statusPath = "/admin/ping";
> +
> + String realm =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_REALM);
> + if (realm == null)
> + realm = "";
> +
> + String userID =
> parameters
> .getParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_USERID);
> + if (userID == null)
> + userID = "";
> +
> + String password =
> parameters
> .getObfuscatedParameter
> (org.apache.lcf.agents.output.solr.SolrConfig.PARAM_PASSWORD);
> + if (password == null)
> + password = "";