use of com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent in project metacat by Netflix.
the class MetacatServiceHelper method postPreDeleteEvent.
/**
* Calls the right method of the event bus for the given qualified name.
*
* @param name name
* @param metacatRequestContext context
*/
public void postPreDeleteEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext) {
if (name.isPartitionDefinition()) {
final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
partitionsSaveRequestDto.setPartitionIdsForDeletes(Lists.newArrayList(name.getPartitionName()));
this.eventBus.post(new MetacatDeleteTablePartitionPreEvent(name, metacatRequestContext, this, partitionsSaveRequestDto));
} else if (name.isViewDefinition()) {
this.eventBus.post(new MetacatDeleteMViewPreEvent(name, metacatRequestContext, this));
} else if (name.isTableDefinition()) {
this.eventBus.post(new MetacatDeleteTablePreEvent(name, metacatRequestContext, this));
} else if (name.isDatabaseDefinition()) {
final DatabaseDto dto = new DatabaseDto();
dto.setName(name);
eventBus.post(new MetacatDeleteDatabasePreEvent(name, metacatRequestContext, this, dto));
} else {
throw new IllegalArgumentException(String.format("Invalid name %s", name));
}
}
use of com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent in project metacat by Netflix.
the class DatabaseServiceImpl method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(final QualifiedName name) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
this.authorizationService.checkPermission(metacatRequestContext.getUserName(), name, MetacatOperation.DELETE);
log.info("Dropping schema {}", name);
final DatabaseDto dto = get(name, GetDatabaseServiceParameters.builder().disableOnReadMetadataIntercetor(false).includeUserMetadata(true).includeTableNames(true).build());
eventBus.post(new MetacatDeleteDatabasePreEvent(name, metacatRequestContext, this, dto));
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorManager.getDatabaseService(name).delete(connectorRequestContext, name);
// Delete definition metadata if it exists
if (userMetadataService.getDefinitionMetadata(name).isPresent()) {
log.info("Deleting user metadata for schema {}", name);
userMetadataService.deleteDefinitionMetadata(ImmutableList.of(name));
}
eventBus.post(new MetacatDeleteDatabasePostEvent(name, metacatRequestContext, this, dto));
}
Aggregations