SQOOP-625 Enforce checking advertised maximal size for MStringInput (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/5f01b032 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/5f01b032 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/5f01b032 Branch: refs/heads/sqoop2 Commit: 5f01b03239ee989119a462140c6dbf059562cf57 Parents: 015e13c Author: Bilung Lee <[email protected]> Authored: Fri Oct 12 16:34:37 2012 -0700 Committer: Bilung Lee <[email protected]> Committed: Fri Oct 12 16:34:37 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/5f01b032/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;
