Package org.jivesoftware.openfire.roster

Examples of org.jivesoftware.openfire.roster.RosterManager


                // Those who already have presence subscriptions to jidFrom
          // will now automatically be subscribed to this new
          // PEPService.
          try {
            final RosterManager rm = XMPPServer.getInstance()
                .getRosterManager();
            final Roster roster = rm.getRoster(senderJID.getNode());
            for (final RosterItem item : roster.getRosterItems()) {
              if (item.getSubStatus() == RosterItem.SUB_BOTH
                  || item.getSubStatus() == RosterItem.SUB_FROM) {
                createSubscriptionToPEPService(pepService, item
                    .getJid(), senderJID);
View Full Code Here


        System.out.println("Accounts created successfully: " + created);
    }

    public void populateRosters(String userPrefix, int from, int total, int usersPerRoster) {
        XMPPServer server = XMPPServer.getInstance();
        RosterManager rosterManager = server.getRosterManager();


        int batchTotal = total / usersPerRoster;
        System.out.println("Total batches of users: " + batchTotal);
        for (int batchNumber = 0; batchNumber < batchTotal; batchNumber++) {

            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);
View Full Code Here

    }     
   
  }
 
  private List<String> getGroups(String ownerJID, String userJID) {
    RosterManager rosterManager = XMPPServer.getInstance().getRosterManager();
    Roster roster;
    try {
      roster = rosterManager.getRoster(new JID(ownerJID).getNode());
      RosterItem rosterItem = roster.getRosterItem(new JID(userJID));
      if (rosterItem != null) {
        return rosterItem.getGroups();
      }
    } catch (UserNotFoundException e) {
View Full Code Here

TOP

Related Classes of org.jivesoftware.openfire.roster.RosterManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.