|
SMILA 1.0 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 class JsonHttpUtils
Utilities for processing data received via an HTTP interface.
Field Summary | |
---|---|
static IpcAnyWriter |
IPC_ANY_WRITER
for Any -> BON/JSON serialization. |
static IpcRecordReader |
IPC_RECORD_READER
for BON/JSON -> record parsing. |
static IpcRecordWriter |
IPC_RECORD_WRITER
for record -> BON/JSON serialization. |
Constructor Summary | |
---|---|
JsonHttpUtils()
|
Method Summary | |
---|---|
Record |
convertGetRequest(HttpExchange he)
Converts a HTTP GET request into a query record by setting all parameters as attributes and literal values. |
Record |
convertPostRequest(HttpExchange he)
Converts a HTTP POST request into a query record by converting the posted JSON stream into a record. |
Record |
convertRequest(HttpExchange exchange)
Create an input record from a request by either parse JSON from the request body, or by converting URI parameters. |
int |
getErrorStatus(java.lang.Throwable ex)
Return a status code for an exception. |
ObjectMapper |
getObjectMapper()
Creates an ObjectMapper instance with disabled JsonGenerator.Feature#AUTO_CLOSE_TARGET and default
SMILA date/time format. |
boolean |
hasRequestContent(HttpExchange exchange)
check if the request contains content in the body. |
boolean |
prepareResponseHeader(HttpExchange exchange,
int statusCode,
boolean hasResponseBody)
set basic HTTP response headers. |
void |
writeErrorDetails(HttpExchange exchange,
java.lang.Throwable error)
write exception in JSON format to response stream. |
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 IpcRecordWriter IPC_RECORD_WRITER
public static final IpcRecordReader IPC_RECORD_READER
public static final IpcAnyWriter IPC_ANY_WRITER
Constructor Detail |
---|
public JsonHttpUtils()
Method Detail |
---|
public Record convertRequest(HttpExchange exchange) throws IpcException
exchange
- the HttpExchange object
IpcException
- if any error occurs during conversionpublic Record convertGetRequest(HttpExchange he) throws IpcException
he
- the HttpExchange object
IpcException
- if any error occurs during conversionpublic Record convertPostRequest(HttpExchange he) throws IpcException
he
- the HttpExchange object
IpcException
- if any error occurs during conversion from JSON to Recordpublic boolean hasRequestContent(HttpExchange exchange)
exchange
- HTTP exchange
public 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 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 int getErrorStatus(java.lang.Throwable ex)
ex
- an exception
public void writeErrorDetails(HttpExchange exchange, java.lang.Throwable error) throws java.io.IOException
java.io.IOException
public ObjectMapper getObjectMapper()
ObjectMapper
instance with disabled JsonGenerator.Feature#AUTO_CLOSE_TARGET
and default
SMILA date/time format.
ObjectMapper
|
SMILA 1.0 API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |