lmccay commented on a change in pull request #231: KNOX-2128 - Custom
DataSource and SQL Commands for KnoxShell and KnoxShellTable
URL: https://github.com/apache/knox/pull/231#discussion_r363387749
##########
File path:
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java
##########
@@ -570,6 +580,89 @@ public String toString() {
return String.format(Locale.ROOT, "KnoxSession{base='%s'}", base);
}
+ /**
+ * 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 persistToKnoxShell(String fileName, Map<String,
List<T>> map) {
+ String s = JsonUtils.renderAsJsonString(map);
+ String home = System.getProperty("user.home");
+ try {
+ FileUtils.write(new File(
+ home + File.separator +
+ ".knoxshell" + File.separator + fileName),
+ s, StandardCharsets.UTF_8);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
Review comment:
I can't say it is impossible to have multiple knoxshells reading/writing at
once, so I'll add those protections. Thanks. It should create .knoxshell if it
doesn't already exist.
----------------------------------------------------------------
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