org.alfresco.bm.json
Class JSONObjectCallback
java.lang.Object
org.alfresco.bm.json.JSONObjectCallback
- All Implemented Interfaces:
- AuthenticatedHttpEventProcessor.HttpRequestCallback<org.json.simple.JSONObject>
public class JSONObjectCallback
- extends Object
- implements AuthenticatedHttpEventProcessor.HttpRequestCallback<org.json.simple.JSONObject>
A AuthenticatedHttpEventProcessor.HttpRequestCallback that parses the response body as a JSONObject.
Optionally, the RestConstants#JSON_DATA object can be returned (first child of
root JSON) if the property 'extractData' is set to true.
An exception is thrown when JSON could not be extracted.
- Author:
- Frederik Heremans
|
Method Summary |
org.json.simple.JSONObject |
onCallSuccess(org.apache.commons.httpclient.HttpMethod method)
Called when call was successful. |
boolean |
onError(org.apache.commons.httpclient.HttpMethod method,
Throwable t)
Called when an error occurs when sending the request. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JSONObjectCallback
public JSONObjectCallback(boolean extractData)
- Parameters:
extractData - true, if the 'data' object (RestConstants#JSON_DATA) should be returned
instead of the whole JSON-body.
onCallSuccess
public org.json.simple.JSONObject onCallSuccess(org.apache.commons.httpclient.HttpMethod method)
- Description copied from interface:
AuthenticatedHttpEventProcessor.HttpRequestCallback
- Called when call was successful.
- Specified by:
onCallSuccess in interface AuthenticatedHttpEventProcessor.HttpRequestCallback<org.json.simple.JSONObject>
- Parameters:
method - the method executed which can be used to extract response from.
- Returns:
- any result extracted from the response body.
onError
public boolean onError(org.apache.commons.httpclient.HttpMethod method,
Throwable t)
- Description copied from interface:
AuthenticatedHttpEventProcessor.HttpRequestCallback
- Called when an error occurs when sending the request.
- Specified by:
onError in interface AuthenticatedHttpEventProcessor.HttpRequestCallback<org.json.simple.JSONObject>
- Parameters:
method - the method executedt - optional exception that caused the error
- Returns:
- true, if error is handled. False, if an exception should be thrown.
Copyright © 2012. All Rights Reserved.