Groovy Documentation

com.adaptc.mws.plugins
[Java] Class MoabRestResponse

java.lang.Object
  com.adaptc.mws.plugins.MoabRestResponse

public class MoabRestResponse
extends Object

This class is used in the IMoabRestService to represent a response from MWS. It contains fields for the response, data, and metadata methods about the response.

Authors:
bsaville


Field Summary
private net.sf.json.JSON data

private org.springframework.mock.web.MockHttpServletResponse response

private boolean success

 
Constructor Summary
MoabRestResponse(org.springframework.mock.web.MockHttpServletResponse response, Object data, boolean success)

Constructs a new response from MWS.

 
Method Summary
private Object convert(net.sf.json.JSON json)

Utility method for converting data from a net.sf.json.JSON instance.

private Map convert(net.sf.json.JSONObject jsonObject)

Recursive utility method for converting data from a net.sf.json.JSON instance.

private List convert(net.sf.json.JSONArray jsonArray)

Recursive utility method for converting data from a net.sf.json.JSON instance.

private Object convert(net.sf.json.JSONNull jsonNull)

Recursive utility method for converting data from a net.sf.json.JSON instance.

Object getConvertedData()

Returns data converted to an actual Map or List (or null) instead of a net.sf.json.JSON instance.

net.sf.json.JSON getData()

The parsed JSON body data from the response.

org.springframework.mock.web.MockHttpServletResponse getResponse()

The actual HTTP response object.

int getStatus()

The status code of the HTTP response (i.e. 200, 404, 400) in a convenience method.

boolean hasError()

Returns true if an error was encountered during the request.

boolean isSuccess()

Returns if the request was successful or not.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

data

private final net.sf.json.JSON data


response

private final org.springframework.mock.web.MockHttpServletResponse response


success

private final boolean success


 
Constructor Detail

MoabRestResponse

public MoabRestResponse(org.springframework.mock.web.MockHttpServletResponse response, Object data, boolean success)
Constructs a new response from MWS.
throws:
IllegalArgumentException If the data param is not a Map or JSON object
Parameters:
response - The HTTP servlet response
data - The data as a Map or JSON, will be converted correctly in either case
success - Whether or not the response is a success


 
Method Detail

convert

private Object convert(net.sf.json.JSON json)
Utility method for converting data from a net.sf.json.JSON instance.
Parameters:
json
Returns:


convert

private Map convert(net.sf.json.JSONObject jsonObject)
Recursive utility method for converting data from a net.sf.json.JSON instance.
Parameters:
jsonObject
Returns:


convert

private List convert(net.sf.json.JSONArray jsonArray)
Recursive utility method for converting data from a net.sf.json.JSON instance.
Parameters:
jsonArray
Returns:


convert

private Object convert(net.sf.json.JSONNull jsonNull)
Recursive utility method for converting data from a net.sf.json.JSON instance.
Parameters:
jsonNull
Returns:


getConvertedData

public Object getConvertedData()
Returns data converted to an actual Map or List (or null) instead of a net.sf.json.JSON instance.
Returns:
The equivalent of getData() converted to a simple Map or List


getData

public net.sf.json.JSON getData()
The parsed JSON body data from the response.
Returns:
The parsed JSON body


getResponse

public org.springframework.mock.web.MockHttpServletResponse getResponse()
The actual HTTP response object. This may be used to return any pertinent information from the response including headers and content type information.
Returns:
The HTTP response


getStatus

public int getStatus()
The status code of the HTTP response (i.e. 200, 404, 400) in a convenience method. Equivalent to calling getResponse().getStatus().
Returns:
The HTTP response code


hasError

public boolean hasError()
Returns true if an error was encountered during the request.
Returns:
True if the HTTP code is 400 or greater, false otherwise


isSuccess

public boolean isSuccess()
Returns if the request was successful or not.
Returns:
True if a 2xx or 3xx HTTP code was encountered or false otherwise


 

Groovy Documentation