Review Board 1.7.22


SQOOP-774 Sqoop2: exception is thrown when creating a connection object if connectionString starts with an empty space

Review Request #8621 - Created Dec. 16, 2012 and submitted

Jarek Cecho
SQOOP-774
Reviewers
Sqoop
sqoop-sqoop2
The problem was that we did not updated Validation part when we were migrating forms to "object" structures.
Unit tests are passing and I've done test on real cluster.
common/src/main/java/org/apache/sqoop/json/ValidationBean.java
Revision 1ad8186c471264d5fd92367bc8a680125213a5c4 New Change
[20] 91 lines
[+20] [+] public JSONObject extract() {
92
    JSONObject object = new JSONObject();
92
    JSONObject object = new JSONObject();
93

    
   
93

   
94
    object.put(STATUS, validation.getStatus().name());
94
    object.put(STATUS, validation.getStatus().name());
95

    
   
95

   
96
    JSONObject jsonMessages = new JSONObject();
96
    JSONObject jsonMessages = new JSONObject();
97
    Map<String, Validation.Message> messages = validation.getMessages();
97
    Map<Validation.FormInput, Validation.Message> messages = validation.getMessages();
98

    
   
98

   
99
    for(Map.Entry<String, Validation.Message> entry : messages.entrySet()) {
99
    for(Map.Entry<Validation.FormInput, Validation.Message> entry : messages.entrySet()) {
100
      JSONObject jsonEntry = new JSONObject();
100
      JSONObject jsonEntry = new JSONObject();
101
      jsonEntry.put(STATUS, entry.getValue().getStatus().name());
101
      jsonEntry.put(STATUS, entry.getValue().getStatus().name());
102
      jsonEntry.put(MESSAGE, entry.getValue().getMessage());
102
      jsonEntry.put(MESSAGE, entry.getValue().getMessage());
103
      jsonMessages.put(entry.getKey(), jsonEntry);
103
      jsonMessages.put(entry.getKey(), jsonEntry);
104
    }
104
    }
[+20] [20] 14 lines
[+20] [+] public void restore(JSONObject jsonObject) {
119
      (JSONObject)jsonObject.get(FRAMEWORK));
119
      (JSONObject)jsonObject.get(FRAMEWORK));
120
  }
120
  }
121

    
   
121

   
122
  public Validation restoreValidation(JSONObject jsonObject) {
122
  public Validation restoreValidation(JSONObject jsonObject) {
123
    JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
123
    JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
124
    Map<String, Validation.Message> messages
124
    Map<Validation.FormInput, Validation.Message> messages
125
      = new HashMap<String, Validation.Message>();
125
      = new HashMap<Validation.FormInput, Validation.Message>();
126

    
   
126

   
127
    for(Object key : jsonMessages.keySet()) {
127
    for(Object key : jsonMessages.keySet()) {
128
      JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
128
      JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
129

    
   
129

   
130
      Status status = Status.valueOf((String) jsonMessage.get(STATUS));
130
      Status status = Status.valueOf((String) jsonMessage.get(STATUS));
131
      String stringMessage = (String) jsonMessage.get(MESSAGE);
131
      String stringMessage = (String) jsonMessage.get(MESSAGE);
132

    
   
132

   
133
      Validation.Message message
133
      Validation.Message message
134
        = new Validation.Message(status, stringMessage);
134
        = new Validation.Message(status, stringMessage);
135

    
   
135

   
136
      messages.put((String)key, message);
136
      messages.put(new Validation.FormInput((String)key), message);
137
    }
137
    }
138

    
   
138

   
139
    Status status = Status.valueOf((String) jsonObject.get(STATUS));
139
    Status status = Status.valueOf((String) jsonObject.get(STATUS));
140

    
   
140

   
141
    return new Validation(status,messages);
141
    return new Validation(status, messages);
142
  }
142
  }
143
}
143
}
common/src/main/java/org/apache/sqoop/model/FormUtils.java
Revision 05941f6fc450d3aa6c83595eaf84363c62f7d51b New Change
 
common/src/main/java/org/apache/sqoop/validation/Validation.java
Revision e4398b66eae6a844b11dc93924c879ecf59a3159 New Change
 
common/src/main/java/org/apache/sqoop/validation/ValidationError.java
Revision 0c7e0edcab49a81cc2015fc4f75e1f992cbe43a8 New Change
 
common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
Revision bdef7e81beaae2d440617cb5dd471eeb1454d7db New Change
 
common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
Revision f17155f20cb15882da9cf70c24fb86e2cf5f65ad New Change
 
connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
Revision 52ad2dcb67aefba816cf3fa8a7cd26dbda6dfd94 New Change
 
  1. common/src/main/java/org/apache/sqoop/json/ValidationBean.java: Loading...
  2. common/src/main/java/org/apache/sqoop/model/FormUtils.java: Loading...
  3. common/src/main/java/org/apache/sqoop/validation/Validation.java: Loading...
  4. common/src/main/java/org/apache/sqoop/validation/ValidationError.java: Loading...
  5. common/src/test/java/org/apache/sqoop/json/TestValidationBean.java: Loading...
  6. common/src/test/java/org/apache/sqoop/model/TestFormUtils.java: Loading...
  7. connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java: Loading...