use of org.apache.hadoop.hive.metastore.model.MDBPrivilege in project hive by apache.
the class ObjectStore method listPrincipalAllDBGrant.
private List<MDBPrivilege> listPrincipalAllDBGrant(String principalName, PrincipalType principalType) throws Exception {
final List<MDBPrivilege> mSecurityDBList;
LOG.debug("Executing listPrincipalAllDBGrant");
Preconditions.checkState(this.currentTransaction.isActive());
if (principalName != null && principalType != null) {
try (Query query = pm.newQuery(MDBPrivilege.class, "principalName == t1 && principalType == t2")) {
query.declareParameters("java.lang.String t1, java.lang.String t2");
mSecurityDBList = (List<MDBPrivilege>) query.execute(principalName, principalType.toString());
pm.retrieveAll(mSecurityDBList);
LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant: {}", mSecurityDBList);
return Collections.unmodifiableList(new ArrayList<>(mSecurityDBList));
}
} else {
try (Query query = pm.newQuery(MDBPrivilege.class)) {
mSecurityDBList = (List<MDBPrivilege>) query.execute();
pm.retrieveAll(mSecurityDBList);
LOG.debug("Done retrieving all objects for listPrincipalAllDBGrant: {}", mSecurityDBList);
return Collections.unmodifiableList(new ArrayList<>(mSecurityDBList));
}
}
}
use of org.apache.hadoop.hive.metastore.model.MDBPrivilege in project hive by apache.
the class ObjectStore method dropDatabase.
@Override
public boolean dropDatabase(String catName, String dbname) throws NoSuchObjectException, MetaException {
boolean success = false;
LOG.info("Dropping database {}.{} along with all tables", catName, dbname);
dbname = normalizeIdentifier(dbname);
catName = normalizeIdentifier(catName);
try {
openTransaction();
// then drop the database
MDatabase db = getMDatabase(catName, dbname);
pm.retrieve(db);
List<MDBPrivilege> dbGrants = this.listDatabaseGrants(catName, dbname, null);
if (CollectionUtils.isNotEmpty(dbGrants)) {
pm.deletePersistentAll(dbGrants);
}
pm.deletePersistent(db);
success = commitTransaction();
} catch (Exception e) {
throw new MetaException(e.getMessage() + " " + org.apache.hadoop.hive.metastore.utils.StringUtils.stringifyException(e));
} finally {
rollbackAndCleanup(success, null);
}
return success;
}
Aggregations