SQOOP-625: Enforce checking advertised maximal size for MStringInput
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/58e6bf62 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/58e6bf62 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/58e6bf62 Branch: refs/heads/sqoop2 Commit: 58e6bf627e93175cc52f4c1db58a6c37e0b338f2 Parents: 015e13c Author: Bilung Lee <[email protected]> Authored: Fri Oct 12 16:05:08 2012 -0700 Committer: Bilung Lee <[email protected]> Committed: Fri Oct 12 16:05:08 2012 -0700 ---------------------------------------------------------------------- .../org/apache/sqoop/client/utils/FormFiller.java | 20 +++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/58e6bf62/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 df39291..0dcfdf7 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 @@ -217,6 +217,16 @@ public final class FormFiller { return true; } + /** + * Load string input from the user. + * + * @param io Shell's IO object + * @param input Input that we should load in + * @param reader Associated console reader + * @param bundle Resource bundle for this input + * @return + * @throws IOException + */ public static boolean fillInputString(IO io, MStringInput input, ConsoleReader reader, @@ -239,11 +249,21 @@ public final class FormFiller { } if (userTyped == null) { + // Propagate end of loading process return false; } else if (userTyped.isEmpty()) { + // Empty input in case that nothing was given input.setEmpty(); } else { + // Set value that user has entered input.setValue(userTyped); + + // Check that it did not exceeds maximal allowance for given input + if(userTyped.length() > input.getMaxLength()) { + errorMessage(io, "Size of input exceeds allowance for this input" + + " field. Maximal allowed size is " + input.getMaxLength()); + return fillInputString(io, input, reader, bundle); + } } return true;
