use of org.dom4j.Element in project Openfire by igniterealtime.
the class UserRequest method addOfferContent.
@Override
void addOfferContent(Element offerElement) {
// Flag the offer as a user request
offerElement.addElement("user-request");
// anonymous user
if (isAnonymousUser()) {
Element element = offerElement.addElement("user", "http://jivesoftware.com/protocol/workgroup");
element.addAttribute("id", getUserID());
}
}
use of org.dom4j.Element in project Openfire by igniterealtime.
the class PEPService method sendLastPublishedItems.
/**
* Sends an event notification for the last published item of each leaf node under the
* root collection node to the recipient JID. If the recipient has no subscription to
* the root collection node, has not yet been authorized, or is pending to be
* configured -- then no notifications are going to be sent.<p>
*
* Depending on the subscription configuration the event notifications 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 recipientJID the recipient that is to receive the last published item notifications.
*/
public void sendLastPublishedItems(JID recipientJID) {
// Ensure the recipient has a subscription to this service's root collection node.
NodeSubscription subscription = rootCollectionNode.getSubscription(recipientJID);
if (subscription == null) {
subscription = rootCollectionNode.getSubscription(new JID(recipientJID.toBareJID()));
}
if (subscription == null) {
return;
}
// Send the last published item of each leaf node to the recipient.
for (Node leafNode : rootCollectionNode.getNodes()) {
// Retrieve last published item for the leaf node.
PublishedItem leafLastPublishedItem = null;
leafLastPublishedItem = leafNode.getLastPublishedItem();
if (leafLastPublishedItem == null) {
continue;
}
// Check if the published item can be sent to the subscriber
if (!subscription.canSendPublicationEvent(leafLastPublishedItem.getNode(), leafLastPublishedItem)) {
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", leafLastPublishedItem.getNodeID());
Element item = items.addElement("item");
if (leafLastPublishedItem.getNode().isItemRequired()) {
item.addAttribute("id", leafLastPublishedItem.getID());
}
if (leafLastPublishedItem.getNode().isPayloadDelivered() && leafLastPublishedItem.getPayload() != null) {
item.add(leafLastPublishedItem.getPayload().createCopy());
}
// Add a message body (if required)
if (subscription.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(leafLastPublishedItem.getCreationDate()));
// Send the event notification to the subscriber
this.sendNotification(subscription.getNode(), notification, subscription.getJID());
}
}
use of org.dom4j.Element 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);
}
use of org.dom4j.Element in project Openfire by igniterealtime.
the class RemotePacketExecution method readExternal.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
String jid = ExternalizableUtil.getInstance().readSafeUTF(in);
// Optimization that was avoiding the need to reparse and validate JIDs but cannot be done due
// to a change in the JID API. We need to bring this constructor back
//receipient = new JID(jid, true);
receipient = new JID(jid);
int packetType = ExternalizableUtil.getInstance().readInt(in);
Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
switch(packetType) {
case 1:
packet = new IQ(packetElement, true);
break;
case 2:
packet = new Message(packetElement, true);
break;
case 3:
packet = new Presence(packetElement, true);
break;
}
}
use of org.dom4j.Element in project Openfire by igniterealtime.
the class WorkgroupFormProvider method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
FormManager formManager = FormManager.getInstance();
DataForm dataForm = formManager.getDataForm(workgroup);
if (dataForm == null) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
return;
}
Element iq = packet.getChildElement();
if (iq.elements().isEmpty()) {
reply.setChildElement(iq.createCopy());
// Send the data form to the requestor
reply.addExtension(dataForm.createCopy());
workgroup.send(reply);
}
}
Aggregations