Author: kwright
Date: Fri Oct  3 12:31:13 2014
New Revision: 1629191

URL: http://svn.apache.org/r1629191
Log:
Reformat and escape all strings in UI

Modified:
    
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/ConfigurationHandler.java
    
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration.js
    
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration_Server.html
    
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/viewConfiguration.html

Modified: 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/ConfigurationHandler.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/ConfigurationHandler.java?rev=1629191&r1=1629190&r2=1629191&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/ConfigurationHandler.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/ConfigurationHandler.java
 Fri Oct  3 12:31:13 2014
@@ -103,14 +103,12 @@ public class ConfigurationHandler {
       IHTTPOutput out, Locale locale, ConfigParams parameters,
       List<String> tabsArray) throws ManifoldCFException, IOException {
     tabsArray.add("Server");
-    InputStream inputStream = 
ConfigurationHandler.class.getResourceAsStream("/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/"
 + EDIT_CONFIG_HEADER);
-    StringWriter writer = new StringWriter();
-    IOUtils.copy(inputStream, writer, "UTF-8");
-    inputStream.close();
-    out.print(writer.toString());
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    fillInParameters(paramMap, parameters);
+    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_HEADER, 
paramMap);
   }
 
-  private static void fillInParameters(Map<String, String> paramMap,
+  private static void fillInParameters(Map<String, Object> paramMap,
       ConfigParams parameters) {
     for (Map.Entry<String, String> parameter : DEFAULT_CONFIGURATION_PARAMETERS
         .entrySet()) {
@@ -125,22 +123,10 @@ public class ConfigurationHandler {
   public static void outputConfigurationBody(IThreadContext threadContext,
       IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
       throws ManifoldCFException, IOException {
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
     paramMap.put("tabName", tabName);
     fillInParameters(paramMap, parameters);
-    VelocityEngine velocityEngine = 
Messages.createVelocityEngine(ConfigurationHandler.class);
-    VelocityContext context = createVelocityContext(paramMap);
-    StringWriter w = new StringWriter();
-    velocityEngine.mergeTemplate(EDIT_CONFIG_SERVER, "UTF-8", context, w);
-    out.print(w.toString());
-  }
-
-  private static VelocityContext createVelocityContext(Map<String, String> 
paramMap) {
-    VelocityContext context = new VelocityContext();
-    for (Map.Entry<String, String> entry : paramMap.entrySet()) {
-      context.put(entry.getKey(), entry.getValue());
-    }
-    return context;
+    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_SERVER, 
paramMap);
   }
 
   public static String processConfigurationPost(IThreadContext threadContext,
@@ -158,13 +144,9 @@ public class ConfigurationHandler {
   public static void viewConfiguration(IThreadContext threadContext,
       IHTTPOutput out, Locale locale, ConfigParams parameters)
       throws ManifoldCFException, IOException {
-    Map<String, String> paramMap = new HashMap<String, String>();
+    Map<String, Object> paramMap = new HashMap<String, Object>();
     fillInParameters(paramMap, parameters);
-    VelocityEngine velocityEngine = 
Messages.createVelocityEngine(ConfigurationHandler.class);
-    VelocityContext context = createVelocityContext(paramMap);
-    StringWriter w = new StringWriter();
-    velocityEngine.mergeTemplate(VIEW_CONFIG, "UTF-8", context, w);
-    out.print(w.toString());
+    Messages.outputResourceWithVelocity(out, locale, VIEW_CONFIG, paramMap);
   }
   
   public static void outputSpecificationHeader(IHTTPOutput out, Locale locale, 
Specification os,
@@ -174,313 +156,313 @@ public class ConfigurationHandler {
     String seqPrefix = "s"+connectionSequenceNumber+"_";
     tabsArray.add(Messages.getString(locale, 
"Alfresco.FilteringConfiguration"));
     out.print(
-               "<script type=\"text/javascript\">\n"+
-               "<!--\n"+
-               "function "+seqPrefix+"checkSpecification()\n"+
-               "{\n"+
-               "  return true;\n"+
-               "}\n"+
-               "\n");
+        "<script type=\"text/javascript\">\n"+
+        "<!--\n"+
+        "function "+seqPrefix+"checkSpecification()\n"+
+        "{\n"+
+        "  return true;\n"+
+        "}\n"+
+        "\n");
     
     for(String node:SPECIFICATION_MAP.keySet()){
-       out.print(
-                       "function "+seqPrefix+"add"+node+"()\n"+
-                       "{\n");
-       Collection<String> vars = SPECIFICATION_MAP.get(node);
-       for(String var:vars){
+      out.print(
+          "function "+seqPrefix+"add"+node+"()\n"+
+          "{\n");
+      Collection<String> vars = SPECIFICATION_MAP.get(node);
+      for(String var:vars){
             Object[] args = new String[]{node,var};
-               out.print(
-                               "if (editjob."+seqPrefix+var+".value == 
\"\")\n"+
-                               "  {\n"+
-//                             "    alert(\"Value of "+ node + "." + var + " 
can't be NULL" +"\");\n"+
+        out.print(
+            "if (editjob."+seqPrefix+var+".value == \"\")\n"+
+              "  {\n"+
+//              "    alert(\"Value of "+ node + "." + var + " can't be NULL" 
+"\");\n"+
                     "    alert(\""+ Messages.getBodyJavascriptString(locale, 
"Alfresco.ParamNullError",args) + "\");\n"+
-                               "    editjob."+seqPrefix+var+".focus();\n"+
-                               "    return;\n"+
-                               "  }\n"
-                               );
-       }
-                       
-       out.print("editjob."+seqPrefix+node+"_op.value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Add") + "\";\n"+
-                       "  postFormSetAnchor(\""+seqPrefix+"+"+node+"\");\n"+
-                       "}\n"+
-                       "\n"+
-       "function "+seqPrefix+"delete"+node+"(i)\n"+
-                       "{\n"+
-                       "  // Set the operation\n"+
-                       "  
eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\"" + 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\\\"\");\n"+
-                       "  // Submit\n"+
-                       "  if (editjob."+seqPrefix+node+"_count.value==i)\n"+
-                       "    postFormSetAnchor(\""+seqPrefix+node+"\");\n"+
-                       "  else\n"+
-                       "    postFormSetAnchor(\""+seqPrefix+node+"_\"+i)\n"+
-                       "  // Undo, so we won't get two deletes next time\n"+
-                       "  
eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Continue") + "\\\"\");\n"+
-                       "}\n"+
-                       "\n");
+              "    editjob."+seqPrefix+var+".focus();\n"+
+              "    return;\n"+
+              "  }\n"
+            );
+      }
+          
+      out.print("editjob."+seqPrefix+node+"_op.value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Add") + "\";\n"+
+          "  postFormSetAnchor(\""+seqPrefix+"+"+node+"\");\n"+
+          "}\n"+
+          "\n"+
+      "function "+seqPrefix+"delete"+node+"(i)\n"+
+          "{\n"+
+          "  // Set the operation\n"+
+          "  eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\"" + 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\\\"\");\n"+
+          "  // Submit\n"+
+          "  if (editjob."+seqPrefix+node+"_count.value==i)\n"+
+          "    postFormSetAnchor(\""+seqPrefix+node+"\");\n"+
+          "  else\n"+
+          "    postFormSetAnchor(\""+seqPrefix+node+"_\"+i)\n"+
+          "  // Undo, so we won't get two deletes next time\n"+
+          "  eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Continue") + "\\\"\");\n"+
+          "}\n"+
+          "\n");
     }
-               
+        
     out.print("\n"+
-               "\n"+
-               "//-->\n"+
-               "</script>\n");         
+        "\n"+
+        "//-->\n"+
+        "</script>\n");    
   }
 
   
   public static void outputSpecificationBody(IHTTPOutput out, Locale locale, 
Specification os,
-                 int connectionSequenceNumber, int actualSequenceNumber, 
String tabName)
-                                 throws ManifoldCFException, IOException
+      int connectionSequenceNumber, int actualSequenceNumber, String tabName)
+          throws ManifoldCFException, IOException
   {
-         String seqPrefix = "s"+connectionSequenceNumber+"_";
-         int i;
-         // Field Mapping tab
-         if (tabName.equals(Messages.getString(locale, 
"Alfresco.FilteringConfiguration")) && connectionSequenceNumber == 
actualSequenceNumber)
-         {
-                 for(String node:SPECIFICATION_MAP.keySet()){
-                         out.print(
-                                         "<table class=\"displaytable\">\n"+
-                                                         "  <tr><td 
class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
-                                                         "  <tr>\n"+
-                                                         "    <td 
class=\"description\"><nobr>" + node + " filtering:</nobr></td>\n"+
-                                                         "    <td 
class=\"boxcell\">\n"+
-                                                         "      <table 
class=\"formtable\">\n"+
-                                                         "        <tr 
class=\"formheaderrow\">\n"+
-                                                         "          <td 
class=\"formcolumnheader\"></td>\n");
-                         Collection<String> vars = SPECIFICATION_MAP.get(node);
-                         for(String var:vars){
-                                 out.print("<td 
class=\"formcolumnheader\"><nobr>" + var + "</nobr></td>\n");
-                         }
-                         out.print("</tr>\n");
-                         
-                         int fieldCounter = 0;
-                         i = 0;
-                         while (i < os.getChildCount()) {
-                                 SpecificationNode sn = os.getChild(i++);
-                                 if (sn.getType().equals(node)) {
-                                         String prefix = seqPrefix+node+"_" + 
Integer.toString(fieldCounter);
-                                         out.print(
-                                                         "        <tr 
class=\""+(((fieldCounter % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
-                                                                         "     
     <td class=\"formcolumncell\">\n"+
-                                                                         "     
       <a name=\""+prefix+"\">\n"+
-                                                                         "     
         <input type=\"button\" value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\" alt=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + 
""+Integer.toString(fieldCounter+1)+"\" 
onclick='javascript:"+seqPrefix+"delete"+node+"("+Integer.toString(fieldCounter)+");'/>\n"+
-                                                                         "     
         <input type=\"hidden\" name=\""+prefix+"_op\" value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Continue") + "\"/>\n");
-                                         for(String var:vars){
-                                                 out.print("<input 
type=\"hidden\" name=\""+prefix+"_"+var+"\" 
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
-                                         }
-
-                                         out.print("            </a>\n"+
-                                                         "          </td>\n");
-                                         for(String var:vars){
-                                                 out.print(
-                                                                 "       <td 
class=\"formcolumncell\">\n"+
-                                                                               
  "            
<nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
-                                                                 "          
</td>\n");
-                                         }
-                                         fieldCounter++;
-
-                                 }
-                         }
-                         if (fieldCounter == 0)
-                     {
-                       out.print(
-                                       "<tr class=\"formrow\"><td 
class=\"formmessage\" colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, 
"Alfresco.NoFilteringConfiguration") + "</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=\""+seqPrefix+node+"\">\n"+
-                                               "              <input 
type=\"button\" value=\""+ Messages.getBodyJavascriptString(locale, 
"Alfresco.Add") + "\" alt=\""+ Messages.getBodyJavascriptString(locale, 
"Alfresco.Add") + " " + node + "\" 
onclick=\"javascript:"+seqPrefix+"add"+node+"();\"/>\n"+
-                                               "            </a>\n"+
-                                               "            <input 
type=\"hidden\" name=\""+seqPrefix+node+"_count\" 
value=\""+fieldCounter+"\"/>\n"+
-                                               "            <input 
type=\"hidden\" name=\""+seqPrefix+node+"_op\" value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Continue") +"\"/>\n"+
-                                               "          </td>\n");
-                         for(String var:vars){
-                                 out.print("          <td 
class=\"formcolumncell\">\n"+
-                                               "            <nobr><input 
type=\"text\" size=\"15\" name=\""+seqPrefix+var+"\" value=\"\"/></nobr>\n"+
-                                               "          </td>\n");
-                         }
-
-                        out.print("</tr>\n"+
-                                               "      </table>\n"+
-                                               "    </td>\n"+
-                                               "  </tr>\n");
-                                               
-
-                 }
-         }
-         else{
-             for(String node:SPECIFICATION_MAP.keySet()){
-                 i = 0;
-                     int fieldCounter = 0;  
-                     while (i < os.getChildCount()) {
-                         SpecificationNode sn = os.getChild(i++);
-                         if(sn.getType().equals(node)){
-                               String prefix = seqPrefix+node+"_" + 
Integer.toString(fieldCounter);  
-                               for(String var:SPECIFICATION_MAP.get(node)){
-                                       out.print(
-                                                       "<input type=\"hidden\" 
name=\""+prefix+"_"+var+"\" 
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
-                               }
-                               fieldCounter++;
-                         }
-                     }
-                     
-                     out.print("<input type=\"hidden\" 
name=\""+seqPrefix+node+"_count\" 
value=\""+Integer.toString(fieldCounter)+"\"/>\n");
-             }
-           }
-         }
-                 
+    String seqPrefix = "s"+connectionSequenceNumber+"_";
+    int i;
+    // Field Mapping tab
+    if (tabName.equals(Messages.getString(locale, 
"Alfresco.FilteringConfiguration")) && connectionSequenceNumber == 
actualSequenceNumber)
+    {
+      for(String node:SPECIFICATION_MAP.keySet()){
+        out.print(
+            "<table class=\"displaytable\">\n"+
+                "  <tr><td class=\"separator\" 
colspan=\"2\"><hr/></td></tr>\n"+
+                "  <tr>\n"+
+                "    <td class=\"description\"><nobr>" + node + " 
filtering:</nobr></td>\n"+
+                "    <td class=\"boxcell\">\n"+
+                "      <table class=\"formtable\">\n"+
+                "        <tr class=\"formheaderrow\">\n"+
+                "          <td class=\"formcolumnheader\"></td>\n");
+        Collection<String> vars = SPECIFICATION_MAP.get(node);
+        for(String var:vars){
+          out.print("<td class=\"formcolumnheader\"><nobr>" + var + 
"</nobr></td>\n");
+        }
+        out.print("</tr>\n");
+        
+        int fieldCounter = 0;
+        i = 0;
+        while (i < os.getChildCount()) {
+          SpecificationNode sn = os.getChild(i++);
+          if (sn.getType().equals(node)) {
+            String prefix = seqPrefix+node+"_" + 
Integer.toString(fieldCounter);
+            out.print(
+                "        <tr class=\""+(((fieldCounter % 
2)==0)?"evenformrow":"oddformrow")+"\">\n"+
+                    "          <td class=\"formcolumncell\">\n"+
+                    "            <a name=\""+prefix+"\">\n"+
+                    "              <input type=\"button\" value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\" alt=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + 
""+Integer.toString(fieldCounter+1)+"\" 
onclick='javascript:"+seqPrefix+"delete"+node+"("+Integer.toString(fieldCounter)+");'/>\n"+
+                    "              <input type=\"hidden\" 
name=\""+prefix+"_op\" value=\""+ Messages.getBodyJavascriptString(locale, 
"Alfresco.Continue") + "\"/>\n");
+            for(String var:vars){
+              out.print("<input type=\"hidden\" name=\""+prefix+"_"+var+"\" 
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
+            }
+
+            out.print("            </a>\n"+
+                "          </td>\n");
+            for(String var:vars){
+              out.print(
+                  "       <td class=\"formcolumncell\">\n"+
+                      "            
<nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
+                  "          </td>\n");
+            }
+            fieldCounter++;
+
+          }
+        }
+        if (fieldCounter == 0)
+          {
+            out.print(
+                "<tr class=\"formrow\"><td class=\"formmessage\" 
colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, 
"Alfresco.NoFilteringConfiguration") + "</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=\""+seqPrefix+node+"\">\n"+
+            "              <input type=\"button\" value=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Add") + "\" alt=\""+ 
Messages.getBodyJavascriptString(locale, "Alfresco.Add") + " " + node + "\" 
onclick=\"javascript:"+seqPrefix+"add"+node+"();\"/>\n"+
+            "            </a>\n"+
+            "            <input type=\"hidden\" 
name=\""+seqPrefix+node+"_count\" value=\""+fieldCounter+"\"/>\n"+
+            "            <input type=\"hidden\" name=\""+seqPrefix+node+"_op\" 
value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Continue") 
+"\"/>\n"+
+            "          </td>\n");
+        for(String var:vars){
+          out.print("          <td class=\"formcolumncell\">\n"+
+            "            <nobr><input type=\"text\" size=\"15\" 
name=\""+seqPrefix+var+"\" value=\"\"/></nobr>\n"+
+            "          </td>\n");
+        }
+
+       out.print("</tr>\n"+
+            "      </table>\n"+
+            "    </td>\n"+
+            "  </tr>\n");
+            
+
+      }
+    }
+    else{
+        for(String node:SPECIFICATION_MAP.keySet()){
+          i = 0;
+          int fieldCounter = 0;  
+          while (i < os.getChildCount()) {
+            SpecificationNode sn = os.getChild(i++);
+            if(sn.getType().equals(node)){
+            String prefix = seqPrefix+node+"_" + 
Integer.toString(fieldCounter);  
+            for(String var:SPECIFICATION_MAP.get(node)){
+              out.print(
+                  "<input type=\"hidden\" name=\""+prefix+"_"+var+"\" 
value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
+            }
+            fieldCounter++;
+            }
+          }
+          
+          out.print("<input type=\"hidden\" name=\""+seqPrefix+node+"_count\" 
value=\""+Integer.toString(fieldCounter)+"\"/>\n");
+        }
+      }
+    }
+      
   public static String processSpecificationPost(IPostParameters 
variableContext, Locale locale, Specification os,
-                 int connectionSequenceNumber) throws ManifoldCFException {
-         // Remove old Nodes
-         int i;
-
-         String seqPrefix = "s"+connectionSequenceNumber+"_";
-                         
-         for(String node:SPECIFICATION_MAP.keySet()){
-                 
-                 String x = 
variableContext.getParameter(seqPrefix+node+"_count");
-                 if (x != null && x.length() > 0){
-                         
-                         i = 0;
-                         while (i < os.getChildCount())
-                         {
-                                 SpecificationNode specNode = os.getChild(i);
-                                 if (specNode.getType().equals(node))
-                                         os.removeChild(i);
-                                 else
-                                         i++;
-                         }
-
-                         Collection<String> vars = SPECIFICATION_MAP.get(node);
-
-                         int count = Integer.parseInt(x);
-                         i = 0;
-                         while (i < count)
-                         {
-                                 String prefix = 
seqPrefix+node+"_"+Integer.toString(i);
-                                 String op = 
variableContext.getParameter(prefix+"_op");
-                                 if (op == null || 
!op.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Delete")))
-                                 {
-                                         SpecificationNode specNode = new 
SpecificationNode(node);
-                                         for(String var:vars){
-                                                 String value = 
variableContext.getParameter(prefix+"_"+var);
-                                                 if(value == null)
-                                                         value = "";
-                                                 specNode.setAttribute(var, 
value);
-                                         }
-                                         os.addChild(os.getChildCount(), 
specNode);
-                                 }
-                                 i++;
-                         }
-
-                         String addop = 
variableContext.getParameter(seqPrefix+node+"_op");
-                         if (addop != null && 
addop.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Add")))
-                         {
-                                 SpecificationNode specNode = new 
SpecificationNode(node);
-                                 for(String var:vars){
-                                         String value = 
variableContext.getParameter(seqPrefix+var);
-                                         if(value == null)
-                                                 value = "";
-                                         specNode.setAttribute(var, value);
-                                 }
-                                 os.addChild(os.getChildCount(), specNode);
-                         }
-                 }
-         }
+      int connectionSequenceNumber) throws ManifoldCFException {
+    // Remove old Nodes
+    int i;
+
+    String seqPrefix = "s"+connectionSequenceNumber+"_";
+          
+    for(String node:SPECIFICATION_MAP.keySet()){
+      
+      String x = variableContext.getParameter(seqPrefix+node+"_count");
+      if (x != null && x.length() > 0){
+        
+        i = 0;
+        while (i < os.getChildCount())
+        {
+          SpecificationNode specNode = os.getChild(i);
+          if (specNode.getType().equals(node))
+            os.removeChild(i);
+          else
+            i++;
+        }
+
+        Collection<String> vars = SPECIFICATION_MAP.get(node);
+
+        int count = Integer.parseInt(x);
+        i = 0;
+        while (i < count)
+        {
+          String prefix = seqPrefix+node+"_"+Integer.toString(i);
+          String op = variableContext.getParameter(prefix+"_op");
+          if (op == null || 
!op.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Delete")))
+          {
+            SpecificationNode specNode = new SpecificationNode(node);
+            for(String var:vars){
+              String value = variableContext.getParameter(prefix+"_"+var);
+              if(value == null)
+                value = "";
+              specNode.setAttribute(var, value);
+            }
+            os.addChild(os.getChildCount(), specNode);
+          }
+          i++;
+        }
+
+        String addop = variableContext.getParameter(seqPrefix+node+"_op");
+        if (addop != null && 
addop.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Add")))
+        {
+          SpecificationNode specNode = new SpecificationNode(node);
+          for(String var:vars){
+            String value = variableContext.getParameter(seqPrefix+var);
+            if(value == null)
+              value = "";
+            specNode.setAttribute(var, value);
+          }
+          os.addChild(os.getChildCount(), specNode);
+        }
+      }
+    }
 
-         return null;
+    return null;
   }
   
   public static void viewSpecification(IHTTPOutput out, Locale locale, 
Specification os,
-                 int connectionSequenceNumber)
-                                 throws ManifoldCFException, IOException
+      int connectionSequenceNumber)
+          throws ManifoldCFException, IOException
   {
-         int i = 0;
+    int i = 0;
 
 
 
 
-         for(String node:SPECIFICATION_MAP.keySet()){
-                 Collection<String> vars = SPECIFICATION_MAP.get(node);
-                 out.print(
-                                 "\n"+
-                                                 "<table 
class=\"displaytable\">\n"+
-                                                 "  <tr>\n"+
-                                                 "    <td 
class=\"description\"><nobr>"+ Messages.getBodyJavascriptString(locale, 
"Alfresco.SpecificFilteringConfiguration",new String[]{node}) +"</nobr></td>\n"+
-                                                 "    <td 
class=\"boxcell\">\n"+
-                                                 "      <table 
class=\"formtable\">\n"+
-                                                 "        <tr 
class=\"formheaderrow\">\n");
-                 for(String var:vars)
-                         out.print(
-                                         "          <td 
class=\"formcolumnheader\"><nobr>" + var + "</nobr></td>\n");
-                                                 
-                out.print("        </tr>\n");
-                
-                int fieldCounter = 0;
-                 i = 0;
-                
-                 while (i < os.getChildCount()) {
-                         SpecificationNode sn = os.getChild(i++);
-                         if (sn.getType().equals(node)) {
-                                 out.print(
-                                                 "        <tr 
class=\""+(((fieldCounter % 2)==0)?"evenformrow":"oddformrow")+"\">\n");
-                                 for(String var:vars)
-                                         out.print(
-                                                                 "          
<td class=\"formcolumncell\">\n"+
-                                                                 "            
<nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
-                                                                 "          
</td>\n");
-                                 out.print(
-                                                                 "        
</tr>\n");
-                                 fieldCounter++;
-                         }
-                 }
-
-                 if (fieldCounter == 0)
-                 {
-                         out.print(
-                                         "        <tr class=\"formrow\"><td 
class=\"formmessage\" colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, 
"Alfresco.NoSpecificFilteringConfiguration",new String[]{node}) + "</td></tr>\n"
-                                         );
-                 }
-                 out.print(
-                                 "      </table>\n"+
-                                                 "    </td>\n"+
-                                                 "  </tr>\n"+
-                                                 "  </tr>\n"+
-                                                 "</table>\n");
-         }
+    for(String node:SPECIFICATION_MAP.keySet()){
+      Collection<String> vars = SPECIFICATION_MAP.get(node);
+      out.print(
+          "\n"+
+              "<table class=\"displaytable\">\n"+
+              "  <tr>\n"+
+              "    <td class=\"description\"><nobr>"+ 
Messages.getBodyJavascriptString(locale, 
"Alfresco.SpecificFilteringConfiguration",new String[]{node}) +"</nobr></td>\n"+
+              "    <td class=\"boxcell\">\n"+
+              "      <table class=\"formtable\">\n"+
+              "        <tr class=\"formheaderrow\">\n");
+      for(String var:vars)
+        out.print(
+            "          <td class=\"formcolumnheader\"><nobr>" + var + 
"</nobr></td>\n");
+              
+     out.print("        </tr>\n");
+     
+     int fieldCounter = 0;
+      i = 0;
+     
+      while (i < os.getChildCount()) {
+        SpecificationNode sn = os.getChild(i++);
+        if (sn.getType().equals(node)) {
+          out.print(
+              "        <tr class=\""+(((fieldCounter % 
2)==0)?"evenformrow":"oddformrow")+"\">\n");
+          for(String var:vars)
+            out.print(
+                  "          <td class=\"formcolumncell\">\n"+
+                  "            
<nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
+                  "          </td>\n");
+          out.print(
+                  "        </tr>\n");
+          fieldCounter++;
+        }
+      }
+
+      if (fieldCounter == 0)
+      {
+        out.print(
+            "        <tr class=\"formrow\"><td class=\"formmessage\" 
colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, 
"Alfresco.NoSpecificFilteringConfiguration",new String[]{node}) + "</td></tr>\n"
+            );
+      }
+      out.print(
+          "      </table>\n"+
+              "    </td>\n"+
+              "  </tr>\n"+
+              "  </tr>\n"+
+              "</table>\n");
+    }
   }
   
   public static String getSpecificationVersion(Specification os){
-         StringBuilder builder = new StringBuilder();
-         int i = 0;
-         while(i < os.getChildCount()){
-                 SpecificationNode node = os.getChild(i);
-                 Collection<String> vars = 
SPECIFICATION_MAP.get(node.getType());
-                 for(String var:vars)
-                         
builder.append(node.getAttributeValue(var)).append("+");
-                 i++;
-         }
-         return builder.toString();
+    StringBuilder builder = new StringBuilder();
+    int i = 0;
+    while(i < os.getChildCount()){
+      SpecificationNode node = os.getChild(i);
+      Collection<String> vars = SPECIFICATION_MAP.get(node.getType());
+      for(String var:vars)
+        builder.append(node.getAttributeValue(var)).append("+");
+      i++;
+    }
+    return builder.toString();
   }
   
   public static AlfrescoFilters getFilters(Specification spec) {
-               AlfrescoFilters filters = new AlfrescoFilters();
-               for(int i = 0; i < spec.getChildCount(); i++){
-                       SpecificationNode node = spec.getChild(i);
-                       if(node.getType().equals(NODE_SITE))
-                               
filters.addSiteFilter(node.getAttributeValue(ATTRIBUTE_SITE));
-                       else if(node.getType().equals(NODE_MIMETYPE))
-                               
filters.addMimetypeFilter(node.getAttributeValue(ATTRIBUTE_MIMETYPE));
-                       else if(node.getType().equals(NODE_ASPECT))
-                               filters.addAspectFilter(
-                                               
node.getAttributeValue(ATTRIBUTE_ASPECT));
-                       else if(node.getType().equals(NODE_METADATA))
-                               filters.addMetadataFilter(
-                                               
node.getAttributeValue(ATTRIBUTE_METADATA_SOURCE),
-                                               
node.getAttributeValue(ATTRIBUTE_METADATA_TARGET));
-               }
-               
-               return filters;
-       }
+    AlfrescoFilters filters = new AlfrescoFilters();
+    for(int i = 0; i < spec.getChildCount(); i++){
+      SpecificationNode node = spec.getChild(i);
+      if(node.getType().equals(NODE_SITE))
+        filters.addSiteFilter(node.getAttributeValue(ATTRIBUTE_SITE));
+      else if(node.getType().equals(NODE_MIMETYPE))
+        filters.addMimetypeFilter(node.getAttributeValue(ATTRIBUTE_MIMETYPE));
+      else if(node.getType().equals(NODE_ASPECT))
+        filters.addAspectFilter(
+            node.getAttributeValue(ATTRIBUTE_ASPECT));
+      else if(node.getType().equals(NODE_METADATA))
+        filters.addMetadataFilter(
+            node.getAttributeValue(ATTRIBUTE_METADATA_SOURCE),
+            node.getAttributeValue(ATTRIBUTE_METADATA_TARGET));
+    }
+    
+    return filters;
+  }
 }

Modified: 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration.js
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration.js?rev=1629191&r1=1629190&r2=1629191&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration.js
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration.js
 Fri Oct  3 12:31:13 2014
@@ -1,41 +1,41 @@
 <script type="text/javascript">
 <!--
 function checkConfig() {
-       return true;
+  return true;
 }
 
 function checkConfigForSave() {
-       if (editconnection.protocol.value == "") {
-               alert("Protocol must not be empty!");
-               SelectTab("Server");
-               editconnection.protocol.focus();
-               return false;
-       }
-       if (editconnection.hostname.value == "") {
-               alert("Hostname must not be empty!");
-               SelectTab("Server");
-               editconnection.hostname.focus();
-               return false;
-       }
-       if (editconnection.endpoint.value == "") {
-               alert("Endpoint must not be empty!");
-               SelectTab("Server");
-               editconnection.endpoint.focus();
-               return false;
-       }
-       if (editconnection.storeprotocol.value == "") {
-               alert("Store protocol must no be empty!");
-               SelectTab("Server");
-               editconnection.storeprotocol.focus();
-               return false;
-       }
-       if (editconnection.storeid.value == "") {
-               alert("Store id must no be empty!");
-               SelectTab("Server");
-               editconnection.storeid.focus();
-               return false;
-       }
-       return true;
+  if (editconnection.protocol.value == "") {
+    alert("Protocol must not be empty!");
+    SelectTab("Server");
+    editconnection.protocol.focus();
+    return false;
+  }
+  if (editconnection.hostname.value == "") {
+    alert("Hostname must not be empty!");
+    SelectTab("Server");
+    editconnection.hostname.focus();
+    return false;
+  }
+  if (editconnection.endpoint.value == "") {
+    alert("Endpoint must not be empty!");
+    SelectTab("Server");
+    editconnection.endpoint.focus();
+    return false;
+  }
+  if (editconnection.storeprotocol.value == "") {
+    alert("Store protocol must no be empty!");
+    SelectTab("Server");
+    editconnection.storeprotocol.focus();
+    return false;
+  }
+  if (editconnection.storeid.value == "") {
+    alert("Store id must no be empty!");
+    SelectTab("Server");
+    editconnection.storeid.focus();
+    return false;
+  }
+  return true;
 }
 // -->
 </script>

Modified: 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration_Server.html
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration_Server.html?rev=1629191&r1=1629190&r2=1629191&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration_Server.html
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/editConfiguration_Server.html
 Fri Oct  3 12:31:13 2014
@@ -1,37 +1,37 @@
 #if($tabName == "Server")
 <table class="displaytable">
-       <tr>
-               <td class="description">
-                       <nobr>Protocol</nobr>
-               </td>
-               <td class="value">
-                       <input name="protocol" type="text" size="32" 
value="$protocol" />
-               </td>
-       </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Hostname</nobr>
-               </td>
-               <td class="value">
-                       <input name="hostname" type="text" size="32" 
value="$hostname"/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Endpoint</nobr>
-               </td>
-               <td class="value">
-                       <input name="endpoint" type="text" size="32" 
value="$endpoint" />
-               </td>
-       </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Store protocol</nobr>
-               </td>
-               <td class="value">
-                       <input name="storeprotocol" type="text" size="32" 
value="$storeprotocol"/>
-               </td>
-       </tr>
+  <tr>
+    <td class="description">
+      <nobr>Protocol</nobr>
+    </td>
+    <td class="value">
+      <input name="protocol" type="text" size="32" 
value="$Encoder.attributeEscape($protocol)" />
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>Hostname</nobr>
+    </td>
+    <td class="value">
+      <input name="hostname" type="text" size="32" 
value="$Encoder.attributeEscape($hostname)"/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>Endpoint</nobr>
+    </td>
+    <td class="value">
+      <input name="endpoint" type="text" size="32" 
value="$Encoder.attributeEscape($endpoint)" />
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>Store protocol</nobr>
+    </td>
+    <td class="value">
+      <input name="storeprotocol" type="text" size="32" 
value="$Encoder.attributeEscape($storeprotocol)"/>
+    </td>
+  </tr>
     <tr>
         <td class="description">
             <nobr>Enable Document Processing</nobr>
@@ -40,38 +40,38 @@
             <input name="enabledocumentprocessing" type="checkbox" 
value="$enabledocumentprocessing"/>
         </td>
     </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Store id</nobr>
-               </td>
-               <td class="value">
-                       <input name="storeid" type="text" size="32" 
value="$storeid"/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Username</nobr>
-               </td>
-               <td class="value">
-                       <input name="username" type="text" size="32" 
value="$username"/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description">
-                       <nobr>Password</nobr>
-               </td>
-               <td class="value">
-                       <input name="password" type="password" size="32" 
value="$password"/>
-               </td>
-       </tr>
+  <tr>
+    <td class="description">
+      <nobr>Store id</nobr>
+    </td>
+    <td class="value">
+      <input name="storeid" type="text" size="32" 
value="$Encoder.attributeEscape($storeid)"/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>Username</nobr>
+    </td>
+    <td class="value">
+      <input name="username" type="text" size="32" 
value="$Encoder.attributeEscape($username)"/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description">
+      <nobr>Password</nobr>
+    </td>
+    <td class="value">
+      <input name="password" type="password" size="32" 
value="$Encoder.attributeEscape($password)"/>
+    </td>
+  </tr>
 </table>
 #else
-<input type="hidden" name="protocol" value="$protocol" />
-<input type="hidden" name="hostname" value="$hostname" />
-<input type="hidden" name="endpoint" value="$endpoint" />
-<input type="hidden" name="storeprotocol" value="$storeprotocol" />
+<input type="hidden" name="protocol" 
value="$Encoder.attributeEscape($protocol)" />
+<input type="hidden" name="hostname" 
value="$Encoder.attributeEscape($hostname)" />
+<input type="hidden" name="endpoint" 
value="$Encoder.attributeEscape($endpoint)" />
+<input type="hidden" name="storeprotocol" 
value="$Encoder.attributeEscape($storeprotocol)" />
 <input type="hidden" name="enabledocumentprocessing" 
value="$enabledocumentprocessing" />
-<input type="hidden" name="storeid" value="$storeid" />
-<input type="hidden" name="username" value="$username" />
-<input type="hidden" name="password" value="$password" />
+<input type="hidden" name="storeid" value="$Encoder.attributeEscape($storeid)" 
/>
+<input type="hidden" name="username" 
value="$Encoder.attributeEscape($username)" />
+<input type="hidden" name="password" 
value="$Encoder.attributeEscape($password)" />
 #end

Modified: 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/viewConfiguration.html
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/viewConfiguration.html?rev=1629191&r1=1629190&r2=1629191&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/viewConfiguration.html
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfrescowebscript/viewConfiguration.html
 Fri Oct  3 12:31:13 2014
@@ -1,36 +1,36 @@
 <table class="displaytable">
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Protocol:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$protocol</nobr><br/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Hostname:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$hostname</nobr><br/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Endpoint:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$endpoint</nobr><br/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Store protocol:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$storeprotocol</nobr><br/>
-               </td>
-       </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Protocol:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($protocol)</nobr><br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Hostname:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($hostname)</nobr><br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Endpoint:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($endpoint)</nobr><br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Store protocol:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($storeprotocol)</nobr><br/>
+    </td>
+  </tr>
     <tr>
         <td class="description" colspan="1">
             <nobr>Enable Document Processing:</nobr>
@@ -39,28 +39,28 @@
             <nobr>$enabledocumentprocessing</nobr><br/>
         </td>
     </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Store id:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$storeid</nobr><br/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Username:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>$username</nobr><br/>
-               </td>
-       </tr>
-       <tr>
-               <td class="description" colspan="1">
-                       <nobr>Password:</nobr>
-               </td>
-               <td class="value" colspan="3">
-                       <nobr>********</nobr><br/>
-               </td>
-       </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Store id:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($storeid)</nobr><br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Username:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>$Encoder.bodyEscape($username)</nobr><br/>
+    </td>
+  </tr>
+  <tr>
+    <td class="description" colspan="1">
+      <nobr>Password:</nobr>
+    </td>
+    <td class="value" colspan="3">
+      <nobr>********</nobr><br/>
+    </td>
+  </tr>
 </table>


Reply via email to