コード例 #1
0
 private void addDeleteNodeNotifications(String node, List<Packet> notifications)
     throws Exception {
   ResultSet<NodeSubscription> subscriptions = channelManager.getNodeSubscriptionListeners(node);
   Message notification = createNodeDeletedNotificationMessage(node);
   if (subscriptions != null) {
     for (NodeSubscription subscription : subscriptions) {
       notification.setTo(subscription.getListener().toString());
       notifications.add(notification.createCopy());
     }
   }
   Collection<JID> adminUsers = Configuration.getInstance().getAdminUsers();
   for (JID admin : adminUsers) {
     notification.setTo(admin);
     notifications.add(notification.createCopy());
   }
 }
コード例 #2
0
  private void addDeleteItemNotifications(String node, String itemId, List<Packet> notifications)
      throws NodeStoreException {
    ResultSet<NodeSubscription> subscriptions = channelManager.getNodeSubscriptionListeners(node);
    Message notification = createItemDeleteNotificationMessage(node, itemId);
    if (subscriptions != null) {
      for (NodeSubscription subscription : subscriptions) {
        if (subscription.getSubscription().equals(Subscriptions.subscribed)) {
          notification.setTo(subscription.getListener().toString());
          notifications.add(notification);
        }
      }
    }

    Collection<JID> adminUsers = Configuration.getInstance().getAdminUsers();
    for (JID admin : adminUsers) {
      notification.setTo(admin);
      notifications.add(notification);
    }
  }
コード例 #3
0
  private void notifySubscribers(HashMap<String, String> configuration)
      throws NodeStoreException, InterruptedException {
    ResultSet<NodeSubscription> subscribers = channelManager.getNodeSubscriptionListeners(node);
    Document document = getDocumentHelper();
    Element message = document.addElement("message");
    message.addAttribute("remote-server-discover", "false");
    Element event = message.addElement("event");
    Element configurationElement = event.addElement("configuration");
    configurationElement.addAttribute("node", node);
    event.addNamespace("", Event.NAMESPACE);
    message.addAttribute("from", request.getTo().toString());
    message.addAttribute("type", "headline");
    Message rootElement = new Message(message);

    Element dataForm = configurationElement.addElement("x");
    dataForm.addAttribute("type", "result");
    dataForm.addNamespace("", DataForm.NAMESPACE);
    DataForm df = new DataForm(dataForm);

    FormField field;
    for (Map.Entry<String, String> entry : configuration.entrySet()) {
      String key = entry.getKey();
      Object value = entry.getValue();
      field = df.addField(key, null, null);
      field.addValue(value);
      // ...
    }

    for (NodeSubscription subscriber : subscribers) {
      Message notification = rootElement.createCopy();
      notification.setTo(subscriber.getListener());
      outQueue.put(notification);
    }

    Collection<JID> admins = getAdminUsers();
    for (JID admin : admins) {
      Message notification = rootElement.createCopy();
      notification.setTo(admin);
      outQueue.put(notification);
    }
  }
コード例 #4
0
  private void addUnsubscribeFromNodeNotifications(
      JID userJid, String node, List<Packet> notifications) throws NodeStoreException {

    ResultSet<NodeSubscription> subscribers = channelManager.getNodeSubscriptionListeners(node);

    Message messagePacket = createUnsubscribeNotification(userJid, node);
    if (subscribers != null) {
      for (NodeSubscription subscriber : subscribers) {
        Message notification = messagePacket.createCopy();
        notification.setTo(subscriber.getListener());
        notifications.add(notification);
      }
    }

    Collection<JID> adminUsers = Configuration.getInstance().getAdminUsers();
    for (JID admin : adminUsers) {
      Message notification = messagePacket.createCopy();
      notification.setTo(admin);
      notifications.add(notification);
    }
  }