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

Jean-Noel Rouvignac
22.44.2014 1345ac0dfae9a555abb7b74ed48452d9bc92b8c3
opends/src/server/org/opends/server/api/Backend.java
@@ -22,77 +22,63 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.api;
import org.opends.messages.Message;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.opends.messages.Message;
import org.opends.server.admin.Configuration;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.*;
import org.opends.server.monitors.BackendMonitor;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.IndexType;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.WritabilityMode;
import org.opends.server.types.ConditionResult;
import org.opends.server.types.*;
import static org.opends.messages.BackendMessages.*;
/**
 * This class defines the set of methods and structures that must be
 * implemented for a Directory Server backend.
 *
 * @param <C>
 *          the type of the BackendCfg for the current backend
 */
@org.opends.server.types.PublicAPI(
     stability=org.opends.server.types.StabilityLevel.VOLATILE,
     mayInstantiate=false,
     mayExtend=true,
     mayInvoke=false)
public abstract class Backend
public abstract class Backend<C extends Configuration>
// should have been BackendCfg instead of Configuration
{
  // The backend that holds a portion of the DIT that is
  // hierarchically above the information in this backend.
  private Backend parentBackend;
  /**
   * The backend that holds a portion of the DIT that is hierarchically above
   * the information in this backend.
   */
  private Backend<?> parentBackend;
  // The set of backends that hold portions of the DIT that are
  // hierarchically below the information in this backend.
  private Backend[] subordinateBackends;
  /**
   * The set of backends that hold portions of the DIT that are hierarchically
   * below the information in this backend.
   */
  private Backend<?>[] subordinateBackends;
  // The backend monitor associated with this backend.
  /** The backend monitor associated with this backend. */
  private BackendMonitor backendMonitor;
  // Indicates whether this is a private backend or one that holds
  // user data.
  /**
   * Indicates whether this is a private backend or one that holds user data.
   */
  private boolean isPrivateBackend;
  // The unique identifier for this backend.
  /** The unique identifier for this backend. */
  private String backendID;
  // The writability mode for this backend.
  /** The writability mode for this backend. */
  private WritabilityMode writabilityMode;
@@ -123,8 +109,7 @@
   * @throws  ConfigException
   *                      If there is an error in the configuration.
   */
  public abstract void configureBackend(Configuration cfg)
         throws ConfigException;
  public abstract void configureBackend(C cfg) throws ConfigException;
@@ -148,7 +133,7 @@
   *          for this backend, or {@code false} if not.
   */
  public boolean isConfigurationAcceptable(
                      Configuration configuration,
                      C configuration,
                      List<Message> unacceptableReasons)
  {
    // This default implementation does not perform any special
@@ -329,7 +314,7 @@
            return false;
          }
        }
        return (! filter.getFilterComponents().isEmpty());
        return !filter.getFilterComponents().isEmpty();
      case NOT:
@@ -389,15 +374,7 @@
        {
          matchingRule = attrType.getEqualityMatchingRule();
        }
        if (matchingRule == null)
        {
          return false;
        }
        else
        {
          return isIndexed(attrType, matchingRule);
        }
        return matchingRule != null && isIndexed(attrType, matchingRule);
      default:
@@ -483,7 +460,7 @@
  public boolean entryExists(DN entryDN)
         throws DirectoryException
  {
    return (getEntry(entryDN) != null);
    return getEntry(entryDN) != null;
  }
@@ -641,8 +618,7 @@
  public final boolean supportsControl(String controlOID)
  {
    Set<String> supportedControls = getSupportedControls();
    return ((supportedControls != null) &&
            supportedControls.contains(controlOID));
    return supportedControls != null && supportedControls.contains(controlOID);
  }
@@ -670,8 +646,7 @@
  public final boolean supportsFeature(String featureOID)
  {
    Set<String> supportedFeatures = getSupportedFeatures();
    return ((supportedFeatures != null) &&
            supportedFeatures.contains(featureOID));
    return supportedFeatures != null && supportedFeatures.contains(featureOID);
  }
@@ -964,7 +939,7 @@
   * @return  The parent backend for this backend, or {@code null} if
   *          there is none.
   */
  public final Backend getParentBackend()
  public final Backend<?> getParentBackend()
  {
    return parentBackend;
  }
