code: public void onSaveItems(ItemStateChangesLog itemStates)
     {
        // nodes that need to be removed from the index.
        final Set<String> removedNodes = new HashSet<String>();
        // nodes that need to be added to the index.
        final Set<String> addedNodes = new HashSet<String>();
        //updated
        final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
  
        final Set<String> parentRemovedNodes = new HashSet<String>();
        // nodes that need to be added to the index.
        final Set<String> parentAddedNodes = new HashSet<String>();
        //updated
        final Map<String, List<ItemState>> parentUpdatedNodes = new HashMap<String, List<ItemState>>();
  
        for (Iterator<ItemState> iter = itemStates.getAllStates().iterator(); iter.hasNext();)
        {
           ItemState itemState = iter.next();
  
           if (itemState.isPersisted())
           {
              if (!indexingTree.isExcluded(itemState))
              {
                 acceptChanges(removedNodes, addedNodes, updatedNodes, itemState);
              }
              else if (parentIndexingTree != null && !parentIndexingTree.isExcluded(itemState))
              {
                 acceptChanges(parentRemovedNodes, parentAddedNodes, parentUpdatedNodes, itemState);
              }
           }
        }
  
        for (String uuid : updatedNodes.keySet())
        {
           removedNodes.add(uuid);
           addedNodes.add(uuid);
        }
  
        for (String uuid : parentUpdatedNodes.keySet())
        {
           parentRemovedNodes.add(uuid);
           parentAddedNodes.add(uuid);
        }
  
        doUpdateIndex(removedNodes, addedNodes, parentRemovedNodes, parentAddedNodes);
     }
docs: {@inheritDoc}