Package org.xmpp.packet

Examples of org.xmpp.packet.JID


                // This component has already registered with this subdomain.
                // TODO: Is this all we should do?  Should we return an error?
                return;
            }
            Log.debug("InternalComponentManager: Registering component for domain: " + subdomain);
            JID componentJID = new JID(subdomain + "." + serverDomain);
            boolean notifyListeners = false;
            if (routable != null) {
                routable.addComponent(component);
            }
            else {
View Full Code Here


            RoutableComponents routable = routables.get(subdomain);
            routable.removeComponent(component);
            if (routable.numberOfComponents() == 0) {
                routables.remove(subdomain);

                JID componentJID = new JID(subdomain + "." + serverDomain);

                // Remove the route for the service provided by the component
                routingTable.removeComponentRoute(componentJID);

                // Ask the component to shutdown
                component.shutdown();

                if (!routingTable.hasComponentRoute(componentJID)) {
                    // Remove the disco item from the server for the component that is being removed
                    IQDiscoItemsHandler iqDiscoItemsHandler = XMPPServer.getInstance().getIQDiscoItemsHandler();
                    if (iqDiscoItemsHandler != null) {
                        iqDiscoItemsHandler.removeComponentItem(componentJID.toBareJID());
                    }
                    removeComponentInfo(componentJID);
                    // Notify listeners that an existing component has been unregistered
                    notifyComponentUnregistered(componentJID);
                    // Alert other nodes of component removed event
View Full Code Here

     */
    public void addListener(ComponentEventListener listener) {
        listeners.add(listener);
        // Notify the new listener about existing components
        for (String domain : routingTable.getComponentsDomains()) {
            JID componentJID = new JID(domain);
            listener.componentRegistered(componentJID);
            // Check if there is disco#info stored for the component
            IQ disco = componentInfo.get(domain);
            if (disco != null) {
                listener.componentInfoReceived(disco);
View Full Code Here

        presenceMap.put(prober, probee);
    }

    private void checkPresences() {
        for (JID prober : presenceMap.keySet()) {
            JID probee = presenceMap.get(prober);

            if (routingTable.hasComponentRoute(probee)) {
                Presence presence = new Presence();
                presence.setFrom(prober);
                presence.setTo(probee);
View Full Code Here

            reply.setChildElement(packet.getChildElement().createCopy());
            reply.setError(PacketError.Condition.service_unavailable);
            return reply;
        }

        final JID senderJID = packet.getFrom();
        if (packet.getTo() == null) {
          // packet addressed to service itself (not to a node/user)
         
            if (packet.getType() == IQ.Type.set) {
                final String jidFrom = senderJID.toBareJID();
                PEPService pepService = pepServiceManager.getPEPService(jidFrom);

                // If no service exists yet for jidFrom, create one.
                if (pepService == null) {
                  try {
                    pepService = pepServiceManager.create(senderJID);                   
                  } catch (IllegalArgumentException ex) {
                  final IQ reply = IQ.createResultIQ(packet);
                  reply.setChildElement(packet.getChildElement().createCopy());
                  reply.setError(PacketError.Condition.not_allowed);
                  return reply;
                  }

                // Probe presences
                pepServiceManager.start(pepService);

                // 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);
              }
            }
          } catch (UserNotFoundException e) {
            // Do nothing
          }
                }

                // If publishing a node, and the node doesn't exist, create it.
                final Element childElement = packet.getChildElement();
                final Element publishElement = childElement.element("publish");
                if (publishElement != null) {
                    final String nodeID = publishElement.attributeValue("node");

                    // Do not allow User Avatar nodes to be created.
                    // TODO: Implement XEP-0084
                    if (nodeID.startsWith("http://www.xmpp.org/extensions/xep-0084.html")) {
                        IQ reply = IQ.createResultIQ(packet);
                        reply.setChildElement(packet.getChildElement().createCopy());
                        reply.setError(PacketError.Condition.feature_not_implemented);
                        return reply;
                    }

                    if (pepService.getNode(nodeID) == null) {
                        // Create the node
                        final JID creator = new JID(jidFrom);
                        final LeafNode newNode = new LeafNode(pepService, pepService.getRootCollectionNode(), nodeID, creator);
                        newNode.addOwner(creator);
                        newNode.saveToDB();
                    }
                }
View Full Code Here

            throws FileTransferRejectedException
    {
        fireFileTransferIntercept(transfer, false);
        if(transfer != null) {
            String streamID = transfer.getSessionID();
            JID from = new JID(transfer.getInitiator());
            JID to = new JID(transfer.getTarget());
            cacheFileTransfer(ProxyConnectionManager.createDigest(streamID, from, to), transfer);
            return true;
        }
        return false;
    }
View Full Code Here

                if (node == rootNode) {
                    continue;
                }

                AccessModel accessModel = node.getAccessModel();
                if (accessModel.canAccessItems(node, senderJID, new JID(recipientJID))) {
                    Element item = defaultItem.createCopy();
                    item.addAttribute("node", node.getNodeID());
                    items.add(item);
                }
            }
View Full Code Here

    public void availableSession(ClientSession session, Presence presence) {
        // Do nothing if server is not enabled
        if (!isEnabled()) {
            return;
        }
        JID newlyAvailableJID = presence.getFrom();

        if (newlyAvailableJID == null) {
            return;
        }
       
View Full Code Here

    public void remoteUserAvailable(Presence presence) {
        // Do nothing if server is not enabled
        if (!isEnabled()) {
            return;
        }
        JID jidFrom = presence.getFrom();
        JID jidTo = presence.getTo();

        // Manage the cache of remote presence resources.
        Set<JID> remotePresenceSet = knownRemotePresences.get(jidTo.toBareJID());

        if (jidFrom.getResource() != null) {
            if (remotePresenceSet != null) {
                remotePresenceSet.add(jidFrom);
            }
            else {
                remotePresenceSet = new HashSet<JID>();
                remotePresenceSet.add(jidFrom);
                knownRemotePresences.put(jidTo.toBareJID(), remotePresenceSet);
            }

            // TODO Check the roster presence subscription to allow or ignore the received presence.
            // TODO Directed presences should be ignored when no presence subscription exists

            // Send the presence packet recipient's last published items to the remote user.
            PEPService pepService = pepServiceManager.getPEPService(jidTo.toBareJID());
            if (pepService != null) {
                pepService.sendLastPublishedItems(jidFrom);
            }
        }
    }
View Full Code Here

    public void remoteUserUnavailable(Presence presence) {
        // Do nothing if server is not enabled
        if (!isEnabled()) {
            return;
        }
        final JID jidFrom = presence.getFrom();
        final JID jidTo = presence.getTo();

        // Manage the cache of remote presence resources.
        final Set<JID> remotePresenceSet = knownRemotePresences.get(jidTo.toBareJID());

        if (remotePresenceSet != null) {
            remotePresenceSet.remove(jidFrom);
        }
    }
View Full Code Here

TOP

Related Classes of org.xmpp.packet.JID

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.