Interface SchemaService

  • All Known Implementing Classes:
    SchemaServiceImpl

    public interface SchemaService
    Service that allow to manage JSON schema. It allows to get, save and delete schemas
    • Method Detail

      • isValid

        boolean isValid​(String data,
                        String schemaId)
        Verify if a jsonNode is valid against a schema (This method is fail safe, if unexpected errors happens it will returns false)
        Parameters:
        data - to validate
        schemaId - id of the schema used for the validation
        Returns:
        true is the object is valid, false otherwise, false also in case of unexpected errors !
      • isEventValid

        @Deprecated
        boolean isEventValid​(String event,
                             String eventType)
        Deprecated.
        Deprecate (since 2.2.0). the eventType is now directly extracted from the event source You can directly use sibling function: isEventValid(String event)
      • isEventValid

        boolean isEventValid​(String event)
        Verify if the event is valid (This method is fail safe, if unexpected errors happens it will returns false)
        Parameters:
        event - the event to check validity
        Returns:
        true is the event is valid, false otherwise, false also in case of unexpected errors !
      • validateEvent

        Set<ValidationError> validateEvent​(String event)
                                    throws ValidationException
        perform a validation on the given event
        Parameters:
        event - the event to validate
        Returns:
        The list of validation errors in case there is some, empty list otherwise
        Throws:
        ValidationException - in case something goes wrong and validation could not be performed.
      • validateEvents

        Map<String,​Set<ValidationError>> validateEvents​(String events)
                                                       throws ValidationException
        perform a validation of a list of the given events
        Parameters:
        events - the events to validate
        Returns:
        The Map of validation errors group per event type in case there is some, empty map otherwise
        Throws:
        ValidationException - in case something goes wrong and validation could not be performed.
      • getInstalledJsonSchemaIds

        Set<String> getInstalledJsonSchemaIds()
        Get the list of installed Json Schema Ids
        Returns:
        A Set of JSON schema ids
      • getSchema

        JsonSchemaWrapper getSchema​(String schemaId)
        Get a schema matching by a schema id
        Parameters:
        schemaId - Id of the schema
        Returns:
        A JSON schema
      • getSchemaForEventType

        JsonSchemaWrapper getSchemaForEventType​(String eventType)
                                         throws ValidationException
        Get the schema that is able to validate the specific event type
        Parameters:
        eventType - the eventType
        Returns:
        The JSON Schema able to validate the given event type or null if not found.
        Throws:
        ValidationException
      • saveSchema

        void saveSchema​(String schema)
        Save a new schema or update a schema
        Parameters:
        schema - as a String value
      • deleteSchema

        boolean deleteSchema​(String schemaId)
        Delete a schema according to its id
        Parameters:
        schemaId - id of the schema to delete
        Returns:
        true if the schema has been deleted
      • loadPredefinedSchema

        void loadPredefinedSchema​(InputStream schemaStream)
                           throws IOException
        Load a predefined schema into memory
        Parameters:
        schemaStream - inputStream of the schema
        Throws:
        IOException
      • unloadPredefinedSchema

        boolean unloadPredefinedSchema​(InputStream schemaStream)
        Unload a predefined schema into memory
        Parameters:
        schemaStream - inputStream of the schema to delete
        Returns:
        true if the schema has been deleted