Class JsonSchemaServiceCache

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.networknt.schema.JsonSchema getClientSchema​(java.lang.String type, JsonRequest request)
      Get the client schema for JSON messages or for specific JSON data schema.
      java.util.Set<java.lang.String> getClientTypes​(java.lang.String version)
      Get the types of JSON messages expected from clients.
      com.networknt.schema.JsonSchema getServerSchema​(java.lang.String type, JsonRequest request)
      Get the server schema for JSON messages or for specific JSON data schema.
      java.util.Set<java.lang.String> getServerTypes​(java.lang.String version)
      Get the types of JSON messages this application sends.
      java.util.Set<JsonHttpService> getServices​(java.lang.String type, java.lang.String version)
      Get the services known to this cache that support a specific JSON type.
      java.util.Set<java.lang.String> getTypes​(java.lang.String version)
      Get all types of JSON messages.
      void validateData​(java.lang.String type, com.fasterxml.jackson.databind.JsonNode data, boolean server, JsonRequest request)
      Validate a JSON data object against the schema for JSON messages and data.
      void validateMessage​(com.fasterxml.jackson.databind.JsonNode message, boolean server, JsonRequest request)
      Validate a JSON message against the schema for JSON messages and data.
      • Methods inherited from class java.lang.Object

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

      • getServices

        @Nonnull
        public java.util.Set<JsonHttpServicegetServices​(@Nonnull
                                                          java.lang.String type,
                                                          @Nonnull
                                                          java.lang.String version)
        Get the services known to this cache that support a specific JSON type.
        Parameters:
        type - the JSON type requested
        version - the JSON protocol version requested
        Returns:
        the supporting services or an empty set if none
        Throws:
        java.lang.NullPointerException - if version is not a known version
      • getClientTypes

        @Nonnull
        public java.util.Set<java.lang.String> getClientTypes​(java.lang.String version)
        Get the types of JSON messages expected from clients.
        Parameters:
        version - the JSON protocol version
        Returns:
        the message types
      • getServerTypes

        @Nonnull
        public java.util.Set<java.lang.String> getServerTypes​(java.lang.String version)
        Get the types of JSON messages this application sends.
        Parameters:
        version - the JSON protocol version
        Returns:
        the message types
      • getClientSchema

        @Nonnull
        public com.networknt.schema.JsonSchema getClientSchema​(@Nonnull
                                                               java.lang.String type,
                                                               @Nonnull
                                                               JsonRequest request)
                                                        throws JsonException
        Get the client schema for JSON messages or for specific JSON data schema.
        Parameters:
        type - the type; use JSON.JSON to get the schema for messages, or any other value for a data schema
        request - the JSON request
        Returns:
        the requested schema
        Throws:
        JsonException - if unable to get schema due to errors processing schema
        java.lang.IllegalArgumentException - if no JSON service provides schemas for type
      • getServerSchema

        @Nonnull
        public com.networknt.schema.JsonSchema getServerSchema​(@Nonnull
                                                               java.lang.String type,
                                                               @Nonnull
                                                               JsonRequest request)
                                                        throws JsonException
        Get the server schema for JSON messages or for specific JSON data schema.
        Parameters:
        type - the type; use JSON.JSON to get the schema for messages, or any other value for a data schema
        request - the JSON request
        Returns:
        the requested schema
        Throws:
        JsonException - if unable to get schema due to errors processing schema
        java.lang.IllegalArgumentException - if no JSON service provides schemas for type
      • validateMessage

        public void validateMessage​(@Nonnull
                                    com.fasterxml.jackson.databind.JsonNode message,
                                    boolean server,
                                    @Nonnull
                                    JsonRequest request)
                             throws JsonException
        Validate a JSON message against the schema for JSON messages and data.
        Parameters:
        message - the message to validate
        server - true if message is from the JSON server; false otherwise
        request - the JSON request
        Throws:
        JsonException - if the message does not validate
      • validateData

        public void validateData​(@Nonnull
                                 java.lang.String type,
                                 @Nonnull
                                 com.fasterxml.jackson.databind.JsonNode data,
                                 boolean server,
                                 @Nonnull
                                 JsonRequest request)
                          throws JsonException
        Validate a JSON data object against the schema for JSON messages and data.
        Parameters:
        type - the type of data object
        data - the data object to validate
        server - true if message is from the JSON server; false otherwise
        request - the JSON request
        Throws:
        JsonException - if the message does not validate