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

abobrov
08.13.2008 100e551066fc2b42a7578906a0a7a734896a2961
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -22,9 +22,12 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
 */
package org.opends.server.backends.jeb;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.DatabaseEntry;
import org.opends.messages.Message;
import java.io.IOException;
@@ -39,6 +42,8 @@
import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
import com.sleepycat.je.RunRecoveryException;
import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn;
@@ -67,6 +72,8 @@
import org.opends.server.admin.std.server.LocalDBBackendCfg;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.DN;
/**
 * This is an implementation of a Directory Server Backend which stores entries
@@ -1729,4 +1736,45 @@
      throw new InitializationException(message, e);
    }
  }
  /**
   * {@inheritDoc}
   */
  public boolean collectStoredDNs(Collection<DN> storedDNs)
    throws UnsupportedOperationException
  {
    for (EntryContainer entryContainer : rootContainer.getEntryContainers()) {
      DN2ID dn2id = entryContainer.getDN2ID();
      Cursor cursor = null;
      try {
        cursor = dn2id.openCursor(null, new CursorConfig());
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        OperationStatus status;
        for (status = cursor.getFirst(key, data, LockMode.DEFAULT);
             status == OperationStatus.SUCCESS;
             status = cursor.getNext(key, data, LockMode.DEFAULT)) {
          DN entryDN = DN.decode(new ASN1OctetString(key.getData()));
          storedDNs.add(entryDN);
        }
      } catch (Exception e) {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }
        return false;
      } finally {
        if (cursor != null) {
          try {
            cursor.close();
          } catch (DatabaseException de) {
            if (debugEnabled()) {
              TRACER.debugCaught(DebugLogLevel.ERROR, de);
            }
          }
        }
      }
    }
    return true;
  }
}