@@ -976,7 +951,7 @@
   *
   * @param  parentBackend  The parent backend for this backend.
   */
  public final void setParentBackend(Backend parentBackend)
  public final void setParentBackend(Backend<?> parentBackend)
  {
    synchronized (this)
    {
@@ -992,7 +967,7 @@
   * @return  The set of subordinate backends for this backend, or an
   *          empty array if none exist.
   */
  public final Backend[] getSubordinateBackends()
  public final Backend<?>[] getSubordinateBackends()
  {
    return subordinateBackends;
  }
@@ -1006,7 +981,7 @@
   *                              this backend.
   */
  public final void setSubordinateBackends(
                         Backend[] subordinateBackends)
                         Backend<?>[] subordinateBackends)
  {
    synchronized (this)
    {
@@ -1030,8 +1005,7 @@
   */
  public final boolean hasSubSuffix(DN subSuffixDN)
  {
    Backend[] subBackends = subordinateBackends;
    for (Backend b : subBackends)
    for (Backend<?> b : subordinateBackends)
    {
      for (DN baseDN : b.getBaseDNs())
      {
@@ -1072,9 +1046,9 @@
    synchronized (this)
    {
      boolean matchFound = false;
      ArrayList<Backend> subBackendList =
           new ArrayList<Backend>(subordinateBackends.length);
      for (Backend b : subordinateBackends)
      ArrayList<Backend<?>> subBackendList =
           new ArrayList<Backend<?>>(subordinateBackends.length);
      for (Backend<?> b : subordinateBackends)
      {
        boolean thisMatches = false;
        DN[] subBaseDNs = b.getBaseDNs();
@@ -1112,7 +1086,7 @@
      if (matchFound)
      {
        Backend[] newSubordinateBackends =
        Backend<?>[] newSubordinateBackends =
             new Backend[subBackendList.size()];
        subBackendList.toArray(newSubordinateBackends);
        subordinateBackends = newSubordinateBackends;
@@ -1130,21 +1104,20 @@
   *                             subordinate backends for this
   *                             backend.
   */
  public final void addSubordinateBackend(Backend subordinateBackend)
  public final void addSubordinateBackend(Backend<?> subordinateBackend)
  {
    synchronized (this)
    {
      LinkedHashSet<Backend> backendSet =
           new LinkedHashSet<Backend>();
      LinkedHashSet<Backend<?>> backendSet = new LinkedHashSet<Backend<?>>();
      for (Backend b : subordinateBackends)
      for (Backend<?> b : subordinateBackends)
      {
        backendSet.add(b);
      }
      if (backendSet.add(subordinateBackend))
      {
        Backend[] newSubordinateBackends =
        Backend<?>[] newSubordinateBackends =
             new Backend[backendSet.size()];
        backendSet.toArray(newSubordinateBackends);
        subordinateBackends = newSubordinateBackends;
@@ -1163,15 +1136,15 @@
   *                             backend.
   */
  public final void removeSubordinateBackend(
                         Backend subordinateBackend)
                         Backend<?> subordinateBackend)
  {
    synchronized (this)
    {
      ArrayList<Backend> backendList =
           new ArrayList<Backend>(subordinateBackends.length);
      ArrayList<Backend<?>> backendList =
           new ArrayList<Backend<?>>(subordinateBackends.length);
      boolean found = false;
      for (Backend b : subordinateBackends)
      for (Backend<?> b : subordinateBackends)
      {
        if (b.equals(subordinateBackend))
        {
@@ -1185,7 +1158,7 @@
      if (found)
      {
        Backend[] newSubordinateBackends =
        Backend<?>[] newSubordinateBackends =
             new Backend[backendList.size()];
        backendList.toArray(newSubordinateBackends);
        subordinateBackends = newSubordinateBackends;
@@ -1207,13 +1180,11 @@
   */
  public final boolean handlesEntry(DN entryDN)
  {
    DN[] baseDNs = getBaseDNs();
    for (DN dn : baseDNs)
    for (DN dn : getBaseDNs())
    {
      if (entryDN.isDescendantOf(dn))
      {
        Backend[] subBackends = subordinateBackends;
        for (Backend b : subBackends)
        for (Backend<?> b : subordinateBackends)
        {
          if (b.handlesEntry(entryDN))
          {
@@ -1249,7 +1220,7 @@
    {
      if (entryDN.isDescendantOf(baseDN))
      {
        if ((excludeDNs == null) || excludeDNs.isEmpty())
        if (excludeDNs == null || excludeDNs.isEmpty())
        {
          return true;
        }