sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-947: Sqoop2: Introduce the concept of "sensitivity" input to all supported metadata structures
Date Mon, 25 Mar 2013 20:34:34 GMT
Updated Branches:
  refs/heads/sqoop2 cc506b9eb -> dd61adf66


SQOOP-947: Sqoop2: Introduce the concept of "sensitivity" input to all supported metadata
structures

(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/dd61adf6
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/dd61adf6
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/dd61adf6

Branch: refs/heads/sqoop2
Commit: dd61adf66cf90172347d2c44e4c8c5f8b79e818c
Parents: cc506b9
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon Mar 25 13:33:15 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Mar 25 13:33:15 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/client/core/Constants.java    |    4 +-
 .../apache/sqoop/client/utils/FormDisplayer.java   |   48 +++++++-------
 .../org/apache/sqoop/client/utils/FormFiller.java  |   38 +++++++++---
 .../src/main/resources/client-resource.properties  |    2 +-
 .../apache/sqoop/json/util/FormSerialization.java  |   17 +++---
 .../java/org/apache/sqoop/model/FormUtils.java     |    6 +-
 .../java/org/apache/sqoop/model/MEnumInput.java    |    4 +-
 .../main/java/org/apache/sqoop/model/MInput.java   |   13 ++++-
 .../java/org/apache/sqoop/model/MIntegerInput.java |    4 +-
 .../java/org/apache/sqoop/model/MMapInput.java     |    4 +-
 .../java/org/apache/sqoop/model/MStringInput.java  |   24 ++-----
 .../org/apache/sqoop/json/TestConnectionBean.java  |   11 +++
 .../java/org/apache/sqoop/model/TestFormUtils.java |    6 +-
 .../apache/sqoop/model/TestMAccountableEntity.java |    2 +-
 .../org/apache/sqoop/model/TestMConnection.java    |    4 +-
 .../org/apache/sqoop/model/TestMEnumInput.java     |   20 +++++-
 .../java/org/apache/sqoop/model/TestMForm.java     |   14 ++--
 .../java/org/apache/sqoop/model/TestMFormList.java |    6 +-
 .../org/apache/sqoop/model/TestMIntegerInput.java  |   25 ++++++--
 .../java/org/apache/sqoop/model/TestMMapInput.java |   25 ++++++--
 .../org/apache/sqoop/model/TestMNamedElement.java  |    2 +-
 .../org/apache/sqoop/model/TestMStringInput.java   |    2 +-
 .../apache/sqoop/model/TestMValidatedElement.java  |    4 +-
 .../repository/derby/DerbyRepositoryHandler.java   |   13 ++--
 24 files changed, 181 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/client/src/main/java/org/apache/sqoop/client/core/Constants.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/core/Constants.java b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
index cc80df1..b93577c 100644
--- a/client/src/main/java/org/apache/sqoop/client/core/Constants.java
+++ b/client/src/main/java/org/apache/sqoop/client/core/Constants.java
@@ -336,8 +336,8 @@ public class Constants {
       "formdisplayer.input";
   public static final String RES_FORMDISPLAYER_TYPE =
       "formdisplayer.type";
-  public static final String RES_FORMDISPLAYER_MASK =
-      "formdisplayer.mask";
+  public static final String RES_FORMDISPLAYER_SENSITIVE =
+      "formdisplayer.sensitive";
   public static final String RES_FORMDISPLAYER_SIZE =
       "formdisplayer.size";
   public static final String RES_FORMDISPLAYER_POSSIBLE_VALUES =

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/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 0609ae1..7cce713 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
@@ -101,9 +101,9 @@ public final class FormDisplayer {
         println(bundle.getString(input.getHelpKey()));
         print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_TYPE));
         println(input.getType());
+        print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_SENSITIVE));
+        println(input.isSensitive());
         if (input.getType() == MInputType.STRING) {
-          print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_MASK));
-          println(((MStringInput)input).isMasked());
           print("        %s: ", resourceString(Constants.RES_FORMDISPLAYER_SIZE));
           println(((MStringInput)input).getMaxLength());
         } else if(input.getType() == MInputType.ENUM) {
@@ -129,23 +129,27 @@ public final class FormDisplayer {
       print(bundle.getString(input.getLabelKey()));
       print(": ");
       if(!input.isEmpty()) {
-        // Based on the input type, let's perform specific load
-        switch (input.getType()) {
-          case STRING:
-            displayInputString((MStringInput) input);
-            break;
-          case INTEGER:
-            displayInputInteger((MIntegerInput) input);
-            break;
-          case MAP:
-            displayInputMap((MMapInput) input);
-            break;
-          case ENUM:
-            displayInputEnum((MEnumInput) input);
-            break;
-          default:
-            print("\n%s " + input.getType(), resourceString(Constants.RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE));
-            return;
+        if (input.isSensitive()) {
+          print("(%s)", resourceString(Constants.RES_FORMDISPLAYER_INPUT_SENSITIVE));
+        } else {
+          // Based on the input type, let's perform specific load
+          switch (input.getType()) {
+            case STRING:
+              displayInputString((MStringInput) input);
+              break;
+            case INTEGER:
+              displayInputInteger((MIntegerInput) input);
+              break;
+            case MAP:
+              displayInputMap((MMapInput) input);
+              break;
+            case ENUM:
+              displayInputEnum((MEnumInput) input);
+              break;
+            default:
+              print("\n%s " + input.getType(), resourceString(Constants.RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE));
+              return;
+          }
         }
       }
       println("");
@@ -158,11 +162,7 @@ public final class FormDisplayer {
    * @param input String input
    */
   private static void displayInputString(MStringInput input) {
-    if (input.isMasked()) {
-      print("(%s)", resourceString(Constants.RES_FORMDISPLAYER_INPUT_SENSITIVE));
-    } else {
-      print(input.getValue());
-    }
+    print(input.getValue());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java b/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
index f11b9d2..95d0612 100644
--- a/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
+++ b/client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
@@ -203,7 +203,8 @@ public final class FormFiller {
 
       println("  " + i  + " : " + value);
 
-      if(!input.isEmpty() && value.equals(input.getValue())) {
+      // Only show last choice if not sensitive
+      if(!input.isEmpty() && value.equals(input.getValue()) && !input.isSensitive())
{
         lastChoice = i;
       }
     }
@@ -217,7 +218,12 @@ public final class FormFiller {
     }
 
     reader.flushConsole();
-    String userTyped = reader.readLine();
+    String userTyped;
+    if(input.isSensitive()) {
+      userTyped = reader.readLine('*');
+    } else {
+      userTyped = reader.readLine();
+    }
 
     if (userTyped == null) {
       return false;
@@ -278,16 +284,23 @@ public final class FormFiller {
 
     while(true) {
       // Print all current items in each iteration
+      // However do not printout if this input contains sensitive information.
       println("There are currently " + values.size() + " values in the map:");
-      for(Map.Entry<String, String> entry : values.entrySet()) {
-        println(entry.getKey() + " = " + entry.getValue());
+      if (!input.isSensitive()) {
+        for(Map.Entry<String, String> entry : values.entrySet()) {
+          println(entry.getKey() + " = " + entry.getValue());
+        }
       }
 
       // Special prompt for Map entry
       reader.printString("entry# ");
       reader.flushConsole();
 
-      userTyped = reader.readLine();
+      if(input.isSensitive()) {
+        userTyped = reader.readLine('*');
+      } else {
+        userTyped = reader.readLine();
+      }
 
       if(userTyped == null) {
         // Finish loading and return back to Sqoop shell
@@ -365,11 +378,18 @@ public final class FormFiller {
     generatePrompt(reader, bundle, input);
 
     // Fill already filled data when available
-    if(!input.isEmpty()) {
+    // However do not printout if this input contains sensitive information.
+    if(!input.isEmpty() && !input.isSensitive()) {
       reader.putString(input.getValue().toString());
     }
 
-    String userTyped = reader.readLine();
+    // Get the data
+    String userTyped;
+    if(input.isSensitive()) {
+      userTyped = reader.readLine('*');
+    } else {
+      userTyped = reader.readLine();
+    }
 
     if (userTyped == null) {
       return false;
@@ -408,13 +428,13 @@ public final class FormFiller {
 
     // Fill already filled data when available
     // However do not printout if this input contains sensitive information.
-    if(!input.isEmpty() && !input.isMasked()) {
+    if(!input.isEmpty() && !input.isSensitive()) {
       reader.putString(input.getValue());
     }
 
     // Get the data
     String userTyped;
-    if(input.isMasked()) {
+    if(input.isSensitive()) {
        userTyped = reader.readLine('*');
     } else {
       userTyped = reader.readLine();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/client/src/main/resources/client-resource.properties
----------------------------------------------------------------------
diff --git a/client/src/main/resources/client-resource.properties b/client/src/main/resources/client-resource.properties
index 734333e..7e68c4f 100644
--- a/client/src/main/resources/client-resource.properties
+++ b/client/src/main/resources/client-resource.properties
@@ -182,7 +182,7 @@ formdisplayer.label = Label
 formdisplayer.help = Help
 formdisplayer.input = Input
 formdisplayer.type = Type
-formdisplayer.mask = Mask
+formdisplayer.sensitive = Sensitive
 formdisplayer.size = Size
 formdisplayer.possible_values = Possible values
 formdisplayer.unsupported_datatype = Unsupported data type

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
index 3f8f985..048323b 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
@@ -52,7 +52,7 @@ public final class FormSerialization {
   public static final String FORM_INPUTS = "inputs";
   public static final String FORM_INPUT_NAME = "name";
   public static final String FORM_INPUT_TYPE = "type";
-  public static final String FORM_INPUT_MASK = "mask";
+  public static final String FORM_INPUT_SENSITIVE = "sensitive";
   public static final String FORM_INPUT_SIZE = "size";
   public static final String FORM_INPUT_VALUE = "value";
   public static final String FORM_INPUT_VALUES = "values";
@@ -95,11 +95,10 @@ public final class FormSerialization {
       input.put(ID, mInput.getPersistenceId());
       input.put(FORM_INPUT_NAME, mInput.getName());
       input.put(FORM_INPUT_TYPE, mInput.getType().toString());
+      input.put(FORM_INPUT_SENSITIVE, mInput.isSensitive());
 
       // String specific serialization
       if (mInput.getType() == MInputType.STRING) {
-        input.put(FORM_INPUT_MASK,
-            ((MStringInput)mInput).isMasked());
         input.put(FORM_INPUT_SIZE,
             ((MStringInput)mInput).getMaxLength());
       }
@@ -112,7 +111,7 @@ public final class FormSerialization {
 
       // Serialize value if is there
       // Skip if sensitive
-      if (!mInput.isEmpty() && !(skipSensitive && ((MStringInput)mInput).isMasked()))
{
+      if (!mInput.isEmpty() && !(skipSensitive && mInput.isSensitive()))
{
         input.put(FORM_INPUT_VALUE, mInput.getUrlSafeValueString());
       }
 
@@ -153,25 +152,25 @@ public final class FormSerialization {
       MInputType type =
           MInputType.valueOf((String) input.get(FORM_INPUT_TYPE));
       String name = (String) input.get(FORM_INPUT_NAME);
+      Boolean sensitive = (Boolean) input.get(FORM_INPUT_SENSITIVE);
       MInput mInput = null;
       switch (type) {
         case STRING: {
-          boolean mask = (Boolean) input.get(FORM_INPUT_MASK);
           long size = (Long) input.get(FORM_INPUT_SIZE);
-          mInput = new MStringInput(name, mask, (short) size);
+          mInput = new MStringInput(name, sensitive.booleanValue(), (short) size);
           break;
         }
         case MAP: {
-          mInput = new MMapInput(name);
+          mInput = new MMapInput(name, sensitive.booleanValue());
           break;
         }
         case INTEGER: {
-          mInput = new MIntegerInput(name);
+          mInput = new MIntegerInput(name, sensitive.booleanValue());
           break;
         }
         case ENUM: {
           String values = (String) input.get(FORM_INPUT_VALUES);
-          mInput = new MEnumInput(name, values.split(","));
+          mInput = new MEnumInput(name, sensitive.booleanValue(), values.split(","));
           break;
         }
       }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/FormUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/FormUtils.java b/common/src/main/java/org/apache/sqoop/model/FormUtils.java
index e88216d..80b10c8 100644
--- a/common/src/main/java/org/apache/sqoop/model/FormUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/FormUtils.java
@@ -139,11 +139,11 @@ public class FormUtils {
         if(type == String.class) {
           input = new MStringInput(inputName, sensitive, maxLen);
         } else if (type.isAssignableFrom(Map.class)) {
-          input = new MMapInput(inputName);
+          input = new MMapInput(inputName, sensitive);
         } else if(type == Integer.class) {
-          input = new MIntegerInput(inputName);
+          input = new MIntegerInput(inputName, sensitive);
         } else if(type.isEnum()) {
-          input = new MEnumInput(inputName, ClassUtils.getEnumStrings(type));
+          input = new MEnumInput(inputName, sensitive, ClassUtils.getEnumStrings(type));
         } else {
           throw new SqoopException(ModelError.MODEL_004,
             "Unsupported type " + type.getName() + " for input " + fieldName);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
index 77598a8..12705a6 100644
--- a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java
@@ -32,8 +32,8 @@ public class MEnumInput extends MInput<String> {
    */
   String []values;
 
-  public MEnumInput(String name, String[] values) {
-    super(name);
+  public MEnumInput(String name, boolean sensitive, String[] values) {
+    super(name, sensitive);
     this.values = values;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/MInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MInput.java b/common/src/main/java/org/apache/sqoop/model/MInput.java
index 96397e8..7d6215f 100644
--- a/common/src/main/java/org/apache/sqoop/model/MInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MInput.java
@@ -21,12 +21,16 @@ package org.apache.sqoop.model;
  * Represents a parameter input used by the connector for creating a connection
  * or a job object.
  * @param <T> the value type associated with this parameter
+ * @param boolean whether or not the field contains sensitive information
  */
 public abstract class MInput<T> extends MValidatedElement {
+  private final boolean sensitive;
+
   private T value;
 
-  protected MInput(String name) {
+  protected MInput(String name, boolean sensitive) {
     super(name);
+    this.sensitive = sensitive;
   }
 
   /**
@@ -44,6 +48,13 @@ public abstract class MInput<T> extends MValidatedElement {
   }
 
   /**
+   * @return <tt>true</tt> if this string represents sensitive information
+   */
+  public boolean isSensitive() {
+    return sensitive;
+  }
+
+  /**
    * @return a URL-safe string representation of the value
    */
   public abstract String getUrlSafeValueString();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java b/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
index d281d7e..d23ac31 100644
--- a/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MIntegerInput.java
@@ -24,8 +24,8 @@ package org.apache.sqoop.model;
  */
 public class MIntegerInput extends MInput<Integer> {
 
-  public MIntegerInput(String name) {
-    super(name);
+  public MIntegerInput(String name, boolean sensitive) {
+    super(name, sensitive);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/MMapInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MMapInput.java b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
index b458022..704c1f8 100644
--- a/common/src/main/java/org/apache/sqoop/model/MMapInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MMapInput.java
@@ -24,8 +24,8 @@ import org.apache.sqoop.utils.UrlSafeUtils;
 
 public final class MMapInput extends MInput<Map<String, String>> {
 
-  public MMapInput(String name) {
-    super(name);
+  public MMapInput(String name, boolean sensitive) {
+    super(name, sensitive);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/main/java/org/apache/sqoop/model/MStringInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MStringInput.java b/common/src/main/java/org/apache/sqoop/model/MStringInput.java
index e96ec92..a437a25 100644
--- a/common/src/main/java/org/apache/sqoop/model/MStringInput.java
+++ b/common/src/main/java/org/apache/sqoop/model/MStringInput.java
@@ -20,36 +20,26 @@ package org.apache.sqoop.model;
 import org.apache.sqoop.utils.UrlSafeUtils;
 
 /**
- * Represents a <tt>String</tt> input. The boolean flag <tt>mask</tt>
supplied
+ * Represents a <tt>String</tt> input. The boolean flag <tt>sensitive</tt>
supplied
  * to its constructor can be used to indicate if the string should be masked
  * from user-view. This is helpful for creating input strings that represent
  * sensitive information such as passwords.
  */
 public final class MStringInput extends MInput<String> {
 
-  private final boolean mask;
   private final short maxLength;
 
   /**
    * @param name the parameter name
-   * @param mask a flag indicating if the string should be masked
+   * @param sensitive a flag indicating if the string should be masked
    * @param maxLength the maximum length of the string
    */
-  public MStringInput(String name, boolean mask, short maxLength) {
-    super(name);
-    this.mask = mask;
+  public MStringInput(String name, boolean sensitive, short maxLength) {
+    super(name, sensitive);
     this.maxLength = maxLength;
   }
 
   /**
-   * @return <tt>true</tt> if this string represents sensitive information that
-   * should be masked
-   */
-  public boolean isMasked() {
-    return mask;
-  }
-
-  /**
    * @return the maximum length of this string type
    */
   public short getMaxLength() {
@@ -78,7 +68,7 @@ public final class MStringInput extends MInput<String> {
 
   @Override
   public String getExtraInfoToString() {
-    return isMasked() + ":" + getMaxLength();
+    return Short.toString(getMaxLength());
   }
 
   @Override
@@ -93,14 +83,14 @@ public final class MStringInput extends MInput<String> {
 
     MStringInput msi = (MStringInput) other;
     return getName().equals(msi.getName())
-        && (mask == msi.mask)
+        && (isSensitive() == msi.isSensitive())
         && (maxLength == msi.maxLength);
   }
 
   @Override
   public int hashCode() {
     int result = 23 + 31 * getName().hashCode();
-    result = 31 * result + (mask ? 1 : 0);
+    result = 31 * result + (isSensitive() ? 1 : 0);
     result = 31 * result + maxLength;
     return result;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
index 5553554..dd1d75b 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectionBean.java
@@ -19,6 +19,7 @@ package org.apache.sqoop.json;
 
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MStringInput;
+import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONValue;
@@ -52,6 +53,16 @@ public class TestConnectionBean {
     ConnectionBean bean = new ConnectionBean(connection);
     JSONObject json = bean.extract(false);
 
+    // Check for sensitivity
+    JSONArray all = (JSONArray)json.get("all");
+    JSONObject allItem = (JSONObject)all.get(0);
+    JSONArray connectors = (JSONArray)allItem.get("connector");
+    JSONObject connector = (JSONObject)connectors.get(0);
+    JSONArray inputs = (JSONArray)connector.get("inputs");
+    for (Object input1 : inputs) {
+      assertTrue(((JSONObject)input1).containsKey("sensitive"));
+    }
+
     // "Move" it across network in text form
     String string = json.toJSONString();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java b/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
index 85c65de..08dfa7b 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
@@ -184,9 +184,9 @@ public class TestFormUtils extends TestCase {
 
     // Form C
     inputs = new LinkedList<MInput<?>>();
-    inputs.add(new MIntegerInput("cForm.intValue"));
-    inputs.add(new MMapInput("cForm.map"));
-    inputs.add(new MEnumInput("cForm.enumeration", new String[]{"X", "Y"}));
+    inputs.add(new MIntegerInput("cForm.intValue", false));
+    inputs.add(new MMapInput("cForm.map", false));
+    inputs.add(new MEnumInput("cForm.enumeration", false, new String[]{"X", "Y"}));
     ret.add(new MForm("cForm", inputs));
 
     return ret;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
index 1cde5cf..4ea42b1 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -36,7 +36,7 @@ public class TestMAccountableEntity {
   @Test
   public void testInitialization() {
     List<MForm> forms = new ArrayList<MForm>();
-    MIntegerInput input = new MIntegerInput("INTEGER-INPUT");
+    MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
     List<MInput<?>> list = new ArrayList<MInput<?>>();
     list.add(input);
     MForm form = new MForm("FORMNAME", list);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
index a99b7dc..c3469ff 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnection.java
@@ -49,7 +49,7 @@ public class TestMConnection {
 
   private MConnectionForms connector1() {
     List<MForm> forms = new ArrayList<MForm>();
-    MIntegerInput input = new MIntegerInput("INTEGER-INPUT");
+    MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
     List<MInput<?>> list = new ArrayList<MInput<?>>();
     list.add(input);
     MForm form = new MForm("FORMNAME", list);
@@ -59,7 +59,7 @@ public class TestMConnection {
 
   private MConnectionForms connector2() {
     List<MForm> forms = new ArrayList<MForm>();
-    MMapInput input = new MMapInput("MAP-INPUT");
+    MMapInput input = new MMapInput("MAP-INPUT", false);
     List<MInput<?>> list = new ArrayList<MInput<?>>();
     list.add(input);
     MForm form = new MForm("form", list);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
index 1d86c13..a25016a 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMEnumInput.java
@@ -33,19 +33,31 @@ public class TestMEnumInput {
   @Test
   public void testInitialization() {
     String[] values = { "value1", "value2" };
-    MEnumInput input = new MEnumInput("NAME", values);
+    MEnumInput input = new MEnumInput("NAME", false, values);
     assertEquals("NAME", input.getName());
     assertArrayEquals(values, input.getValues());
     assertEquals(MInputType.ENUM, input.getType());
 
-    MEnumInput input1 = new MEnumInput("NAME", values);
+    MEnumInput input1 = new MEnumInput("NAME", false, values);
     assertEquals(input1, input);
     String[] testVal = { "val", "test" };
-    MEnumInput input2 = new MEnumInput("NAME1", testVal);
+    MEnumInput input2 = new MEnumInput("NAME1", false, testVal);
     assertFalse(input1.equals(input2));
 
-    MEnumInput input3 = new MEnumInput("NAME", values);
+    MEnumInput input3 = new MEnumInput("NAME", false, values);
     input3.setValue(Enumeration.value1);
     assertEquals("value1", input3.getValue());
   }
+
+  /**
+   * Test for sensitivity
+   */
+  @Test
+  public void testSensitivity() {
+    String[] values = { "value1", "value2" };
+    MEnumInput input1 = new MEnumInput("NAME", false, values);
+    MEnumInput input2 = new MEnumInput("NAME", true, values);
+    assertFalse(input1.isSensitive());
+    assertTrue(input2.isSensitive());
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMForm.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMForm.java b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
index b7b1356..0bd55d9 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMForm.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
@@ -50,15 +50,15 @@ public class TestMForm {
    */
   @Test
   public void testEquals() {
-    MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1");
-    MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2");
+    MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
+    MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
     List<MInput<?>> list1 = new ArrayList<MInput<?>>();
     list1.add(input1);
     list1.add(input2);
     MForm mform1 = new MForm("form", list1);
 
-    MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1");
-    MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2");
+    MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
+    MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
     List<MInput<?>> list2 = new ArrayList<MInput<?>>();
     list2.add(input3);
     list2.add(input4);
@@ -68,10 +68,10 @@ public class TestMForm {
 
   @Test
   public void testGetInputs() {
-    MIntegerInput intInput = new MIntegerInput("Form.A");
-    MMapInput mapInput = new MMapInput("Form.B");
+    MIntegerInput intInput = new MIntegerInput("Form.A", false);
+    MMapInput mapInput = new MMapInput("Form.B", false);
     MStringInput stringInput = new MStringInput("Form.C", false, (short)3);
-    MEnumInput enumInput = new MEnumInput("Form.D", new String[] {"I", "V"});
+    MEnumInput enumInput = new MEnumInput("Form.D", false, new String[] {"I", "V"});
 
     List<MInput<?>> inputs = new ArrayList<MInput<?>>();
     inputs.add(intInput);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
index 5f599eb..bd21fcb 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
@@ -33,8 +33,8 @@ public class TestMFormList {
   public void testGetInputs() {
     List<MForm> forms = new LinkedList<MForm>();
 
-    MIntegerInput intInput = new MIntegerInput("Form1.A");
-    MMapInput mapInput = new MMapInput("Form1.B");
+    MIntegerInput intInput = new MIntegerInput("Form1.A", false);
+    MMapInput mapInput = new MMapInput("Form1.B", false);
 
     List<MInput<?>> inputs = new ArrayList<MInput<?>>();
     inputs.add(intInput);
@@ -42,7 +42,7 @@ public class TestMFormList {
     forms.add(new MForm("Form1", inputs));
 
     MStringInput stringInput = new MStringInput("Form2.C", false, (short)3);
-    MEnumInput enumInput = new MEnumInput("Form2.D", new String[] {"I", "V"});
+    MEnumInput enumInput = new MEnumInput("Form2.D", false, new String[] {"I", "V"});
 
     inputs = new ArrayList<MInput<?>>();
     inputs.add(stringInput);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
index 042158a..1f38e6d 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMIntegerInput.java
@@ -33,7 +33,7 @@ public class TestMIntegerInput {
    */
   @Test
   public void testInitialization() {
-    MIntegerInput input = new MIntegerInput("sqoopsqoop");
+    MIntegerInput input = new MIntegerInput("sqoopsqoop", false);
     assertEquals("sqoopsqoop", input.getName());
     assertEquals(MInputType.INTEGER, input.getType());
   }
@@ -44,13 +44,13 @@ public class TestMIntegerInput {
   @Test
   public void testEquals() {
     // Positive test
-    MIntegerInput input1 = new MIntegerInput("sqoopsqoop");
-    MIntegerInput input2 = new MIntegerInput("sqoopsqoop");
+    MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
+    MIntegerInput input2 = new MIntegerInput("sqoopsqoop", false);
     assertTrue(input1.equals(input2));
 
     // Negative test
-    MIntegerInput input3 = new MIntegerInput("sqoopsqoop");
-    MIntegerInput input4 = new MIntegerInput("sqoopsqoop1");
+    MIntegerInput input3 = new MIntegerInput("sqoopsqoop", false);
+    MIntegerInput input4 = new MIntegerInput("sqoopsqoop1", false);
     assertFalse(input3.equals(input4));
   }
 
@@ -59,7 +59,7 @@ public class TestMIntegerInput {
    */
   @Test
   public void testValue() {
-    MIntegerInput input1 = new MIntegerInput("sqoopsqoop");
+    MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
     input1.setValue(99);
     assertEquals(new Integer(99), input1.getValue());
     input1.setEmpty();
@@ -71,7 +71,7 @@ public class TestMIntegerInput {
    */
   @Test
   public void testUrlSafe() {
-    MIntegerInput input1 = new MIntegerInput("sqoopsqoop");
+    MIntegerInput input1 = new MIntegerInput("sqoopsqoop", false);
     input1.setValue(1001);
     // Getting URL safe string
     String tmp = input1.getUrlSafeValueString();
@@ -89,4 +89,15 @@ public class TestMIntegerInput {
     assertEquals("sqoopsqoop.label", input1.getLabelKey());
     assertEquals("sqoopsqoop.help", input1.getHelpKey());
   }
+
+  /**
+   * Test for sensitivity
+   */
+  @Test
+  public void testSensitivity() {
+    MIntegerInput input1 = new MIntegerInput("NAME", false);
+    MIntegerInput input2 = new MIntegerInput("NAME", true);
+    assertFalse(input1.isSensitive());
+    assertTrue(input2.isSensitive());
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
index 772f230..eb877cf 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMMapInput.java
@@ -36,7 +36,7 @@ public class TestMMapInput {
    */
   @Test
   public void testInitialization() {
-    MMapInput input = new MMapInput("sqoopsqoop");
+    MMapInput input = new MMapInput("sqoopsqoop", false);
     assertEquals("sqoopsqoop", input.getName());
     assertEquals(MInputType.MAP, input.getType());
   }
@@ -47,13 +47,13 @@ public class TestMMapInput {
   @Test
   public void testEquals() {
     // Positive test
-    MMapInput input1 = new MMapInput("sqoopsqoop");
-    MMapInput input2 = new MMapInput("sqoopsqoop");
+    MMapInput input1 = new MMapInput("sqoopsqoop", false);
+    MMapInput input2 = new MMapInput("sqoopsqoop", false);
     assertTrue(input1.equals(input2));
 
     // Negative test
-    MMapInput input3 = new MMapInput("sqoopsqoop");
-    MMapInput input4 = new MMapInput("sqoopsqoop1");
+    MMapInput input3 = new MMapInput("sqoopsqoop", false);
+    MMapInput input4 = new MMapInput("sqoopsqoop1", false);
     assertFalse(input3.equals(input4));
   }
 
@@ -62,7 +62,7 @@ public class TestMMapInput {
    */
   @Test
   public void testValue() {
-    MMapInput input1 = new MMapInput("sqoopsqoop");
+    MMapInput input1 = new MMapInput("sqoopsqoop", false);
     Map<String, String> map1 = new HashMap<String, String>();
     input1.setValue(map1);
     assertEquals(map1, input1.getValue());
@@ -75,7 +75,7 @@ public class TestMMapInput {
    */
   @Test
   public void testUrlSafe() {
-    MMapInput input1 = new MMapInput("sqoopsqoop");
+    MMapInput input1 = new MMapInput("sqoopsqoop", false);
     Map<String, String> map1 = new HashMap<String, String>();
     input1.setValue(map1);
     // Getting URL safe string
@@ -94,4 +94,15 @@ public class TestMMapInput {
     assertEquals("sqoopsqoop.label", input1.getLabelKey());
     assertEquals("sqoopsqoop.help", input1.getHelpKey());
   }
+
+  /**
+   * Test for sensitivity
+   */
+  @Test
+  public void testSensitivity() {
+    MMapInput input1 = new MMapInput("NAME", false);
+    MMapInput input2 = new MMapInput("NAME", true);
+    assertFalse(input1.isSensitive());
+    assertTrue(input2.isSensitive());
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
index fa6b9ad..f336bab 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMNamedElement.java
@@ -31,7 +31,7 @@ public class TestMNamedElement {
    */
   @Test
   public void testInitialization() {
-    MNamedElement named = new MIntegerInput("SQOOP");
+    MNamedElement named = new MIntegerInput("SQOOP", false);
     assertEquals("SQOOP", named.getName());
     assertEquals("SQOOP.label", named.getLabelKey());
     assertEquals("SQOOP.help", named.getHelpKey());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
index 2ba9709..2fe0335 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMStringInput.java
@@ -34,7 +34,7 @@ public class TestMStringInput {
     short len = 6;
     MStringInput input = new MStringInput("sqoopsqoop", true, len);
     assertEquals("sqoopsqoop", input.getName());
-    assertEquals(true, input.isMasked());
+    assertEquals(true, input.isSensitive());
     assertEquals(len, input.getMaxLength());
     assertEquals(MInputType.STRING, input.getType());
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
index 8d07521..3fd5a95 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMValidatedElement.java
@@ -32,7 +32,7 @@ public class TestMValidatedElement {
    */
   @Test
   public void testInitialization() {
-    MValidatedElement input = new MIntegerInput("input");
+    MValidatedElement input = new MIntegerInput("input", false);
     assertEquals("input", input.getName());
     assertEquals(Status.FINE, input.getValidationStatus());
   }
@@ -42,7 +42,7 @@ public class TestMValidatedElement {
    */
   @Test
   public void testValidationMessageStatus() {
-    MValidatedElement input = new MIntegerInput("input");
+    MValidatedElement input = new MIntegerInput("input", false);
     // Default status
     assertEquals(Status.FINE, input.getValidationStatus());
     // Set status and user message

http://git-wip-us.apache.org/repos/asf/sqoop/blob/dd61adf6/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 8af86b7..486635d 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -1369,13 +1369,12 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler
{
       baseInputStmt.setLong(2, formId);
       baseInputStmt.setShort(3, inputIndex++);
       baseInputStmt.setString(4, input.getType().name());
+      baseInputStmt.setBoolean(5, input.isSensitive());
       // String specific column(s)
       if (input.getType().equals(MInputType.STRING)) {
         MStringInput	strInput = (MStringInput) input;
-        baseInputStmt.setBoolean(5, strInput.isMasked());
         baseInputStmt.setShort(6, strInput.getMaxLength());
       } else {
-        baseInputStmt.setNull(5, Types.BOOLEAN);
         baseInputStmt.setNull(6, Types.INTEGER);
       }
       // Enum specific column(s)
@@ -1494,7 +1493,7 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler
{
         long inputForm = rsetInput.getLong(3);
         short inputIndex = rsetInput.getShort(4);
         String inputType = rsetInput.getString(5);
-        boolean inputStrMask = rsetInput.getBoolean(6);
+        boolean inputSensitivity = rsetInput.getBoolean(6);
         short inputStrLength = rsetInput.getShort(7);
         String inputEnumValues = rsetInput.getString(8);
         String value = rsetInput.getString(9);
@@ -1504,16 +1503,16 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler
{
         MInput input = null;
         switch (mit) {
         case STRING:
-          input = new MStringInput(inputName, inputStrMask, inputStrLength);
+          input = new MStringInput(inputName, inputSensitivity, inputStrLength);
           break;
         case MAP:
-          input = new MMapInput(inputName);
+          input = new MMapInput(inputName, inputSensitivity);
           break;
         case INTEGER:
-          input = new MIntegerInput(inputName);
+          input = new MIntegerInput(inputName, inputSensitivity);
           break;
         case ENUM:
-          input = new MEnumInput(inputName, inputEnumValues.split(","));
+          input = new MEnumInput(inputName, inputSensitivity, inputEnumValues.split(","));
           break;
         default:
           throw new SqoopException(DerbyRepoError.DERBYREPO_0006,


Mime
View raw message