Package jmri.server.json.schema
Class JsonSchemaServiceCache
java.lang.Object
jmri.server.json.schema.JsonSchemaServiceCache
- All Implemented Interfaces:
InstanceManagerAutoDefault
public class JsonSchemaServiceCache extends Object implements InstanceManagerAutoDefault
Cache for mapping
JsonHttpService
s to types for
getting schemas.-
Constructor Summary
Constructors Constructor Description JsonSchemaServiceCache()
-
Method Summary
Modifier and Type Method Description com.networknt.schema.JsonSchema
getClientSchema(String type, Locale locale, int id)
Deprecated.since 4.19.2; usegetClientSchema(String, JsonRequest)
insteadcom.networknt.schema.JsonSchema
getClientSchema(String type, JsonRequest request)
Get the client schema for JSON messages or for specific JSON data schema.Set<String>
getClientTypes()
Deprecated.since 4.19.2; usegetClientTypes(String)
insteadSet<String>
getClientTypes(String version)
Get the types of JSON messages expected from clients.com.networknt.schema.JsonSchema
getServerSchema(String type, Locale locale, int id)
Deprecated.since 4.19.2; usegetServerSchema(String, JsonRequest)
insteadcom.networknt.schema.JsonSchema
getServerSchema(String type, JsonRequest request)
Get the server schema for JSON messages or for specific JSON data schema.Set<String>
getServerTypes()
Deprecated.since 4.19.2; usegetServerTypes(String)
insteadSet<String>
getServerTypes(String version)
Get the types of JSON messages this application sends.Set<JsonHttpService>
getServices(String type)
Deprecated.since 4.19.2; usegetServices(String, String)
insteadSet<JsonHttpService>
getServices(String type, String version)
Get the services known to this cache that support a specific JSON type.Set<String>
getTypes()
Deprecated.since 4.19.2; usegetTypes(String)
insteadSet<String>
getTypes(String version)
Get all types of JSON messages.void
validateData(String type, com.fasterxml.jackson.databind.JsonNode data, boolean server, Locale locale, int id)
Deprecated.since 4.19.2; usevalidateData(String, JsonNode, boolean, JsonRequest)
insteadvoid
validateData(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, Locale locale, int id)
Deprecated.since 4.19.2; usevalidateMessage(JsonNode, boolean, JsonRequest)
insteadvoid
validateMessage(com.fasterxml.jackson.databind.JsonNode message, boolean server, JsonRequest request)
Validate a JSON message against the schema for JSON messages and data.
-
Constructor Details
-
Method Details
-
getServices
Get the services known to this cache that support a specific JSON type.- Parameters:
type
- the JSON type requestedversion
- the JSON protocol version requested- Returns:
- the supporting services or an empty set if none
- Throws:
NullPointerException
- if version is not a known version
-
getServices
Deprecated.since 4.19.2; usegetServices(String, String)
insteadGet the services known to this cache that support a specific JSON type for version 5 of the JSON protocol.- Parameters:
type
- the JSON type requested- Returns:
- the supporting services or an empty set if none
-
getTypes
Get all types of JSON messages.- Parameters:
version
- the JSON protocol version- Returns:
- the union of the results from
getClientTypes()
andgetServerTypes()
-
getClientTypes
Get the types of JSON messages expected from clients.- Parameters:
version
- the JSON protocol version- Returns:
- the message types
-
getServerTypes
Get the types of JSON messages this application sends.- Parameters:
version
- the JSON protocol version- Returns:
- the message types
-
getTypes
Deprecated.since 4.19.2; usegetTypes(String)
insteadGet all types of JSON messages.- Returns:
- the union of the results from
getClientTypes()
andgetServerTypes()
-
getClientTypes
Deprecated.since 4.19.2; usegetClientTypes(String)
insteadGet the types of JSON messages expected from clients.- Returns:
- the message types
-
getServerTypes
Deprecated.since 4.19.2; usegetServerTypes(String)
insteadGet the types of JSON messages this application sends.- Returns:
- the message types
-
getClientSchema
@Nonnull public com.networknt.schema.JsonSchema getClientSchema(@Nonnull String type, @Nonnull JsonRequest request) throws JsonExceptionGet the client schema for JSON messages or for specific JSON data schema.- Parameters:
type
- the type; useJSON.JSON
to get the schema for messages, or any other value for a data schemarequest
- the JSON request- Returns:
- the requested schema
- Throws:
JsonException
- if unable to get schema due to errors processing schemaIllegalArgumentException
- if no JSON service provides schemas for type
-
getClientSchema
@Deprecated @Nonnull public com.networknt.schema.JsonSchema getClientSchema(@Nonnull String type, @Nonnull Locale locale, int id) throws JsonExceptionDeprecated.since 4.19.2; usegetClientSchema(String, JsonRequest)
insteadGet the client schema for JSON messages or for specific JSON data schema.- Parameters:
type
- the type; useJSON.JSON
to get the schema for messages, or any other value for a data schemalocale
- the locale for error messages, if anyid
- message id set by client- Returns:
- the requested schema
- Throws:
JsonException
- if unable to get schema due to errors processing schemaIllegalArgumentException
- if no JSON service provides schemas for type
-
getServerSchema
@Nonnull public com.networknt.schema.JsonSchema getServerSchema(@Nonnull String type, @Nonnull JsonRequest request) throws JsonExceptionGet the server schema for JSON messages or for specific JSON data schema.- Parameters:
type
- the type; useJSON.JSON
to get the schema for messages, or any other value for a data schemarequest
- the JSON request- Returns:
- the requested schema
- Throws:
JsonException
- if unable to get schema due to errors processing schemaIllegalArgumentException
- if no JSON service provides schemas for type
-
getServerSchema
@Deprecated @Nonnull public com.networknt.schema.JsonSchema getServerSchema(@Nonnull String type, @Nonnull Locale locale, int id) throws JsonExceptionDeprecated.since 4.19.2; usegetServerSchema(String, JsonRequest)
insteadGet the server schema for JSON messages or for specific JSON data schema.- Parameters:
type
- the type; useJSON.JSON
to get the schema for messages, or any other value for a data schemalocale
- the locale for error messages, if anyid
- message id set by client- Returns:
- the requested schema
- Throws:
JsonException
- if unable to get schema due to errors processing schemaIllegalArgumentException
- 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 JsonExceptionValidate a JSON message against the schema for JSON messages and data.- Parameters:
message
- the message to validateserver
- true if message is from the JSON server; false otherwiserequest
- the JSON request- Throws:
JsonException
- if the message does not validate
-
validateMessage
@Deprecated public void validateMessage(@Nonnull com.fasterxml.jackson.databind.JsonNode message, boolean server, @Nonnull Locale locale, int id) throws JsonExceptionDeprecated.since 4.19.2; usevalidateMessage(JsonNode, boolean, JsonRequest)
insteadValidate a JSON message against the schema for JSON messages and data.- Parameters:
message
- the message to validateserver
- true if message is from the JSON server; false otherwiselocale
- the locale for any exceptions that need to be reported to clientsid
- the id to be included with any exceptions reported to clients- Throws:
JsonException
- if the message does not validate
-
validateData
public void validateData(@Nonnull String type, @Nonnull com.fasterxml.jackson.databind.JsonNode data, boolean server, @Nonnull JsonRequest request) throws JsonExceptionValidate a JSON data object against the schema for JSON messages and data.- Parameters:
type
- the type of data objectdata
- the data object to validateserver
- true if message is from the JSON server; false otherwiserequest
- the JSON request- Throws:
JsonException
- if the message does not validate
-
validateData
@Deprecated public void validateData(@Nonnull String type, @Nonnull com.fasterxml.jackson.databind.JsonNode data, boolean server, @Nonnull Locale locale, int id) throws JsonExceptionDeprecated.since 4.19.2; usevalidateData(String, JsonNode, boolean, JsonRequest)
insteadValidate a JSON data object against the schema for JSON messages and data.- Parameters:
type
- the type of data objectdata
- the data object to validateserver
- true if message is from the JSON server; false otherwiselocale
- the locale for any exceptions that need to be reported to clientsid
- the id to be included with any exceptions reported to clients- Throws:
JsonException
- if the message does not validate
-