use of com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent 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.MetacatUpdateDatabasePostEvent 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));
}
use of com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent in project metacat by Netflix.
the class MetacatServiceHelper method postPostUpdateEvent.
/**
* Calls the right method of the event bus for the given qualified name.
*
* @param name name
* @param metacatRequestContext context
* @param oldDTo dto
* @param currentDto dto
*/
public void postPostUpdateEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext, final BaseDto oldDTo, final BaseDto currentDto) {
if (name.isPartitionDefinition()) {
final List<PartitionDto> dtos = Lists.newArrayList();
if (currentDto != null) {
dtos.add((PartitionDto) currentDto);
}
// This request neither added nor updated partitions
final PartitionsSaveResponseDto partitionsSaveResponseDto = new PartitionsSaveResponseDto();
this.eventBus.postAsync(new MetacatSaveTablePartitionPostEvent(name, metacatRequestContext, this, dtos, partitionsSaveResponseDto));
} else if (name.isTableDefinition()) {
final MetacatUpdateTablePostEvent event = new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, (TableDto) oldDTo, (TableDto) currentDto);
this.eventBus.postAsync(event);
} else if (name.isDatabaseDefinition()) {
this.eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
} else {
throw new IllegalArgumentException(String.format("Invalid name %s", name));
}
}
Aggregations