/**
  * Returns true if an event notification can be sent to the subscriber for the specified published
  * item based on the subsription configuration and subscriber status.
  *
  * @param leafNode the node that received the publication.
  * @param publishedItem the published item to send or null if the publication didn't contain an
  *     item.
  * @return true if an event notification can be sent to the subscriber for the specified published
  *     item.
  */
 public boolean canSendPublicationEvent(LeafNode leafNode, PublishedItem publishedItem) {
   if (!canSendEvents()) {
     return false;
   }
   // Check that any defined keyword was matched (applies only if an item was published)
   if (publishedItem != null && !isKeywordMatched(publishedItem)) {
     return false;
   }
   // Check special conditions when subscribed to collection node
   if (node.isCollectionNode()) {
     // Check if not subscribe to items
     if (Type.items != type) {
       return false;
     }
     // Check if published node is a first-level child of the subscribed node
     if (getDepth() == 1 && !node.isChildNode(leafNode)) {
       return false;
     }
     // Check if published node is a descendant child of the subscribed node
     if (getDepth() == 0 && !node.isDescendantNode(leafNode)) {
       return false;
     }
   }
   return true;
 }
  /**
   * Returns true if an event notification can be sent to the subscriber of the collection node for
   * a newly created node that was associated to the collection node or a child node that was
   * deleted. The subscription has to be of type {@link Type#nodes}.
   *
   * @param originatingNode the node that was added or deleted from the collection node.
   * @return true if an event notification can be sent to the subscriber of the collection node.
   */
  boolean canSendChildNodeEvent(Node originatingNode) {
    // Check that this is a subscriber to a collection node
    if (!node.isCollectionNode()) {
      return false;
    }

    if (!canSendEvents()) {
      return false;
    }
    // Check that subscriber is using type "nodes"
    if (Type.nodes != type) {
      return false;
    }
    // Check if added/deleted node is a first-level child of the subscribed node
    if (getDepth() == 1 && !node.isChildNode(originatingNode)) {
      return false;
    }
    // Check if added/deleted node is a descendant child of the subscribed node
    if (getDepth() == 0 && !node.isDescendantNode(originatingNode)) {
      return false;
    }
    return true;
  }