fr.paris.lutece.plugins.genericattributes.util
Class JSONUtils

java.lang.Object
  extended by fr.paris.lutece.plugins.genericattributes.util.JSONUtils

public final class JSONUtils
extends Object

Provides json utility methods for forms


Field Summary
static String JSON_KEY_FIELD_NAME
          JSON key for field name
static String JSON_KEY_SUCCESS
          JSON key to describe a success
 
Method Summary
static GenericAttributeError buildFormError(String strJson)
          Builds GenericAttributeError from json string
static String buildJson(GenericAttributeError formError)
          Builds json form GenericAttributeError
static void buildJsonError(net.sf.json.JSONObject json, String strMessage)
          Builds a json object with the error message.
static net.sf.json.JSONObject buildJsonErrorRemovingFile(javax.servlet.http.HttpServletRequest request)
          Builds a json object with the error message.
static Map<Integer,List<Response>> buildListResponses(String strJSON, Locale locale, javax.servlet.http.HttpSession session)
          Builds the responses list - null if JSON_KEY_RESPONSE is missing.
static net.sf.json.JSONObject getUploadedFileJSON(List<org.apache.commons.fileupload.FileItem> listFileItem)
          Builds a json object for the file item list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JSON_KEY_FIELD_NAME

public static final String JSON_KEY_FIELD_NAME
JSON key for field name

See Also:
Constant Field Values

JSON_KEY_SUCCESS

public static final String JSON_KEY_SUCCESS
JSON key to describe a success

See Also:
Constant Field Values
Method Detail

buildListResponses

public static Map<Integer,List<Response>> buildListResponses(String strJSON,
                                                             Locale locale,
                                                             javax.servlet.http.HttpSession session)
Builds the responses list - null if JSON_KEY_RESPONSE is missing.

Parameters:
strJSON - the json
locale - the locale
session - the session
Returns:
the responses list - null if JSON_KEY_RESPONSE is missing

buildJson

public static String buildJson(GenericAttributeError formError)
Builds json form GenericAttributeError

Parameters:
formError - GenericAttributeError
Returns:
json string

buildFormError

public static GenericAttributeError buildFormError(String strJson)
Builds GenericAttributeError from json string

Parameters:
strJson - json string
Returns:
the GenericAttributeError

getUploadedFileJSON

public static net.sf.json.JSONObject getUploadedFileJSON(List<org.apache.commons.fileupload.FileItem> listFileItem)
Builds a json object for the file item list. Key is JSON_KEY_UPLOADED_FILES, value is the array of uploaded file.

Parameters:
listFileItem - the fileItem list
Returns:
the json

buildJsonErrorRemovingFile

public static net.sf.json.JSONObject buildJsonErrorRemovingFile(javax.servlet.http.HttpServletRequest request)
Builds a json object with the error message.

Parameters:
request - the request
Returns:
the json object.

buildJsonError

public static void buildJsonError(net.sf.json.JSONObject json,
                                  String strMessage)
Builds a json object with the error message.

Parameters:
json - the JSON
strMessage - the error message


Copyright © 2014 Mairie de Paris. All Rights Reserved.