Search in sources :

Example 16 with MTablePrivilege

use of org.apache.hadoop.hive.metastore.model.MTablePrivilege in project hive by apache.

the class ObjectStore method listAllMTableGrants.

@SuppressWarnings("unchecked")
public List<MTablePrivilege> listAllMTableGrants(String principalName, PrincipalType principalType, String dbName, String tableName) {
    tableName = HiveStringUtils.normalizeIdentifier(tableName);
    dbName = HiveStringUtils.normalizeIdentifier(dbName);
    boolean success = false;
    Query query = null;
    List<MTablePrivilege> mSecurityTabPartList = new ArrayList<MTablePrivilege>();
    try {
        openTransaction();
        LOG.debug("Executing listAllTableGrants");
        query = pm.newQuery(MTablePrivilege.class, "principalName == t1 && principalType == t2 && table.tableName == t3 && table.database.name == t4");
        query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3, java.lang.String t4");
        List<MTablePrivilege> mPrivs = (List<MTablePrivilege>) query.executeWithArray(principalName, principalType.toString(), tableName, dbName);
        pm.retrieveAll(mPrivs);
        success = commitTransaction();
        mSecurityTabPartList.addAll(mPrivs);
        LOG.debug("Done retrieving all objects for listAllTableGrants");
    } finally {
        if (!success) {
            rollbackTransaction();
        }
        if (query != null) {
            query.closeAll();
        }
    }
    return mSecurityTabPartList;
}
Also used : Query(javax.jdo.Query) ArrayList(java.util.ArrayList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) MTablePrivilege(org.apache.hadoop.hive.metastore.model.MTablePrivilege)

Aggregations

MTablePrivilege (org.apache.hadoop.hive.metastore.model.MTablePrivilege)16 ArrayList (java.util.ArrayList)11 MConstraint (org.apache.hadoop.hive.metastore.model.MConstraint)8 MPartitionColumnPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)7 MPartitionPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionPrivilege)7 MTableColumnPrivilege (org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege)7 LinkedList (java.util.LinkedList)6 List (java.util.List)6 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)6 MStringList (org.apache.hadoop.hive.metastore.model.MStringList)6 MTable (org.apache.hadoop.hive.metastore.model.MTable)6 Query (javax.jdo.Query)5 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)4 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)4 MPartition (org.apache.hadoop.hive.metastore.model.MPartition)4 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)3 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)3 MDBPrivilege (org.apache.hadoop.hive.metastore.model.MDBPrivilege)3 MGlobalPrivilege (org.apache.hadoop.hive.metastore.model.MGlobalPrivilege)3 InvalidObjectException (org.apache.hadoop.hive.metastore.api.InvalidObjectException)2