lmccay commented on a change in pull request #296: KNOX-2240 - KnoxShell Custom 
Command for WEBHDFS Use
URL: https://github.com/apache/knox/pull/296#discussion_r396696175
 
 

 ##########
 File path: 
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
 ##########
 @@ -705,6 +734,15 @@ private static String readFileToString(File file) throws 
IOException {
     return obj;
   }
 
+  public static <T> Map<String, T> getMapFromJsonString(String json) throws 
IOException {
+    Map<String, T> obj;
+    JsonFactory factory = new JsonFactory();
+    ObjectMapper mapper = new ObjectMapper(factory);
+    TypeReference<Map<String, T>> typeRef = new TypeReference<Map<String, 
T>>() {};
+    obj = mapper.readValue(json, typeRef);
+    return obj;
+  }
+
 
 Review comment:
   Okay - the reason that I did that was to bubble up the exception in the 
groovysh and scripting environments. Rather than swallowing it and logging we 
allow it to be handled directly or at least communicated via stacktrace in the 
console. This is not acceptable for other uses of that util method in the 
gateway. At somepoint, a gateway-shell specific JSONUtils may be required. We 
can visit that later.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to