Class JythonResponse


  • public class JythonResponse
    extends java.lang.Object
    Response object which is always available as response inside Jython scripts which implement REST endpoints in XL extensions. The content of HTTP response returned to the client will be the following:
     
      {
          entity: "object, or array",
          stdout: "Text which has been sent to standard output during the execution",
          stderr: "Text which has been sent to standard error during the execution",
          exception: "Textual representation of exception that has been thrown during script execution"
    
      }
     
     
    • Constructor Summary

      Constructors 
      Constructor Description
      JythonResponse()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getEntity()  
      java.util.Map<java.lang.String,​java.lang.String> getHeaders()  
      java.lang.Integer getStatusCode()  
      void setEntity​(java.lang.Object entity)
      Sets body of the response which will be serialized into JSON and returned to the client.
      void setHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
      Sets response headers.
      void setStatusCode​(java.lang.Integer statusCode)
      Sets an HTTP status code for the response.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JythonResponse

        public JythonResponse()
    • Method Detail

      • getEntity

        public java.lang.Object getEntity()
      • getStatusCode

        public java.lang.Integer getStatusCode()
      • getHeaders

        public java.util.Map<java.lang.String,​java.lang.String> getHeaders()
      • setEntity

        public void setEntity​(java.lang.Object entity)
        Sets body of the response which will be serialized into JSON and returned to the client. response.entity=[{"foo": 42, "bar": "some value"}, 34] Supported types are:
        • Standard JSON data types: Number, String, Boolean, Array*, Dictionary*
        • XL configuration items: ConfigurationItem
        * Array and Dictionary can recursively contain aforementioned types as values of their elements.
      • setStatusCode

        public void setStatusCode​(java.lang.Integer statusCode)
        Sets an HTTP status code for the response. Normally this HTTP status code will be returned to the client. E.g.: response.statusCode = 307. If this value is not set and script has been executed successfully, client will receive 200. If script throws exception which is not caught, this value will be ignored and 500 will be returned.
      • setHeaders

        public void setHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
        Sets response headers. E.g.: response.headers = {'Location': 'http://google.com'}