Package org.openhab.core.io.rest
Class JSONResponse
java.lang.Object
org.openhab.core.io.rest.JSONResponse
Static helper methods to build up JSON-like Response objects and error handling.
- Author:
- Joerg Plewe - Initial contribution, Henning Treu - Provide streaming capabilities, Jörg Sautter - Improve streaming capabilities
- 
Nested Class SummaryNested Classes
- 
Method SummaryModifier and TypeMethodDescriptionstatic javax.ws.rs.core.ResponsecreateErrorResponse(javax.ws.rs.core.Response.StatusType status, String errormessage) in case of error (404 and such)static javax.ws.rs.core.ResponsecreateResponse(javax.ws.rs.core.Response.StatusType status, Object entity, String errormessage) Depending on the status, create a Response object containing either the entity alone or an error JSON which might hold the entity as well.
- 
Method Details- 
createErrorResponsepublic static javax.ws.rs.core.Response createErrorResponse(javax.ws.rs.core.Response.StatusType status, String errormessage) in case of error (404 and such)- Parameters:
- status-
- errormessage-
- Returns:
- Response containing a status and the errormessage in JSON format
 
- 
createResponsepublic static javax.ws.rs.core.Response createResponse(javax.ws.rs.core.Response.StatusType status, Object entity, String errormessage) Depending on the status, create a Response object containing either the entity alone or an error JSON which might hold the entity as well.- Parameters:
- status- the status for the response.
- entity- the entity which is transformed into a JSON stream.
- errormessage- an optional error message (may be null), ignored if the status family is successful
- Returns:
- Response configure for error or success
 
 
-