manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1603459 - in /manifoldcf/trunk/connectors/hdfs/connector/src/main: java/org/apache/manifoldcf/agents/output/hdfs/ resources/org/apache/manifoldcf/agents/output/hdfs/
Date Wed, 18 Jun 2014 14:21:16 GMT
Author: kwright
Date: Wed Jun 18 14:21:15 2014
New Revision: 1603459

URL: http://svn.apache.org/r1603459
Log:
Fix CONNECTORS-968 for the Hadoop output connector

Modified:
    manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
    manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputSpecs.java
    manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.html
    manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.js

Modified: manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java?rev=1603459&r1=1603458&r2=1603459&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
(original)
+++ manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputConnector.java
Wed Jun 18 14:21:15 2014
@@ -30,17 +30,18 @@ import java.net.URISyntaxException;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity;
 import org.apache.manifoldcf.agents.interfaces.IOutputRemoveActivity;
-import org.apache.manifoldcf.agents.interfaces.OutputSpecification;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 import org.apache.manifoldcf.agents.system.Logging;
 import org.apache.manifoldcf.agents.output.BaseOutputConnector;
+import org.apache.manifoldcf.core.interfaces.Specification;
 import org.apache.manifoldcf.core.interfaces.ConfigParams;
 import org.apache.manifoldcf.core.interfaces.ConfigurationNode;
 import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
@@ -248,7 +249,7 @@ public class HDFSOutputConnector extends
    * the document will not need to be sent again to the output data store.
    */
   @Override
-  public String getOutputDescription(OutputSpecification spec) throws ManifoldCFException,
ServiceInterruption {
+  public String getPipelineDescription(Specification spec) throws ManifoldCFException, ServiceInterruption
{
     HDFSOutputSpecs specs = new HDFSOutputSpecs(getSpecNode(spec));
     return specs.toJson().toString();
   }
@@ -343,7 +344,7 @@ public class HDFSOutputConnector extends
   public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, Locale
locale, ConfigParams parameters, List<String> tabsArray) throws ManifoldCFException,
IOException {
     super.outputConfigurationHeader(threadContext, out, locale, parameters, tabsArray);
     tabsArray.add(Messages.getString(locale,"HDFSOutputConnector.ServerTabName"));
-    outputResource(EDIT_CONFIGURATION_JS, out, locale, null, null);
+    outputResource(EDIT_CONFIGURATION_JS, out, locale, null, null, null, null);
   }
 
   /** Output the configuration body section.
@@ -359,7 +360,7 @@ public class HDFSOutputConnector extends
   public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, Locale
locale, ConfigParams parameters, String tabName) throws ManifoldCFException, IOException {
     super.outputConfigurationBody(threadContext, out, locale, parameters, tabName);
     HDFSOutputConfig config = this.getConfigParameters(parameters);
-    outputResource(EDIT_CONFIGURATION_HTML, out, locale, config, tabName);
+    outputResource(EDIT_CONFIGURATION_HTML, out, locale, config, tabName, null, null);
   }
 
   /** Process a configuration post.
@@ -386,54 +387,87 @@ public class HDFSOutputConnector extends
    */
   @Override
   public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, Locale locale,
ConfigParams parameters) throws ManifoldCFException, IOException {
-    outputResource(VIEW_CONFIGURATION_HTML, out, locale, getConfigParameters(parameters),
null);
+    outputResource(VIEW_CONFIGURATION_HTML, out, locale, getConfigParameters(parameters),
null, null, null);
+  }
+
+  /** 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";
+  }
+
+  /** 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";
   }
 
   /** Output the specification header section.
-   * This method is called in the head section of a job page which has selected an output
connection of the current type.  Its purpose is to add the required tabs
-   * to the list, and to output any javascript methods that might be needed by the job editing
HTML.
-   *@param out is the output to which any HTML should be sent.
-   *@param os is the current output specification for this job.
-   *@param tabsArray is an array of tab names.  Add to this array any tab names that are
specific to the connector.
-   */
+  * This method is called in the head section of a job page which has selected a pipeline
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 locale is the preferred local of the output.
+  *@param os is the current pipeline specification for this connection.
+  *@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, OutputSpecification
os, List<String> tabsArray) throws ManifoldCFException, IOException {
-    super.outputSpecificationHeader(out, locale, os, tabsArray);
+  public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification os,
+    int connectionSequenceNumber, List<String> tabsArray)
+    throws ManifoldCFException, IOException {
+    super.outputSpecificationHeader(out, locale, os, connectionSequenceNumber, tabsArray);
     tabsArray.add(Messages.getString(locale, "HDFSOutputConnector.PathTabName"));
-    outputResource(EDIT_SPECIFICATION_JS, out, locale, null, null);
+    outputResource(EDIT_SPECIFICATION_JS, out, locale, null, null, new Integer(connectionSequenceNumber),
null);
   }
 
   /** Output the specification body section.
-   * This method is called in the body section of a job page which has selected an output
connection of the current type.  Its purpose is to present the required form elements for
editing.
-   * The coder can presume that the HTML that is output from this configuration will be within
appropriate <html>, <body>, and <form> tags.  The name of the
-   * form is "editjob".
-   *@param out is the output to which any HTML should be sent.
-   *@param os is the current output specification for this job.
-   *@param tabName is the current tab name.
-   */
+  * This method is called in the body section of a job page which has selected a pipeline
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 locale is the preferred local of the output.
+  *@param os is the current pipeline 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.
+  */
   @Override
