Package org.apache.unomi.schema.api
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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
deleteSchema(String schemaId)
Delete a schema according to its idSet<String>
getInstalledJsonSchemaIds()
Get the list of installed Json Schema IdsJsonSchemaWrapper
getSchema(String schemaId)
Get a schema matching by a schema idJsonSchemaWrapper
getSchemaForEventType(String eventType)
Get the schema that is able to validate the specific event typeList<JsonSchemaWrapper>
getSchemasByTarget(String target)
Get a list aJsonSchemaWrapper
boolean
isEventValid(String event, String eventType)
Verify if the event is validboolean
isValid(String data, String schemaId)
Verify if a jsonNode is valid against a schemavoid
loadPredefinedSchema(InputStream schemaStream)
Load a predefined schema into memoryvoid
saveSchema(String schema)
Save a new schema or update a schemaboolean
unloadPredefinedSchema(InputStream schemaStream)
Unload a predefined schema into memory
-
-
-
Method Detail
-
isValid
boolean isValid(String data, String schemaId)
Verify if a jsonNode is valid against a schema- Parameters:
data
- to validateschemaId
- id of the schema used for the validation- Returns:
- true is the object is valid
-
isEventValid
boolean isEventValid(String event, String eventType)
Verify if the event is valid- Parameters:
event
- to validateeventType
- The type of the event- Returns:
- true is the event is valid
-
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
-
getSchemasByTarget
List<JsonSchemaWrapper> getSchemasByTarget(String target)
Get a list aJsonSchemaWrapper
- Parameters:
target
- to filter the schemas- Returns:
- a list of JSONSchema
-
getSchemaForEventType
JsonSchemaWrapper getSchemaForEventType(String eventType)
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.
-
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
-
-