System.out.println("Current batch: " + batchNumber + ". Users: " + batchNumber*usersPerRoster + " - " + ((batchNumber*usersPerRoster)+usersPerRoster));
// Add rosters items between connected users
for (int i = (batchNumber * usersPerRoster) + from;
i < (batchNumber * usersPerRoster) + usersPerRoster + from; i++) {
String username = userPrefix + i;
Roster roster;
try {
roster = rosterManager.getRoster(username);
} catch (UserNotFoundException e) {
continue;
}
if (roster.getRosterItems().size() >= usersPerRoster) {
// Roster already populated. Skip it.
continue;
}
for (int j = (batchNumber * usersPerRoster) + from;
j < (batchNumber * usersPerRoster) + usersPerRoster + from; j++) {
if (i == j) {
continue;
}
try {
Roster recipientRoster = rosterManager.getRoster(userPrefix + j);
manageSub(server.createJID(userPrefix + j, null), true, Presence.Type.subscribe, roster);
manageSub(server.createJID(username, null), false, Presence.Type.subscribe, recipientRoster);
manageSub(server.createJID(userPrefix + j, null), true, Presence.Type.subscribed, roster);