From 2a0b8d46a81084388998cc2c86cc9a10b1edc5d5 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 27 Apr 2016 13:37:18 +0100 Subject: [PATCH] RM-3276 (Edit and Application of Marks to a Single User) --- .../org/alfresco/util/WebScriptUtils.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/util/WebScriptUtils.java b/rm-community/rm-community-repo/source/java/org/alfresco/util/WebScriptUtils.java index 8e67875520..f11a9016a4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/util/WebScriptUtils.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/util/WebScriptUtils.java @@ -327,6 +327,30 @@ public final class WebScriptUtils return jsonObject; } + /** + * Creates a json array from the given {@link String} + * + * @param json The json array as {@link String} + * @return The json array created from the given {@link String} + */ + public static JSONArray createJSONArray(String json) + { + mandatory("json", json); + + JSONArray jsonArray; + + try + { + jsonArray = new JSONArray(json); + } + catch (JSONException error) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Cannot create a json array from the given string '" + json + "'.", error); + } + + return jsonArray; + } + /** * Gets the {@link JSONArray} value of a given key from a json object *