table.flushCommits();
rm.putTable(table);
}
public User getUser(String username) throws IOException {
User user = null;
HTable table = null;
try {
table = rm.getTable(UserTable.NAME);
Get get = new Get(Bytes.toBytes(username));
Result result = table.get(get);
if (result.isEmpty()) {
return null;
}
String firstName = Bytes.toString(
result.getValue(UserTable.DATA_FAMILY, UserTable.FIRSTNAME));
String lastName = Bytes.toString(
result.getValue(UserTable.DATA_FAMILY, UserTable.LASTNAME));
String email = Bytes.toString(result.getValue(UserTable.DATA_FAMILY,
UserTable.EMAIL));
String credentials = Bytes.toString(result.getValue(UserTable.DATA_FAMILY,
UserTable.CREDENTIALS));
String roles = Bytes.toString(result.getValue(UserTable.DATA_FAMILY,
UserTable.ROLES));
user = new User(username, firstName, lastName, email, credentials, roles);
} catch (Exception e) {
LOG.error(String.format("Unable to get user '%s'", username), e);
} finally {
rm.putTable(table);
}