Package org.onesocialweb.xml.dom

Examples of org.onesocialweb.xml.dom.ActivityDomReader


          PEPActivityHandler.NODE)) {
               
               
        Log.debug("Processing an activity event from " + fromJID
            + " to " + toJID);
        final ActivityDomReader reader = new PersistentActivityDomReader();
        List<Element> items=(List<Element>) itemsElement.elements("item");
        if ((items!=null) && (items.size()!=0)){
          for (Element itemElement :items) {
            ActivityEntry activity = reader
            .readEntry(new ElementAdapter(itemElement
                .element("entry")));
            try {

              ActivityManager.getInstance().handleMessage(
                  fromJID.toBareJID(), toJID.toBareJID(),
                  activity);             
             
            } catch (InvalidActivityException e) {
              throw new PacketRejectedException();
            } catch (AccessDeniedException e) {
              throw new PacketRejectedException();
            }
          }
        } else if (itemsElement.element("retract")!=null)
        {         
          Element retractElement = itemsElement.element("retract");
          String activityId=reader.readActivityId(new ElementAdapter(retractElement));
          ActivityManager.getInstance().deleteMessage(activityId);
        }
        Set<JID> recipientFullJIDs = getFullJIDs(toJID
            .toBareJID());
        Iterator<JID> it = recipientFullJIDs.iterator();
        Message extendedMessage = message.createCopy();
        while (it.hasNext()) {
          String fullJid = it.next().toString();
          extendedMessage.setTo(fullJid);
          server.getMessageRouter().route(extendedMessage);
        }
        throw new PacketRejectedException();
      }
     
      // or a relation event
      else if (itemsElement.attribute("node").getValue().equals(
          RelationManager.NODE)) {
        final RelationDomReader reader = new PersistentRelationDomReader();
        for (Element itemElement : (List<Element>) itemsElement
            .elements("item")) {
          Relation relation = reader.readElement(new ElementAdapter(
              itemElement.element("relation")));
          try {
            RelationManager.getInstance().handleMessage(
                fromJID.toBareJID(), toJID.toBareJID(),
                relation);
View Full Code Here


        result.setError(PacketError.Condition.bad_request);
        return result;
      }

      // Parse the activities
      ActivityDomReader reader = new PersistentActivityDomReader();
      List<String> itemIds = new ArrayList<String>(items.size());
      for (Element item : items) {
        Element entry = item.element("entry");
        if (entry != null) {
          ActivityEntry activity = reader.readEntry(new ElementAdapter(entry));
          Log.debug("ActivityPublishHandler received activity: " + activity);
          try {
            if ((activity.getId()!=null) && (activity.getId().length()!=0))
              activityManager.updateActivity(sender.toBareJID(), activity);
            else{
View Full Code Here

        result.setChildElement(packet.getChildElement().createCopy());
        result.setError(PacketError.Condition.not_authorized);
        return result;
      }
     
      ActivityDomReader reader = new PersistentActivityDomReader();
      Element pubsubElement = packet.getChildElement();
      Element retractElement = pubsubElement.element("retract");
      Element item = (Element)retractElement.elements("item").get(0);
      String activityId=reader.readActivityId(new ElementAdapter(item));
     
      if ((activityId==null) || (activityId.length()==0)){           
          IQ result = IQ.createResultIQ(packet);
          result.setChildElement(packet.getChildElement().createCopy());
          result.setError(PacketError.Condition.item_not_found);
View Full Code Here

TOP

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

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.