Package org.jivesoftware.openfire.roster

Examples of org.jivesoftware.openfire.roster.RosterItem


    }


    private boolean manageSub(JID target, boolean isSending, Presence.Type type, Roster roster)
            throws UserAlreadyExistsException, SharedGroupException {
        RosterItem item = null;
        RosterItem.AskType oldAsk;
        RosterItem.SubType oldSub = null;
        RosterItem.RecvType oldRecv;
        boolean newItem = false;
        try {
            if (roster.isRosterItem(target)) {
                item = roster.getRosterItem(target);
            } else {
                if (Presence.Type.unsubscribed == type || Presence.Type.unsubscribe == type ||
                        Presence.Type.subscribed == type) {
                    // Do not create a roster item when processing a confirmation of
                    // an unsubscription or receiving an unsubscription request or a
                    // subscription approval from an unknown user
                    return false;
                }
                item = roster.createRosterItem(target, false, true);
                item.setGroups(Arrays.asList("Friends"));
                roster.updateRosterItem(item);
                newItem = true;
            }
            // Get a snapshot of the item state
            oldAsk = item.getAskStatus();
            oldSub = item.getSubStatus();
            oldRecv = item.getRecvStatus();
            // Update the item state based in the received presence type
            updateState(item, type, isSending);
            // Update the roster IF the item state has changed
            if (oldAsk != item.getAskStatus() || oldSub != item.getSubStatus() ||
                    oldRecv != item.getRecvStatus()) {
                roster.updateRosterItem(item);
            } else if (newItem) {
                // Do not push items with a state of "None + Pending In"
                if (item.getSubStatus() != RosterItem.SUB_NONE ||
                        item.getRecvStatus() != RosterItem.RECV_SUBSCRIBE) {
                    roster.broadcast(item, false);
                }
            }
        }
        catch (UserNotFoundException e) {
            // Should be there because we just checked that it's an item
            Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
        }
        return oldSub != item.getSubStatus();
    }
View Full Code Here


     *         is not present in the roster of the probee.
     */
    private boolean canProbePresence(JID prober, JID probee) throws UserNotFoundException {
        Roster roster;
        roster = XMPPServer.getInstance().getRosterManager().getRoster(prober.getNode());
        RosterItem item = roster.getRosterItem(probee);

        if (item.getSubStatus() == RosterItem.SUB_BOTH || item.getSubStatus() == RosterItem.SUB_FROM) {
            return true;
        }

        return false;
    }
View Full Code Here

        XMPPServer server = XMPPServer.getInstance();
        // Check that the node owner is a local user
        if (server.isLocal(nodeOwner)) {
            try {
                Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
                RosterItem item = roster.getRosterItem(owner);
                // Check that the subscriber is subscribe to the node owner's presence
                boolean isSubscribed = item != null && (
                        RosterItem.SUB_BOTH == item.getSubStatus() ||
                                RosterItem.SUB_FROM == item.getSubStatus());
                if (isSubscribed) {
                    // Get list of groups where the contact belongs
                    List<String> contactGroups = new ArrayList<String>(item.getGroups());
                    for (Group group : item.getSharedGroups()) {
                        contactGroups.add(group.getName());
                    }
                    for (Group group : item.getInvisibleSharedGroups()) {
                        contactGroups.add(group.getName());
                    }
                    // Check if subscriber is present in the allowed groups of the node
                    return contactGroups.removeAll(node.getRosterGroupsAllowed());
                }
View Full Code Here

        XMPPServer server = XMPPServer.getInstance();
        // Check that the node owner is a local user
        if (server.isLocal(nodeOwner)) {
            try {
                Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
                RosterItem item = roster.getRosterItem(owner);
                // Check that the subscriber is subscribe to the node owner's presence
                return item != null && (RosterItem.SUB_BOTH == item.getSubStatus() ||
                        RosterItem.SUB_FROM == item.getSubStatus());
            }
            catch (UserNotFoundException e) {
                return false;
            }
        }
View Full Code Here

        }
        else if (type == Type.group) {
            Collection<String> contactGroups;
            try {
                // Get the groups where the contact belongs
                RosterItem item = roster.getRosterItem(jid);
                contactGroups = item.getGroups();
            }
            catch (UserNotFoundException e) {
                // Sender is not in the user's roster
                contactGroups = Collections.emptyList();
            }
            // Check if the contact belongs to the specified group
            return contactGroups.contains(groupValue);
        }
        else {
            RosterItem.SubType contactSubscription = RosterItem.SUB_NONE;
            try {
                // Get the groups where the contact belongs
                RosterItem item = roster.getRosterItem(jid);
                contactSubscription = item.getSubStatus();
            }
            catch (UserNotFoundException e) {
                // Sender is not in the user's roster
            }
            // Check if the contact has the specified subscription status
View Full Code Here

      return false;

    Roster roster =XMPPServer.getInstance().getRosterManager().getRoster(new JID(owner).getNode());
    // Get the roster entry that match the viewer, this is only
    // used for the groups based matches
    RosterItem rosterItem = null;
    try {
      rosterItem = roster.getRosterItem(new JID(viewer));
    } catch (UserNotFoundException e) {
    }

    // Iterate through the subjects and hope for the best
    for (AclSubject aclSubject : subjects) {
      if (aclSubject.getType().equals(AclSubject.EVERYONE)) {
        return true;
      } else if (aclSubject.getType().equals(AclSubject.GROUP)) {
        if (rosterItem != null && rosterItem.getGroups().contains(aclSubject.getName())) {
          return true;
        }
      } else if (aclSubject.getType().equals(AclSubject.PERSON)) {
        if (viewer.equals(aclSubject.getName())) {
          return true;
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) {
    }

    return new ArrayList<String>();
View Full Code Here

TOP

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

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.