Groovy Documentation

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

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

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