Search in sources :

Example 46 with ConnectorException

use of com.netflix.metacat.common.server.connectors.exception.ConnectorException in project metacat by Netflix.

the class S3ConnectorDatabaseService method delete.

@Override
public void delete(@Nonnull final ConnectorContext context, @Nonnull final QualifiedName name) {
    log.debug("Start: Delete database {}", name);
    final String databaseName = name.getDatabaseName();
    Preconditions.checkNotNull(databaseName, "Database name is null");
    final Database database = databaseDao.getBySourceDatabaseName(catalogName, databaseName);
    if (database == null) {
        throw new DatabaseNotFoundException(name);
    } else if (database.getTables() != null && !database.getTables().isEmpty()) {
        throw new ConnectorException("Database " + databaseName + " is not empty. One or more tables exist.", null);
    }
    databaseDao.delete(database);
    log.debug("End: Delete database {}", name);
}
Also used : DatabaseNotFoundException(com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException) ConnectorException(com.netflix.metacat.common.server.connectors.exception.ConnectorException) Database(com.netflix.metacat.connector.s3.model.Database)

Aggregations

ConnectorException (com.netflix.metacat.common.server.connectors.exception.ConnectorException)46 InvalidMetaException (com.netflix.metacat.common.server.connectors.exception.InvalidMetaException)35 QualifiedName (com.netflix.metacat.common.QualifiedName)26 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)25 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)24 TException (org.apache.thrift.TException)24 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)20 Table (org.apache.hadoop.hive.metastore.api.Table)17 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)16 Pageable (com.netflix.metacat.common.dto.Pageable)15 DatabaseNotFoundException (com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException)15 TableAlreadyExistsException (com.netflix.metacat.common.server.connectors.exception.TableAlreadyExistsException)13 Sort (com.netflix.metacat.common.dto.Sort)12 List (java.util.List)12 Nullable (javax.annotation.Nullable)12 Lists (com.google.common.collect.Lists)11 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)11 TableInfo (com.netflix.metacat.common.server.connectors.model.TableInfo)11 ConnectorUtils (com.netflix.metacat.common.server.connectors.ConnectorUtils)10 HiveConnectorInfoConverter (com.netflix.metacat.connector.hive.converters.HiveConnectorInfoConverter)10