// Loop through the existing zookeeper nodes
int k = 0;
for (int i = 0; i < parameters.getChildCount(); i++)
{
ConfigurationNode cn = parameters.getChild(i);
if (cn.getType().equals(SolrConfig.NODE_ZOOKEEPER))
{
String host = cn.getAttributeValue(SolrConfig.ATTR_HOST);
String zkport = cn.getAttributeValue(SolrConfig.ATTR_PORT);
String postfix = "zookeeper_"+k;
out.print(
" <tr class=\""+(((k % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
" <td class=\"formcolumncell\">\n"+
" <a name=\""+postfix+"\">\n"+
" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"SolrConnector.Delete") + "\" alt=\""+Messages.getAttributeString(locale,"SolrConnector.DeleteZookeeperHost")+Integer.toString(k+1)+"\" onclick='javascript:deleteZookeeperHost("+Integer.toString(k)+");'/>\n"+
" <input type=\"hidden\" name=\""+"op_"+postfix+"\" value=\"Continue\"/>\n"+
" <input type=\"hidden\" name=\""+"host_"+postfix+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(host)+"\"/>\n"+
" <input type=\"hidden\" name=\""+"port_"+postfix+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(zkport)+"\"/>\n"+
" </a>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(host)+"</nobr>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(zkport)+"</nobr>\n"+
" </td>\n"+
" </tr>\n"
);
k++;
}
}
// If this looks like the first time through for this connection, add a default zookeeper setup.
// Only works because after the first post, parameters always will have children.
if (parameters.getChildCount() == 0)
{
String postfix = "zookeeper_"+k;
out.print(
" <tr class=\""+(((k % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
" <td class=\"formcolumncell\">\n"+
" <a name=\""+postfix+"\">\n"+
" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"SolrConnector.Delete") + "\" alt=\""+Messages.getAttributeString(locale,"SolrConnector.DeleteZookeeperHost")+Integer.toString(k+1)+"\" onclick='javascript:deleteZookeeperHost("+Integer.toString(k)+");'/>\n"+
" <input type=\"hidden\" name=\""+"op_"+postfix+"\" value=\"Continue\"/>\n"+
" <input type=\"hidden\" name=\""+"host_"+postfix+"\" value=\"localhost\"/>\n"+
" <input type=\"hidden\" name=\""+"port_"+postfix+"\" value=\"2181\"/>\n"+
" </a>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>localhost</nobr>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>2181</nobr>\n"+
" </td>\n"+
" </tr>\n"
);
k++;
}
if (k == 0)
{
out.print(
" <tr class=\"formrow\"><td class=\"formmessage\" colspan=\"3\">"+Messages.getBodyString(locale,"SolrConnector.NoZookeeperHostsSpecified")+"</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=\"zookeeper\">\n"+
" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"SolrConnector.Add") + "\" alt=\"" + Messages.getAttributeString(locale,"SolrConnector.AddZookeeperHost") + "\" onclick=\"javascript:addZookeeperHost();\"/>\n"+
" </a>\n"+
" <input type=\"hidden\" name=\"count_zookeeper\" value=\""+k+"\"/>\n"+
" <input type=\"hidden\" name=\"op_zookeeper\" value=\"Continue\"/>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr><input type=\"text\" size=\"30\" name=\"host_zookeeper\" value=\"\"/></nobr>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr><input type=\"text\" size=\"5\" name=\"port_zookeeper\" value=\"\"/></nobr>\n"+
" </td>\n"+
" </tr>\n"+
" </table>\n"+
" </td>\n"+
" </tr>\n"+
" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+
" <tr>\n"+
" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.ZnodePath") + "</nobr></td>\n"+
" <td class=\"value\">\n"+
" <input name=\"znodepath\" type=\"text\" size=\"16\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(znodePath)+"\"/>\n"+
" </td>\n"+
" </tr>\n"+
" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+
" <tr>\n"+
" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.CollectionName") + "</nobr></td>\n"+
" <td class=\"value\">\n"+
" <input name=\"collection\" type=\"text\" size=\"16\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(collection)+"\"/>\n"+
" </td>\n"+
" </tr>\n"+
" <tr><td colspan=\"2\" class=\"separator\"><hr/></td></tr>\n"+
" <tr>\n"+
" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.ZookeeperClientTimeout") + "</nobr></td>\n"+
" <td class=\"value\">\n"+
" <input name=\"zkclienttimeout\" type=\"text\" size=\"5\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(zkClientTimeout)+"\"/>\n"+
" </td>\n"+
" </tr>\n"+
" <tr>\n"+
" <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"SolrConnector.ZookeeperConnectTimeout") + "</nobr></td>\n"+
" <td class=\"value\">\n"+
" <input name=\"zkconnecttimeout\" type=\"text\" size=\"5\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(zkConnectTimeout)+"\"/>\n"+
" </td>\n"+
" </tr>\n"+
"</table>\n"
);
}
else
{
// Hiddens for Zookeeper tab
int k = 0;
for (int i = 0; i < parameters.getChildCount(); i++)
{
ConfigurationNode cn = parameters.getChild(i);
if (cn.getType().equals(SolrConfig.NODE_ZOOKEEPER))
{
String host = cn.getAttributeValue(SolrConfig.ATTR_HOST);
String zkport = cn.getAttributeValue(SolrConfig.ATTR_PORT);
String postfix = "zookeeper_"+k;
out.print(
"<input type=\"hidden\" name=\"host_"+postfix+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(host)+"\"/>\n"+
"<input type=\"hidden\" name=\"port_"+postfix+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(zkport)+"\"/>\n"
);