public final class WebScriptUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkMandatoryJsonParam(org.json.JSONObject jsonObject,
String paramName)
Checks if the json object contains an entry with the specified parameter name
|
static void |
checkMandatoryJsonParams(org.json.JSONObject jsonObject,
List<String> paramNames)
Checks if the json object contains entries with the specified parameter names
|
static org.json.JSONObject |
createJSONObject(String json)
Creates a json object from the given
String |
static org.json.JSONArray |
getJSONArrayFromJSONObject(org.json.JSONObject jsonObject,
String key)
Gets the
JSONArray value of a given key from a json object |
static Object |
getJSONArrayValue(org.json.JSONArray jsonArray,
int index)
Gets the value of an element from a json array at the given index
|
static org.json.JSONObject |
getRequestContentAsJsonObject(org.springframework.extensions.webscripts.WebScriptRequest req)
Gets the request content as JSON object
|
static String |
getRequestParameterValue(org.springframework.extensions.webscripts.WebScriptRequest req,
String parameter)
Gets the value of a request parameter
|
static String |
getRequestParameterValue(org.springframework.extensions.webscripts.WebScriptRequest req,
String parameter,
boolean checkValue)
Gets the value of a request parameter
|
static String |
getStringValueFromJSONObject(org.json.JSONObject jsonObject,
String key)
Gets the
String value of a given key from a json object |
static String |
getStringValueFromJSONObject(org.json.JSONObject jsonObject,
String key,
boolean checkKey,
boolean checkValue)
Gets the
String value of a given key from a json object |
static Map<String,String> |
getTemplateVars(org.springframework.extensions.webscripts.WebScriptRequest req)
Gets the template variable substitutions map
|
static boolean |
is4xxError(org.springframework.extensions.webscripts.WebScriptException e)
Returns
true if the provided WebScriptException
represents an HTTP 4xx error, else false. |
static boolean |
is5xxError(org.springframework.extensions.webscripts.WebScriptException e)
Returns
true if the provided WebScriptException
represents an HTTP 5xx error, else false. |
static void |
putValuetoJSONObject(org.json.JSONObject jsonObject,
String key,
Object value)
Puts the given key and value to the json object
|
public static Map<String,String> getTemplateVars(org.springframework.extensions.webscripts.WebScriptRequest req)
req - The webscript requestpublic static String getRequestParameterValue(org.springframework.extensions.webscripts.WebScriptRequest req, String parameter)
req - The webscript requestparameter - The request parameterpublic static String getRequestParameterValue(org.springframework.extensions.webscripts.WebScriptRequest req, String parameter, boolean checkValue)
req - The webscript requestparameter - The request parametercheckValue - Determines if the value of the parameter should be checked or notpublic static org.json.JSONObject getRequestContentAsJsonObject(org.springframework.extensions.webscripts.WebScriptRequest req)
req - The webscript requestpublic static void checkMandatoryJsonParam(org.json.JSONObject jsonObject,
String paramName)
jsonObject - The json objectparamName - The parameter name to check forpublic static void checkMandatoryJsonParams(org.json.JSONObject jsonObject,
List<String> paramNames)
jsonObject - The json object.paramNames - The parameter names to check forpublic static String getStringValueFromJSONObject(org.json.JSONObject jsonObject, String key)
String value of a given key from a json objectjsonObject - The json objectkey - The keyString value of the given key from the json objectpublic static String getStringValueFromJSONObject(org.json.JSONObject jsonObject, String key, boolean checkKey, boolean checkValue)
String value of a given key from a json objectjsonObject - The json objectkey - The keycheckKey - Determines if the existence of the key should be checkedcheckValue - Determines if the value should be checked if it is blank or notString value of the given key from the json objectpublic static void putValuetoJSONObject(org.json.JSONObject jsonObject,
String key,
Object value)
jsonObject - The json objectkey - The keyvalue - The valuepublic static Object getJSONArrayValue(org.json.JSONArray jsonArray, int index)
jsonArray - The json arrayindex - The indexpublic static org.json.JSONObject createJSONObject(String json)
Stringpublic static org.json.JSONArray getJSONArrayFromJSONObject(org.json.JSONObject jsonObject,
String key)
JSONArray value of a given key from a json objectjsonObject - The json objectkey - The keyJSONArray value of the given key from the json objectpublic static boolean is4xxError(org.springframework.extensions.webscripts.WebScriptException e)
true if the provided WebScriptException
represents an HTTP 4xx error, else false.public static boolean is5xxError(org.springframework.extensions.webscripts.WebScriptException e)
true if the provided WebScriptException
represents an HTTP 5xx error, else false.Copyright © 2005–2016 Alfresco Software. All rights reserved.