Modified: manifoldcf/branches/dev_1x/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java (original) +++ manifoldcf/branches/dev_1x/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java Thu Sep 18 16:56:59 2014 @@ -1016,103 +1016,110 @@ public class JDBCConnector extends org.a } /** 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. + * 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,"JDBCConnector.Queries")); tabsArray.add(Messages.getString(locale,"JDBCConnector.Security")); + String seqPrefix = "s"+connectionSequenceNumber+"_"; + out.print( "<script type=\"text/javascript\">\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"+ "}\n"+ "\n"+ -"function SpecAddToken(anchorvalue)\n"+ +"function "+seqPrefix+"SpecAddToken(anchorvalue)\n"+ "{\n"+ -" if (editjob.spectoken.value == \"\")\n"+ +" if (editjob."+seqPrefix+"spectoken.value == \"\")\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.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"+ "\n"+ -"function checkSpecification()\n"+ +"function "+seqPrefix+"checkSpecification()\n"+ "{\n"+ -" if (editjob.idquery.value == \"\")\n"+ +" if (editjob."+seqPrefix+"idquery.value == \"\")\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.EnterASeedingQuery") + "\");\n"+ -" editjob.idquery.focus();\n"+ +" editjob."+seqPrefix+"idquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.idquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"idquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnIDCOLUMNInTheResult") + "\");\n"+ -" editjob.idquery.focus();\n"+ +" editjob."+seqPrefix+"idquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.versionquery.value != \"\")\n"+ +" if (editjob."+seqPrefix+"versionquery.value != \"\")\n"+ " {\n"+ -" if (editjob.versionquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"versionquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnIDCOLUMNInTheResult") + "\");\n"+ -" editjob.versionquery.focus();\n"+ +" editjob."+seqPrefix+"versionquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.versionquery.value.indexOf(\"$(VERSIONCOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"versionquery.value.indexOf(\"$(VERSIONCOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnVERSIONCOLUMNInTheResult") + "\");\n"+ -" editjob.versionquery.focus();\n"+ +" editjob."+seqPrefix+"versionquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.versionquery.value.indexOf(\"$(IDLIST)\") == -1)\n"+ +" if (editjob."+seqPrefix+"versionquery.value.indexOf(\"$(IDLIST)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustUseIDLISTInWHEREClause") + "\");\n"+ -" editjob.versionquery.focus();\n"+ +" editjob."+seqPrefix+"versionquery.focus();\n"+ " return false;\n"+ " }\n"+ " }\n"+ -" if (editjob.dataquery.value == \"\")\n"+ +" if (editjob."+seqPrefix+"dataquery.value == \"\")\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.EnterADataQuery") + "\");\n"+ -" editjob.dataquery.focus();\n"+ +" editjob."+seqPrefix+"dataquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.dataquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"dataquery.value.indexOf(\"$(IDCOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnIDCOLUMNInTheResult2") + "\");\n"+ -" editjob.dataquery.focus();\n"+ +" editjob."+seqPrefix+"dataquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.dataquery.value.indexOf(\"$(URLCOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"dataquery.value.indexOf(\"$(URLCOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnURLCOLUMNInTheResult") + "\");\n"+ -" editjob.dataquery.focus();\n"+ +" editjob."+seqPrefix+"dataquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.dataquery.value.indexOf(\"$(DATACOLUMN)\") == -1)\n"+ +" if (editjob."+seqPrefix+"dataquery.value.indexOf(\"$(DATACOLUMN)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustReturnDATACOLUMNInTheResult") + "\");\n"+ -" editjob.dataquery.focus();\n"+ +" editjob."+seqPrefix+"dataquery.focus();\n"+ " return false;\n"+ " }\n"+ -" if (editjob.dataquery.value.indexOf(\"$(IDLIST)\") == -1)\n"+ +" if (editjob."+seqPrefix+"dataquery.value.indexOf(\"$(IDLIST)\") == -1)\n"+ " {\n"+ " alert(\"" + Messages.getBodyJavascriptString(locale,"JDBCConnector.MustUseIDLISTInWHEREClause") + "\");\n"+ -" editjob.dataquery.focus();\n"+ +" editjob."+seqPrefix+"dataquery.focus();\n"+ " return false;\n"+ " }\n"+ "\n"+ @@ -1125,17 +1132,26 @@ public class JDBCConnector extends org.a } /** 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". + * 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 tabName is the current tab name. + *@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+"_"; + String idQuery = "SELECT idfield AS $(IDCOLUMN) FROM documenttable WHERE modifydatefield > $(STARTTIME) AND modifydatefield <= $(ENDTIME)"; String versionQuery = "SELECT idfield AS $(IDCOLUMN), versionfield AS $(VERSIONCOLUMN) FROM documenttable WHERE idfield IN $(IDLIST)"; String dataQuery = "SELECT idfield AS $(IDCOLUMN), urlfield AS $(URLCOLUMN), datafield AS $(DATACOLUMN) FROM documenttable WHERE idfield IN $(IDLIST)"; @@ -1166,22 +1182,22 @@ public class JDBCConnector extends org.a // The Queries tab - if (tabName.equals(Messages.getString(locale,"JDBCConnector.Queries"))) + if (tabName.equals(Messages.getString(locale,"JDBCConnector.Queries")) && connectionSequenceNumber == actualSequenceNumber) { out.print( "<table class=\"displaytable\">\n"+ " <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+ " <tr>\n"+ " <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"JDBCConnector.SeedingQuery") + "</nobr><br/><nobr>" + Messages.getBodyString(locale,"JDBCConnector.returnIdsThatNeedToBeChecked") + "</nobr></td>\n"+ -" <td class=\"value\"><textarea name=\"idquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(idQuery)+"</textarea></td>\n"+ +" <td class=\"value\"><textarea name=\""+seqPrefix+"idquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(idQuery)+"</textarea></td>\n"+ " </tr>\n"+ " <tr>\n"+ " <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"JDBCConnector.VersionCheckQuery") + "</nobr><br/><nobr>" + Messages.getBodyString(locale,"JDBCConnector.returnIdsAndVersionsForASetOfDocuments") + "</nobr><br/><nobr>" + Messages.getBodyString(locale,"JDBCConnector.leaveBlankIfNoVersioningCapability") + "</nobr></td>\n"+ -" <td class=\"value\"><textarea name=\"versionquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(versionQuery)+"</textarea></td>\n"+ +" <td class=\"value\"><textarea name=\""+seqPrefix+"versionquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(versionQuery)+"</textarea></td>\n"+ " </tr>\n"+ " <tr>\n"+ " <td class=\"description\"><nobr>" + Messages.getBodyString(locale,"JDBCConnector.DataQuery") + "</nobr><br/><nobr>" + Messages.getBodyString(locale,"JDBCConnector.returnIdsUrlsAndDataForASetOfDocuments") + "</nobr></td>\n"+ -" <td class=\"value\"><textarea name=\"dataquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(dataQuery)+"</textarea></td>\n"+ +" <td class=\"value\"><textarea name=\""+seqPrefix+"dataquery\" cols=\"64\" rows=\"6\">"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(dataQuery)+"</textarea></td>\n"+ " </tr>\n"+ "</table>\n" ); @@ -1189,9 +1205,9 @@ public class JDBCConnector extends org.a else { out.print( -"<input type=\"hidden\" name=\"idquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(idQuery)+"\"/>\n"+ -"<input type=\"hidden\" name=\"versionquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(versionQuery)+"\"/>\n"+ -"<input type=\"hidden\" name=\"dataquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(dataQuery)+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"idquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(idQuery)+"\"/>\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"versionquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(versionQuery)+"\"/>\n"+ +"<input type=\"hidden\" name=\""+seqPrefix+"dataquery\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(dataQuery)+"\"/>\n" ); } @@ -1199,7 +1215,7 @@ public class JDBCConnector extends org.a // There is no native security, so all we care about are the tokens. i = 0; - if (tabName.equals(Messages.getString(locale,"JDBCConnector.Security"))) + if (tabName.equals(Messages.getString(locale,"JDBCConnector.Security")) && connectionSequenceNumber == actualSequenceNumber) { out.print( "<table class=\"displaytable\">\n"+ @@ -1214,15 +1230,15 @@ public class JDBCConnector extends org.a 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>\n"+ " <td class=\"description\">\n"+ " <input type=\"hidden\" name=\""+accessOpName+"\" value=\"\"/>\n"+ -" <input type=\"hidden\" name=\""+"spectoken"+accessDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token)+"\"/>\n"+ -" <a name=\""+"token_"+Integer.toString(k)+"\">\n"+ -" <input type=\"button\" value=\"Delete\" onClick='Javascript:SpecOp(\""+accessOpName+"\",\"Delete\",\"token_"+Integer.toString(k)+"\")' alt=\"" + Messages.getAttributeString(locale,"JDBCConnector.DeleteToken") + "\""+Integer.toString(k)+"\"/>\n"+ +" <input type=\"hidden\" name=\""+seqPrefix+"spectoken"+accessDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token)+"\"/>\n"+ +" <a name=\""+seqPrefix+"token_"+Integer.toString(k)+"\">\n"+ +" <input type=\"button\" value=\"Delete\" onClick='Javascript:"+seqPrefix+"SpecOp(\""+accessOpName+"\",\"Delete\",\""+seqPrefix+"token_"+Integer.toString(k)+"\")' alt=\"" + Messages.getAttributeString(locale,"JDBCConnector.DeleteToken") + "\""+Integer.toString(k)+"\"/>\n"+ " </a> \n"+ " </td>\n"+ " <td class=\"value\">\n"+ @@ -1245,14 +1261,14 @@ public class JDBCConnector extends org.a " <tr><td class=\"lightseparator\" colspan=\"2\"><hr/></td></tr>\n"+ " <tr>\n"+ " <td class=\"description\">\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=\"Add\" onClick='Javascript:SpecAddToken(\"token_"+Integer.toString(k+1)+"\")' alt=\"" + Messages.getAttributeString(locale,"JDBCConnector.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=\"Add\" onClick='Javascript:"+seqPrefix+"SpecAddToken(\""+seqPrefix+"token_"+Integer.toString(k+1)+"\")' alt=\"" + Messages.getAttributeString(locale,"JDBCConnector.AddAccessToken") + "\"/>\n"+ " </a> \n"+ " </td>\n"+ " <td class=\"value\">\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" @@ -1271,32 +1287,39 @@ public class JDBCConnector extends org.a String accessDescription = "_"+Integer.toString(k); String token = sn.getAttributeValue("token"); out.print( -"<input type=\"hidden\" name=\""+"spectoken"+accessDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token)+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"spectoken"+accessDescription+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(token)+"\"/>\n" ); k++; } } out.print( -"<input type=\"hidden\" name=\"tokencount\" value=\""+Integer.toString(k)+"\"/>\n" +"<input type=\"hidden\" name=\""+seqPrefix+"tokencount\" 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". + * 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. - *@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). + *@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 idQuery = variableContext.getParameter("idquery"); - String versionQuery = variableContext.getParameter("versionquery"); - String dataQuery = variableContext.getParameter("dataquery"); + String seqPrefix = "s"+connectionSequenceNumber+"_"; + + String idQuery = variableContext.getParameter(seqPrefix+"idquery"); + String versionQuery = variableContext.getParameter(seqPrefix+"versionquery"); + String dataQuery = variableContext.getParameter(seqPrefix+"dataquery"); SpecificationNode sn; if (idQuery != null) @@ -1342,7 +1365,7 @@ public class JDBCConnector extends org.a ds.addChild(ds.getChildCount(),sn); } - String xc = variableContext.getParameter("tokencount"); + String xc = variableContext.getParameter(seqPrefix+"tokencount"); if (xc != null) { // Delete all tokens first @@ -1361,7 +1384,7 @@ public class JDBCConnector extends org.a 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")) { @@ -1370,17 +1393,17 @@ public class JDBCConnector extends org.a 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); @@ -1390,13 +1413,18 @@ public class JDBCConnector extends org.a } /** 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. + * 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 { String idQuery = "";
Modified: manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java (original) +++ manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jira/JiraRepositoryConnector.java Thu Sep 18 16:56:59 2014 @@ -46,6 +46,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; @@ -608,7 +609,7 @@ public class JiraRepositoryConnector ext /** * Fill in specification Velocity parameter map for JIRAQuery tab. */ - private static void fillInJIRAQuerySpecificationMap(Map<String, Object> newMap, DocumentSpecification ds) { + private static void fillInJIRAQuerySpecificationMap(Map<String, Object> newMap, Specification ds) { String JiraQuery = JiraConfig.JIRA_QUERY_DEFAULT; for (int i = 0; i < ds.getChildCount(); i++) { SpecificationNode sn = ds.getChild(i); @@ -622,7 +623,7 @@ public class JiraRepositoryConnector ext /** * Fill in specification Velocity parameter map for JIRASecurity tab. */ - private static void fillInJIRASecuritySpecificationMap(Map<String, Object> newMap, DocumentSpecification ds) { + private static void fillInJIRASecuritySpecificationMap(Map<String, Object> newMap, Specification ds) { List<Map<String,String>> accessTokenList = new ArrayList<Map<String,String>>(); String securityValue = "on"; for (int i = 0; i < ds.getChildCount(); i++) { @@ -640,21 +641,23 @@ public class JiraRepositoryConnector ext newMap.put("SECURITYON", securityValue); } - /** - * 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 fillInJIRAQuerySpecificationMap(paramMap, ds); @@ -663,25 +666,25 @@ public class JiraRepositoryConnector ext 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 jiraDriveQuery = variableContext.getParameter("jiraquery"); + String jiraDriveQuery = variableContext.getParameter(seqPrefix+"jiraquery"); if (jiraDriveQuery != null) { int i = 0; while (i < ds.getChildCount()) { @@ -697,7 +700,7 @@ public class JiraRepositoryConnector ext ds.addChild(ds.getChildCount(), node); } - String securityOn = variableContext.getParameter("specsecurity"); + String securityOn = variableContext.getParameter(seqPrefix+"specsecurity"); if (securityOn != null) { // Delete all security records first int i = 0; @@ -713,7 +716,7 @@ public class JiraRepositoryConnector ext 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; @@ -729,7 +732,7 @@ public class JiraRepositoryConnector ext 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 @@ -737,17 +740,17 @@ public class JiraRepositoryConnector ext 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); @@ -757,53 +760,80 @@ public class JiraRepositoryConnector ext 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 void outputSpecificationBody(IHTTPOutput out, - Locale locale, DocumentSpecification ds, String tabName) throws ManifoldCFException, - IOException { + 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, Specification ds, + int connectionSequenceNumber, int actualSequenceNumber, String tabName) + throws ManifoldCFException, IOException { // Output JIRAQuery 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)); + fillInJIRAQuerySpecificationMap(paramMap, ds); fillInJIRASecuritySpecificationMap(paramMap, ds); Messages.outputResourceWithVelocity(out,locale,EDIT_SPEC_FORWARD_JIRAQUERY,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, JIRA_QUERY_TAB_PROPERTY)); tabsArray.add(Messages.getString(locale, JIRA_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. fillInJIRAQuerySpecificationMap(paramMap, ds); Modified: manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jira.js URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jira.js?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jira.js (original) +++ manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jira.js Thu Sep 18 16:56:59 2014 @@ -17,37 +17,37 @@ <script type="text/javascript"> <!-- -function checkSpecificationForSave() +function s${SeqNum}_checkSpecificationForSave() { - if (editjob.jiraquery.value == "") { + if (editjob.s${SeqNum}_jiraquery.value == "") { alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('JiraRepositoryConnector.SeedQueryCannotBeNull'))"); SelectTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('JiraRepositoryConnector.JiraQuery'))"); - editjob.jiraquery.focus(); + editjob.s${SeqNum}_jiraquery.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('JiraRepositoryConnector.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/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraQuery.html URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraQuery.html?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraQuery.html (original) +++ manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraQuery.html Thu Sep 18 16:56:59 2014 @@ -15,7 +15,7 @@ limitations under the License. --> -#if($TabName == $ResourceBundle.getString('JiraRepositoryConnector.JiraQuery')) +#if($TabName == $ResourceBundle.getString('JiraRepositoryConnector.JiraQuery') && ${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="jiraquery" value="$Encoder.attributeEscape($JIRAQUERY)" /> + <input type="text" size="120" name="s${SeqNum}_jiraquery" value="$Encoder.attributeEscape($JIRAQUERY)" /> </nobr> </td> </tr> @@ -35,6 +35,6 @@ #else -<input type="hidden" name="jiraquery" value="$Encoder.attributeEscape($JIRAQUERY)" /> +<input type="hidden" name="s${SeqNum}_jiraquery" value="$Encoder.attributeEscape($JIRAQUERY)" /> #end Modified: manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraSecurity.html URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraSecurity.html?rev=1626026&r1=1626025&r2=1626026&view=diff ============================================================================== --- manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraSecurity.html (original) +++ manifoldcf/branches/dev_1x/connectors/jira/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/jira/editSpecification_jiraSecurity.html Thu Sep 18 16:56:59 2014 @@ -15,7 +15,7 @@ limitations under the License. --> -#if($TabName == $ResourceBundle.getString('JiraRepositoryConnector.Security')) +#if($TabName == $ResourceBundle.getString('JiraRepositoryConnector.Security') && ${SeqNum} == ${SelectedNum}) <table class="displaytable"> <tr><td class="separator" colspan="2"><hr/></td></tr> @@ -24,15 +24,15 @@ <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('JiraRepositoryConnector.SecurityColon'))</nobr></td> <td class="value"> #if($SECURITYON == 'on') - <input type="radio" name="specsecurity" value="on" checked="true"/> + <input type="radio" name="s${SeqNum}_specsecurity" value="on" checked="true"/> #else - <input type="radio" name="specsecurity" value="on"/> + <input type="radio" name="s${SeqNum}_specsecurity" value="on"/> #end $Encoder.bodyEscape($ResourceBundle.getString('JiraRepositoryConnector.Enabled')) #if($SECURITYON == 'off') - <input type="radio" name="specsecurity" value="off" checked="true"/> + <input type="radio" name="s${SeqNum}_specsecurity" value="off" checked="true"/> #else - <input type="radio" name="specsecurity" value="off"/> + <input type="radio" name="s${SeqNum}_specsecurity" value="off"/> #end $Encoder.bodyEscape($ResourceBundle.getString('JiraRepositoryConnector.Disabled')) </td> @@ -45,10 +45,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('JiraRepositoryConnector.Delete'))" onClick='Javascript:SpecDeleteToken($atcounter)' alt="$Encoder.attributeEscape($ResourceBundle.getString('JiraRepositoryConnector.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('JiraRepositoryConnector.Delete'))" onClick='Javascript:s${SeqNum}_SpecDeleteToken($atcounter)' alt="$Encoder.attributeEscape($ResourceBundle.getString('JiraRepositoryConnector.DeleteToken'))$atcounter"/> </a> </td> <td class="value">$Encoder.bodyEscape($atoken.get('TOKEN'))</td> @@ -69,27 +69,27 @@ <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('JiraRepositoryConnector.Add'))" onClick='Javascript:SpecAddToken($nexttoken)' alt="$Encoder.attributeEscape($ResourceBundle.getString('JiraRepositoryConnector.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('JiraRepositoryConnector.Add'))" onClick='Javascript:s${SeqNum}_SpecAddToken($nexttoken)' alt="$Encoder.attributeEscape($ResourceBundle.getString('JiraRepositoryConnector.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> #else -<input type="hidden" name="specsecurity" value="$SECURITYON"/> +<input type="hidden" name="s${SeqNum}_specsecurity" value="$SECURITYON"/> #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
