use of org.apache.hadoop.hive.metastore.model.MRole in project hive by apache.
the class ObjectStore method listMRoles.
public List<MRoleMap> listMRoles(String principalName, PrincipalType principalType) {
boolean success = false;
Query query = null;
List<MRoleMap> mRoleMember = new ArrayList<>();
try {
LOG.debug("Executing listRoles");
openTransaction();
query = pm.newQuery(MRoleMap.class, "principalName == t1 && principalType == t2");
query.declareParameters("java.lang.String t1, java.lang.String t2");
query.setUnique(false);
List<MRoleMap> mRoles = (List<MRoleMap>) query.executeWithArray(principalName, principalType.toString());
pm.retrieveAll(mRoles);
success = commitTransaction();
mRoleMember.addAll(mRoles);
LOG.debug("Done retrieving all objects for listRoles");
} finally {
rollbackAndCleanup(success, query);
}
if (principalType == PrincipalType.USER) {
// All users belong to public role implicitly, add that role
// TODO MS-SPLIT Change this back to HMSHandler.PUBLIC once HiveMetaStore has moved to
// stand-alone metastore.
// MRole publicRole = new MRole(HMSHandler.PUBLIC, 0, HMSHandler.PUBLIC);
MRole publicRole = new MRole("public", 0, "public");
mRoleMember.add(new MRoleMap(principalName, principalType.toString(), publicRole, 0, null, null, false));
}
return mRoleMember;
}
use of org.apache.hadoop.hive.metastore.model.MRole in project hive by apache.
the class ObjectStore method getMRole.
private MRole getMRole(String roleName) {
MRole mrole = null;
boolean commited = false;
Query query = null;
try {
openTransaction();
query = pm.newQuery(MRole.class, "roleName == t1");
query.declareParameters("java.lang.String t1");
query.setUnique(true);
mrole = (MRole) query.execute(roleName);
pm.retrieve(mrole);
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
}
return mrole;
}
Aggregations