5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-04 06:10:18 +08:00

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

(Abraham Elmahrek via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2013-03-25 13:33:15 -07:00
parent cc506b9ebf
commit dd61adf66c
24 changed files with 181 additions and 117 deletions

View File

@ -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 =

View File

@ -101,9 +101,9 @@ public static void displayFormsMetadata(List<MForm> forms,
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 @@ private static void displayForm(MForm form, ResourceBundle bundle) {
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 @@ private static void displayForm(MForm form, ResourceBundle bundle) {
* @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());
}
/**

View File

@ -203,7 +203,8 @@ private static boolean fillInputEnum(MEnumInput input,
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 @@ private static boolean fillInputEnum(MEnumInput input,
}
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 @@ private static boolean fillInputMap(MMapInput input,
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 @@ private static boolean fillInputInteger(MIntegerInput input,
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 static boolean fillInputString(MStringInput input,
// 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();

View File

@ -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

View File

@ -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 static JSONObject extractForm(MForm mForm, boolean skipSensitive) {
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 static JSONObject extractForm(MForm mForm, boolean skipSensitive) {
// 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 static MForm restoreForm(JSONObject form) {
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;
}
}

View File

@ -139,11 +139,11 @@ private static MForm toForm(String formName, Class klass, Object object) {
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);

View File

@ -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;
}

View File

@ -21,12 +21,16 @@
* 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;
}
/**
@ -43,6 +47,13 @@ public T getValue() {
return value;
}
/**
* @return <tt>true</tt> if this string represents sensitive information
*/
public boolean isSensitive() {
return sensitive;
}
/**
* @return a URL-safe string representation of the value
*/

View File

@ -24,8 +24,8 @@
*/
public class MIntegerInput extends MInput<Integer> {
public MIntegerInput(String name) {
super(name);
public MIntegerInput(String name, boolean sensitive) {
super(name, sensitive);
}
@Override

View File

@ -24,8 +24,8 @@
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

View File

@ -20,35 +20,25 @@
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
*/
@ -78,7 +68,7 @@ public boolean hasExtraInfo() {
@Override
public String getExtraInfoToString() {
return isMasked() + ":" + getMaxLength();
return Short.toString(getMaxLength());
}
@Override
@ -93,14 +83,14 @@ public boolean equals(Object other) {
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;
}

View File

@ -19,6 +19,7 @@
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 void testSerialization() {
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();

View File

@ -184,9 +184,9 @@ protected List<MForm> getForms() {
// 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;

View File

@ -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);

View File

@ -49,7 +49,7 @@ public void testInitialization() {
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 @@ private MConnectionForms connector1() {
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);

View File

@ -33,19 +33,31 @@ public enum Enumeration { value1, value2}
@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());
}
}

View File

@ -50,15 +50,15 @@ public void testInitialization() {
*/
@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 void testEquals() {
@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);

View File

@ -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 void testGetInputs() {
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);

View File

@ -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 void testInitialization() {
@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 void testEquals() {
*/
@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 void testValue() {
*/
@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 void testNamedElement() {
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());
}
}

View File

@ -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 void testInitialization() {
@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 void testEquals() {
*/
@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 void testValue() {
*/
@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 void testNamedElement() {
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());
}
}

View File

@ -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());

View File

@ -34,7 +34,7 @@ public void testInitialization() {
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());
}

View File

@ -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 void testInitialization() {
*/
@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

View File

@ -1369,13 +1369,12 @@ private void registerFormInputs(long formId, List<MInput<?>> inputs,
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 void loadForms(List<MForm> connectionForms,
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 void loadForms(List<MForm> connectionForms,
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,