/** * Item handler of this data handler implementation. Checks if received items are already cached, * if not, it caches them. Ultimately it sends the items to the subscribed listeners. */ @Override public void handlePublishedItems(ItemPublishEvent<PayloadItem<SimplePayload>> items){ String spaceId = getSpaceId(items.getNodeId()); if (spaceId == null) return; List<String> toRequest = new ArrayList<String>(); for (PayloadItem<SimplePayload> item:items.getItems()){ if (item.getPayload() == null && !pendingPayloadRequests.containsKey(item.getId())){ toRequest.add(item.getId()); continue; } DataObject obj = parseItemToDataObject(item); if (dataObjectFilter == null || dataObjectFilter.isDataObjectValid(obj)) { if (!datawrapper.isDataObjectAlreadyCached(item.getId())){ datawrapper.saveDataObject(items.getNodeId(), obj, item.getId()); } for (DataObjectListener listener:listeners){ listener.handleDataObject(obj, spaceId); } } } if (!toRequest.isEmpty()){ for (String id:toRequest){ try { retrievePayload(items.getNodeId(), id); } catch (Exception e) { //Ignore continue; } } } }
/** * Called whenever an item is published to the node the listener * is registered with. * * @param items The publishing details. */ void handlePublishedItems(ItemPublishEvent<T> items);
/** * Called whenever an item is published to the node the listener is * registered with. * * @param items * The publishing details. */ void handlePublishedItems(ItemPublishEvent<T> items);