Search in sources :

Example 41 with HiveObjectPrivilege

use of org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege in project hive by apache.

the class ObjectStore method listPartitionColumnGrantsAll.

@Override
public List<HiveObjectPrivilege> listPartitionColumnGrantsAll(String dbName, String tableName, String partitionName, String columnName) {
    boolean success = false;
    Query query = null;
    try {
        openTransaction();
        LOG.debug("Executing listPartitionColumnGrantsAll");
        query = pm.newQuery(MPartitionColumnPrivilege.class, "partition.table.tableName == t3 && partition.table.database.name == t4 && " + "partition.partitionName == t5 && columnName == t6");
        query.declareParameters("java.lang.String t3, java.lang.String t4, java.lang.String t5, java.lang.String t6");
        List<MPartitionColumnPrivilege> mSecurityTabPartList = (List<MPartitionColumnPrivilege>) query.executeWithArray(tableName, dbName, partitionName, columnName);
        LOG.debug("Done executing query for listPartitionColumnGrantsAll");
        pm.retrieveAll(mSecurityTabPartList);
        List<HiveObjectPrivilege> result = convertPartCols(mSecurityTabPartList);
        success = commitTransaction();
        LOG.debug("Done retrieving all objects for listPartitionColumnGrantsAll");
        return result;
    } finally {
        rollbackAndCleanup(success, query);
    }
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) Query(javax.jdo.Query) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List) MPartitionColumnPrivilege(org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)

Example 42 with HiveObjectPrivilege

use of org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege in project hive by apache.

the class ObjectStore method listAllTableGrants.

@Override
public List<HiveObjectPrivilege> listAllTableGrants(String principalName, PrincipalType principalType, String dbName, String tableName) {
    List<MTablePrivilege> mTbls = listAllMTableGrants(principalName, principalType, dbName, tableName);
    if (mTbls.isEmpty()) {
        return Collections.emptyList();
    }
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (int i = 0; i < mTbls.size(); i++) {
        MTablePrivilege sTbl = mTbls.get(i);
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.TABLE, dbName, tableName, null, null);
        HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef, sTbl.getPrincipalName(), principalType, new PrivilegeGrantInfo(sTbl.getPrivilege(), sTbl.getCreateTime(), sTbl.getGrantor(), PrincipalType.valueOf(sTbl.getGrantorType()), sTbl.getGrantOption()));
        result.add(secObj);
    }
    return result;
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) ArrayList(java.util.ArrayList) MTablePrivilege(org.apache.hadoop.hive.metastore.model.MTablePrivilege) MConstraint(org.apache.hadoop.hive.metastore.model.MConstraint) SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) SQLDefaultConstraint(org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint) SQLNotNullConstraint(org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)

Example 43 with HiveObjectPrivilege

use of org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege in project hive by apache.

the class ObjectStore method listTableColumnGrantsAll.

@Override
public List<HiveObjectPrivilege> listTableColumnGrantsAll(String dbName, String tableName, String columnName) {
    boolean success = false;
    Query query = null;
    dbName = normalizeIdentifier(dbName);
    tableName = normalizeIdentifier(tableName);
    try {
        openTransaction();
        LOG.debug("Executing listPrincipalTableColumnGrantsAll");
        query = pm.newQuery(MTableColumnPrivilege.class, "table.tableName == t3 && table.database.name == t4 &&  columnName == t5");
        query.declareParameters("java.lang.String t3, java.lang.String t4, java.lang.String t5");
        List<MTableColumnPrivilege> mSecurityTabPartList = (List<MTableColumnPrivilege>) query.executeWithArray(tableName, dbName, columnName);
        LOG.debug("Done executing query for listPrincipalTableColumnGrantsAll");
        pm.retrieveAll(mSecurityTabPartList);
        List<HiveObjectPrivilege> result = convertTableCols(mSecurityTabPartList);
        success = commitTransaction();
        LOG.debug("Done retrieving all objects for listPrincipalTableColumnGrantsAll");
        return result;
    } finally {
        rollbackAndCleanup(success, query);
    }
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) Query(javax.jdo.Query) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) List(java.util.List) MTableColumnPrivilege(org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege)

