return 1;
}
String dbName = null;
String tableName = null;
Table tableObj = null;
Database dbObj = null;
try {
if (privSubjectDesc != null) {
if (privSubjectDesc.getPartSpec() != null && isGrant) {
throw new HiveException("Grant does not support partition level.");
}
String obj = privSubjectDesc.getObject();
boolean notFound = true;
if (privSubjectDesc.getTable()) {
String[] dbTab = obj.split("\\.");
if (dbTab.length == 2) {
dbName = dbTab[0];
tableName = dbTab[1];
} else {
dbName = db.getCurrentDatabase();
tableName = obj;
}
dbObj = db.getDatabase(dbName);
tableObj = db.getTable(dbName, tableName);
notFound = (dbObj == null || tableObj == null);
} else {
dbName = privSubjectDesc.getObject();
dbObj = db.getDatabase(dbName);
notFound = (dbObj == null);
}
if (notFound) {
throw new HiveException(obj + " can not be found");
}
}
PrivilegeBag privBag = new PrivilegeBag();
if (privSubjectDesc == null) {
for (int idx = 0; idx < privileges.size(); idx++) {
Privilege priv = privileges.get(idx).getPrivilege();
if (privileges.get(idx).getColumns() != null
&& privileges.get(idx).getColumns().size() > 0) {
throw new HiveException(
"For user-level privileges, column sets should be null. columns="
+ privileges.get(idx).getColumns().toString());
}
privBag.addToPrivileges(new HiveObjectPrivilege(new HiveObjectRef(
HiveObjectType.GLOBAL, null, null, null, null), null, null,
new PrivilegeGrantInfo(priv.getPriv(), 0, grantor, grantorType,
grantOption)));
}
} else {
org.apache.hadoop.hive.metastore.api.Partition partObj = null;
List<String> partValues = null;
if (tableObj != null) {
if ((!tableObj.isPartitioned())
&& privSubjectDesc.getPartSpec() != null) {
throw new HiveException(
"Table is not partitioned, but partition name is present: partSpec="
+ privSubjectDesc.getPartSpec().toString());
}