-  public void outputSpecificationBody(IHTTPOutput out, Locale locale, OutputSpecification
os, String tabName) throws ManifoldCFException, IOException {
-    super.outputSpecificationBody(out, locale, os, tabName);
+  public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification os,
+    int connectionSequenceNumber, int actualSequenceNumber, String tabName)
+    throws ManifoldCFException, IOException {
+    super.outputSpecificationBody(out, locale, os, connectionSequenceNumber, actualSequenceNumber,
tabName);
     HDFSOutputSpecs specs = getSpecParameters(os);
-    outputResource(EDIT_SPECIFICATION_HTML, out, locale, specs, tabName);
+    outputResource(EDIT_SPECIFICATION_HTML, out, locale, specs, tabName, new Integer(connectionSequenceNumber),
new Integer(actualSequenceNumber));
   }
 
   /** Process a specification post.
-   * This method is called at the start of job's edit or view page, whenever there is a possibility
that form data for a connection has been
-   * posted.  Its purpose is to gather form information and modify the output specification
accordingly.
-   * The name of the posted form is "editjob".
-   *@param variableContext contains the post data, including binary file-upload information.
-   *@param os is the current output specification for this job.
-   *@return null if all is well, or a string error message if there is an error that should
prevent saving of the job (and cause a redirection to an error page).
-   */
+  * 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 transformation specification
accordingly.
+  * The name of the posted form is "editjob".
+  *@param variableContext contains the post data, including binary file-upload information.
+  *@param locale is the preferred local of the output.
+  *@param os is the current pipeline 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,
OutputSpecification os) throws ManifoldCFException {
+  public String processSpecificationPost(IPostParameters variableContext, Locale locale,
Specification os,
+    int connectionSequenceNumber)
+    throws ManifoldCFException {
     ConfigurationNode specNode = getSpecNode(os);
     boolean bAdd = (specNode == null);
     if (bAdd) {
       specNode = new SpecificationNode(ParameterEnum.rootpath.name());
     }
-    HDFSOutputSpecs.contextToSpecNode(variableContext, specNode);
+    HDFSOutputSpecs.contextToSpecNode(variableContext, specNode, connectionSequenceNumber);
     if (bAdd) {
       os.addChild(os.getChildCount(), specNode);
     }
@@ -442,21 +476,25 @@ public class HDFSOutputConnector extends
   }
 
   /** View specification.
-   * This method is called in the body section of a job's view page.  Its purpose is to present
the output specification information to the user.
-   * The coder can presume that the HTML that is output from this configuration will be within
appropriate <html> and <body> tags.
-   *@param out is the output to which any HTML should be sent.
-   *@param os is the current output specification for this job.
-   */
+  * This method is called in the body section of a job's view page.  Its purpose is to present
the pipeline 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 locale is the preferred local of the output.
+  *@param connectionSequenceNumber is the unique number of this connection within the job.
+  *@param os is the current pipeline specification for this job.
+  */
   @Override
-  public void viewSpecification(IHTTPOutput out, Locale locale, OutputSpecification os) throws
ManifoldCFException, IOException {
-    outputResource(VIEW_SPECIFICATION_HTML, out, locale, getSpecParameters(os), null);
+  public void viewSpecification(IHTTPOutput out, Locale locale, Specification os,
+    int connectionSequenceNumber)
+    throws ManifoldCFException, IOException {
+    outputResource(VIEW_SPECIFICATION_HTML, out, locale, getSpecParameters(os), null, new
Integer(connectionSequenceNumber), null);
   }
 
   /**
    * @param os
    * @return
    */
-  final private SpecificationNode getSpecNode(OutputSpecification os)
+  final private SpecificationNode getSpecNode(Specification os)
   {
     int l = os.getChildCount();
     for (int i = 0; i < l; i++) {
@@ -473,7 +511,7 @@ public class HDFSOutputConnector extends
    * @return
    * @throws ManifoldCFException
    */
-  final private HDFSOutputSpecs getSpecParameters(OutputSpecification os) throws ManifoldCFException
{
+  final private HDFSOutputSpecs getSpecParameters(Specification os) throws ManifoldCFException
{
     return new HDFSOutputSpecs(getSpecNode(os));
   }
 
@@ -493,14 +531,22 @@ public class HDFSOutputConnector extends
    * @param resName
    * @param out
    * @throws ManifoldCFException */
-  private static void outputResource(String resName, IHTTPOutput out, Locale locale, HDFSOutputParam
params, String tabName) throws ManifoldCFException {
+  private static void outputResource(String resName, IHTTPOutput out, Locale locale, HDFSOutputParam
params, String tabName, Integer sequenceNumber, Integer actualSequenceNumber) throws ManifoldCFException
{
     Map<String,String> paramMap = null;
     if (params != null) {
       paramMap = params.buildMap();
       if (tabName != null) {
         paramMap.put("TabName", tabName);
       }
+      if (actualSequenceNumber != null)
+        paramMap.put("SelectedNum",actualSequenceNumber.toString());
+    }
+    else
+    {
+      paramMap = new HashMap<String,String>();
     }
+    if (sequenceNumber != null)
+      paramMap.put("SeqNum",sequenceNumber.toString());
     Messages.outputResourceWithVelocity(out, locale, resName, paramMap, true);
   }
 

Modified: manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputSpecs.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputSpecs.java?rev=1603459&r1=1603458&r2=1603459&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputSpecs.java
(original)
+++ manifoldcf/trunk/connectors/hdfs/connector/src/main/java/org/apache/manifoldcf/agents/output/hdfs/HDFSOutputSpecs.java
Wed Jun 18 14:21:15 2014
@@ -100,9 +100,9 @@ public class HDFSOutputSpecs extends HDF
    * @param variableContext
    * @param specNode
    */
-  public static void contextToSpecNode(IPostParameters variableContext, ConfigurationNode
specNode) {
+  public static void contextToSpecNode(IPostParameters variableContext, ConfigurationNode
specNode, int sequenceNumber) {
     for (ParameterEnum param : SPECIFICATIONLIST) {
-      String p = variableContext.getParameter(param.name().toLowerCase());
+      String p = variableContext.getParameter("s"+sequenceNumber+"_"+param.name().toLowerCase());
       if (p != null) {
         specNode.setAttribute(param.name(), p);
       }

Modified: manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.html?rev=1603459&r1=1603458&r2=1603459&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.html
(original)
+++ manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.html
Wed Jun 18 14:21:15 2014
@@ -15,18 +15,18 @@
  limitations under the License.
 -->
 
-#if($TABNAME == $ResourceBundle.getString('HDFSOutputConnector.PathTabName'))
+#if($TABNAME == $ResourceBundle.getString('HDFSOutputConnector.PathTabName') && ${SEQNUM}
== ${SELECTEDNUM})
 
 <table class="displaytable">
   <tr><td class="separator" colspan="2"><hr/></td></tr>
   <tr>
     <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('HDFSOutputConnector.RootPath'))</nobr></td>
-    <td class="value"><input type="text" name="rootpath" size="64" value="$Encoder.attributeEscape($ROOTPATH)"
/></td>
+    <td class="value"><input type="text" name="s${SEQNUM}_rootpath" size="64" value="$Encoder.attributeEscape($ROOTPATH)"
/></td>
   </tr>
 </table>
 
 #else
 
-<input type="hidden" name="rootpath" value="$Encoder.attributeEscape($ROOTPATH)" />
+<input type="hidden" name="s${SEQNUM}_rootpath" value="$Encoder.attributeEscape($ROOTPATH)"
/>
 
 #end

Modified: manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.js
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.js?rev=1603459&r1=1603458&r2=1603459&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.js
(original)
+++ manifoldcf/trunk/connectors/hdfs/connector/src/main/resources/org/apache/manifoldcf/agents/output/hdfs/editSpecification.js
Wed Jun 18 14:21:15 2014
@@ -17,13 +17,13 @@
 
 <script type="text/javascript">
 <!--
-function checkOutputSpecificationForSave()
+function s${SEQNUM}_checkSpecificationForSave()
 {
-  if (editjob.rootpath.value == "")
+  if (editjob.s${SEQNUM}_rootpath.value == "")
   {
     alert("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('HDFSOutputConnector.RootPathCannotBeNull'))");
-    SelectTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('HDFSOutputConnector.PathTabName'))");
-    editjob.rootpath.focus();
+    SelectSequencedTab("$Encoder.bodyJavascriptEscape($ResourceBundle.getString('HDFSOutputConnector.PathTabName'))",${SEQNUM});
+    editjob.s${SEQNUM}_rootpath.focus();
     return false;
   }
   return true;



Mime
View raw message