From: Bill Erickson Date: Fri, 12 Apr 2019 19:23:38 +0000 (-0400) Subject: LP1824391 Hatch set (file write) 'bare' option X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8294721f2bd8e462e97c3a8e2dbaed5fba3c8537;p=working%2FHatch.git 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 --- diff --git a/src/org/evergreen_ils/hatch/RequestHandler.java b/src/org/evergreen_ils/hatch/RequestHandler.java index 9fcd24de39..fa89dfa19f 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);