public void addRosterToUsers() { String tmpUser = ""; JID innerTmpUser; Collection c = conn.getUsernames(); for (Object o : c) { tmpUser = (String)o; if (tmpUser.equals("admin")) continue; System.out.println("--> Processing roster for user "+ tmpUser); Roster r = new Roster(tmpUser); for (Object inner_o : c) { innerTmpUser = new JID((String)inner_o,"@wonderlight", "Spark"); System.out.println(tmpUser + ": Adding user " + innerTmpUser.toString()); try { r.createRosterItem(innerTmpUser, true, true); } catch (UserAlreadyExistsException uae) { System.out.println("Unable to add "+ innerTmpUser.toString() +" to roster. User already exists."); } catch (SharedGroupException sge) { System.out.println("Unable to add "+ innerTmpUser.toString() +" to roster. Shared user group exception."); } } } }