@Override
    public synchronized List<PublishedItem> getPublishedItems(int recentItems) {
        List<PublishedItem> publishedItems = XMPPServer.getInstance().getPubSubModule().getPersistenceProvider().getPublishedItems(this, recentItems);
        if (lastPublished != null) {
            // The persistent items may not contain the last item, if it wasn't persisted anymore (e.g. if node configuration changed).
            // Therefore check, if the last item has been persisted.
            boolean persistentItemsContainsLastItem = false;
            for (PublishedItem publishedItem : publishedItems) {
                if (publishedItem.getID().equals(lastPublished.getID())) {
                    persistentItemsContainsLastItem = true;
                    break;
                }
            }
            if (!persistentItemsContainsLastItem) {
                // And if not, include the last item.
                publishedItems.add(0, lastPublished);
                // Recheck the collection size, it might have one more element now (the last item).
                // Remove it, if it exceeds the max items.
                if (publishedItems.size() > recentItems) {
                    publishedItems.remove(publishedItems.size() - 1);
                }
            }
        }
        Log.trace("Got {} published item(s)", publishedItems.size());
        return publishedItems;
    }
Sends an IQ result with the list of items published to the node. Item ID and payload are always included.
Should only be used for use-cases described in section "6.5 Retrieve Items from a Node" from XEP-0060 (as
opposed to processing of notifications or service discovery, which are allowed to discard payloads).

@param originalRequest the IQ packet sent by a subscriber (or anyone) to get the node items.
@param publishedItems the list of published items to send to the subscriber.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/LeafNode.java