You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2020/01/21 14:38:33 UTC

[GitHub] [knox] lmccay commented on a change in pull request #241: KNOX-1742 - Simple SQL Client in KnoxShell for access to JDBC sources

lmccay commented on a change in pull request #241: KNOX-1742 - Simple SQL Client in KnoxShell for access to JDBC sources
URL: https://github.com/apache/knox/pull/241#discussion_r369037891
 
 

 ##########
 File path: gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
 ##########
 @@ -593,21 +594,42 @@ public String toString() {
     String s = JsonUtils.renderAsJsonString(map);
     String home = System.getProperty("user.home");
     try {
-      write(new File(home + File.separator + ".knoxshell" + File.separator + fileName), s);
+      write(new File(
+          home + File.separator + ".knoxshell" + File.separator + fileName),
+          s, StandardCharsets.UTF_8);
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 
-  private static void write(File file, String s) throws IOException {
+  /**
+   * Persist provided Map to a file within the {user.home}/.knoxshell directory
+   * @param <T>
+   * @param fileName of persisted file
+   * @param map to persist
+   */
+  public static <T> void persistDataSourcesToKnoxShell(String fileName, Map<String, T> map) {
+    String s = JsonUtils.renderAsJsonString(map);
+    String home = System.getProperty("user.home");
+    try {
+      write(new File(
+          home + File.separator +
+          ".knoxshell" + File.separator + fileName),
+          s, StandardCharsets.UTF_8);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+  }
+
+  private static void write(File file, String s, Charset utf8) throws IOException {
 
 Review comment:
   Ahhh - had a merge conflict with that and thought someone else must have added it. I see now that you removed for the javadoc error patch.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services