Search in sources :

Example 26 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class NodeSubscription method sendAuthorizationRequest.

/**
     * Sends an request to authorize the pending subscription to all owners. The first
     * answer sent by a owner will be processed. Rest of the answers will be discarded.
     */
public void sendAuthorizationRequest() {
    Message authRequest = new Message();
    authRequest.addExtension(node.getAuthRequestForm(this));
    // Send authentication request to node owners
    node.getService().broadcast(node, authRequest, node.getOwners());
}
Also used : Message(org.xmpp.packet.Message)

Example 27 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class NodeSubscription method sendAuthorizationRequest.

/**
     * Sends an request to authorize the pending subscription to the specified owner.
     *
     * @param owner the JID of the user that will get the authorization request.
     */
public void sendAuthorizationRequest(JID owner) {
    Message authRequest = new Message();
    authRequest.addExtension(node.getAuthRequestForm(this));
    authRequest.setTo(owner);
    authRequest.setFrom(node.getService().getAddress());
    // Send authentication request to node owners
    node.getService().send(authRequest);
}
Also used : Message(org.xmpp.packet.Message)

Example 28 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class NodeSubscription method sendLastPublishedItem.

/**
     * Sends an event notification for the last published item to the subscriber. If
     * the subscription has not yet been authorized or is pending to be configured then
     * no notification is going to be sent.<p>
     *
     * Depending on the subscription configuration the event notification may or may not have
     * a payload, may not be sent if a keyword (i.e. filter) was defined and it was not matched.
     *
     * @param publishedItem the last item that was published to the node.
     */
void sendLastPublishedItem(PublishedItem publishedItem) {
    // Check if the published item can be sent to the subscriber
    if (!canSendPublicationEvent(publishedItem.getNode(), publishedItem)) {
        return;
    }
    // Send event notification to the subscriber
    Message notification = new Message();
    Element event = notification.getElement().addElement("event", "http://jabber.org/protocol/pubsub#event");
    Element items = event.addElement("items");
    items.addAttribute("node", node.getNodeID());
    Element item = items.addElement("item");
    if (((LeafNode) node).isItemRequired()) {
        item.addAttribute("id", publishedItem.getID());
    }
    if (node.isPayloadDelivered() && publishedItem.getPayload() != null) {
        item.add(publishedItem.getPayload().createCopy());
    }
    // Add a message body (if required)
    if (isIncludingBody()) {
        notification.setBody(LocaleUtils.getLocalizedString("pubsub.notification.message.body"));
    }
    // Include date when published item was created
    notification.getElement().addElement("delay", "urn:xmpp:delay").addAttribute("stamp", XMPPDateTimeFormat.format(publishedItem.getCreationDate()));
    // Send the event notification to the subscriber
    node.getService().sendNotification(node, notification, jid);
}
Also used : Message(org.xmpp.packet.Message) Element(org.dom4j.Element)

Example 29 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class CollectionNode method childNodeAdded.

/**
     * Notification that a new node was created and added to this node. Trigger notifications
     * to node subscribers whose subscription type is {@link NodeSubscription.Type#nodes} and
     * have the proper depth.
     *
     * @param child the newly created node that was added to this node.
     */
void childNodeAdded(Node child) {
    // Build packet to broadcast to subscribers
    Message message = new Message();
    Element event = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
    Element item = event.addElement("items").addElement("item");
    item.addAttribute("id", child.getNodeID());
    if (deliverPayloads) {
        item.add(child.getMetadataForm().getElement());
    }
    // Broadcast event notification to subscribers
    broadcastCollectionNodeEvent(child, message);
}
Also used : Message(org.xmpp.packet.Message) Element(org.dom4j.Element)

Example 30 with Message

use of org.xmpp.packet.Message in project Openfire by igniterealtime.

the class BroadcastMessage method readExternal.

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
    packet = new Message(packetElement, true);
}
Also used : Message(org.xmpp.packet.Message) DefaultElement(org.dom4j.tree.DefaultElement) Element(org.dom4j.Element)

Aggregations

Message (org.xmpp.packet.Message)111 Element (org.dom4j.Element)35 JID (org.xmpp.packet.JID)25 Test (org.junit.Test)23 Presence (org.xmpp.packet.Presence)18 IQ (org.xmpp.packet.IQ)16 ArrayList (java.util.ArrayList)10 Packet (org.xmpp.packet.Packet)10 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)9 Date (java.util.Date)6 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 NotFoundException (org.jivesoftware.util.NotFoundException)6 StringReader (java.io.StringReader)4 List (java.util.List)4 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)4 User (org.jivesoftware.openfire.user.User)4 IOException (java.io.IOException)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 SAXReader (org.dom4j.io.SAXReader)3 DefaultElement (org.dom4j.tree.DefaultElement)3