use of com.netflix.metacat.common.server.events.MetacatCreateTablePostEvent in project metacat by Netflix.
the class TableServiceImpl method create.
@Override
public TableDto create(@Nonnull final QualifiedName name, @Nonnull final TableDto tableDto) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
validate(name);
//
// Set the owner,if null, with the session user name.
//
setOwnerIfNull(tableDto, metacatRequestContext.getUserName());
log.info("Creating table {}", name);
eventBus.postSync(new MetacatCreateTablePreEvent(name, metacatRequestContext, this, tableDto));
final ConnectorTableService service = connectorManager.getTableService(name.getCatalogName());
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
service.create(connectorContext, converterUtil.fromTableDto(tableDto));
if (tableDto.getDataMetadata() != null || tableDto.getDefinitionMetadata() != null) {
log.info("Saving user metadata for table {}", name);
userMetadataService.saveMetadata(metacatRequestContext.getUserName(), tableDto, false);
tag(name, tableDto.getDefinitionMetadata());
}
final TableDto dto = get(name, true).orElseThrow(() -> new IllegalStateException("Should exist"));
eventBus.postAsync(new MetacatCreateTablePostEvent(name, metacatRequestContext, this, dto));
return dto;
}
Aggregations