Class JSONResponse

java.lang.Object
org.openhab.core.io.rest.JSONResponse

public class JSONResponse extends Object
Static helper methods to build up JSON-like Response objects and error handling.
Author:
Joerg Plewe - Initial contribution, Henning Treu - Provide streaming capabilities
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    trap exceptions
  • Method Summary

    Modifier and Type
    Method
    Description
    static javax.ws.rs.core.Response
    createErrorResponse(javax.ws.rs.core.Response.StatusType status, String errormessage)
    in case of error (404 and such)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createErrorResponse

      public 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
    • createResponse

      public 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