use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class DatabaseServiceImpl method create.
/**
* {@inheritDoc}
*/
@Override
public DatabaseDto create(final QualifiedName name, final DatabaseDto dto) {
validate(name);
log.info("Creating schema {}", name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
eventBus.postSync(new MetacatCreateDatabasePreEvent(name, metacatRequestContext, this));
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorManager.getDatabaseService(name).create(connectorRequestContext, converterUtil.fromDatabaseDto(dto));
if (dto.getDefinitionMetadata() != null) {
log.info("Saving user metadata for schema {}", name);
userMetadataService.saveDefinitionMetadata(name, metacatRequestContext.getUserName(), Optional.of(dto.getDefinitionMetadata()), true);
}
final DatabaseDto createdDto = get(name, GetDatabaseServiceParameters.builder().disableOnReadMetadataIntercetor(true).includeUserMetadata(dto.getDefinitionMetadata() != null).includeTableNames(true).build());
eventBus.postAsync(new MetacatCreateDatabasePostEvent(name, metacatRequestContext, this, createdDto));
return createdDto;
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class DatabaseServiceImpl method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(final QualifiedName name) {
validate(name);
log.info("Dropping schema {}", name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final DatabaseDto dto = get(name, GetDatabaseServiceParameters.builder().disableOnReadMetadataIntercetor(false).includeUserMetadata(true).includeTableNames(true).build());
eventBus.postSync(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.postAsync(new MetacatDeleteDatabasePostEvent(name, metacatRequestContext, this, dto));
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class CatalogThriftHiveMetastore method get_database.
/**
* {@inheritDoc}
*/
@Override
public Database get_database(final String name) throws TException {
return requestWrapper("get_database", new Object[] { name }, () -> {
final String databaseName = normalizeIdentifier(name);
final DatabaseDto dto = v1.getDatabase(catalogName, databaseName, true, false);
return hiveConverters.metacatToHiveDatabase(dto);
});
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class MetacatController method updateDatabase.
/**
* Updates the given database in the given catalog.
*
* @param catalogName catalog name.
* @param databaseName database name.
* @param databaseUpdateRequestDto database
*/
@RequestMapping(method = RequestMethod.PUT, path = "/catalog/{catalog-name}/database/{database-name}", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiOperation(position = 3, value = "Updates the given database in the given catalog", notes = "Given a catalog and a database name, updates the database in the catalog")
@ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Database successfully updated"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested catalog or database cannot be located") })
public void updateDatabase(@ApiParam(value = "The name of the catalog", required = true) @PathVariable("catalog-name") final String catalogName, @ApiParam(value = "The name of the database", required = true) @PathVariable("database-name") final String databaseName, @ApiParam(value = "The database information", required = true) @RequestBody final DatabaseCreateRequestDto databaseUpdateRequestDto) {
final QualifiedName name = this.requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
this.requestWrapper.processRequest(name, "updateDatabase", () -> {
final DatabaseDto newDto = new DatabaseDto();
newDto.setName(name);
newDto.setDefinitionMetadata(databaseUpdateRequestDto.getDefinitionMetadata());
this.databaseService.update(name, newDto);
return null;
});
}
Aggregations