use of com.netflix.metacat.common.server.events.MetacatCreateDatabasePreEvent in project metacat by Netflix.
the class DatabaseServiceImpl method create.
@Override
public DatabaseDto create(@Nonnull final QualifiedName name, @Nonnull final DatabaseDto dto) {
validate(name);
log.info("Creating schema {}", name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
eventBus.postSync(new MetacatCreateDatabasePreEvent(name, metacatRequestContext, this));
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorManager.getDatabaseService(name.getCatalogName()).create(connectorContext, converterUtil.fromDatabaseDto(dto));
if (dto.getDefinitionMetadata() != null) {
log.info("Saving user metadata for schema {}", name);
userMetadataService.saveDefinitionMetadata(name, metacatRequestContext.getUserName(), Optional.of(dto.getDefinitionMetadata()), true);
}
final DatabaseDto createdDto = get(name, dto.getDefinitionMetadata() != null);
eventBus.postAsync(new MetacatCreateDatabasePostEvent(name, metacatRequestContext, this, createdDto));
return createdDto;
}
Aggregations