com.tinkerpop.rexster.extension
Class ExtensionResponse

java.lang.Object
  extended by com.tinkerpop.rexster.extension.ExtensionResponse

public class ExtensionResponse
extends Object

Wraps the Jersey response object with some simple response builder methods.


Constructor Summary
ExtensionResponse(javax.ws.rs.core.Response response)
          Create a non-error ExtensionResponse object.
ExtensionResponse(javax.ws.rs.core.Response response, boolean errorResponse)
          Create an ExtensionResponse object.
 
Method Summary
static ExtensionResponse availableOptions(String... methods)
           
static ExtensionResponse error(Exception source)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(Exception source, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(Exception source, String appendKey, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message, Exception source)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message, Exception source, int statusCode)
          Generates standard Rexster JSON error with a specified server error response code.
static ExtensionResponse error(String message, Exception source, int statusCode, String appendKey, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with a specified server error response code.
static ExtensionResponse error(String message, Exception source, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message, Exception source, String appendKey, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
static ExtensionResponse error(String message, String appendKey, org.codehaus.jettison.json.JSONObject appendJson)
          Generates standard Rexster JSON error with an internal server error response code.
 javax.ws.rs.core.Response getJerseyResponse()
           
 boolean isErrorResponse()
           
static ExtensionResponse noContent()
          Generates a response with no content and matching status code.
static ExtensionResponse ok(org.codehaus.jettison.json.JSONObject result)
          Generates an response with an OK status code.
static ExtensionResponse ok(Map result)
          Generates an response with an OK status code.
static ExtensionResponse override(javax.ws.rs.core.Response response)
          Override the builder and literally construct the Jersey response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionResponse

public ExtensionResponse(javax.ws.rs.core.Response response)
Create a non-error ExtensionResponse object.


ExtensionResponse

public ExtensionResponse(javax.ws.rs.core.Response response,
                         boolean errorResponse)
Create an ExtensionResponse object.

Method Detail

override

public static ExtensionResponse override(javax.ws.rs.core.Response response)
Override the builder and literally construct the Jersey response.

Rexster will add its standard headers and override any provided in the response. It is recommended to use the @see error methods as opposed to override if the intention is to return an error on the response. The override methods will not throw a WebApplicationException or do any standard Rexster server side logging.


error

public static ExtensionResponse error(String message)
Generates standard Rexster JSON error with an internal server error response code.


error

public static ExtensionResponse error(String message,
                                      String appendKey,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.


error

public static ExtensionResponse error(String message,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.

Parameters:
appendJson - Additional JSON to push into the response. The root of the key values from this object will be merged into the root of the resulting JSON.

error

public static ExtensionResponse error(Exception source)
Generates standard Rexster JSON error with an internal server error response code.


error

public static ExtensionResponse error(Exception source,
                                      String appendKey,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.


error

public static ExtensionResponse error(Exception source,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.

Parameters:
appendJson - Additional JSON to push into the response. The root of the key values from this object will be merged into the root of the resulting JSON.

error

public static ExtensionResponse error(String message,
                                      Exception source)
Generates standard Rexster JSON error with an internal server error response code.


error

public static ExtensionResponse error(String message,
                                      Exception source,
                                      String appendKey,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.

Parameters:
appendKey - This parameter is only relevant if the appendJson parameter is passed. If this value is not null or non-empty the value of appendJson will be assigned to this key value in the response object. If the key is null or empty the appendJson parameter will be written at the root of the response object.
appendJson - Additional JSON to push into the response.

error

public static ExtensionResponse error(String message,
                                      Exception source,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with an internal server error response code.

Parameters:
appendJson - Additional JSON to push into the response. The root of the key values from this object will be merged into the root of the resulting JSON.

error

public static ExtensionResponse error(String message,
                                      Exception source,
                                      int statusCode)
Generates standard Rexster JSON error with a specified server error response code.

The status code is not validated, so throw the right code.


error

public static ExtensionResponse error(String message,
                                      Exception source,
                                      int statusCode,
                                      String appendKey,
                                      org.codehaus.jettison.json.JSONObject appendJson)
Generates standard Rexster JSON error with a specified server error response code.

The status code is not validated, so throw the right code.

Parameters:
appendKey - This parameter is only relevant if the appendJson parameter is passed. If this value is not null or non-empty the value of appendJson will be assigned to this key value in the response object. If the key is null or empty the appendJson parameter will be written at the root of the response object.
appendJson - Additional JSON to push into the response.

noContent

public static ExtensionResponse noContent()
Generates a response with no content and matching status code.


ok

public static ExtensionResponse ok(Map result)
Generates an response with an OK status code. Accepts a HashMap as the response value. It is converted to JSON.


availableOptions

public static ExtensionResponse availableOptions(String... methods)

ok

public static ExtensionResponse ok(org.codehaus.jettison.json.JSONObject result)
Generates an response with an OK status code.


getJerseyResponse

public javax.ws.rs.core.Response getJerseyResponse()

isErrorResponse

public boolean isErrorResponse()


Copyright © 2009-2012. All Rights Reserved.