pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.util.adminui
Class JSONCommunicationUtils

java.lang.Object
  extended by org.torweg.pulse.util.adminui.JSONCommunicationUtils

public final class JSONCommunicationUtils
extends java.lang.Object

provides different types of json-error- and -success-messages to be used for the communication within the admin-ui.

Version:
$Revision: 1406 $
Author:
Daniel Dietz

Method Summary
static void jsonErrorMessage(ServiceRequest request)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonErrorMessage(ServiceRequest request, net.sf.json.JSONObject error)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonErrorMessage(ServiceRequest request, java.lang.String error)
          adds a JSONOutputEvent to the current ServiceRequest, which is a HashMap<String, Object> containing "data.status = false" and "errorTopic => errorTopic".
static void jsonSuccessMessage(ServiceRequest request)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonSuccessMessage(ServiceRequest request, net.sf.json.JSONObject jsonObject)
          adds a JSONOutputEvent that indicates success to the current ServiceRequest.
static void jsonSuccessMessage(ServiceRequest request, java.lang.String arrayName, net.sf.json.JSONArray jsonArray)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonSuccessMessage(ServiceRequest request, java.lang.String arrayName, net.sf.json.JSONArray jsonArray, long total)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonSuccessMessage(ServiceRequest request, java.lang.String objectName, net.sf.json.JSONObject jsonObject)
          adds a JSONOutputEvent to the current ServiceRequest.
static void jsonSuccessMessage(ServiceRequest request, java.lang.String parameterName, java.lang.Object message)
          adds a JSONOutputEvent to the current ServiceRequest, which is a HashMap<String, Object> containing "data.status = true" and "parameterName => message".
static void jsonSuccessParameterListMessage(ServiceRequest request, java.util.List<Parameter> parameterList)
          builds a JSON-response for a list of Parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

jsonErrorMessage

public static void jsonErrorMessage(ServiceRequest request)
adds a JSONOutputEvent to the current ServiceRequest.

responds with Object: { status: false

Parameters:
request - the current ServiceRequest

jsonErrorMessage

public static void jsonErrorMessage(ServiceRequest request,
                                    java.lang.String error)
adds a JSONOutputEvent to the current ServiceRequest, which is a HashMap&lt;String, Object&gt; containing "data.status = false" and "errorTopic => errorTopic".

Parameters:
request - the current ServiceRequest
error - the error

jsonErrorMessage

public static void jsonErrorMessage(ServiceRequest request,
                                    net.sf.json.JSONObject error)
adds a JSONOutputEvent to the current ServiceRequest.

if (error != null) responds with Object: { status: false, error: { JSONObject error } }

else if (error == null) responds with Object: { status: false

Parameters:
request - the current ServiceRequest
error - the error

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request)
adds a JSONOutputEvent to the current ServiceRequest.

responds with Object: { status: true

Parameters:
request - the current ServiceRequest

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request,
                                      net.sf.json.JSONObject jsonObject)
adds a JSONOutputEvent that indicates success to the current ServiceRequest.

Sets status=true for the passed JSONObject.

Parameters:
request - the current ServiceRequest
jsonObject - the JSONObjects

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request,
                                      java.lang.String objectName,
                                      net.sf.json.JSONObject jsonObject)
adds a JSONOutputEvent to the current ServiceRequest.

if (objectName != null) responds with Object: { status: true , objectName: { JSONObject jsonObject } }

else if (objectName == null) responds with Object: { status: true

Parameters:
request - the current ServiceRequest *
objectName - the JSONObject parameter name
jsonObject - the JSONObjects

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request,
                                      java.lang.String arrayName,
                                      net.sf.json.JSONArray jsonArray)
adds a JSONOutputEvent to the current ServiceRequest.

if (arrayName != null) responds with Object: { status: true, arrayName: { JSONArray jsonArray } }

else if (arrayName == null) responds with Object: { status: true

Parameters:
request - the current ServiceRequest
arrayName - the JSONArray name
jsonArray - the JSONArrays

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request,
                                      java.lang.String arrayName,
                                      net.sf.json.JSONArray jsonArray,
                                      long total)
adds a JSONOutputEvent to the current ServiceRequest.

if (arrayName != null) responds with Object: { status: true, arrayName: { JSONArray jsonArray } }

else if (arrayName == null) responds with Object: { status: true

Parameters:
request - the current ServiceRequest
arrayName - the JSONArray name
jsonArray - the JSONArrays
total - the total of results to be used (e.g. for paging)

jsonSuccessMessage

public static void jsonSuccessMessage(ServiceRequest request,
                                      java.lang.String parameterName,
                                      java.lang.Object message)
adds a JSONOutputEvent to the current ServiceRequest, which is a HashMap&lt;String, Object&gt; containing "data.status = true" and "parameterName => message".

Parameters:
request - the current ServiceRequest *
parameterName - the message parameter name
message - the message

jsonSuccessParameterListMessage

public static void jsonSuccessParameterListMessage(ServiceRequest request,
                                                   java.util.List<Parameter> parameterList)
builds a JSON-response for a list of Parameters.

Parameters:
request - the current ServiceRequest
parameterList - the parameters