mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
14.31.2014 2f13f91c158747ca997a44d8e61830f46b77dd82
opendj3-server-dev/src/server/org/opends/server/backends/jeb/ID2CIndexer.java
@@ -22,28 +22,24 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.backends.jeb;
import java.util.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import com.sleepycat.je.DatabaseEntry;
import java.util.*;
/**
 * Implementation of an Indexer for the children index.
 */
public class ID2CIndexer extends Indexer
{
  /**
   * The comparator for keys generated by this class.
   */
  private static final Comparator<byte[]> comparator =
       new AttributeIndex.KeyComparator();
  /**
   * Create a new indexer for a children index.
   */
  public ID2CIndexer()
@@ -56,42 +52,33 @@
   * used to name an index created using this object.
   * @return A string representation of this object.
   */
  @Override
  public String toString()
  {
    return "id2children";
  }
  /**
   * Get the comparator that must be used to compare index keys
   * generated by this class.
   *
   * @return A byte array comparator.
   */
  public Comparator<byte[]> getComparator()
  {
    return comparator;
  }
  /**
   * Generate the set of index keys for an entry.
   *
   * @param entry The entry.
   * @param addKeys The set into which the generated keys will be inserted.
   */
  public void indexEntry(Entry entry, Set<byte[]> addKeys)
  @Override
  public void indexEntry(Entry entry, Set<ByteString> addKeys)
  {
    // The superior entry IDs are in the entry attachment.
    ArrayList ids = (ArrayList)entry.getAttachment();
    ArrayList<EntryID> ids = (ArrayList<EntryID>) entry.getAttachment();
    // Skip the entry's own ID.
    Iterator iter = ids.iterator();
    Iterator<EntryID> iter = ids.iterator();
    iter.next();
    // Get the parent ID.
    if (iter.hasNext())
    {
      DatabaseEntry nodeIDData = ((EntryID)iter.next()).getDatabaseEntry();
      addKeys.add(nodeIDData.getData());
      DatabaseEntry nodeIDData = iter.next().getDatabaseEntry();
      addKeys.add(ByteString.wrap(nodeIDData.getData()));
    }
  }
@@ -103,8 +90,9 @@
   * @param newEntry The new entry contents.
   * @param modifiedKeys The map into which the modified keys will be inserted.
   */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry,
                           Map<byte[], Boolean> modifiedKeys)
                           Map<ByteString, Boolean> modifiedKeys)
  {
    // Nothing to do.
  }
@@ -120,9 +108,10 @@
   * @param mods The set of modifications that were applied to the entry.
   * @param modifiedKeys The map into which the modified keys will be inserted.
   */
  @Override
  public void modifyEntry(Entry oldEntry, Entry newEntry,
                          List<Modification> mods,
                          Map<byte[], Boolean> modifiedKeys)
                          Map<ByteString, Boolean> modifiedKeys)
  {
    // Nothing to do.
  }