Package org.onesocialweb.xml.dom

Examples of org.onesocialweb.xml.dom.ActivityDomWriter


     
      // We fetch the activities of the target user
      List<ActivityEntry> activities = ActivityManager.getInstance().getActivities(sender.toBareJID(), target.toBareJID());
     
      // Prepare the result packet
      ActivityDomWriter writer = new DefaultActivityDomWriter();
      DOMDocument domDocument = new DOMDocument();
      IQ result = IQ.createResultIQ(packet);
      org.dom4j.Element pubsubElement = result.setChildElement("pubsub", "http://jabber.org/protocol/pubsub");
      org.dom4j.Element itemsElement = pubsubElement.addElement("items");
      itemsElement.addAttribute("node", PEPActivityHandler.NODE);

      for (ActivityEntry entry : activities) {
        Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Atom.NAMESPACE, Atom.ENTRY_ELEMENT));
        writer.write(entry, entryElement);
        domDocument.removeChild(entryElement);
        org.dom4j.Element itemElement = itemsElement.addElement("item");
        itemElement.addAttribute("id", entry.getId());
        itemElement.add((org.dom4j.Element) entryElement);
      }
View Full Code Here


     
      // We fetch the notifications fot the requesting user
      List<ActivityMessage> messages = inboxManager.getMessages(sender.toBareJID());
     
      // Prepare the result packet
      ActivityDomWriter writer = new DefaultActivityDomWriter();
      DOMDocument domDocument = new DOMDocument();
      IQ result = IQ.createResultIQ(packet);
      org.dom4j.Element pubsubElement = result.setChildElement("pubsub", "http://jabber.org/protocol/pubsub");
      org.dom4j.Element itemsElement = pubsubElement.addElement("items");
      itemsElement.addAttribute("node", PEPActivityHandler.NODE);

      for (ActivityMessage message : messages) {
        Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Atom.NAMESPACE, Atom.ENTRY_ELEMENT));
        writer.write(message.getActivity(), entryElement);
        domDocument.removeChild(entryElement);
        org.dom4j.Element itemElement = itemsElement.addElement("item");
        itemElement.addAttribute("id", message.getActivity().getId());
        itemElement.add((org.dom4j.Element) entryElement);
      }
View Full Code Here

  private void notify(String fromJID, ActivityEntry entry) throws UserNotFoundException {

    // TODO We may want to do some cleaning of activities before
    // forwarding them (e.g. remove the acl, it is no one business)
    final ActivityDomWriter writer = new DefaultActivityDomWriter();
    final XMPPServer server = XMPPServer.getInstance();
    final List<Subscription> subscriptions = getSubscribers(fromJID);
  //  final Roster roster = XMPPServer.getInstance().getRosterManager().getRoster(new JID(fromJID).getNode());
    final DOMDocument domDocument = new DOMDocument();

    // Prepare the message
    final Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Atom.NAMESPACE, Atom.ENTRY_ELEMENT));
    writer.write(entry, entryElement);
    domDocument.removeChild(entryElement);

    final Message message = new Message();
    message.setFrom(fromJID);
    message.setBody("New activity: " + entry.getTitle());
View Full Code Here

TOP

Related Classes of org.onesocialweb.xml.dom.ActivityDomWriter

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.