Search in sources :

Example 1 with MetacatCreateDatabasePreEvent

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;
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) MetacatCreateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatCreateDatabasePostEvent) ConnectorContext(com.netflix.metacat.common.server.connectors.ConnectorContext) MetacatCreateDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatCreateDatabasePreEvent)

Aggregations

MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)1 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)1 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)1 MetacatCreateDatabasePostEvent (com.netflix.metacat.common.server.events.MetacatCreateDatabasePostEvent)1 MetacatCreateDatabasePreEvent (com.netflix.metacat.common.server.events.MetacatCreateDatabasePreEvent)1