• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RosterItem类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.jivesoftware.openfire.roster.RosterItem的典型用法代码示例。如果您正苦于以下问题:Java RosterItem类的具体用法?Java RosterItem怎么用?Java RosterItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RosterItem类属于org.jivesoftware.openfire.roster包,在下文中一共展示了RosterItem类的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public void run() {
    // Send the last published items for the contacts on availableSessionJID's roster.
    try {
        final XMPPServer server = XMPPServer.getInstance();
        final Roster roster = server.getRosterManager().getRoster(availableSessionJID.getNode());
        for (final RosterItem item : roster.getRosterItems()) {
            if (server.isLocal(item.getJid()) && (item.getSubStatus() == RosterItem.SUB_BOTH ||
                    item.getSubStatus() == RosterItem.SUB_TO)) {
                PEPService pepService = pepServiceManager.getPEPService(item.getJid().toBareJID());
                if (pepService != null) {
                    pepService.sendLastPublishedItems(availableSessionJID);
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        // Do nothing
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:21,
代码来源:IQPEPHandler.java

示例2: getUserItems

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public Iterator<Element> getUserItems(String name, JID senderJID) {
    List<Element> answer = new ArrayList<>();
    try {
        User user = UserManager.getInstance().getUser(name);
        RosterItem item = user.getRoster().getRosterItem(senderJID);
        // If the requesting entity is subscribed to the account's presence then
        // answer the user's "available resources"
        if (item.getSubStatus() == RosterItem.SUB_FROM ||
                item.getSubStatus() == RosterItem.SUB_BOTH) {
            for (Session session : SessionManager.getInstance().getSessions(name)) {
                Element element = DocumentHelper.createElement("item");
                element.addAttribute("jid", session.getAddress().toString());
                answer.add(element);
            }
        }
        return answer.iterator();
    }
    catch (UserNotFoundException e) {
        return answer.iterator();
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:23,
代码来源:IQDiscoItemsHandler.java

示例3: completedPendingContactAdd

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Completes the addition of groups to a new contact after the contact has been created.
 *
 * @param msnContact Contact that was added.
 */
public void completedPendingContactAdd(MsnContact msnContact) {
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        Email contact = msnContact.getEmail();
        JID contactJID = getTransport().convertIDToJID(contact.toString());
        RosterItem item = roster.getRosterItem(contactJID);

        getBuddyManager().storeBuddy(new MSNBuddy(getBuddyManager(), msnContact));

        syncContactGroups(contact, item.getGroups());
    }
    catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pendingcontact for "+getJID());
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:21,
代码来源:MSNSession.java

示例4: completedPendingGroupAdd

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Completes the addition of a contact to a new group after the group has been created.
 *
 * @param msnGroup Group that was added.
 */
public void completedPendingGroupAdd(MsnGroup msnGroup) {
    if (!msnPendingGroups.containsKey(msnGroup.getGroupName())) {
        // Nothing to do, no pending.
        return;
    }
    try {
        Roster roster = getTransport().getRosterManager().getRoster(getJID().getNode());
        for (Email contact : msnPendingGroups.get(msnGroup.getGroupName())) {
            JID contactJID = getTransport().convertIDToJID(contact.toString());
            RosterItem item = roster.getRosterItem(contactJID);
            syncContactGroups(contact, item.getGroups());
        }
    }
    catch (UserNotFoundException e) {
        Log.debug("MSN: Unable to find roster when adding pending group contacts for "+getJID());
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:23,
代码来源:MSNSession.java

示例5: handleIQget

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
private void handleIQget(IQ myPacket, String subdomain, String username) {
    if (JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)) {
        Roster roster;
        try {
            roster = _rosterManager.getRoster(username);
            Collection<RosterItem> items = roster.getRosterItems();
            Log.debug("Sending contacts with subdomain " + subdomain + " from user " + username + " to external Component");
            sendRosterToComponent(myPacket, items, subdomain);
        } catch (UserNotFoundException e) {
            e.printStackTrace();
        }
    } else {
        Log.debug("Sending nonpersistant-RemoteRosterResponse to external Component  for User: " + username);
        sendEmptyRoster(myPacket, subdomain);
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:17,
代码来源:IQRosterPayloadProcessor.java

示例6: sendRosterToComponent

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {

        IQ response = IQ.createResultIQ(requestPacket);
        response.setTo(subdomain);
        Element query = new DefaultElement( QName.get("query","jabber:iq:roster"));
        for (RosterItem i : items) {
            String jid = i.getJid().toString();
            if (!jid.equals(subdomain) && jid.contains(subdomain)) {
                Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
                Element item = new DefaultElement("item", null);
                item.add(new DefaultAttribute("jid", i.getJid().toString()));
                item.add(new DefaultAttribute("name", i.getNickname()));
                item.add(new DefaultAttribute("subscription", "both"));
                for (String s : i.getGroups()) {
                    Element group = new DefaultElement("group");
                    group.setText(s);
                    item.add(group);
                }
                query.add(item);
            }
        }
        response.setChildElement(query);
        dispatchPacket(response);
    }
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:25,
代码来源:IQRosterPayloadProcessor.java

示例7: updateRosterItem

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Update roster item for specified user
 *
 * @param username
 *            the username of the local user to update roster item for.
 * @param itemJID
 *            the JID of the roster item to be updated.
 * @param itemName
 *            the nickname of the roster item.
 * @param subscription
 *            the type of subscription of the roster item. Possible values
 *            are: -1(remove), 0(none), 1(to), 2(from), 3(both).
 * @param groupNames
 *            the name of a group.
 * @throws UserNotFoundException
 *             if the user does not exist in the local server or roster item
 *             does not exist.
 * @throws SharedGroupException
 *             if roster item cannot be added to a shared group.
 */
public void updateRosterItem(String username, String itemJID, String itemName, String subscription,
        String groupNames) throws UserNotFoundException, SharedGroupException {
    getUser(username);
    Roster r = rosterManager.getRoster(username);
    JID j = new JID(itemJID);

    RosterItem ri = r.getRosterItem(j);

    List<String> groups = new ArrayList<String>();
    if (groupNames != null) {
        StringTokenizer tkn = new StringTokenizer(groupNames, ",");
        while (tkn.hasMoreTokens()) {
            groups.add(tkn.nextToken());
        }
    }

    ri.setGroups(groups);
    ri.setNickname(itemName);

    if (subscription == null) {
        subscription = "0";
    }
    ri.setSubStatus(RosterItem.SubType.getTypeFromInt(Integer.parseInt(subscription)));
    r.updateRosterItem(ri);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:46,
代码来源:UserServicePlugin.java

示例8: addRosterItem

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Adds the roster item.
 *
 * @param username
 *            the username
 * @param rosterItemEntity
 *            the roster item entity
 * @throws ServiceException
 *             the service exception
 * @throws UserAlreadyExistsException
 *             the user already exists exception
 * @throws SharedGroupException
 *             the shared group exception
 * @throws UserNotFoundException
 *             the user not found exception
 */
public void addRosterItem(String username, RosterItemEntity rosterItemEntity) throws ServiceException,
        UserAlreadyExistsException, SharedGroupException, UserNotFoundException {
    Roster roster = getUserRoster(username);
    if (rosterItemEntity.getJid() == null) {
        throw new ServiceException("JID is null", "JID", "IllegalArgumentException", Response.Status.BAD_REQUEST);
    }
    JID jid = new JID(rosterItemEntity.getJid());

    try {
        roster.getRosterItem(jid);
        throw new UserAlreadyExistsException(jid.toBareJID());
    } catch (UserNotFoundException e) {
        // Roster item does not exist. Try to add it.
    }

    if (roster != null) {
        RosterItem rosterItem = roster.createRosterItem(jid, rosterItemEntity.getNickname(),
                rosterItemEntity.getGroups(), false, true);
        UserUtils.checkSubType(rosterItemEntity.getSubscriptionType());
        rosterItem.setSubStatus(RosterItem.SubType.getTypeFromInt(rosterItemEntity.getSubscriptionType()));
        roster.updateRosterItem(rosterItem);
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:40,
代码来源:UserServicePluginNG.java

示例9: updateRosterItem

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Update roster item.
 *
 * @param username
 *            the username
 * @param rosterJid
 *            the roster jid
 * @param rosterItemEntity
 *            the roster item entity
 * @throws ServiceException
 *             the service exception
 * @throws UserNotFoundException
 *             the user not found exception
 * @throws UserAlreadyExistsException
 *             the user already exists exception
 * @throws SharedGroupException
 *             the shared group exception
 */
public void updateRosterItem(String username, String rosterJid, RosterItemEntity rosterItemEntity)
        throws ServiceException, UserNotFoundException, UserAlreadyExistsException, SharedGroupException {
    getAndCheckUser(username);

    Roster roster = getUserRoster(username);
    JID jid = new JID(rosterJid);
    RosterItem rosterItem = roster.getRosterItem(jid);

    if (rosterItemEntity.getNickname() != null) {
        rosterItem.setNickname(rosterItemEntity.getNickname());
    }
    if (rosterItemEntity.getGroups() != null) {
        rosterItem.setGroups(rosterItemEntity.getGroups());
    }
    UserUtils.checkSubType(rosterItemEntity.getSubscriptionType());

    rosterItem.setSubStatus(RosterItem.SubType.getTypeFromInt(rosterItemEntity.getSubscriptionType()));
    roster.updateRosterItem(rosterItem);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:38,
代码来源:UserServicePluginNG.java

示例10: updateRosterItem

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Update roster item for specified user.
 *
 * @param username            the username of the local user to update roster item for.
 * @param itemJID            the JID of the roster item to be updated.
 * @param itemName            the nickname of the roster item.
 * @param subscription            the type of subscription of the roster item. Possible values
 *            are: -1(remove), 0(none), 1(to), 2(from), 3(both).
 * @param groupNames            the name of a group.
 * @throws UserNotFoundException             if the user does not exist in the local server or roster item
 *             does not exist.
 * @throws SharedGroupException             if roster item cannot be added to a shared group.
 */
public void updateRosterItem(String username, String itemJID, String itemName, String subscription,
        String groupNames) throws UserNotFoundException, SharedGroupException {
    getUser(username);
    Roster r = rosterManager.getRoster(username);
    JID j = new JID(itemJID);

    RosterItem ri = r.getRosterItem(j);

    List<String> groups = new ArrayList<String>();
    if (groupNames != null) {
        StringTokenizer tkn = new StringTokenizer(groupNames, ",");
        while (tkn.hasMoreTokens()) {
            groups.add(tkn.nextToken());
        }
    }

    ri.setGroups(groups);
    ri.setNickname(itemName);

    if (subscription == null) {
        subscription = "0";
    }
    ri.setSubStatus(RosterItem.SubType.getTypeFromInt(Integer.parseInt(subscription)));
    r.updateRosterItem(ri);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:39,
代码来源:UserServiceLegacyController.java

示例11: removeRosterItem

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Remove a roster item. At this stage, this is recipient who has received
 * a roster update. We must check that it is a removal, and if so, remove
 * the roster item based on the sender's id rather than what is in the item
 * listing itself.
 *
 * @param packet The packet suspected of containing a roster removal
 */
private void removeRosterItem(org.xmpp.packet.Roster packet) throws UnauthorizedException,
        SharedGroupException {
    JID recipientJID = packet.getTo();
    JID senderJID = packet.getFrom();
    try {
        for (org.xmpp.packet.Roster.Item packetItem : packet.getItems()) {
            if (packetItem.getSubscription() == org.xmpp.packet.Roster.Subscription.remove) {
                Roster roster = userManager.getUser(recipientJID.getNode()).getRoster();
                RosterItem item = roster.getRosterItem(senderJID);
                roster.deleteRosterItem(senderJID, true);
                item.setSubStatus(RosterItem.SUB_REMOVE);
                item.setSubStatus(RosterItem.SUB_NONE);

                Packet itemPacket = packet.createCopy();
                sessionManager.userBroadcast(recipientJID.getNode(), itemPacket);
            }
        }
    }
    catch (UserNotFoundException e) {
        throw new UnauthorizedException(e);
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:31,
代码来源:IQRosterHandler.java

示例12: getUserItems

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
public Iterator<Element> getUserItems(String name, JID senderJID) {
    List<Element> answer = new ArrayList<Element>();
    try {
        User user = UserManager.getInstance().getUser(name);
        RosterItem item = user.getRoster().getRosterItem(senderJID);
        // If the requesting entity is subscribed to the account's presence then
        // answer the user's "available resources"
        if (item.getSubStatus() == RosterItem.SUB_FROM ||
                item.getSubStatus() == RosterItem.SUB_BOTH) {
            for (Session session : SessionManager.getInstance().getSessions(name)) {
                Element element = DocumentHelper.createElement("item");
                element.addAttribute("jid", session.getAddress().toString());
                answer.add(element);
            }
        }
        return answer.iterator();
    }
    catch (UserNotFoundException e) {
        return answer.iterator();
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:22,
代码来源:IQDiscoItemsHandler.java

示例13: run

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
public void run() {
    // Send the last published items for the contacts on availableSessionJID's roster.
    try {
        final XMPPServer server = XMPPServer.getInstance();
        final Roster roster = server.getRosterManager().getRoster(availableSessionJID.getNode());
        for (final RosterItem item : roster.getRosterItems()) {
            if (server.isLocal(item.getJid()) && (item.getSubStatus() == RosterItem.SUB_BOTH ||
                    item.getSubStatus() == RosterItem.SUB_TO)) {
                PEPService pepService = pepServiceManager.getPEPService(item.getJid().toBareJID());
                if (pepService != null) {
                    pepService.sendLastPublishedItems(availableSessionJID);
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        // Do nothing
    }
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:20,
代码来源:IQPEPHandler.java

示例14: handleIQget

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
private void handleIQget(IQ myPacket, String subdomain, String username) {
	if (JiveGlobals.getBooleanProperty("plugin.remoteroster.persistent", false)) {
		Roster roster;
		try {
			roster = _rosterManager.getRoster(username);
			Collection<RosterItem> items = roster.getRosterItems();
			Log.debug("Sending contacts with subdomain " + subdomain + " from user " + username + " to external Component");
			sendRosterToComponent(myPacket, items, subdomain);
		} catch (UserNotFoundException e) {
			e.printStackTrace();
		}
	} else {
		Log.debug("Sending nonpersistant-RemoteRosterResponse to external Component  for User: " + username);
		sendEmptyRoster(myPacket, subdomain);
	}
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:17,
代码来源:IQRosterPayloadProcessor.java

示例15: sendRosterToComponent

点赞 3

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {

		IQ response = IQ.createResultIQ(requestPacket);
		response.setTo(subdomain);
		Element query = new DefaultElement("query");
		for (RosterItem i : items) {
			String jid = i.getJid().toString();
			if (!jid.equals(subdomain) && jid.contains(subdomain)) {
				Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
				Element item = new DefaultElement("item", null);
				item.add(new DefaultAttribute("jid", i.getJid().toString()));
				item.add(new DefaultAttribute("name", i.getNickname()));
				item.add(new DefaultAttribute("subscription", "both"));
				for (String s : i.getGroups()) {
					Element group = new DefaultElement("group");
					group.setText(s);
					item.add(group);
				}
				query.add(item);
			}
		}
		query.addNamespace("", "jabber:iq:roster");

		response.setChildElement(query);
		dispatchPacket(response);
	}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:27,
代码来源:IQRosterPayloadProcessor.java

示例16: canSubscribe

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
    // Let node owners and sysadmins always subcribe to the node
    if (node.isAdmin(owner)) {
        return true;
    }
    XMPPServer server = XMPPServer.getInstance();
    for (JID nodeOwner : node.getOwners()) {
        // Give access to the owner of the roster :)
        if (nodeOwner.equals(owner)) {
            return true;
        }
        // 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) {
                // Do nothing
            }
        }
        else {
            // Owner of the node is a remote user. This should never happen.
            Log.warn("Node with access model Presence has a remote user as owner: " +
                    node.getNodeID());
        }
    }
    return false;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:34,
代码来源:PresenceAccess.java

示例17: canProbePresence

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public boolean canProbePresence(JID prober, String probee) throws UserNotFoundException {
    if (probee.equals(prober.getNode()) && XMPPServer.getInstance().isLocal(prober)) {
        return true;
    }
    RosterItem item = rosterManager.getRoster(probee).getRosterItem(prober);
    return item.getSubStatus() == RosterItem.SUB_FROM
            || item.getSubStatus() == RosterItem.SUB_BOTH;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:10,
代码来源:PresenceManagerImpl.java

示例18: initSession

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * A session that has transitioned to available status must be initialized.
 * This includes:
 * <ul>
 * <li>Sending all offline presence subscription requests</li>
 * <li>Sending offline messages</li>
 * </ul>
 *
 * @param session The session being updated
 * @throws UserNotFoundException If the user being updated does not exist
 */
private void initSession(ClientSession session) throws UserNotFoundException {

    // Only user sessions need to be authenticated
    if (userManager.isRegisteredUser(session.getAddress().getNode())) {
        String username = session.getAddress().getNode();

        // Send pending subscription requests to user if roster service is enabled
        if (RosterManager.isRosterServiceEnabled()) {
            Roster roster = rosterManager.getRoster(username);
            for (RosterItem item : roster.getRosterItems()) {
                if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            session.getAddress().asBareJID(), true));
                } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            session.getAddress().asBareJID(), false));
                }
                if (item.getSubStatus() == RosterItem.SUB_TO
                        || item.getSubStatus() == RosterItem.SUB_BOTH) {
                    presenceManager.probePresence(session.getAddress(), item.getJid());
                }
            }
        }
        if (session.canFloodOfflineMessages()) {
            // deliver offline messages if any
            Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
            for (Message message : messages) {
                session.process(message);
            }
        }
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:44,
代码来源:PresenceUpdateHandler.java

示例19: updateState

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Determine and call the update method based on the item's subscription state.
 * <p/>
 *
 * @param item      The item to be updated
 * @param action    The new state change request
 * @param isSending True if the roster owner of the item is sending the new state change request
 */
private static void updateState(RosterItem item, Presence.Type action, boolean isSending) {
    Change change = getStateChange(item.getSubStatus(), action, isSending);
    if (change.getNewAsk() != null && change.getNewAsk() != item.getAskStatus()) {
        item.setAskStatus(change.getNewAsk());
    }
    if (change.getNewSub() != null && change.getNewSub() != item.getSubStatus()) {
        item.setSubStatus(change.getNewSub());
    }
    if (change.getNewRecv() != null && change.getNewRecv() != item.getRecvStatus()) {
        item.setRecvStatus(change.getNewRecv());
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:21,
代码来源:PresenceSubscribeHandler.java

示例20: canProbePresence

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Returns true if the the prober is allowed to see the presence of the probee.
 *
 * @param prober the user that is trying to probe the presence of another user.
 * @param probee the username of the uset that is being probed.
 * @return true if the the prober is allowed to see the presence of the probee.
 * @throws UserNotFoundException If the probee does not exist in the local server or the prober
 *         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;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:21,
代码来源:PEPService.java

示例21: contactDeleted

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public void contactDeleted(Roster roster, RosterItem item) {
    JID rosterOwner = XMPPServer.getInstance().createJID(roster.getUsername(), null);
    JID deletedContact = item.getJid();

    cancelSubscriptionToPEPService(deletedContact, rosterOwner);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:8,
代码来源:IQPEPHandler.java

示例22: exportRoster

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Add roster and its groups to a DOM element
 * 
 * @param userElement
 *            DOM element
 * @param user
 *            User
 */
private void exportRoster(Element userElement, User user) {
  Element rosterElement = userElement.addElement(QUERY_ELEMENT_NAME,
      JABBER_IQ_ROSTER_NS);

  Collection<RosterItem> roster = user.getRoster().getRosterItems();
  for (RosterItem ri : roster) {
    Element itemElement = rosterElement.addElement(ITEM_ELEMENT_NAME);

    itemElement.addAttribute(JID_NAME, ri.getJid().toBareJID());
    itemElement.addAttribute(NAME_NAME, ri.getNickname());
    itemElement.addAttribute(SUBSCRIPTION_NAME, ri.getSubStatus()
        .getName());
    if ( ri.getAskStatus() == AskType.SUBSCRIBE ) {
      itemElement.addAttribute(ASK_NAME, ASK_SUBSCRIBE_ENUM);
    }

    /**
     * Adding groups
     */
    Element groupElement = itemElement.addElement(GROUP_ELEMENT_NAME);
    List<String> groups = ri.getGroups();
    for (String group : groups) {
      groupElement.addText(group);
    }

  }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:36,
代码来源:Xep227Exporter.java

示例23: TestRoster

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 */
public TestRoster() {
  rosteritems = new ArrayList<RosterItem>();
  JID jid = new JID("[email protected]");
  SubType subStatus = SubType.BOTH;
  AskType askStatus = AskType.NONE;
  RecvType recvStatus = RecvType.SUBSCRIBE;
  String nickname = "nick";
  List<String> groups = null;
  rosteritems.add(new RosterItem(1, jid, subStatus, askStatus, recvStatus, nickname, groups));
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:13,
代码来源:TestUserProvider.java

示例24: process

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
    Presence myPacket = (Presence) packet;
    if (myPacket.getType() != null && myPacket.getType().equals(Presence.Type.unavailable)
            && !myPacket.getElement().getStringValue().equals("Connecting")) {
        String username = getUsernameFromJid(to);
        Log.debug("Processing packet in NonPersistantRosterProcessor for " + subdomain + "and user " + username + " Packet: "
                + packet.toString());

        try {
            Roster roster = _rosterManager.getRoster(username);
            Collection<RosterItem> items = roster.getRosterItems();
            for (RosterItem item : items) {
                String itemName = item.getJid().toString();
                if (itemName.contains(subdomain)) {
                    Log.debug("Removing contact " + item.getJid().toString() + " from contact list.");
                    roster.deleteRosterItem(item.getJid(), false);
                    
                }
            }

        } catch (Exception e) {
            Log.debug("Execption occured when cleaning up the Roster.", e);
            e.printStackTrace();
        }
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:28,
代码来源:NonPersistantRosterProcessor.java

示例25: addRosterItem

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Add new roster item for specified user
 *
 * @param username
 *            the username of the local user to add roster item to.
 * @param itemJID
 *            the JID of the roster item to be added.
 * @param itemName
 *            the nickname of the roster item.
 * @param subscription
 *            the type of subscription of the roster item. Possible values
 *            are: -1(remove), 0(none), 1(to), 2(from), 3(both).
 * @param groupNames
 *            the name of a group to place contact into.
 * @throws UserNotFoundException
 *             if the user does not exist in the local server.
 * @throws UserAlreadyExistsException
 *             if roster item with the same JID already exists.
 * @throws SharedGroupException
 *             if roster item cannot be added to a shared group.
 */
public void addRosterItem(String username, String itemJID, String itemName, String subscription, String groupNames)
        throws UserNotFoundException, UserAlreadyExistsException, SharedGroupException {
    getUser(username);
    Roster r = rosterManager.getRoster(username);
    JID j = new JID(itemJID);

    try {
        r.getRosterItem(j);
        throw new UserAlreadyExistsException(j.toBareJID());
    } catch (UserNotFoundException e) {
        // Roster item does not exist. Try to add it.
    }

    if (r != null) {
        List<String> groups = new ArrayList<String>();
        if (groupNames != null) {
            StringTokenizer tkn = new StringTokenizer(groupNames, ",");
            while (tkn.hasMoreTokens()) {
                groups.add(tkn.nextToken());
            }
        }
        RosterItem ri = r.createRosterItem(j, itemName, groups, false, true);
        if (subscription == null) {
            subscription = "0";
        }
        ri.setSubStatus(RosterItem.SubType.getTypeFromInt(Integer.parseInt(subscription)));
        r.updateRosterItem(ri);
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:51,
代码来源:UserServicePlugin.java

示例26: getRosterEntities

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Gets the roster entities.
 *
 * @param username
 *            the username
 * @return the roster entities
 * @throws ServiceException
 *             the service exception
 */
public RosterEntities getRosterEntities(String username) throws ServiceException {
    Roster roster = getUserRoster(username);

    List<RosterItemEntity> rosterEntities = new ArrayList<RosterItemEntity>();
    for (RosterItem rosterItem : roster.getRosterItems()) {
        RosterItemEntity rosterItemEntity = new RosterItemEntity(rosterItem.getJid().toBareJID(),
                rosterItem.getNickname(), rosterItem.getSubStatus().getValue());
        rosterItemEntity.setGroups(rosterItem.getGroups());

        rosterEntities.add(rosterItemEntity);
    }

    return new RosterEntities(rosterEntities);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:24,
代码来源:UserServicePluginNG.java

示例27: updateState

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
private static void updateState(RosterItem item, Presence.Type action, boolean isSending) {
    Map<String, Map<Presence.Type, Change>> srTable = stateTable.get(item.getSubStatus());
    Map<Presence.Type, Change> changeTable = srTable.get(isSending ? "send" : "recv");
    Change change = changeTable.get(action);
    if (change.newAsk != null && change.newAsk != item.getAskStatus()) {
        item.setAskStatus(change.newAsk);
    }
    if (change.newSub != null && change.newSub != item.getSubStatus()) {
        item.setSubStatus(change.newSub);
    }
    if (change.newRecv != null && change.newRecv != item.getRecvStatus()) {
        item.setRecvStatus(change.newRecv);
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:15,
代码来源:UserCreationPlugin.java

示例28: canSubscribe

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
       // Let node owners and sysadmins always subcribe to the node
       if (node.isAdmin(owner)) {
           return true;
       }
       // Get the only owner of the node
       JID nodeOwner = node.getOwners().iterator().next();
       // Give access to the owner of the roster :)
       if (nodeOwner.toBareJID().equals(owner.toBareJID())) {
           return true;
       }
       // Get the roster of the node owner
       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;
           }
       }
       else {
           // Owner of the node is a remote user. This should never happen.
           Log.warn("Node with access model Presence has a remote user as owner: " +
                   node.getNodeID());
           return false;
       }
   }
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:35,
代码来源:PresenceAccess.java

示例29: initSession

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * A session that has transitioned to available status must be initialized.
 * This includes:
 * <ul>
 * <li>Sending all offline presence subscription requests</li>
 * <li>Sending offline messages</li>
 * </ul>
 *
 * @param session The session being updated
 * @throws UserNotFoundException If the user being updated does not exist
 */
private void initSession(ClientSession session) throws UserNotFoundException {

    // Only user sessions need to be authenticated
    if (userManager.isRegisteredUser(session.getAddress().getNode())) {
        String username = session.getAddress().getNode();

        // Send pending subscription requests to user if roster service is enabled
        if (RosterManager.isRosterServiceEnabled()) {
            Roster roster = rosterManager.getRoster(username);
            for (RosterItem item : roster.getRosterItems()) {
                if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), true));
                } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), false));
                }
                if (item.getSubStatus() == RosterItem.SUB_TO
                        || item.getSubStatus() == RosterItem.SUB_BOTH) {
                    presenceManager.probePresence(session.getAddress(), item.getJid());
                }
            }
        }
        if (session.canFloodOfflineMessages()) {
            // deliver offline messages if any
            Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
            for (Message message : messages) {
                session.process(message);
            }
        }
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:44,
代码来源:PresenceUpdateHandler.java

示例30: updateRosterItem

点赞 2

import org.jivesoftware.openfire.roster.RosterItem; //导入依赖的package包/类
/**
 * Update roster item for specified user
 *
 * @param username the username of the local user to update roster item for.
 * @param itemJID the JID of the roster item to be updated.
 * @param itemName the nickname of the roster item.
 * @param subscription the type of subscription of the roster item. Possible values are: -1(remove), 0(none), 1(to), 2(from), 3(both).
 * @param groupNames the name of a group.
 * @throws UserNotFoundException if the user does not exist in the local server or roster item does not exist.
 * @throws SharedGroupException if roster item cannot be added to a shared group.
 */
public void updateRosterItem(String username, String itemJID, String itemName, String subscription, String groupNames)
        throws UserNotFoundException, SharedGroupException
{
    getUser(username);
    Roster r = rosterManager.getRoster(username);
    JID j = new JID(itemJID);

    RosterItem ri = r.getRosterItem(j);

    List<String> groups = new ArrayList<String>();
    if (groupNames != null) {
        StringTokenizer tkn = new StringTokenizer(groupNames, ",");
        while (tkn.hasMoreTokens()) {
            groups.add(tkn.nextToken());
        }
    }

    ri.setGroups(groups);
    ri.setNickname(itemName);

    if (subscription == null) {
        subscription = "0";
    }
    ri.setSubStatus(RosterItem.SubType.getTypeFromInt(Integer.parseInt(subscription)));
    r.updateRosterItem(ri);
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:38,
代码来源:UserServicePlugin.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)