Search in sources :

Example 41 with PrivilegeGrantInfo

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

the class ObjectStore method listPrincipalPartitionColumnGrants.

@Override
public List<HiveObjectPrivilege> listPrincipalPartitionColumnGrants(String principalName, PrincipalType principalType, String dbName, String tableName, List<String> partValues, String partitionName, String columnName) {
    List<MPartitionColumnPrivilege> mPartitionCols = listPrincipalMPartitionColumnGrants(principalName, principalType, dbName, tableName, partitionName, columnName);
    if (mPartitionCols.isEmpty()) {
        return Collections.emptyList();
    }
    List<HiveObjectPrivilege> result = new ArrayList<>();
    for (int i = 0; i < mPartitionCols.size(); i++) {
        MPartitionColumnPrivilege sCol = mPartitionCols.get(i);
        HiveObjectRef objectRef = new HiveObjectRef(HiveObjectType.COLUMN, dbName, tableName, partValues, sCol.getColumnName());
        HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef, sCol.getPrincipalName(), principalType, new PrivilegeGrantInfo(sCol.getPrivilege(), sCol.getCreateTime(), sCol.getGrantor(), PrincipalType.valueOf(sCol.getGrantorType()), sCol.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) MPartitionColumnPrivilege(org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege) 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 42 with PrivilegeGrantInfo

use of org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo 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 PrivilegeGrantInfo

use of org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo 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 44 with PrivilegeGrantInfo

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

the class ObjectStore method getPartitionPrivilege.

private List<PrivilegeGrantInfo> getPartitionPrivilege(String dbName, String tableName, String partName, String principalName, PrincipalType principalType) {
    tableName = normalizeIdentifier(tableName);
    dbName = normalizeIdentifier(dbName);
    if (principalName != null) {
        List<MPartitionPrivilege> userNameTabPartPriv = this.listPrincipalMPartitionGrants(principalName, principalType, dbName, tableName, partName);
        if (CollectionUtils.isNotEmpty(userNameTabPartPriv)) {
            List<PrivilegeGrantInfo> grantInfos = new ArrayList<>(userNameTabPartPriv.size());
            for (int i = 0; i < userNameTabPartPriv.size(); i++) {
                MPartitionPrivilege item = userNameTabPartPriv.get(i);
                grantInfos.add(new PrivilegeGrantInfo(item.getPrivilege(), item.getCreateTime(), item.getGrantor(), getPrincipalTypeFromStr(item.getGrantorType()), item.getGrantOption()));
            }
            return grantInfos;
        }
    }
    return new ArrayList<>(0);
}
Also used : PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) 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 PrivilegeGrantInfo

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

the class ObjectStore method getDBPrivilege.

public List<PrivilegeGrantInfo> getDBPrivilege(String dbName, String principalName, PrincipalType principalType) throws InvalidObjectException, MetaException {
    dbName = normalizeIdentifier(dbName);
    if (principalName != null) {
        List<MDBPrivilege> userNameDbPriv = this.listPrincipalMDBGrants(principalName, principalType, dbName);
        if (CollectionUtils.isNotEmpty(userNameDbPriv)) {
            List<PrivilegeGrantInfo> grantInfos = new ArrayList<>(userNameDbPriv.size());
            for (int i = 0; i < userNameDbPriv.size(); i++) {
                MDBPrivilege item = userNameDbPriv.get(i);
                grantInfos.add(new PrivilegeGrantInfo(item.getPrivilege(), item.getCreateTime(), item.getGrantor(), getPrincipalTypeFromStr(item.getGrantorType()), item.getGrantOption()));
            }
            return grantInfos;
        }
    }
    return new ArrayList<>(0);
}
Also used : PrivilegeGrantInfo(org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo) ArrayList(java.util.ArrayList) MDBPrivilege(org.apache.hadoop.hive.metastore.model.MDBPrivilege) 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)

Aggregations

PrivilegeGrantInfo (org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo)45 ArrayList (java.util.ArrayList)39 HiveObjectPrivilege (org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege)31 HiveObjectRef (org.apache.hadoop.hive.metastore.api.HiveObjectRef)29 PrincipalPrivilegeSet (org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet)13 IOException (java.io.IOException)12 List (java.util.List)12 SQLCheckConstraint (org.apache.hadoop.hive.metastore.api.SQLCheckConstraint)12 SQLDefaultConstraint (org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint)12 SQLNotNullConstraint (org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint)12 SQLUniqueConstraint (org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint)12 MConstraint (org.apache.hadoop.hive.metastore.model.MConstraint)12 LinkedList (java.util.LinkedList)11 Database (org.apache.hadoop.hive.metastore.api.Database)8 PrincipalType (org.apache.hadoop.hive.metastore.api.PrincipalType)8 PrivilegeBag (org.apache.hadoop.hive.metastore.api.PrivilegeBag)7 HashMap (java.util.HashMap)6 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)6 Table (org.apache.hadoop.hive.metastore.api.Table)6 Role (org.apache.hadoop.hive.metastore.api.Role)5