List<String> lst = new LinkedList<String>();
dbConnection = getDBConnection();
if (dbConnection == null) {
throw new UserStoreException("null connection");
}
dbConnection.setAutoCommit(false);
dbConnection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
sqlStmt = realmConfig.getUserStoreProperty(JDBCRealmConstants.GET_USER_FILTER);
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setString(1, filter);
if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
prepStmt.setInt(2, tenantId);
}
rs = prepStmt.executeQuery();
while (rs.next()) {
if (i < maxItemLimit) {
String name = rs.getString(1);
if(CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(name)){
continue;
}
lst.add(name);
} else {
break;
}
i++;
}
rs.close();
if (lst.size() > 0) {
users = (String[]) lst.toArray(new String[lst.size()]);
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
log.error("Using sql : " + sqlStmt);
throw new UserStoreException(e.getMessage(), e);
} finally {
DatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt);
}
return users;