use of com.netflix.metacat.common.server.events.MetacatRenameTablePreEvent in project metacat by Netflix.
the class TableServiceImpl method rename.
@Override
public void rename(@Nonnull final QualifiedName oldName, @Nonnull final QualifiedName newName, final boolean isMView) {
validate(oldName);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorTableService service = connectorManager.getTableService(oldName.getCatalogName());
final TableDto oldTable = get(oldName, true).orElseThrow(() -> new TableNotFoundException(oldName));
if (oldTable != null) {
//Ignore if the operation is not supported, so that we can at least go ahead and save the user metadata
eventBus.postSync(new MetacatRenameTablePreEvent(oldName, metacatRequestContext, this, newName));
try {
log.info("Renaming {} {} to {}", isMView ? "view" : "table", oldName, newName);
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
service.rename(connectorContext, oldName, newName);
} catch (UnsupportedOperationException ignored) {
}
userMetadataService.renameDefinitionMetadataKey(oldName, newName);
tagService.rename(oldName, newName.getTableName());
final TableDto dto = get(newName, true).orElseThrow(() -> new IllegalStateException("should exist"));
eventBus.postAsync(new MetacatRenameTablePostEvent(oldName, metacatRequestContext, this, oldTable, dto));
}
}
Aggregations