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 java.lang.Object

JSONUtils


Method Summary
static void buildJsonError(net.sf.json.JSONObject json, java.lang.String strMessage)
          Builds a json object with the error message.
static net.sf.json.JSONObject buildJsonError(java.lang.String strMessage)
          Builds a json object with the error message.
static void buildJsonSuccess(java.lang.String strFieldName, net.sf.json.JSONObject json)
          Build the json form success removing file
static net.sf.json.JSONObject buildJsonSuccess(java.lang.String strIdEntry, java.lang.String strSessionId)
          Build the json form success removing file
static net.sf.json.JSONObject getUploadedFileJSON(java.util.List<org.apache.commons.fileupload.FileItem> listFileItem)
          Builds a json object for the file item list.
static java.util.Map<java.lang.String,java.lang.String> getUserInfos(java.lang.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(java.lang.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,
                                  java.lang.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(java.lang.String strIdEntry,
                                                      java.lang.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(java.lang.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)
strSessionId - the session id
json - the json

getUploadedFileJSON

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

Parameters:
listFileItem - the fileItem list
Returns:
the json

getUserInfos

public static java.util.Map<java.lang.String,java.lang.String> getUserInfos(java.lang.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 © 2012 Mairie de Paris. All Rights Reserved.