Search in sources :

Example 1 with SchemaRegistrationException

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();
        }
    }
}
Also used : SchemaDescriptor(org.kie.kogito.persistence.api.schema.SchemaDescriptor) XMLStringConfiguration(org.infinispan.commons.configuration.XMLStringConfiguration) SchemaRegistrationException(org.kie.kogito.persistence.api.schema.SchemaRegistrationException)

Aggregations

XMLStringConfiguration (org.infinispan.commons.configuration.XMLStringConfiguration)1 SchemaDescriptor (org.kie.kogito.persistence.api.schema.SchemaDescriptor)1 SchemaRegistrationException (org.kie.kogito.persistence.api.schema.SchemaRegistrationException)1