Class JsonSignalHeadHttpService


public class JsonSignalHeadHttpService
extends JsonNonProvidedNamedBeanHttpService<SignalHead>
JSON HTTP service for SignalHeads.
  • Constructor Details

  • Method Details

    • doGet

      public com.fasterxml.jackson.databind.JsonNode doGet​(String type, String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException
      Description copied from class: JsonHttpService
      Respond to an HTTP GET request for the requested name.

      If name is null, return a list of all objects for the given type, if appropriate.

      This method should throw a 500 Internal Server Error if type is not recognized.

      Specified by:
      doGet in class JsonHttpService
      Parameters:
      type - the type of the requested object
      name - the system name of the requested object
      data - JSON data set of attributes of the requested object
      request - the JSON request
      Returns:
      a JSON description of the requested object
      Throws:
      JsonException - if the named object does not exist or other error occurs
    • doGet

      protected com.fasterxml.jackson.databind.node.ObjectNode doGet​(SignalHead signalHead, String name, String type, JsonRequest request) throws JsonException
      Description copied from class: JsonNonProvidedNamedBeanHttpService
      Respond to an HTTP GET request for the requested name.

      If name is null, return a list of all objects for the given type, if appropriate.

      This method should throw a 500 Internal Server Error if type is not recognized.

      Specified by:
      doGet in class JsonNonProvidedNamedBeanHttpService<SignalHead>
      Parameters:
      signalHead - the requested object
      name - the name of the requested object
      type - the type of the requested object
      request - the JSON request
      Returns:
      a JSON description of the requested object
      Throws:
      JsonException - if the named object does not exist or other error occurs
    • doPost

      public com.fasterxml.jackson.databind.JsonNode doPost​(String type, String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException
      Description copied from class: JsonHttpService
      Respond to an HTTP POST request for the requested name.

      This method should throw a 400 Invalid Request error if the named object does not exist.

      Specified by:
      doPost in class JsonHttpService
      Parameters:
      type - the type of the requested object
      name - the system name of the requested object
      data - JSON data set of attributes of the requested object to be updated
      request - the JSON request
      Returns:
      a JSON description of the requested object after updates have been applied
      Throws:
      JsonException - if the named object does not exist or other error occurs
    • doGetList

      public com.fasterxml.jackson.databind.JsonNode doGetList​(String type, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException
      Description copied from class: JsonHttpService
      Respond to an HTTP GET request for a list of items of type.

      This is called by the JsonServlet to handle get requests for a type, but no name. Services that do not have named objects, such as the JsonTimeHttpService should respond to this with a list containing a single JSON object. Services that can't return a list may throw a 400 Bad Request JsonException in this case.

      Specified by:
      doGetList in class JsonHttpService
      Parameters:
      type - the type of the requested list
      data - JSON data set of attributes of the requested objects
      request - the JSON request
      Returns:
      a JSON list or message containing type "list", the list as data, and the passed in id
      Throws:
      JsonException - may be thrown by concrete implementations
    • doSchema

      public com.fasterxml.jackson.databind.JsonNode doSchema​(String type, boolean server, JsonRequest request) throws JsonException
      Description copied from class: JsonHttpService
      Get the JSON Schema for the data property of the requested type of JSON object. It is a invalid for implementations to not return a valid schema that clients can use to validate a request to or response from the JSON services.

      Note that a schema must be contained in a standard object as:

      {"type":"schema", "data":{"schema":<em>schema</em>, "server":boolean}}

      If using JsonHttpService.doSchema(String, boolean, String, String, int), an implementation can be as simple as: return doSchema(type, server, "path/to/client/schema.json", "path/to/server/schema.json", id);

      Specified by:
      doSchema in class JsonHttpService
      Parameters:
      type - the type for which a schema is requested
      server - true if the schema is for a message from the server; false if the schema is for a message from the client
      request - the JSON request
      Returns:
      a JSON Schema valid for the type
      Throws:
      JsonException - if an error occurs preparing schema; if type is is not a type handled by this service, this must be thrown with an error code of 500 and the localized message ERROR_UNKNOWN_TYPE
    • getNamedBean

      public SignalHead getNamedBean​(String type, String name, com.fasterxml.jackson.databind.JsonNode data, JsonRequest request) throws JsonException
      Description copied from class: JsonNonProvidedNamedBeanHttpService
      Get the NamedBean matching name and type. If the request has a method other than GET, this may modify or create the NamedBean requested. Note that name or data may be null, but it is an error to have both be null.
      Specified by:
      getNamedBean in class JsonNonProvidedNamedBeanHttpService<SignalHead>
      Parameters:
      type - the type of the requested object
      name - the name of the requested object
      data - the JsonNode containing the JSON representation of the bean to get
      request - the JSON request
      Returns:
      the matching NamedBean or null if there is no match
      Throws:
      JsonException - if the name is invalid for the type