Review Board 1.7.22


SQOOP-625: Enforce checking advertised maximal size for MStringInput

Review Request #7499 - Created Oct. 9, 2012 and submitted

Jarek Cecho
SQOOP-625
Reviewers
Sqoop
sqoop-sqoop2
I've put code that is enforcing maximal size for MStringInput as was configured by connector/framework.
No new unit tests were added. I've manually tested behavior.
client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java
Revision df3929163f30927806a0d6882a7aaeef42e6b6e8 New Change
[20] 214 lines
[+20] [+] private static boolean fillInputInteger(IO io,
215
    }
215
    }
216

    
   
216

   
217
    return true;
217
    return true;
218
  }
218
  }
219

    
   
219

   

    
   
220
  /**

    
   
221
   * Load string input from the user.

    
   
222
   *

    
   
223
   * @param io Shell's IO object

    
   
224
   * @param input Input that we should load in

    
   
225
   * @param reader Associated console reader

    
   
226
   * @param bundle Resource bundle for this input

    
   
227
   * @return

    
   
228
   * @throws IOException

    
   
229
   */
220
  public static boolean fillInputString(IO io,
230
  public static boolean fillInputString(IO io,
221
                                        MStringInput input,
231
                                        MStringInput input,
222
                                        ConsoleReader reader,
232
                                        ConsoleReader reader,
223
                                        ResourceBundle bundle)
233
                                        ResourceBundle bundle)
224
                                        throws IOException {
234
                                        throws IOException {
[+20] [20] 12 lines
[+20] public static boolean fillInputString(IO io,
237
    } else {
247
    } else {
238
      userTyped = reader.readLine();
248
      userTyped = reader.readLine();
239
    }
249
    }
240

    
   
250

   
241
    if (userTyped == null) {
251
    if (userTyped == null) {

    
   
252
      // Propagate end of loading process
242
      return false;
253
      return false;
243
    } else if (userTyped.isEmpty()) {
254
    } else if (userTyped.isEmpty()) {

    
   
255
      // Empty input in case that nothing was given
244
      input.setEmpty();
256
      input.setEmpty();
245
    } else {
257
    } else {

    
   
258
      // Set value that user has entered
246
      input.setValue(userTyped);
259
      input.setValue(userTyped);

    
   
260

   

    
   
261
      // Check that it did not exceeds maximal allowance for given input

    
   
262
      if(userTyped.length() > input.getMaxLength()) {

    
   
263
        errorMessage(io, "Size of input exceeds allowance for this input"

    
   
264
          + " field. Maximal allowed size is " + input.getMaxLength());

    
   
265
        return fillInputString(io, input, reader, bundle);

    
   
266
      }
247
    }
267
    }
248

    
   
268

   
249
    return true;
269
    return true;
250
  }
270
  }
251

    
   
271

   
[+20] [20] 39 lines
  1. client/src/main/java/org/apache/sqoop/client/utils/FormFiller.java: Loading...