use of org.kie.kogito.persistence.api.schema.SchemaRegistrationException in project kogito-apps by kiegroup.
the class ProtoSchemaManager method onSchemaRegisteredEvent.
public void onSchemaRegisteredEvent(@Observes SchemaRegisteredEvent event) {
if (schemaAcceptor.accept(event.getSchemaType())) {
SchemaDescriptor schemaDescriptor = event.getSchemaDescriptor();
Storage<String, String> cache = protobufCacheService.getProtobufCache();
cache.put(schemaDescriptor.getName(), schemaDescriptor.getSchemaContent());
schemaDescriptor.getProcessDescriptor().ifPresent(processDescriptor -> {
cacheManager.getProcessIdModelCache().put(processDescriptor.getProcessId(), processDescriptor.getProcessType());
// Initialize domain cache
String cacheName = cacheManager.getDomainModelCacheName(processDescriptor.getProcessId());
String cacheTemplateRendered = getTemplateRendered(schemaDescriptor, cacheName);
LOGGER.debug("Cache template: \n{}", cacheTemplateRendered);
manager.administration().getOrCreateCache(cacheName, new XMLStringConfiguration(cacheTemplateRendered));
});
List<String> errors = checkSchemaErrors(cache);
if (!errors.isEmpty()) {
String message = "Proto Schema contain errors:\n" + String.join("\n", errors);
throw new SchemaRegistrationException(message);
}
if (LOGGER.isDebugEnabled()) {
logProtoCacheKeys();
}
}
}
Aggregations