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

Nicolas Capponi
21.22.2014 80e2d352bedcafd7b83fc85f07239655fadb66dd
Checkpoint commit for OPENDJ-1206 : Create a new ReplicationBackend/ChangelogBackend 
to support cn=changelog
CR-4052

Preparatory work for the changelog backend: make the "Changelog Exchange Control"
available to the backend when search(SearchOperation) method is called

* LocalBackendSearchOperation#handleRequestControls() method:
handle the "Changelog Exchange Control" : add it to the SearchOperation
if provided in the request

* SearchOperation, SearchOperationBasis and SearchOperationWrapper classes:
add getter and setter for the "Changelog Exchange Control" (ECLRequestControl class)

* core.properties : add new message for case when "Changelog Exchange Control" is requested
but not supported by a backend
5 files modified
91 ■■■■ changed files
opends/src/messages/messages/core.properties 7 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperation.java 20 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperationBasis.java 19 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperationWrapper.java 17 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java 28 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/core.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
#      Copyright 2006-2010 Sun Microsystems, Inc.
#      Portions copyright 2011-2012 ForgeRock AS
#      Portions copyright 2011-2014 ForgeRock AS
@@ -1429,4 +1429,7 @@
SEVERE_ERR_PWPOLICY_REJECT_DUE_TO_UNKNOWN_VALIDATOR_LOG_747=The password for \
 user %s could not be validated because the password policy subentry %s is \
 referring to an unknown password validator (%s). Please make sure the password \
 policy subentry only refers to validators that exist on all replicas
 policy subentry only refers to validators that exist on all replicas
MILD_ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL_ECL_COOKIE_EXCHANGE_748=The search request \
 cannot be processed because the backend "%s" does not support the Changelog Exchange Control \
  (oid: 1.3.6.1.4.1.26027.1.5.4)
opends/src/server/org/opends/server/core/SearchOperation.java
@@ -22,13 +22,14 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2013 ForgeRock AS
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.core;
import java.util.List;
import java.util.Set;
import org.opends.server.controls.ExternalChangelogRequestControl;
import org.opends.server.controls.MatchedValuesControl;
import org.opends.server.types.*;
@@ -488,4 +489,21 @@
   */
  public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN);
  /**
   * Retrieves the external changelog request control.
   *
   * @return the external changelog request control, or {@code null}
   *  if the control has not been requested.
   */
  public abstract ExternalChangelogRequestControl getECLRequestControl();
  /**
   * Sets the external changelog request control.
   * <p>
   * It should be set only when searching the external changelog.
   *
   * @param control
   *            The external changelog request control.
   */
  public abstract void setECLRequestControl(ExternalChangelogRequestControl control);
}
opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2013 ForgeRock AS
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.core;
@@ -34,6 +34,7 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.controls.AccountUsableResponseControl;
import org.opends.server.controls.ExternalChangelogRequestControl;
import org.opends.server.controls.MatchedValuesControl;
import org.opends.server.core.networkgroups.NetworkGroup;
import org.opends.server.loggers.debug.DebugLogger;
@@ -163,6 +164,8 @@
  /** Indicates whether to send the search result done to the client or not. */
  private boolean sendResponse = true;
  private ExternalChangelogRequestControl eclRequestControl;
  /**
   * Creates a new search operation with the provided information.
   *
@@ -1078,6 +1081,20 @@
    this.matchedValuesControl = controls;
  }
  /** {@inheritDoc} */
  @Override
  public ExternalChangelogRequestControl getECLRequestControl()
  {
    return eclRequestControl;
  }
  /** {@inheritDoc} */
  @Override
  public void setECLRequestControl(ExternalChangelogRequestControl control)
  {
    eclRequestControl = control;
  }
  /**
   * {@inheritDoc}
   */
opends/src/server/org/opends/server/core/SearchOperationWrapper.java
@@ -22,13 +22,14 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2013 ForgeRock AS
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.core;
import java.util.List;
import java.util.Set;
import org.opends.server.controls.ExternalChangelogRequestControl;
import org.opends.server.controls.MatchedValuesControl;
import org.opends.server.types.*;
@@ -492,4 +493,18 @@
    getOperation().setProxiedAuthorizationDN(proxiedAuthorizationDN);
  }
  /** {@inheritDoc} */
  @Override
  public ExternalChangelogRequestControl getECLRequestControl()
  {
    return getOperation().getECLRequestControl();
  }
  /** {@inheritDoc} */
  @Override
  public void setECLRequestControl(ExternalChangelogRequestControl control)
  {
    getOperation().setECLRequestControl(control);
  }
}
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendSearchOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2013 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package org.opends.server.workflowelement.localbackend;
@@ -526,20 +526,32 @@
        {
          // Do nothing here and let AciHandler deal with it.
        }
        // NYI -- Add support for additional controls.
        else if (c.isCritical())
        else if (OID_ECL_COOKIE_EXCHANGE_CONTROL.equals(oid))
        {
          if ((backend == null) || (! backend.supportsControl(oid)))
          if (c.isCritical() && !backendSupportsControl(oid))
          {
            throw new DirectoryException(
                           ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
                           ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL.get(oid));
                ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
                ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL_ECL_COOKIE_EXCHANGE.get(backend.getBackendID()));
          }
          setECLRequestControl(getRequestControl(ExternalChangelogRequestControl.DECODER));
        }
        // NYI -- Add support for additional controls.
        else if (c.isCritical() && !backendSupportsControl(oid))
        {
          throw new DirectoryException(
              ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
              ERR_SEARCH_UNSUPPORTED_CRITICAL_CONTROL.get(oid));
        }
      }
    }
  }
  /** Indicates if the backend supports the control corresponding to provided oid. */
  private boolean backendSupportsControl(final String oid)
  {
    return backend != null && backend.supportsControl(oid);
  }
}