|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.smila.http.server.json.JsonHttpUtils
public final class JsonHttpUtils
Utilities for processing data received via an HTTP interface.
Field Summary | |
---|---|
static IpcSerializationUtils |
SERIALIZATION_UTILS
for record<->BON/JSON serialization. |
Method Summary | |
---|---|
static Record |
convertGetRequest(HttpExchange he)
Converts a HTTP GET request into a query record by setting all parameters as attributes and literal values. |
static Record |
convertPostRequest(HttpExchange he)
Converts a HTTP POST request into a query record by converting the posted JSON stream into a record. |
static Record |
convertRequest(HttpExchange exchange)
Create an input record from a request by either parse JSON from the request body, or by converting URI parameters. |
static int |
getErrorStatus(java.lang.Throwable ex)
Return a status code for an exception. |
static ObjectMapper |
getObjectMapper()
Creates an ObjectMapper instance with disabled JsonGenerator.Feature#AUTO_CLOSE_TARGET and default
SMILA date/time format. |
static boolean |
hasRequestContent(HttpExchange exchange)
check if the request contains content in the body. |
static boolean |
prepareResponseHeader(HttpExchange exchange,
int statusCode,
boolean hasResponseBody)
set basic HTTP response headers. |
static void |
writeErrorDetails(HttpExchange exchange,
java.lang.Throwable error)
write exception in JSON format to response stream. |
static void |
writeResultObject(java.io.OutputStream responseStream,
java.lang.Object resultObject)
write result object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final IpcSerializationUtils SERIALIZATION_UTILS
Method Detail |
---|
public static Record convertRequest(HttpExchange exchange) throws IpcException
exchange
- the HttpExchange object
IpcException
- if any error occurs during conversionpublic static Record convertGetRequest(HttpExchange he) throws IpcException
he
- the HttpExchange object
IpcException
- if any error occurs during conversionpublic static Record convertPostRequest(HttpExchange he) throws IpcException
he
- the HttpExchange object
IpcException
- if any error occurs during conversion from JSON to Recordpublic static boolean hasRequestContent(HttpExchange exchange)
exchange
- HTTP exchange
public static boolean prepareResponseHeader(HttpExchange exchange, int statusCode, boolean hasResponseBody)
exchange
- HTTP exchangestatusCode
- HTTP response status code.hasResponseBody
- true if the response will have data in body, else false.
public static void writeResultObject(java.io.OutputStream responseStream, java.lang.Object resultObject) throws java.io.IOException
Record
results. Subclasses that produce
different result types must override this method.
responseStream
- response streamresultObject
- result object.
java.io.IOException
- error writing resultpublic static int getErrorStatus(java.lang.Throwable ex)
ex
- an exception
public static void writeErrorDetails(HttpExchange exchange, java.lang.Throwable error) throws java.io.IOException
java.io.IOException
public static ObjectMapper getObjectMapper()
ObjectMapper
instance with disabled JsonGenerator.Feature#AUTO_CLOSE_TARGET
and default
SMILA date/time format.
ObjectMapper
|
SMILA (incubation) API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |