fr.paris.lutece.plugins.directory.utils
Class JSONUtils

java.lang.Object
  extended by fr.paris.lutece.plugins.directory.utils.JSONUtils

public final class JSONUtils
extends Object

JSONUtils


Method Summary
static void buildJsonError(net.sf.json.JSONObject json, String strMessage)
          Builds a json object with the error message.
static net.sf.json.JSONObject buildJsonError(String strMessage)
          Builds a json object with the error message.
static void buildJsonSuccess(String strFieldName, net.sf.json.JSONObject json)
          Build the json form success removing file
static net.sf.json.JSONObject buildJsonSuccess(String strIdEntry, String strSessionId)
          Build the json form success removing file
static net.sf.json.JSONObject getUploadedFileJSON(List<org.apache.commons.fileupload.FileItem> listFileItem)
          Builds a json object for the file item list.
static Map<String,String> getUserInfos(String strJSON)
          Get the user infos.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

buildJsonError

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

Parameters:
strMessage - the error message
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

buildJsonSuccess

public static net.sf.json.JSONObject buildJsonSuccess(String strIdEntry,
                                                      String strSessionId)
Build the json form success removing file

Parameters:
strIdEntry - the id entry
strSessionId - the session id
Returns:
the json object

buildJsonSuccess

public static void buildJsonSuccess(String strFieldName,
                                    net.sf.json.JSONObject json)
Build the json form success removing file

Parameters:
strFieldName - the field name (WARNING : it is not the id entry, it is 'directory_', ex: directory_11)
json - the JSON object

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

getUserInfos

public static Map<String,String> getUserInfos(String strJSON)
Get the user infos.
The json must be written with the following format :

{ "user-attributes": [
{ "user-attribute-key": "user.name.family", "user-attribute-value": "FAMILYNAME" },
{ "user-attribute-key": "user.home-info.online.email", "user-attribute-value": "EMAIL@EMAIL.EMAIL"}
] }

Parameters:
strJSON - the json
Returns:
the user attributes


Copyright © 2013 Mairie de Paris. All Rights Reserved.