use of com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent in project metacat by Netflix.
the class MetacatServiceHelper method postPreUpdateEvent.
/**
* Calls the right method of the event bus for the given qualified name.
*
* @param name name
* @param metacatRequestContext context
* @param dto dto
*/
public void postPreUpdateEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext, final BaseDto dto) {
if (name.isPartitionDefinition()) {
final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
if (dto != null) {
partitionsSaveRequestDto.setPartitions(ImmutableList.of((PartitionDto) dto));
}
this.eventBus.postSync(new MetacatSaveTablePartitionPreEvent(name, metacatRequestContext, this, partitionsSaveRequestDto));
} else if (name.isTableDefinition()) {
this.eventBus.postSync(new MetacatUpdateTablePreEvent(name, metacatRequestContext, this, (TableDto) dto, (TableDto) dto));
} else if (name.isDatabaseDefinition()) {
eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
} else {
throw new IllegalArgumentException(String.format("Invalid name %s", name));
}
}
use of com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent in project metacat by Netflix.
the class CatalogServiceImpl method update.
/**
* {@inheritDoc}
*/
@Override
public void update(@Nonnull final QualifiedName name, @Nonnull final CreateCatalogDto createCatalogDto) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
connectorManager.getCatalogConfig(name);
userMetadataService.saveMetadata(metacatRequestContext.getUserName(), createCatalogDto, true);
eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
}
use of com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent in project metacat by Netflix.
the class DatabaseServiceImpl method update.
@Override
public void update(@Nonnull final QualifiedName name, @Nonnull final DatabaseDto dto) {
validate(name);
log.info("Updating schema {}", name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
try {
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorManager.getDatabaseService(name.getCatalogName()).update(connectorContext, converterUtil.fromDatabaseDto(dto));
} catch (UnsupportedOperationException ignored) {
}
if (dto.getDefinitionMetadata() != null) {
log.info("Saving user metadata for schema {}", name);
userMetadataService.saveDefinitionMetadata(name, metacatRequestContext.getUserName(), Optional.of(dto.getDefinitionMetadata()), true);
}
eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
}
Aggregations