Class JsonNonProvidedNamedBeanHttpService<T extends NamedBean>

    • Method Detail

      • doGetList

        @Nonnull
        protected final com.fasterxml.jackson.databind.JsonNode doGetList​(Manager<T> manager,
                                                                          java.lang.String type,
                                                                          com.fasterxml.jackson.databind.JsonNode data,
                                                                          JsonRequest request)
                                                                   throws JsonException
        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.

        Parameters:
        manager - the manager for the requested type
        type - the type of the requested list
        data - JSON object possibly containing filters to limit the list to
        request - the JSON request
        Returns:
        a JSON list
        Throws:
        JsonException - may be thrown by concrete implementations
      • doGetList

        @Nonnull
        protected final com.fasterxml.jackson.databind.JsonNode doGetList​(Manager<T> manager,
                                                                          java.lang.String type,
                                                                          com.fasterxml.jackson.databind.JsonNode data,
                                                                          java.util.Locale locale,
                                                                          int id)
                                                                   throws JsonException
        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.

        Parameters:
        manager - the manager for the requested type
        type - the type of the requested list
        data - JSON object possibly containing filters to limit the list to
        locale - the requesting client's Locale
        id - the message id set by the client
        Returns:
        a JSON list
        Throws:
        JsonException - may be thrown by concrete implementations
      • doGet

        @Nonnull
        protected abstract com.fasterxml.jackson.databind.node.ObjectNode doGet​(T bean,
                                                                                @Nonnull
                                                                                java.lang.String name,
                                                                                @Nonnull
                                                                                java.lang.String type,
                                                                                @Nonnull
                                                                                JsonRequest request)
                                                                         throws JsonException
        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.

        Parameters:
        bean - 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
      • getNamedBean

        @CheckForNull
        protected abstract T getNamedBean​(@Nonnull
                                          java.lang.String type,
                                          @Nonnull
                                          java.lang.String name,
                                          @Nonnull
                                          com.fasterxml.jackson.databind.JsonNode data,
                                          @Nonnull
                                          JsonRequest request)
                                   throws JsonException
        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.
        Parameters:
        name - the name of the requested object
        type - the type 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
        java.lang.IllegalArgumentException - if both name is null and data is empty
      • getNamedBean

        @Nonnull
        public com.fasterxml.jackson.databind.node.ObjectNode getNamedBean​(T bean,
                                                                           @Nonnull
                                                                           java.lang.String name,
                                                                           @Nonnull
                                                                           java.lang.String type,
                                                                           @Nonnull
                                                                           JsonRequest request)
                                                                    throws JsonException
        Create the JsonNode for a NamedBean object.
        Parameters:
        bean - the bean to create the node for
        name - the name of the bean; used only if the bean is null
        type - the JSON type of the bean
        request - the JSON request
        Returns:
        a JSON node
        Throws:
        JsonException - if the bean is null
      • postNamedBean

        @Nonnull
        protected T postNamedBean​(T bean,
                                  @Nonnull
                                  com.fasterxml.jackson.databind.JsonNode data,
                                  @Nonnull
                                  java.lang.String name,
                                  @Nonnull
                                  java.lang.String type,
                                  @Nonnull
                                  JsonRequest request)
                           throws JsonException
        Handle the common elements of a NamedBean that can be changed in an POST message.

        Note: the system name of a NamedBean cannot be changed using this method.

        Parameters:
        bean - the bean to modify
        data - the JsonNode containing the JSON representation of bean
        name - the system name of the bean
        type - the JSON type of the bean
        request - the JSON request
        Returns:
        the bean so that this can be used in a method chain
        Throws:
        JsonException - if the bean is null