Package org.apache.unomi.schema.impl
Class SchemaServiceImpl
java.lang.Object
org.apache.unomi.schema.impl.SchemaServiceImpl
- All Implemented Interfaces:
SchemaService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteSchema(String schemaId) Delete a schema according to its idvoiddestroy()Get the list of installed Json Schema IdsGet a schema matching by a schema idgetSchemaForEventType(String eventType) Get the schema that is able to validate the specific event typegetSchemasByTarget(String target) Get a list aJsonSchemaWrappervoidinit()booleanisEventValid(String event) Verify if the event is valid (This method is fail safe, if unexpected errors happens it will returns false)booleanisEventValid(String event, String eventType) Deprecate (since 2.2.0).booleanVerify if a jsonNode is valid against a schema (This method is fail safe, if unexpected errors happens it will returns false)voidloadPredefinedSchema(InputStream schemaStream) Load a predefined schema into memoryvoidRefresh the JSON schemasvoidsaveSchema(String schema) Save a new schema or update a schemavoidsetJsonSchemaRefreshInterval(Integer jsonSchemaRefreshInterval) voidsetPersistenceService(PersistenceService persistenceService) voidsetScopeService(ScopeService scopeService) booleanunloadPredefinedSchema(InputStream schemaStream) Unload a predefined schema into memoryvalidateEvent(String event) perform a validation on the given eventvalidateEvents(String events) perform a validation of a list of the given events
-
Constructor Details
-
SchemaServiceImpl
public SchemaServiceImpl()
-
-
Method Details
-
isValid
Description copied from interface:SchemaServiceVerify if a jsonNode is valid against a schema (This method is fail safe, if unexpected errors happens it will returns false)- Specified by:
isValidin interfaceSchemaService- Parameters:
data- to validateschemaId- 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
Description copied from interface:SchemaServiceDeprecate (since 2.2.0). the eventType is now directly extracted from the event source You can directly use sibling function: isEventValid(String event)- Specified by:
isEventValidin interfaceSchemaService
-
isEventValid
Description copied from interface:SchemaServiceVerify if the event is valid (This method is fail safe, if unexpected errors happens it will returns false)- Specified by:
isEventValidin interfaceSchemaService- Parameters:
event- the event to check validity- Returns:
- true is the event is valid, false otherwise, false also in case of unexpected errors !
-
validateEvent
Description copied from interface:SchemaServiceperform a validation on the given event- Specified by:
validateEventin interfaceSchemaService- 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
Description copied from interface:SchemaServiceperform a validation of a list of the given events- Specified by:
validateEventsin interfaceSchemaService- 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.
-
getSchema
Description copied from interface:SchemaServiceGet a schema matching by a schema id- Specified by:
getSchemain interfaceSchemaService- Parameters:
schemaId- Id of the schema- Returns:
- A JSON schema
-
getInstalledJsonSchemaIds
Description copied from interface:SchemaServiceGet the list of installed Json Schema Ids- Specified by:
getInstalledJsonSchemaIdsin interfaceSchemaService- Returns:
- A Set of JSON schema ids
-
getSchemasByTarget
Description copied from interface:SchemaServiceGet a list aJsonSchemaWrapper- Specified by:
getSchemasByTargetin interfaceSchemaService- Parameters:
target- to filter the schemas- Returns:
- a list of JSONSchema
-
getSchemaForEventType
Description copied from interface:SchemaServiceGet the schema that is able to validate the specific event type- Specified by:
getSchemaForEventTypein interfaceSchemaService- Parameters:
eventType- the eventType- Returns:
- The JSON Schema able to validate the given event type or null if not found.
- Throws:
ValidationException
-
saveSchema
Description copied from interface:SchemaServiceSave a new schema or update a schema- Specified by:
saveSchemain interfaceSchemaService- Parameters:
schema- as a String value
-
deleteSchema
Description copied from interface:SchemaServiceDelete a schema according to its id- Specified by:
deleteSchemain interfaceSchemaService- Parameters:
schemaId- id of the schema to delete- Returns:
- true if the schema has been deleted
-
loadPredefinedSchema
Description copied from interface:SchemaServiceLoad a predefined schema into memory- Specified by:
loadPredefinedSchemain interfaceSchemaService- Parameters:
schemaStream- inputStream of the schema- Throws:
IOException
-
unloadPredefinedSchema
Description copied from interface:SchemaServiceUnload a predefined schema into memory- Specified by:
unloadPredefinedSchemain interfaceSchemaService- Parameters:
schemaStream- inputStream of the schema to delete- Returns:
- true if the schema has been deleted
-
refreshJSONSchemas
public void refreshJSONSchemas()Description copied from interface:SchemaServiceRefresh the JSON schemas- Specified by:
refreshJSONSchemasin interfaceSchemaService
-
init
public void init() -
destroy
public void destroy() -
setPersistenceService
-
setScopeService
-
setJsonSchemaRefreshInterval
-