You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2015/04/28 20:22:04 UTC

sqoop git commit: SQOOP-2323: Sqoop2: Add validation for connector supported directions

Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 6284d590f -> 3d3454103


SQOOP-2323: Sqoop2: Add validation for connector supported directions

(Abraham Elmahrek via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/3d345410
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/3d345410
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/3d345410

Branch: refs/heads/sqoop2
Commit: 3d3454103f476c2af029ae1cce079b0111e19a71
Parents: 6284d59
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Tue Apr 28 11:20:51 2015 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Tue Apr 28 11:20:51 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/sqoop/shell/CreateJobFunction.java | 13 +++++++++++++
 .../org/apache/sqoop/shell/utils/ConfigFiller.java     |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/3d345410/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
index cc87bde..91dc828 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
@@ -21,6 +21,7 @@ import jline.ConsoleReader;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MConnector;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.utils.ConfigDisplayer;
@@ -73,6 +74,18 @@ public class CreateJobFunction extends  SqoopFunction {
     ConsoleReader reader = new ConsoleReader();
     MJob job = client.createJob(fromLinkId, toLinkId);
 
+    MConnector fromConnector = client.getConnector(job.getFromConnectorId());
+    if (!fromConnector.getSupportedDirections().isDirectionSupported(Direction.FROM)) {
+      errorMessage("Connector " + fromConnector.getUniqueName() + " does not support direction " + Direction.FROM);
+      return Status.ERROR;
+    }
+
+    MConnector toConnector = client.getConnector(job.getToConnectorId());
+    if (!toConnector.getSupportedDirections().isDirectionSupported(Direction.TO)) {
+      errorMessage("Connector " + toConnector.getUniqueName() + " does not support direction " + Direction.TO);
+      return Status.ERROR;
+    }
+
     ResourceBundle fromConfigBundle = client.getConnectorConfigBundle(
         job.getFromConnectorId());
     ResourceBundle toConfigBundle = client.getConnectorConfigBundle(

http://git-wip-us.apache.org/repos/asf/sqoop/blob/3d345410/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
index 5149cd2..b3345b6 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
@@ -919,7 +919,7 @@ public final class ConfigFiller {
     }
   }
 
-  static void errorMessage(String message) {
+  public static void errorMessage(String message) {
     println("Error message: @|red " + message + " |@");
   }