{
// Check for realm conflicts with specified alias
final Slot<Boolean> found = new Slot<Boolean>(false);
if (alias!=null) {
// check realm against alias
DBConnection connection = getConnection();
try {
connection.query(REALM_USER_BY_ALIAS, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,realm.getId());
s.setString(2,alias);
}
public void onResults(ResultSet set)
throws SQLException
{
found.set(set.next());
}
});
if (found.get()) {
return false;
}
// check inherited aliases
connection.query(REALM_USER_HAS_INHERITED_ALIAS, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,realm.getId());
s.setString(2,alias);
}
public void onResults(ResultSet set)
throws SQLException
{
found.set(set.next());
}
});
if (found.get()) {
return false;
}
} finally {
release(connection);
}
}
//
if (alias==null) {
// Check inherited alias against local aliases
DBConnection connection = getConnection();
try {
connection.query(REALM_USER_BY_ALIAS, new DBQueryHandler() {
public void prepare(PreparedStatement s)
throws SQLException
{
s.setInt(1,realm.getId());
s.setString(2,user.getAlias());