Example 44 with HiveObjectPrivilege

use of org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege in project hive by apache.

the class ObjectStore method listPrincipalPartitionGrants.

@Override
public List<HiveObjectPrivilege> listPrincipalPartitionGrants(String principalName, PrincipalType principalType, String dbName, String tableName, List<String> partValues, String partName) {
    List<MPartitionPrivilege> mParts = listPrincipalMPartitionGrants(principalName, principalType, dbName, tableName, partName);
    if (mParts.isEmpty()) {
        return Collections.emptyList();
    }
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (int i = 0; i < mParts.size(); i++) {
        MPartitionPrivilege sPart = mParts.get(i);
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.PARTITION, dbName, tableName, partValues, null);
        HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef, sPart.getPrincipalName(), principalType, new PrivilegeGrantInfo(sPart.getPrivilege(), sPart.getCreateTime(), sPart.getGrantor(), PrincipalType.valueOf(sPart.getGrantorType()), sPart.getGrantOption()));
        result.add(secObj);
    }
    return result;
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) HiveObjectRef(org.apache.hadoop.hive.metastore.api.HiveObjectRef) MPartitionPrivilege(org.apache.hadoop.hive.metastore.model.MPartitionPrivilege) ArrayList(java.util.ArrayList) MConstraint(org.apache.hadoop.hive.metastore.model.MConstraint) SQLUniqueConstraint(org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint) SQLCheckConstraint(org.apache.hadoop.hive.metastore.api.SQLCheckConstraint) SQLDefaultConstraint(org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint) SQLNotNullConstraint(org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)

Example 45 with HiveObjectPrivilege

use of org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege in project hive by apache.

the class ObjectStore method listPrincipalTableColumnGrantsAll.

@Override
public List<HiveObjectPrivilege> listPrincipalTableColumnGrantsAll(String principalName, PrincipalType principalType) {
    boolean success = false;
    Query query = null;
    try {
        openTransaction();
        LOG.debug("Executing listPrincipalTableColumnGrantsAll");
        List<MTableColumnPrivilege> mSecurityTabPartList;
        if (principalName != null && principalType != null) {
            query = pm.newQuery(MTableColumnPrivilege.class, "principalName == t1 && principalType == t2");
            query.declareParameters("java.lang.String t1, java.lang.String t2");
            mSecurityTabPartList = (List<MTableColumnPrivilege>) query.execute(principalName, principalType.toString());
        } else {
            query = pm.newQuery(MTableColumnPrivilege.class);
            mSecurityTabPartList = (List<MTableColumnPrivilege>) query.execute();
        }
        LOG.debug("Done executing query for listPrincipalTableColumnGrantsAll");
        pm.retrieveAll(mSecurityTabPartList);
        List<HiveObjectPrivilege> result = convertTableCols(mSecurityTabPartList);
        success = commitTransaction();
        LOG.debug("Done retrieving all objects for listPrincipalTableColumnGrantsAll");
        return result;
    } finally {
        rollbackAndCleanup(success, query);
    }
}
Also used : HiveObjectPrivilege(org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege) Query(javax.jdo.Query) MTableColumnPrivilege(org.apache.hadoop.hive.metastore.model.MTableColumnPrivilege)

Aggregations

HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)45 ArrayList (java.util.ArrayList)35 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)31 PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)31 List (java.util.List)16 LinkedList (java.util.LinkedList)14 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)12 PrincipalPrivilegeSet (org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet)9 IOException (java.io.IOException)8 Query (javax.jdo.Query)8 Database (org.apache.hadoop.hive.metastore.api.Database)8 PrivilegeBag (org.apache.hadoop.hive.metastore.api.PrivilegeBag)8 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)7 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)7 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)7 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)7 MConstraint (org.apache.hadoop.hive.metastore.model.MConstraint)7 Table (org.apache.hadoop.hive.metastore.api.Table)6 MPartitionColumnPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege)6 MPartitionPrivilege (org.apache.hadoop.hive.metastore.model.MPartitionPrivilege)6