Modified: manifoldcf/branches/dev_1x/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java (original) +++ manifoldcf/branches/dev_1x/connectors/generic/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/generic/GenericConnector.java Thu Sep 18 16:56:59 2014 @@ -432,7 +432,7 @@ public class GenericConnector extends Ba try { // Can only index while background thread is running! doc.setBinary(is, fileLength); - activities.ingestDocument(documentIdentifiers[i], versions[i], item.url, doc); + activities.ingestDocumentWithException(documentIdentifiers[i], versions[i], item.url, doc); } finally { is.close(); } @@ -596,53 +596,77 @@ public class GenericConnector extends Ba + "</table>\n"); } + /** Obtain the name of the form check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form check javascript method. + */ @Override - public void outputSpecificationHeader(IHTTPOutput out, Locale locale, DocumentSpecification ds, List<String> tabsArray) + public String getFormCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecification"; + //return "checkSpecification"; + } + + /** Obtain the name of the form presave check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form presave check javascript method. + */ + @Override + public String getFormPresaveCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecificationForSave"; + //return "checkSpecificationForSave"; + } + + @Override + public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, List<String> tabsArray) throws ManifoldCFException, IOException { tabsArray.add(Messages.getString(locale, "generic.Parameters")); tabsArray.add(Messages.getString(locale, "generic.Security")); + String seqPrefix = "s"+connectionSequenceNumber+"_"; + out.print( "<script type=\"text/javascript\">\n" + "<!--\n" - + "function SpecOp(n, opValue, anchorvalue) {\n" + + "function "+seqPrefix+"SpecOp(n, opValue, anchorvalue) {\n" + " eval(\"editjob.\"+n+\".value = \\\"\"+opValue+\"\\\"\");\n" + " postFormSetAnchor(anchorvalue);\n" + "}\n" + "\n" - + "function checkSpecification() {\n" - + " return true;\n" - + "}\n" - + "\n" - + "function SpecAddToken(anchorvalue) {\n" - + " if (editjob.spectoken.value == \"\")\n" + + "function "+seqPrefix+"SpecAddToken(anchorvalue) {\n" + + " if (editjob."+seqPrefix+"spectoken.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "generic.TypeInAnAccessToken") + "\");\n" - + " editjob.spectoken.focus();\n" + + " editjob."+seqPrefix+"spectoken.focus();\n" + " return;\n" + " }\n" - + " SpecOp(\"accessop\",\"Add\",anchorvalue);\n" + + " "+seqPrefix+"SpecOp(\""+seqPrefix+"accessop\",\"Add\",anchorvalue);\n" + "}\n" - + "function SpecAddParam(anchorvalue) {\n" - + " if (editjob.specparamname.value == \"\")\n" + + "function "+seqPrefix+"SpecAddParam(anchorvalue) {\n" + + " if (editjob."+seqPrefix+"specparamname.value == \"\")\n" + " {\n" + " alert(\"" + Messages.getBodyJavascriptString(locale, "generic.TypeInParamName") + "\");\n" - + " editjob.specparamname.focus();\n" + + " editjob."+seqPrefix+"specparamname.focus();\n" + " return;\n" + " }\n" - + " SpecOp(\"paramop\",\"Add\",anchorvalue);\n" + + " "+seqPrefix+"SpecOp(\""+seqPrefix+"paramop\",\"Add\",anchorvalue);\n" + "}\n" + "//-->\n" + "</script>\n"); } @Override - public void outputSpecificationBody(IHTTPOutput out, Locale locale, DocumentSpecification ds, String tabName) + public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, int actualSequenceNumber, String tabName) throws ManifoldCFException, IOException { + String seqPrefix = "s"+connectionSequenceNumber+"_"; + int k, i; - if (tabName.equals(Messages.getString(locale, "generic.Parameters"))) { + if (tabName.equals(Messages.getString(locale, "generic.Parameters")) && connectionSequenceNumber == actualSequenceNumber) { out.print("<table class=\"displaytable\">" + "<tr><td class=\"description\"><nobr>" + Messages.getBodyString(locale, "generic.ParametersColon") + "</nobr></td>" @@ -661,22 +685,22 @@ public class GenericConnector extends Ba SpecificationNode sn = ds.getChild(i++); if (sn.getType().equals("param")) { String paramDescription = "_" + Integer.toString(k); - String paramOpName = "paramop" + paramDescription; + String paramOpName = seqPrefix + "paramop" + paramDescription; String paramName = sn.getAttributeValue("name"); String paramValue = sn.getValue(); out.print( " <tr class=\"evenformrow\">\n" + " <td class=\"formcolumncell\">\n" + " <input type=\"hidden\" name=\"" + paramOpName + "\" value=\"\"/>\n" - + " <a name=\"" + "param_" + Integer.toString(k) + "\">\n" + + " <a name=\"" + seqPrefix + "param_" + Integer.toString(k) + "\">\n" + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Delete") + "\" onClick='Javascript:SpecOp(\"" + paramOpName + "\",\"Delete\",\"param" + paramDescription + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.DeleteParameter") + Integer.toString(k) + "\"/>\n" + " </a> \n" + " </td>\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"text\" name=\"specparamname" + paramDescription + "\" value=\"" + Encoder.attributeEscape(paramName) + "\"/>\n" + + " <input type=\"text\" name=\""+seqPrefix+"specparamname" + paramDescription + "\" value=\"" + Encoder.attributeEscape(paramName) + "\"/>\n" + " </td>\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"text\" name=\"specparamvalue" + paramDescription + "\" value=\"" + Encoder.attributeEscape(paramValue) + "\"/>\n" + + " <input type=\"text\" name=\""+seqPrefix+"specparamvalue" + paramDescription + "\" value=\"" + Encoder.attributeEscape(paramValue) + "\"/>\n" + " </td>\n" + " </tr>\n"); k++; @@ -692,17 +716,17 @@ public class GenericConnector extends Ba " <tr><td class=\"lightseparator\" colspan=\"3\"><hr/></td></tr>\n" + " <tr class=\"evenformrow\">\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"hidden\" name=\"paramcount\" value=\"" + Integer.toString(k) + "\"/>\n" - + " <input type=\"hidden\" name=\"paramop\" value=\"\"/>\n" - + " <a name=\"param_" + Integer.toString(k) + "\">\n" - + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Add") + "\" onClick='Javascript:SpecAddParam(\"param_" + Integer.toString(k + 1) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.AddParameter") + "\"/>\n" + + " <input type=\"hidden\" name=\""+seqPrefix+"paramcount\" value=\"" + Integer.toString(k) + "\"/>\n" + + " <input type=\"hidden\" name=\""+seqPrefix+"paramop\" value=\"\"/>\n" + + " <a name=\""+seqPrefix+"param_" + Integer.toString(k) + "\">\n" + + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Add") + "\" onClick='Javascript:"+seqPrefix+"SpecAddParam(\""+seqPrefix+"param_" + Integer.toString(k + 1) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.AddParameter") + "\"/>\n" + " </a> \n" + " </td>\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"text\" size=\"30\" name=\"specparamname\" value=\"\"/>\n" + + " <input type=\"text\" size=\"30\" name=\""+seqPrefix+"specparamname\" value=\"\"/>\n" + " </td>\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"text\" size=\"30\" name=\"specparamvalue\" value=\"\"/>\n" + + " <input type=\"text\" size=\"30\" name=\""+seqPrefix+"specparamvalue\" value=\"\"/>\n" + " </td>\n" + " </tr>\n" + "</table>\n"); @@ -717,12 +741,12 @@ public class GenericConnector extends Ba String paramName = sn.getAttributeValue("name"); String paramValue = sn.getValue(); out.print( - "<input type=\"hidden\" name=\"" + "specparamname" + accessDescription + "\" value=\"" + Encoder.attributeEscape(paramName) + "\"/>\n" - + "<input type=\"hidden\" name=\"" + "specparamvalue" + accessDescription + "\" value=\"" + Encoder.attributeEscape(paramValue) + "\"/>\n"); + "<input type=\"hidden\" name=\"" + seqPrefix + "specparamname" + accessDescription + "\" value=\"" + Encoder.attributeEscape(paramName) + "\"/>\n" + + "<input type=\"hidden\" name=\"" + seqPrefix + "specparamvalue" + accessDescription + "\" value=\"" + Encoder.attributeEscape(paramValue) + "\"/>\n"); k++; } } - out.print("<input type=\"hidden\" name=\"paramcount\" value=\"" + Integer.toString(k) + "\"/>\n"); + out.print("<input type=\"hidden\" name=\""+seqPrefix+"paramcount\" value=\"" + Integer.toString(k) + "\"/>\n"); } // Security tab @@ -733,7 +757,7 @@ public class GenericConnector extends Ba genericAuthMode = sn.getValue(); } } - if (tabName.equals(Messages.getString(locale, "generic.Security"))) { + if (tabName.equals(Messages.getString(locale, "generic.Security")) && connectionSequenceNumber == actualSequenceNumber) { out.print( "<table class=\"displaytable\">\n" + " <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"); @@ -741,8 +765,8 @@ public class GenericConnector extends Ba out.print(" <tr>\n" + " <td class=\"description\">" + Messages.getBodyString(locale, "generic.AuthMode") + "</td>\n" + " <td class=\"value\" >\n" - + " <input type=\"radio\" name=\"genericAuthMode\" value=\"provided\" " + ("provided".equals(genericAuthMode) ? "checked=\"checked\"" : "") + "/>" + Messages.getBodyString(locale, "generic.AuthModeProvided") + "<br/>\n" - + " <input type=\"radio\" name=\"genericAuthMode\" value=\"forced\" " + ("forced".equals(genericAuthMode) ? "checked=\"checked\"" : "") + "/>" + Messages.getBodyString(locale, "generic.AuthModeForced") + "<br/>\n" + + " <input type=\"radio\" name=\""+seqPrefix+"genericAuthMode\" value=\"provided\" " + ("provided".equals(genericAuthMode) ? "checked=\"checked\"" : "") + "/>" + Messages.getBodyString(locale, "generic.AuthModeProvided") + "<br/>\n" + + " <input type=\"radio\" name=\""+seqPrefix+"genericAuthMode\" value=\"forced\" " + ("forced".equals(genericAuthMode) ? "checked=\"checked\"" : "") + "/>" + Messages.getBodyString(locale, "generic.AuthModeForced") + "<br/>\n" + " </td>\n" + " </tr>\n"); // Go through forced ACL @@ -759,15 +783,15 @@ public class GenericConnector extends Ba SpecificationNode sn = ds.getChild(i++); if (sn.getType().equals("access")) { String accessDescription = "_" + Integer.toString(k); - String accessOpName = "accessop" + accessDescription; + String accessOpName = seqPrefix + "accessop" + accessDescription; String token = sn.getAttributeValue("token"); out.print( " <tr class=\"evenformrow\">\n" + " <td class=\"formcolumncell\">\n" + " <input type=\"hidden\" name=\"" + accessOpName + "\" value=\"\"/>\n" - + " <input type=\"hidden\" name=\"" + "spectoken" + accessDescription + "\" value=\"" + Encoder.attributeEscape(token) + "\"/>\n" - + " <a name=\"" + "token_" + Integer.toString(k) + "\">\n" - + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Delete") + "\" onClick='Javascript:SpecOp(\"" + accessOpName + "\",\"Delete\",\"token_" + Integer.toString(k) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.DeleteToken") + Integer.toString(k) + "\"/>\n" + + " <input type=\"hidden\" name=\"" + seqPrefix + "spectoken" + accessDescription + "\" value=\"" + Encoder.attributeEscape(token) + "\"/>\n" + + " <a name=\"" + seqPrefix + "token_" + Integer.toString(k) + "\">\n" + + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Delete") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\"" + accessOpName + "\",\"Delete\",\""+seqPrefix+"token_" + Integer.toString(k) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.DeleteToken") + Integer.toString(k) + "\"/>\n" + " </a> \n" + " </td>\n" + " <td class=\"formcolumncell\">\n" @@ -787,14 +811,14 @@ public class GenericConnector extends Ba " <tr><td class=\"lightseparator\" colspan=\"2\"><hr/></td></tr>\n" + " <tr class=\"evenformrow\">\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"hidden\" name=\"tokencount\" value=\"" + Integer.toString(k) + "\"/>\n" - + " <input type=\"hidden\" name=\"accessop\" value=\"\"/>\n" - + " <a name=\"" + "token_" + Integer.toString(k) + "\">\n" - + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Add") + "\" onClick='Javascript:SpecAddToken(\"token_" + Integer.toString(k + 1) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.AddAccessToken") + "\"/>\n" + + " <input type=\"hidden\" name=\""+seqPrefix+"tokencount\" value=\"" + Integer.toString(k) + "\"/>\n" + + " <input type=\"hidden\" name=\""+seqPrefix+"accessop\" value=\"\"/>\n" + + " <a name=\"" + seqPrefix + "token_" + Integer.toString(k) + "\">\n" + + " <input type=\"button\" value=\"" + Messages.getAttributeString(locale, "generic.Add") + "\" onClick='Javascript:"+seqPrefix+"SpecAddToken(\""+seqPrefix+"token_" + Integer.toString(k + 1) + "\")' alt=\"" + Messages.getAttributeString(locale, "generic.AddAccessToken") + "\"/>\n" + " </a> \n" + " </td>\n" + " <td class=\"formcolumncell\">\n" - + " <input type=\"text\" size=\"30\" name=\"spectoken\" value=\"\"/>\n" + + " <input type=\"text\" size=\"30\" name=\""+seqPrefix+"spectoken\" value=\"\"/>\n" + " </td>\n" + " </tr>\n" + "</table>\n"); @@ -807,22 +831,24 @@ public class GenericConnector extends Ba SpecificationNode sn = ds.getChild(i++); if (sn.getType().equals("access")) { String accessDescription = "_" + Integer.toString(k); - String token = "" + sn.getAttributeValue("token"); + String token = sn.getAttributeValue("token"); out.print( - "<input type=\"hidden\" name=\"" + "spectoken" + accessDescription + "\" value=\"" + Encoder.attributeEscape(token) + "\"/>\n"); + "<input type=\"hidden\" name=\"" + seqPrefix + "spectoken" + accessDescription + "\" value=\"" + Encoder.attributeEscape(token) + "\"/>\n"); k++; } } - out.print("<input type=\"hidden\" name=\"tokencount\" value=\"" + Integer.toString(k) + "\"/>\n"); - out.print("<input type=\"hidden\" name=\"genericAuthMode\" value=\"" + Encoder.attributeEscape(genericAuthMode) + "\"/>\n"); + out.print("<input type=\"hidden\" name=\""+seqPrefix+"tokencount\" value=\"" + Integer.toString(k) + "\"/>\n"); + out.print("<input type=\"hidden\" name=\""+seqPrefix+"genericAuthMode\" value=\"" + Encoder.attributeEscape(genericAuthMode) + "\"/>\n"); } } @Override - public String processSpecificationPost(IPostParameters variableContext, Locale locale, DocumentSpecification ds) + public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds, + int connectionSequenceNumber) throws ManifoldCFException { + String seqPrefix = "s"+connectionSequenceNumber+"_"; - String xc = variableContext.getParameter("paramcount"); + String xc = variableContext.getParameter(seqPrefix+"paramcount"); if (xc != null) { // Delete all tokens first int i = 0; @@ -839,7 +865,7 @@ public class GenericConnector extends Ba i = 0; while (i < accessCount) { String paramDescription = "_" + Integer.toString(i); - String paramOpName = "paramop" + paramDescription; + String paramOpName = seqPrefix + "paramop" + paramDescription; xc = variableContext.getParameter(paramOpName); if (xc != null && xc.equals("Delete")) { // Next row @@ -847,8 +873,8 @@ public class GenericConnector extends Ba continue; } // Get the stuff we need - String paramName = variableContext.getParameter("specparamname" + paramDescription); - String paramValue = variableContext.getParameter("specparamvalue" + paramDescription); + String paramName = variableContext.getParameter(seqPrefix + "specparamname" + paramDescription); + String paramValue = variableContext.getParameter(seqPrefix + "specparamvalue" + paramDescription); SpecificationNode node = new SpecificationNode("param"); node.setAttribute("name", paramName); node.setValue(paramValue); @@ -856,10 +882,10 @@ public class GenericConnector extends Ba i++; } - String op = variableContext.getParameter("paramop"); + String op = variableContext.getParameter(seqPrefix+"paramop"); if (op != null && op.equals("Add")) { - String paramName = variableContext.getParameter("specparamname"); - String paramValue = variableContext.getParameter("specparamvalue"); + String paramName = variableContext.getParameter(seqPrefix+"specparamname"); + String paramValue = variableContext.getParameter(seqPrefix+"specparamvalue"); SpecificationNode node = new SpecificationNode("param"); node.setAttribute("name", paramName); node.setValue(paramValue); @@ -867,7 +893,7 @@ public class GenericConnector extends Ba } } - String redmineAuthMode = variableContext.getParameter("genericAuthMode"); + String redmineAuthMode = variableContext.getParameter(seqPrefix+"genericAuthMode"); if (redmineAuthMode != null) { // Delete existing seeds record first int i = 0; @@ -884,7 +910,7 @@ public class GenericConnector extends Ba ds.addChild(ds.getChildCount(), cn); } - xc = variableContext.getParameter("tokencount"); + xc = variableContext.getParameter(seqPrefix+"tokencount"); if (xc != null) { // Delete all tokens first int i = 0; @@ -901,7 +927,7 @@ public class GenericConnector extends Ba i = 0; while (i < accessCount) { String accessDescription = "_" + Integer.toString(i); - String accessOpName = "accessop" + accessDescription; + String accessOpName = seqPrefix + "accessop" + accessDescription; xc = variableContext.getParameter(accessOpName); if (xc != null && xc.equals("Delete")) { // Next row @@ -909,16 +935,16 @@ public class GenericConnector extends Ba continue; } // Get the stuff we need - String accessSpec = variableContext.getParameter("spectoken" + accessDescription); + String accessSpec = variableContext.getParameter(seqPrefix + "spectoken" + accessDescription); SpecificationNode node = new SpecificationNode("access"); node.setAttribute("token", accessSpec); ds.addChild(ds.getChildCount(), node); i++; } - String op = variableContext.getParameter("accessop"); + String op = variableContext.getParameter(seqPrefix+"accessop"); if (op != null && op.equals("Add")) { - String accessspec = variableContext.getParameter("spectoken"); + String accessspec = variableContext.getParameter(seqPrefix+"spectoken"); SpecificationNode node = new SpecificationNode("access"); node.setAttribute("token", accessspec); ds.addChild(ds.getChildCount(), node); @@ -929,7 +955,8 @@ public class GenericConnector extends Ba } @Override - public void viewSpecification(IHTTPOutput out, Locale locale, DocumentSpecification ds) + public void viewSpecification(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber) throws ManifoldCFException, IOException { boolean seenAny; int i;
Modified: manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java (original) +++ manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/googledrive/GoogleDriveRepositoryConnector.java Thu Sep 18 16:56:59 2014 @@ -45,6 +45,7 @@ import org.apache.manifoldcf.core.interf import org.apache.manifoldcf.core.interfaces.IPasswordMapperActivity; import org.apache.manifoldcf.core.interfaces.IPostParameters; import org.apache.manifoldcf.core.interfaces.IThreadContext; +import org.apache.manifoldcf.core.interfaces.Specification; import org.apache.manifoldcf.core.interfaces.SpecificationNode; import org.apache.manifoldcf.crawler.interfaces.DocumentSpecification; import org.apache.manifoldcf.crawler.interfaces.IProcessActivity; @@ -563,7 +564,7 @@ public class GoogleDriveRepositoryConnec /** * Fill in specification Velocity parameter map for GOOGLEDRIVEQuery tab. */ - private static void fillInGOOGLEDRIVEQuerySpecificationMap(Map<String, Object> newMap, DocumentSpecification ds) { + private static void fillInGOOGLEDRIVEQuerySpecificationMap(Map<String, Object> newMap, Specification ds) { String GoogleDriveQuery = GoogleDriveConfig.GOOGLEDRIVE_QUERY_DEFAULT; for (int i = 0; i < ds.getChildCount(); i++) { SpecificationNode sn = ds.getChild(i); @@ -577,7 +578,7 @@ public class GoogleDriveRepositoryConnec /** * Fill in specification Velocity parameter map for GOOGLEDRIVESecurity tab. */ - private static void fillInGOOGLEDRIVESecuritySpecificationMap(Map<String, Object> newMap, DocumentSpecification ds) { + private static void fillInGOOGLEDRIVESecuritySpecificationMap(Map<String, Object> newMap, Specification ds) { List<Map<String,String>> accessTokenList = new ArrayList<Map<String,String>>(); for (int i = 0; i < ds.getChildCount(); i++) { SpecificationNode sn = ds.getChild(i); @@ -591,21 +592,23 @@ public class GoogleDriveRepositoryConnec newMap.put("ACCESSTOKENS", accessTokenList); } - /** - * View specification. This method is called in the body section of a job's - * view page. Its purpose is to present the document 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 ds is the current document specification for this job. - */ + /** View specification. + * This method is called in the body section of a job's view page. Its purpose is to present the document + * 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. + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + */ @Override - public void viewSpecification(IHTTPOutput out, Locale locale, DocumentSpecification ds) - throws ManifoldCFException, IOException { + public void viewSpecification(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber) + throws ManifoldCFException, IOException { Map<String, Object> paramMap = new HashMap<String, Object>(); + paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber)); // Fill in the map with data from all tabs fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds); @@ -614,25 +617,26 @@ public class GoogleDriveRepositoryConnec Messages.outputResourceWithVelocity(out,locale,VIEW_SPEC_FORWARD,paramMap); } - /** - * 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 document specification accordingly. The name of the posted - * form is "editjob". - * - * @param variableContext contains the post data, including binary - * file-upload information. - * @param ds is the current document 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). - */ + /** 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 + * document specification accordingly. The name of the posted form is always "editjob". + * The connector will be connected before this method can be called. + *@param variableContext contains the post data, including binary file-upload information. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the 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). + */ @Override - public String processSpecificationPost(IPostParameters variableContext, - DocumentSpecification ds) throws ManifoldCFException { + public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds, + int connectionSequenceNumber) + throws ManifoldCFException { + + String seqPrefix = "s"+connectionSequenceNumber+"_"; - String googleDriveQuery = variableContext.getParameter("googledrivequery"); + String googleDriveQuery = variableContext.getParameter(seqPrefix+"googledrivequery"); if (googleDriveQuery != null) { int i = 0; while (i < ds.getChildCount()) { @@ -648,7 +652,7 @@ public class GoogleDriveRepositoryConnec ds.addChild(ds.getChildCount(), node); } - String xc = variableContext.getParameter("tokencount"); + String xc = variableContext.getParameter(seqPrefix+"tokencount"); if (xc != null) { // Delete all tokens first int i = 0; @@ -664,7 +668,7 @@ public class GoogleDriveRepositoryConnec i = 0; while (i < accessCount) { String accessDescription = "_"+Integer.toString(i); - String accessOpName = "accessop"+accessDescription; + String accessOpName = seqPrefix+"accessop"+accessDescription; xc = variableContext.getParameter(accessOpName); if (xc != null && xc.equals("Delete")) { // Next row @@ -672,17 +676,17 @@ public class GoogleDriveRepositoryConnec continue; } // Get the stuff we need - String accessSpec = variableContext.getParameter("spectoken"+accessDescription); + String accessSpec = variableContext.getParameter(seqPrefix+"spectoken"+accessDescription); SpecificationNode node = new SpecificationNode(JOB_ACCESS_NODE_TYPE); node.setAttribute(JOB_TOKEN_ATTRIBUTE,accessSpec); ds.addChild(ds.getChildCount(),node); i++; } - String op = variableContext.getParameter("accessop"); + String op = variableContext.getParameter(seqPrefix+"accessop"); if (op != null && op.equals("Add")) { - String accessspec = variableContext.getParameter("spectoken"); + String accessspec = variableContext.getParameter(seqPrefix+"spectoken"); SpecificationNode node = new SpecificationNode(JOB_ACCESS_NODE_TYPE); node.setAttribute(JOB_TOKEN_ATTRIBUTE,accessspec); ds.addChild(ds.getChildCount(),node); @@ -692,53 +696,80 @@ public class GoogleDriveRepositoryConnec return null; } - /** - * Output the specification body section. This method is called in the body - * section of a job page which has selected a repository 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 ds is the current document specification for this job. - * @param tabName is the current tab name. - */ + /** Obtain the name of the form check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form check javascript method. + */ + @Override + public String getFormCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecification"; + //return "checkSpecification"; + } + + /** Obtain the name of the form presave check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form presave check javascript method. + */ + @Override + public String getFormPresaveCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecificationForSave"; + //return "checkSpecificationForSave"; + } + + /** Output the specification body section. + * This method is called in the body section of a job page which has selected a repository 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 always "editjob". + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@param actualSequenceNumber is the connection within the job that has currently been selected. + *@param tabName is the current tab name. (actualSequenceNumber, tabName) form a unique tuple within + * the job. + */ @Override - public void outputSpecificationBody(IHTTPOutput out, - Locale locale, DocumentSpecification ds, String tabName) throws ManifoldCFException, - IOException { + public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, int actualSequenceNumber, String tabName) + throws ManifoldCFException, IOException { // Output GOOGLEDRIVEQuery tab Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("TabName", tabName); + paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber)); + paramMap.put("SelectedNum", Integer.toString(actualSequenceNumber)); + fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds); fillInGOOGLEDRIVESecuritySpecificationMap(paramMap, ds); Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_FORWARD_GOOGLEDRIVEQUERY,paramMap); Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_FORWARD_SECURITY,paramMap); } - /** - * Output the specification header section. This method is called in the - * head section of a job page which has selected a repository 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 ds is the current document 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. - */ + /** Output the specification header section. + * This method is called in the head section of a job page which has selected a repository 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. + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector. + */ @Override - public void outputSpecificationHeader(IHTTPOutput out, - Locale locale, DocumentSpecification ds, List<String> tabsArray) - throws ManifoldCFException, IOException { + public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, List<String> tabsArray) + throws ManifoldCFException, IOException { tabsArray.add(Messages.getString(locale, GOOGLEDRIVE_QUERY_TAB_PROPERTY)); tabsArray.add(Messages.getString(locale, GOOGLEDRIVE_SECURITY_TAB_PROPERTY)); Map<String, Object> paramMap = new HashMap<String, Object>(); + paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber)); // Fill in the specification header map, using data from all tabs. fillInGOOGLEDRIVEQuerySpecificationMap(paramMap, ds); Modified: manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js (original) +++ manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledrive.js Thu Sep 18 16:56:59 2014 @@ -17,37 +17,37 @@ <script type="text/javascript"> <!-- -function checkSpecificationForSave() +function s${SeqNum}_checkSpecificationForSave() { - if (editjob.googledrivequery.value == "") { + if (editjob.s${SeqNum}_googledrivequery.value == "") { alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.SeedQueryCannotBeNull'))"); - SelectTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery'))"); - editjob.googledrivequery.focus(); + SelectSequencedTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery'))",${SeqNum}); + editjob.s${SeqNum}_googledrivequery.focus(); return false; } return true; } -function SpecOp(n, opValue, anchorvalue) +function s${SeqNum}_SpecOp(n, opValue, anchorvalue) { eval("editjob."+n+".value = \""+opValue+"\""); postFormSetAnchor(anchorvalue); } -function SpecDeleteToken(i) +function s${SeqNum}_SpecDeleteToken(i) { - SpecOp("accessop_"+i,"Delete","token_"+i); + s${SeqNum}_SpecOp("s${SeqNum}_accessop_"+i,"Delete","s${SeqNum}_token_"+i); } -function SpecAddToken(i) +function s${SeqNum}_SpecAddToken(i) { - if (editjob.spectoken.value == "") + if (editjob.s${SeqNum}_spectoken.value == "") { alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.TypeInAnAccessToken'))"); - editjob.spectoken.focus(); + editjob.s${SeqNum}_spectoken.focus(); return; } - SpecOp("accessop","Add","token_"+i); + s${SeqNum}_SpecOp("s${SeqNum}_accessop","Add","s${SeqNum}_token_"+i); } //--> Modified: manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html (original) +++ manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveQuery.html Thu Sep 18 16:56:59 2014 @@ -15,7 +15,7 @@ limitations under the License. --> -#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery')) +#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.GoogleDriveQuery') && ${SeqNum} == ${SelectedNum}) <table class="displaytable"> <tr><td class="separator" colspan="2"><hr/></td></tr> @@ -27,7 +27,7 @@ </td> <td class="value"> <nobr> - <input type="text" size="120" name="googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)" /> + <input type="text" size="120" name="s${SeqNum}_googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)" /> </nobr> </td> </tr> @@ -35,6 +35,6 @@ #else -<input type="hidden" name="googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)" /> +<input type="hidden" name="s${SeqNum}_googledrivequery" value="$Encoder.attributeEscape($GOOGLEDRIVEQUERY)" /> #end Modified: manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html (original) +++ manifoldcf/branches/dev_1x/connectors/googledrive/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/googledrive/editSpecification_googledriveSecurity.html Thu Sep 18 16:56:59 2014 @@ -15,7 +15,7 @@ limitations under the License. --> -#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.Security')) +#if($TabName == $ResourceBundle.getString('GoogleDriveRepositoryConnector.Security') && ${SeqNum} == ${SelectedNum}) <table class="displaytable"> <tr><td class="separator" colspan="2"><hr/></td></tr> @@ -25,10 +25,10 @@ <tr> <td class="description"> - <input type="hidden" name="accessop_$atcounter" value=""/> - <input type="hidden" name="spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/> - <a name="token_$atcounter"> - <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Delete'))" onClick='Javascript:SpecDeleteToken($atcounter)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.DeleteToken'))$atcounter"/> + <input type="hidden" name="s${SeqNum}_accessop_$atcounter" value=""/> + <input type="hidden" name="s${SeqNum}_spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/> + <a name="s${SeqNum}_token_$atcounter"> + <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Delete'))" onClick='Javascript:s${SeqNum}_SpecDeleteToken($atcounter)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.DeleteToken'))$atcounter"/> </a> </td> <td class="value">$Encoder.bodyEscape($atoken.get('TOKEN'))</td> @@ -49,14 +49,14 @@ <tr> <td class="description"> - <input type="hidden" name="tokencount" value="$atcounter"/> - <input type="hidden" name="accessop" value=""/> - <a name="token_$atcounter"> - <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Add'))" onClick='Javascript:SpecAddToken($nexttoken)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.AddAccessToken'))"/> + <input type="hidden" name="s${SeqNum}_tokencount" value="$atcounter"/> + <input type="hidden" name="s${SeqNum}_accessop" value=""/> + <a name="s${SeqNum}_token_$atcounter"> + <input type="button" value="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.Add'))" onClick='Javascript:s${SeqNum}_SpecAddToken($nexttoken)' alt="$Encoder.attributeEscape($ResourceBundle.getString('GoogleDriveRepositoryConnector.AddAccessToken'))"/> </a> </td> <td class="value"> - <input type="text" size="30" name="spectoken" value=""/> + <input type="text" size="30" name="s${SeqNum}_spectoken" value=""/> </td> </tr> </table> @@ -65,9 +65,9 @@ #set($atcounter = 0) #foreach($atoken in $ACCESSTOKENS) -<input type="hidden" name="spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/> +<input type="hidden" name="s${SeqNum}_spectoken_$atcounter" value="$Encoder.attributeEscape($atoken.get('TOKEN'))"/> #set($atcounter = $atcounter + 1) #end -<input type="hidden" name="tokencount" value="$atcounter"/> +<input type="hidden" name="s${SeqNum}_tokencount" value="$atcounter"/> #end Modified: manifoldcf/branches/dev_1x/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/hdfs/HDFSRepositoryConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/hdfs/HDFSRepositoryConnector.java?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/hdfs/HDFSRepositoryConnector.java (original) +++ manifoldcf/branches/dev_1x/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/hdfs/HDFSRepositoryConnector.java Thu Sep 18 16:56:59 2014 @@ -751,30 +751,54 @@ public class HDFSRepositoryConnector ext "</table>\n" ); } - + + /** Obtain the name of the form check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form check javascript method. + */ + @Override + public String getFormCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecification"; + //return "checkSpecification"; + } + + /** Obtain the name of the form presave check javascript method to call. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@return the name of the form presave check javascript method. + */ + @Override + public String getFormPresaveCheckJavascriptMethodName(int connectionSequenceNumber) + { + return "s"+connectionSequenceNumber+"_checkSpecificationForSave"; + //return "checkSpecificationForSave"; + } + /** Output the specification header section. - * This method is called in the head section of a job page which has selected a repository 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 ds is the current document 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. - */ + * This method is called in the head section of a job page which has selected a repository 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. + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector. + */ @Override - public void outputSpecificationHeader(IHTTPOutput out, Locale locale, DocumentSpecification ds, List<String> tabsArray) + public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, List<String> tabsArray) throws ManifoldCFException, IOException { tabsArray.add(Messages.getString(locale,"HDFSRepositoryConnector.Paths")); + String seqPrefix = "s"+connectionSequenceNumber+"_"; + out.print( "<script type=\"text/javascript\">\n"+ "<!--\n"+ -"function checkSpecification()\n"+ -"{\n"+ -" // Does nothing right now.\n"+ -" return true;\n"+ -"}\n"+ "\n"+ -"function SpecOp(n, opValue, anchorvalue)\n"+ +"function "+seqPrefix+"SpecOp(n, opValue, anchorvalue)\n"+ "{\n"+ " eval(\"editjob.\"+n+\".value = \\\"\"+opValue+\"\\\"\");\n"+ " postFormSetAnchor(anchorvalue);\n"+ @@ -785,22 +809,31 @@ public class HDFSRepositoryConnector ext } /** Output the specification body section. - * This method is called in the body section of a job page which has selected a repository 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 ds is the current document specification for this job. - *@param tabName is the current tab name. - */ + * This method is called in the body section of a job page which has selected a repository 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 always "editjob". + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + *@param actualSequenceNumber is the connection within the job that has currently been selected. + *@param tabName is the current tab name. (actualSequenceNumber, tabName) form a unique tuple within + * the job. + */ @Override - public void outputSpecificationBody(IHTTPOutput out, Locale locale, DocumentSpecification ds, String tabName) + public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber, int actualSequenceNumber, String tabName) throws ManifoldCFException, IOException { + String seqPrefix = "s"+connectionSequenceNumber+"_"; + int i; int k; // Paths tab - if (tabName.equals(Messages.getString(locale,"HDFSRepositoryConnector.Paths"))) + if (tabName.equals(Messages.getString(locale,"HDFSRepositoryConnector.Paths")) && connectionSequenceNumber == actualSequenceNumber) { out.print( "<table class=\"displaytable\">\n"+ @@ -824,7 +857,7 @@ public class HDFSRepositoryConnector ext if (sn.getType().equals("startpoint")) { String pathDescription = "_"+Integer.toString(k); - String pathOpName = "specop"+pathDescription; + String pathOpName = seqPrefix+"specop"+pathDescription; String path = sn.getAttributeValue("path"); String convertToURIString = sn.getAttributeValue("converttouri"); @@ -837,9 +870,9 @@ public class HDFSRepositoryConnector ext " <tr class=\""+(((k % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+ " <td class=\"formcolumncell\">\n"+ " <input type=\"hidden\" name=\""+pathOpName+"\" value=\"\"/>\n"+ -" <input type=\"hidden\" name=\""+"specpath"+pathDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue("path"))+"\"/>\n"+ -" <a name=\""+"path_"+Integer.toString(k)+"\">\n"+ -" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Delete") + "\" onClick='Javascript:SpecOp(\""+pathOpName+"\",\"Delete\",\"path_"+Integer.toString(k)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.DeletePath")+Integer.toString(k)+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specpath"+pathDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue("path"))+"\"/>\n"+ +" <a name=\""+seqPrefix+"path_"+Integer.toString(k)+"\">\n"+ +" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Delete") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+pathOpName+"\",\"Delete\",\""+seqPrefix+"path_"+Integer.toString(k)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.DeletePath")+Integer.toString(k)+"\"/>\n"+ " </a>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ @@ -848,13 +881,13 @@ public class HDFSRepositoryConnector ext " </nobr>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ -" <input type=\"hidden\" name=\"converttouri"+pathDescription+"\" value=\""+(convertToURI?"true":"false")+"\">\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"converttouri"+pathDescription+"\" value=\""+(convertToURI?"true":"false")+"\">\n"+ " <nobr>\n"+ " "+(convertToURI?Messages.getBodyString(locale,"HDFSRepositoryConnector.Yes"):Messages.getBodyString(locale,"HDFSRepositoryConnector.No"))+" \n"+ " </nobr>\n"+ " </td>\n"+ " <td class=\"boxcell\">\n"+ -" <input type=\"hidden\" name=\""+"specchildcount"+pathDescription+"\" value=\""+Integer.toString(sn.getChildCount())+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specchildcount"+pathDescription+"\" value=\""+Integer.toString(sn.getChildCount())+"\"/>\n"+ " <table class=\"formtable\">\n"+ " <tr class=\"formheaderrow\">\n"+ " <td class=\"formcolumnheader\"></td>\n"+ @@ -868,7 +901,7 @@ public class HDFSRepositoryConnector ext { SpecificationNode excludeNode = sn.getChild(j); String instanceDescription = "_"+Integer.toString(k)+"_"+Integer.toString(j); - String instanceOpName = "specop" + instanceDescription; + String instanceOpName = seqPrefix + "specop" + instanceDescription; String nodeFlavor = excludeNode.getType(); String nodeType = excludeNode.getAttributeValue("type"); @@ -877,12 +910,12 @@ public class HDFSRepositoryConnector ext " <tr class=\"evenformrow\">\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.InsertHere") + "\" onClick='Javascript:SpecOp(\"specop"+instanceDescription+"\",\"Insert Here\",\"match_"+Integer.toString(k)+"_"+Integer.toString(j+1)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.InsertNewMatchForPath")+Integer.toString(k)+" before position #"+Integer.toString(j)+"\"/>\n"+ +" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.InsertHere") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+seqPrefix+"specop"+instanceDescription+"\",\"Insert Here\",\""+seqPrefix+"match_"+Integer.toString(k)+"_"+Integer.toString(j+1)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.InsertNewMatchForPath")+Integer.toString(k)+" before position #"+Integer.toString(j)+"\"/>\n"+ " </nobr>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <select name=\""+"specflavor"+instanceDescription+"\">\n"+ +" <select name=\""+seqPrefix+"specflavor"+instanceDescription+"\">\n"+ " <option value=\"include\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.include") + "</option>\n"+ " <option value=\"exclude\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.exclude") + "</option>\n"+ " </select>\n"+ @@ -890,7 +923,7 @@ public class HDFSRepositoryConnector ext " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <select name=\""+"spectype"+instanceDescription+"\">\n"+ +" <select name=\""+seqPrefix+"spectype"+instanceDescription+"\">\n"+ " <option value=\"file\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.File") + "</option>\n"+ " <option value=\"directory\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.Directory") + "</option>\n"+ " </select>\n"+ @@ -898,19 +931,19 @@ public class HDFSRepositoryConnector ext " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input type=\"text\" size=\"10\" name=\""+"specmatch"+instanceDescription+"\" value=\"\"/>\n"+ +" <input type=\"text\" size=\"10\" name=\""+seqPrefix+"specmatch"+instanceDescription+"\" value=\"\"/>\n"+ " </nobr>\n"+ " </td>\n"+ " </tr>\n"+ " <tr class=\"oddformrow\">\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input type=\"hidden\" name=\""+"specop"+instanceDescription+"\" value=\"\"/>\n"+ -" <input type=\"hidden\" name=\""+"specfl"+instanceDescription+"\" value=\""+nodeFlavor+"\"/>\n"+ -" <input type=\"hidden\" name=\""+"specty"+instanceDescription+"\" value=\""+nodeType+"\"/>\n"+ -" <input type=\"hidden\" name=\""+"specma"+instanceDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(nodeMatch)+"\"/>\n"+ -" <a name=\""+"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\">\n"+ -" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Delete") + "\" onClick='Javascript:SpecOp(\"specop"+instanceDescription+"\",\"Delete\",\"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.DeletePath")+Integer.toString(k)+", match spec #"+Integer.toString(j)+"\"/>\n"+ +" <input type=\"hidden\" name=\""+instanceOpName+"\" value=\"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specfl"+instanceDescription+"\" value=\""+nodeFlavor+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specty"+instanceDescription+"\" value=\""+nodeType+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specma"+instanceDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(nodeMatch)+"\"/>\n"+ +" <a name=\""+seqPrefix+"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\">\n"+ +" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Delete") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+instanceOpName+"\",\"Delete\",\""+seqPrefix+"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.DeletePath")+Integer.toString(k)+", match spec #"+Integer.toString(j)+"\"/>\n"+ " </a>\n"+ " </nobr>\n"+ " </td>\n"+ @@ -943,13 +976,13 @@ public class HDFSRepositoryConnector ext " <tr class=\"formrow\"><td class=\"lightseparator\" colspan=\"4\"><hr/></td></tr>\n"+ " <tr class=\"formrow\">\n"+ " <td class=\"formcolumncell\">\n"+ -" <a name=\""+"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\">\n"+ -" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Add") + "\" onClick='Javascript:SpecOp(\""+pathOpName+"\",\"Add\",\"match_"+Integer.toString(k)+"_"+Integer.toString(j+1)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.AddNewMatchForPath")+Integer.toString(k)+"\"/>\n"+ +" <a name=\""+seqPrefix+"match_"+Integer.toString(k)+"_"+Integer.toString(j)+"\">\n"+ +" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Add") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+pathOpName+"\",\"Add\",\""+seqPrefix+"match_"+Integer.toString(k)+"_"+Integer.toString(j+1)+"\")' alt=\""+Messages.getAttributeString(locale,"HDFSRepositoryConnector.AddNewMatchForPath")+Integer.toString(k)+"\"/>\n"+ " </a>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <select name=\""+"specflavor"+pathDescription+"\">\n"+ +" <select name=\""+seqPrefix+"specflavor"+pathDescription+"\">\n"+ " <option value=\"include\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.include") + "</option>\n"+ " <option value=\"exclude\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.exclude") + "</option>\n"+ " </select>\n"+ @@ -957,7 +990,7 @@ public class HDFSRepositoryConnector ext " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <select name=\""+"spectype"+pathDescription+"\">\n"+ +" <select name=\""+seqPrefix+"spectype"+pathDescription+"\">\n"+ " <option value=\"file\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.File") + "</option>\n"+ " <option value=\"directory\">" + Messages.getBodyString(locale,"HDFSRepositoryConnector.Directory") + "</option>\n"+ " </select>\n"+ @@ -965,7 +998,7 @@ public class HDFSRepositoryConnector ext " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input type=\"text\" size=\"10\" name=\""+"specmatch"+pathDescription+"\" value=\"\"/>\n"+ +" <input type=\"text\" size=\"10\" name=\""+seqPrefix+"specmatch"+pathDescription+"\" value=\"\"/>\n"+ " </nobr>\n"+ " </td>\n"+ " </tr>\n"+ @@ -987,21 +1020,21 @@ public class HDFSRepositoryConnector ext " <tr class=\"formrow\">\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <a name=\""+"path_"+Integer.toString(k)+"\">\n"+ -" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Add") + "\" onClick='Javascript:SpecOp(\"specop\",\"Add\",\"path_"+Integer.toString(i+1)+"\")' alt=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.AddNewPath") + "\"/>\n"+ -" <input type=\"hidden\" name=\"pathcount\" value=\""+Integer.toString(k)+"\"/>\n"+ -" <input type=\"hidden\" name=\"specop\" value=\"\"/>\n"+ +" <a name=\""+seqPrefix+"path_"+Integer.toString(k)+"\">\n"+ +" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.Add") + "\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+seqPrefix+"specop\",\"Add\",\""+seqPrefix+"path_"+Integer.toString(i+1)+"\")' alt=\"" + Messages.getAttributeString(locale,"HDFSRepositoryConnector.AddNewPath") + "\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"pathcount\" value=\""+Integer.toString(k)+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"specop\" value=\"\"/>\n"+ " </a>\n"+ " </nobr>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input type=\"text\" size=\"30\" name=\"specpath\" value=\"\"/>\n"+ +" <input type=\"text\" size=\"30\" name=\""+seqPrefix+"specpath\" value=\"\"/>\n"+ " </nobr>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ " <nobr>\n"+ -" <input name=\"converttouri\" type=\"checkbox\" value=\"true\"/>\n"+ +" <input name=\""+seqPrefix+"converttouri\" type=\"checkbox\" value=\"true\"/>\n"+ " </nobr>\n"+ " </td>\n"+ " <td class=\"formcolumncell\">\n"+ @@ -1032,9 +1065,9 @@ public class HDFSRepositoryConnector ext convertToURI = true; out.print( -"<input type=\"hidden\" name=\"specpath"+pathDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"+ -"<input type=\"hidden\" name=\"converttouri"+pathDescription+"\" value=\""+(convertToURI?"true":"false")+"\">\n"+ -"<input type=\"hidden\" name=\"specchildcount"+pathDescription+"\" value=\""+Integer.toString(sn.getChildCount())+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"specpath"+pathDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(path)+"\"/>\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"converttouri"+pathDescription+"\" value=\""+(convertToURI?"true":"false")+"\">\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"specchildcount"+pathDescription+"\" value=\""+Integer.toString(sn.getChildCount())+"\"/>\n" ); int j = 0; @@ -1047,9 +1080,9 @@ public class HDFSRepositoryConnector ext String nodeType = excludeNode.getAttributeValue("type"); String nodeMatch = excludeNode.getAttributeValue("match"); out.print( -"<input type=\"hidden\" name=\"specfl"+instanceDescription+"\" value=\""+nodeFlavor+"\"/>\n"+ -"<input type=\"hidden\" name=\"specty"+instanceDescription+"\" value=\""+nodeType+"\"/>\n"+ -"<input type=\"hidden\" name=\"specma"+instanceDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(nodeMatch)+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"specfl"+instanceDescription+"\" value=\""+nodeFlavor+"\"/>\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"specty"+instanceDescription+"\" value=\""+nodeType+"\"/>\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"specma"+instanceDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(nodeMatch)+"\"/>\n" ); j++; } @@ -1057,24 +1090,31 @@ public class HDFSRepositoryConnector ext } } out.print( -"<input type=\"hidden\" name=\"pathcount\" value=\""+Integer.toString(k)+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"pathcount\" value=\""+Integer.toString(k)+"\"/>\n" ); } } /** 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 document specification accordingly. - * The name of the posted form is "editjob". - *@param variableContext contains the post data, including binary file-upload information. - *@param ds is the current document 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). - */ + * 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 + * document specification accordingly. The name of the posted form is always "editjob". + * The connector will be connected before this method can be called. + *@param variableContext contains the post data, including binary file-upload information. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the 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). + */ @Override - public String processSpecificationPost(IPostParameters variableContext, Locale locale, DocumentSpecification ds) + public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds, + int connectionSequenceNumber) throws ManifoldCFException { - String x = variableContext.getParameter("pathcount"); + String seqPrefix = "s"+connectionSequenceNumber+"_"; + + String x = variableContext.getParameter(seqPrefix+"pathcount"); if (x != null) { ds.clearChildren(); @@ -1086,7 +1126,7 @@ public class HDFSRepositoryConnector ext while (i < pathCount) { String pathDescription = "_"+Integer.toString(i); - String pathOpName = "specop"+pathDescription; + String pathOpName = seqPrefix+"specop"+pathDescription; x = variableContext.getParameter(pathOpName); if (x != null && x.equals("Delete")) { @@ -1095,8 +1135,8 @@ public class HDFSRepositoryConnector ext continue; } // Path inserts won't happen until the very end - String path = variableContext.getParameter("specpath"+pathDescription); - String convertToURI = variableContext.getParameter("converttouri"+pathDescription); + String path = variableContext.getParameter(seqPrefix+"specpath"+pathDescription); + String convertToURI = variableContext.getParameter(seqPrefix+"converttouri"+pathDescription); SpecificationNode node = new SpecificationNode("startpoint"); node.setAttribute("path",path); @@ -1104,7 +1144,7 @@ public class HDFSRepositoryConnector ext node.setAttribute("converttouri",convertToURI); // Now, get the number of children - String y = variableContext.getParameter("specchildcount"+pathDescription); + String y = variableContext.getParameter(seqPrefix+"specchildcount"+pathDescription); int childCount = Integer.parseInt(y); int j = 0; int w = 0; @@ -1112,7 +1152,7 @@ public class HDFSRepositoryConnector ext { String instanceDescription = "_"+Integer.toString(i)+"_"+Integer.toString(j); // Look for an insert or a delete at this point - String instanceOp = "specop"+instanceDescription; + String instanceOp = seqPrefix+"specop"+instanceDescription; String z = variableContext.getParameter(instanceOp); String flavor; String type; @@ -1127,17 +1167,17 @@ public class HDFSRepositoryConnector ext if (z != null && z.equals("Insert Here")) { // Process the insertion as we gather. - flavor = variableContext.getParameter("specflavor"+instanceDescription); - type = variableContext.getParameter("spectype"+instanceDescription); - match = variableContext.getParameter("specmatch"+instanceDescription); + flavor = variableContext.getParameter(seqPrefix+"specflavor"+instanceDescription); + type = variableContext.getParameter(seqPrefix+"spectype"+instanceDescription); + match = variableContext.getParameter(seqPrefix+"specmatch"+instanceDescription); sn = new SpecificationNode(flavor); sn.setAttribute("type",type); sn.setAttribute("match",match); node.addChild(w++,sn); } - flavor = variableContext.getParameter("specfl"+instanceDescription); - type = variableContext.getParameter("specty"+instanceDescription); - match = variableContext.getParameter("specma"+instanceDescription); + flavor = variableContext.getParameter(seqPrefix+"specfl"+instanceDescription); + type = variableContext.getParameter(seqPrefix+"specty"+instanceDescription); + match = variableContext.getParameter(seqPrefix+"specma"+instanceDescription); sn = new SpecificationNode(flavor); sn.setAttribute("type",type); sn.setAttribute("match",match); @@ -1147,9 +1187,9 @@ public class HDFSRepositoryConnector ext if (x != null && x.equals("Add")) { // Process adds to the end of the rules in-line - String match = variableContext.getParameter("specmatch"+pathDescription); - String type = variableContext.getParameter("spectype"+pathDescription); - String flavor = variableContext.getParameter("specflavor"+pathDescription); + String match = variableContext.getParameter(seqPrefix+"specmatch"+pathDescription); + String type = variableContext.getParameter(seqPrefix+"spectype"+pathDescription); + String flavor = variableContext.getParameter(seqPrefix+"specflavor"+pathDescription); SpecificationNode sn = new SpecificationNode(flavor); sn.setAttribute("type",type); sn.setAttribute("match",match); @@ -1160,11 +1200,11 @@ public class HDFSRepositoryConnector ext } // See if there's a global add operation - String op = variableContext.getParameter("specop"); + String op = variableContext.getParameter(seqPrefix+"specop"); if (op != null && op.equals("Add")) { - String path = variableContext.getParameter("specpath"); - String convertToURI = variableContext.getParameter("converttouri"); + String path = variableContext.getParameter(seqPrefix+"specpath"); + String convertToURI = variableContext.getParameter(seqPrefix+"converttouri"); SpecificationNode node = new SpecificationNode("startpoint"); node.setAttribute("path",path); @@ -1185,36 +1225,22 @@ public class HDFSRepositoryConnector ext } } - /* - * "filepathtouri" - */ - String filepathtouri = variableContext.getParameter("filepathtouri"); - if (filepathtouri != null) { - SpecificationNode sn; - int i = 0; - while (i < ds.getChildCount()) { - if (ds.getChild(i).getType().equals("filepathtouri")) { - ds.removeChild(i); - } else { - i++; - } - } - sn = new SpecificationNode("filepathtouri"); - sn.setValue(filepathtouri); - ds.addChild(ds.getChildCount(),sn); - } - return null; } /** View specification. - * This method is called in the body section of a job's view page. Its purpose is to present the document 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 ds is the current document specification for this job. - */ + * This method is called in the body section of a job's view page. Its purpose is to present the document + * 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. + * The connector will be connected before this method can be called. + *@param out is the output to which any HTML should be sent. + *@param locale is the locale the output is preferred to be in. + *@param ds is the current document specification for this job. + *@param connectionSequenceNumber is the unique number of this connection within the job. + */ @Override - public void viewSpecification(IHTTPOutput out, Locale locale, DocumentSpecification ds) + public void viewSpecification(IHTTPOutput out, Locale locale, Specification ds, + int connectionSequenceNumber) throws ManifoldCFException, IOException { out.print(
