sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject [7/10] git commit: SQOOP-776: show connection command shows password in plain text
Date Tue, 18 Dec 2012 02:46:11 GMT
SQOOP-776: show connection command shows password in plain text

(Jarek Jarcec Cecho via Cheolsoo Park)


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

Branch: refs/heads/branch-1.99.1
Commit: db531e4359788d3e6b97df7f69d7c131f8ec33b6
Parents: 191f230
Author: Cheolsoo Park <cheolsoo@apache.org>
Authored: Mon Dec 17 13:10:11 2012 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Dec 17 17:37:36 2012 -0800

----------------------------------------------------------------------
 .../apache/sqoop/client/utils/FormDisplayer.java   |   72 ++++++++++++++-
 1 files changed, 71 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/db531e43/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
index 97eea79..4d0442f 100644
--- a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
+++ b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java
@@ -22,13 +22,16 @@ import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFramework;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
+import org.apache.sqoop.model.MIntegerInput;
 import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.utils.StringUtils;
 import org.codehaus.groovy.tools.shell.IO;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
 
 /**
@@ -128,12 +131,79 @@ public final class FormDisplayer {
       io.out.print(bundle.getString(input.getLabelKey()));
       io.out.print(": ");
       if(!input.isEmpty()) {
-        io.out.print(input.getUrlSafeValueString());
+        // Based on the input type, let's perform specific load
+        switch (input.getType()) {
+          case STRING:
+            displayInputString(io, (MStringInput) input);
+            break;
+          case INTEGER:
+            displayInputInteger(io, (MIntegerInput) input);
+            break;
+          case MAP:
+            displayInputMap(io, (MMapInput) input);
+            break;
+          case ENUM:
+            displayInputEnum(io, (MEnumInput) input);
+            break;
+          default:
+            io.out.println("Unsupported data type " + input.getType());
+            return;
+        }
       }
       io.out.println("");
     }
   }
 
+  /**
+   * Display content of String input.
+   *
+   * @param io Shell's IO object
+   * @param input String input
+   */
+  private static void displayInputString(IO io, MStringInput input) {
+    if (input.isMasked()) {
+      io.out.print("(This input is sensitive)");
+    } else {
+      io.out.print(input.getValue());
+    }
+  }
+
+  /**
+   * Display content of Integer input.
+   *
+   * @param io Shell's IO object
+   * @param input Integer input
+   */
+  private static void displayInputInteger(IO io, MIntegerInput input) {
+    io.out.print(input.getValue());
+  }
+
+  /**
+   * Display content of Map input
+   *
+   * @param io Shell's IO object
+   * @param input Map input
+   */
+  private static void displayInputMap(IO io, MMapInput input) {
+    for(Map.Entry<String, String> entry : input.getValue().entrySet()) {
+      io.out.println();
+      io.out.print("      ");
+      io.out.print(entry.getKey());
+      io.out.print(" = ");
+      io.out.print(entry.getValue());
+    }
+  }
+
+  /**
+   * Display content of Enum input
+   *
+   * @param io Shell's IO object
+   * @param input Enum input
+   */
+  private static void displayInputEnum(IO io, MEnumInput input) {
+    io.out.print(input.getValue());
+  }
+
   private FormDisplayer() {
     // Do not instantiate
   }


Mime
View raw message