From df096dd2c2ce0bb78b25cba185f8fca8111c4acc Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 12 Apr 2019 15:23:38 -0400 Subject: [PATCH] LP1824391 Hatch set (file write) 'bare' option Adds a "bare" option to the hatch "set" command indicating to Hatch the string content should be written as-is instead of encoded as JSON first. This essentially gives Hatch a text/plain print-to-file option. Signed-off-by: Bill Erickson Signed-off-by: Jason Boyer --- src/org/evergreen_ils/hatch/RequestHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/evergreen_ils/hatch/RequestHandler.java b/src/org/evergreen_ils/hatch/RequestHandler.java index 9fcd24d..fa89dfa 100644 --- a/src/org/evergreen_ils/hatch/RequestHandler.java +++ b/src/org/evergreen_ils/hatch/RequestHandler.java @@ -155,8 +155,14 @@ public class RequestHandler extends Thread { case "set" : key = request.getString("key"); - // JSON-ify the thing stored under "content" - String json = JSONObject.valueToString(request.get("content")); + String json; + if (request.optBoolean("bare", false)) { + // Bare strings are stored as-is, no JSON. + json = request.getString("content"); + } else { + // JSON-ify the thing stored under "content" + json = JSONObject.valueToString(request.get("content")); + } if (!fileIO.set(key, json)) { response.put("status", 500); -- 2.11.0