public class GXInboundResponse extends Object
| Constructor and Description |
|---|
GXInboundResponse(HttpURLConnection connection) |
GXInboundResponse(javax.ws.rs.core.Response source)
Builds a new inbound response.
|
GXInboundResponse(javax.ws.rs.core.Response response,
javax.ws.rs.core.MediaType[] expectedMediaTypes)
Builds a new inbound response.
|
| Modifier and Type | Method and Description |
|---|---|
ErrorCode |
getErrorCode()
Gets the
ErrorCode inside the entity. |
<E extends Exception> |
getException()
Gets the
Exception inside the entity. |
Map<String,List<String>> |
getHeaderFields()
Returns an unmodifiable Map of the header fields.
|
int |
getHTTPCode()
Gets the status code from the HTTP response message.
|
InputStream |
getInputStream() |
String |
getMessage()
Gets the message in the response
|
javax.ws.rs.core.Response |
getSource() |
byte[] |
getStreamedContent()
Returns the content of the response as byte array.
|
String |
getStreamedContentAsString()
Gets the streamed content as a string, if possible.
|
boolean |
hasBAD_REQUESTCode()
Checks if the response has a BAD_REQUEST (400) HTTP status.
|
boolean |
hasCREATEDCode()
Checks if the response has a CREATED (201) HTTP status.
|
boolean |
hasErrorCode()
Checks if there is an
ErrorCode in the entity. |
boolean |
hasException()
Checks if there is an
Exception in the entity. |
boolean |
hasGXError()
Checks if the response was generated as a
GXOutboundErrorResponse
. |
boolean |
hasNOT_ACCEPTABLECode()
Checks if the response has a NOT_ACCEPTABLE (406) HTTP status.
|
boolean |
hasOKCode()
Checks if the response has a OK (200) HTTP status.
|
boolean |
isErrorResponse()
Checks if the response is in the range 4xx - 5xx
.
|
boolean |
isSuccessResponse()
Checks if the response is in the range 2xx
.
|
<T> T |
tryConvertStreamedContentFromJson(Class<T> raw)
Tries to convert the content from its Json serialization, if possible.
|
public GXInboundResponse(javax.ws.rs.core.Response source)
source - the original responsepublic GXInboundResponse(HttpURLConnection connection) throws IOException
connection - the connection from which to parse the informationIOExceptionpublic GXInboundResponse(javax.ws.rs.core.Response response,
javax.ws.rs.core.MediaType[] expectedMediaTypes)
source - the original responseexpectedMediaTypes - the expected media type(s) in the responsepublic boolean hasException()
Exception in the entity.public boolean isErrorResponse()
public boolean isSuccessResponse()
public boolean hasGXError()
GXOutboundErrorResponse
.public <E extends Exception> E getException() throws ClassNotFoundException
Exception inside the entity.ClassNotFoundException - if the exception's class is not available on the classpathpublic boolean hasErrorCode()
ErrorCode in the entity.public ErrorCode getErrorCode()
ErrorCode inside the entity.public String getMessage()
public String getStreamedContentAsString() throws IOException
IOException - if unable to read the contentpublic InputStream getInputStream() throws IOException
IOExceptionpublic byte[] getStreamedContent()
throws IOException
IOException - if unable to read the contentpublic <T> T tryConvertStreamedContentFromJson(Class<T> raw) throws Exception
T - the type of the desired objectException - if the deserialization failspublic int getHTTPCode()
public boolean hasCREATEDCode()
public boolean hasOKCode()
public boolean hasNOT_ACCEPTABLECode()
public boolean hasBAD_REQUESTCode()
public Map<String,List<String>> getHeaderFields()
public javax.ws.rs.core.Response getSource()
throws UnsupportedOperationException
UnsupportedOperationException - if not availableCopyright © 2019. All Rights Reserved.