public class ResponseStatusConverter extends Object
Helper class to easily convert different handler status types to a common one.
ResponseStatus
,
KeyValueStatus
Modifier and Type | Field and Description |
---|---|
static int |
HTTP_ACCEPTED |
static int |
HTTP_BAD_REQUEST |
static int |
HTTP_CREATED |
static int |
HTTP_INTERNAL_ERROR |
static int |
HTTP_NOT_FOUND |
static int |
HTTP_OK |
static int |
HTTP_UNAUTHORIZED |
Constructor and Description |
---|
ResponseStatusConverter() |
Modifier and Type | Method and Description |
---|---|
static ResponseStatusDetails |
detailsFromBinary(byte dataType,
ByteBuf content) |
static ResponseStatus |
fromBinary(short code)
Convert the binary protocol status in a typesafe enum that can be acted upon later.
|
static ResponseStatus |
fromHttp(int code)
Convert the http protocol status in a typesafe enum that can be acted upon later.
|
static ErrorMap |
getBinaryErrorMap()
Get the current error map used by the response status converter
|
static ErrorMap.ErrorCode |
readErrorCodeFromErrorMap(short code)
Get the error code from Key Value error map
|
static void |
updateBinaryErrorMap(ErrorMap map)
Updates the current error map in use for all uses of the response status converter.
|
public static final int HTTP_OK
public static final int HTTP_CREATED
public static final int HTTP_ACCEPTED
public static final int HTTP_BAD_REQUEST
public static final int HTTP_UNAUTHORIZED
public static final int HTTP_NOT_FOUND
public static final int HTTP_INTERNAL_ERROR
public static ResponseStatus fromBinary(short code)
Convert the binary protocol status in a typesafe enum that can be acted upon later.
code
- the status to convert.public static ErrorMap.ErrorCode readErrorCodeFromErrorMap(short code)
Get the error code from Key Value error map
code
- the status to convert.public static ResponseStatus fromHttp(int code)
Convert the http protocol status in a typesafe enum that can be acted upon later.
code
- the status to convert.public static ResponseStatusDetails detailsFromBinary(byte dataType, ByteBuf content)
public static void updateBinaryErrorMap(ErrorMap map)
Updates the current error map in use for all uses of the response status converter.
If the provided one is older than the one stored, this update operation will be ignored.
map
- the map in use, it always uses the latest one.public static ErrorMap getBinaryErrorMap()
Get the current error map used by the response status converter
Copyright © 2018 Couchbase, Inc.. All rights reserved.