From 8eccbf96dbbd591db95fe10c20b6cc5210dc2142 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 22 Sep 2014 08:55:26 +0000
Subject: [PATCH] Code cleanup

---
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperation.java        |  128 +++---
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java                 |  182 +---------
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationWrapper.java |  206 ++---------
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/WorkflowTopology.java       |   36 -
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java   |  431 +++++++-----------------
 5 files changed, 268 insertions(+), 715 deletions(-)

diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
index 30c95a3..70b405c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -32,17 +32,22 @@
 import java.util.Set;
 
 import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.opendj.ldap.ConditionResult;
 import org.opends.server.admin.Configuration;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.*;
+import org.opends.server.core.AddOperation;
+import org.opends.server.core.DeleteOperation;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ModifyDNOperation;
+import org.opends.server.core.ModifyOperation;
+import org.opends.server.core.SearchOperation;
 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.DirectoryException;
 import org.opends.server.types.Entry;
 import org.opends.server.types.IndexType;
 import org.opends.server.types.InitializationException;
@@ -53,8 +58,6 @@
 import org.opends.server.types.SearchFilter;
 import org.opends.server.types.WritabilityMode;
 
-import static org.opends.messages.BackendMessages.*;
-
 /**
  * This class defines the set of methods and structures that must be
  * implemented for a Directory Server backend.
@@ -80,7 +83,7 @@
    * The set of backends that hold portions of the DIT that are hierarchically
    * below the information in this backend.
    */
-  private Backend<?>[] subordinateBackends;
+  private Backend<?>[] subordinateBackends = new Backend[0];
 
   /** The backend monitor associated with this backend. */
   private BackendMonitor backendMonitor;
@@ -94,26 +97,7 @@
   private String backendID;
 
   /** The writability mode for this backend. */
-  private WritabilityMode writabilityMode;
-
-
-
-  /**
-   * Creates a new backend with the provided information.  All backend
-   * implementations must implement a default constructor that use
-   * {@code super} to invoke this constructor.
-   */
-  protected Backend()
-  {
-    backendID           = null;
-    parentBackend       = null;
-    subordinateBackends = new Backend[0];
-    isPrivateBackend    = false;
-    writabilityMode     = WritabilityMode.ENABLED;
-    backendMonitor      = null;
-  }
-
-
+  private WritabilityMode writabilityMode = WritabilityMode.ENABLED;
 
   /**
    * Configure this backend based on the information in the provided
@@ -282,10 +266,10 @@
    *          matching rule should be considered indexed, or
    *          {@code false} if not.
    */
-  public boolean isIndexed(AttributeType attributeType,
+  private boolean isIndexed(AttributeType attributeType,
                            MatchingRule matchingRule)
   {
-    return false;
+    return false; // FIXME This should be overridden by the JE Backend at least!
   }
 
 
@@ -336,36 +320,23 @@
         // NOT filters are not considered indexed by default.
         return false;
 
-
       case EQUALITY:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.EQUALITY);
-
+        return isIndexed(filter.getAttributeType(), IndexType.EQUALITY);
 
       case SUBSTRING:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.SUBSTRING);
-
+        return isIndexed(filter.getAttributeType(), IndexType.SUBSTRING);
 
       case GREATER_OR_EQUAL:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.GREATER_OR_EQUAL);
-
+        return isIndexed(filter.getAttributeType(), IndexType.GREATER_OR_EQUAL);
 
       case LESS_OR_EQUAL:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.LESS_OR_EQUAL);
-
+        return isIndexed(filter.getAttributeType(), IndexType.LESS_OR_EQUAL);
 
       case PRESENT:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.PRESENCE);
-
+        return isIndexed(filter.getAttributeType(), IndexType.PRESENCE);
 
       case APPROXIMATE_MATCH:
-        return isIndexed(filter.getAttributeType(),
-                         IndexType.APPROXIMATE);
-
+        return isIndexed(filter.getAttributeType(), IndexType.APPROXIMATE);
 
       case EXTENSIBLE_MATCH:
         // The attribute type must be provided for us to make the
@@ -389,6 +360,7 @@
         {
           matchingRule = attrType.getEqualityMatchingRule();
         }
+        // FIXME isIndexed() always return false down below
         return matchingRule != null && isIndexed(attrType, matchingRule);
 
 
@@ -889,8 +861,6 @@
     return writabilityMode;
   }
 
-
-
   /**
    * Specifies the writability mode for this backend.
    *
@@ -899,14 +869,8 @@
   public final void setWritabilityMode(
                          WritabilityMode writabilityMode)
   {
-    if (writabilityMode == null)
-    {
-      this.writabilityMode = WritabilityMode.ENABLED;
-    }
-    else
-    {
-      this.writabilityMode = writabilityMode;
-    }
+    this.writabilityMode =
+        writabilityMode != null ? writabilityMode : WritabilityMode.ENABLED;
   }
 
 
@@ -1004,110 +968,6 @@
     }
   }
 
-
-
-  /**
-   * Indicates whether this backend has a subordinate backend
-   * registered with the provided base DN.  This may check recursively
-   * if a subordinate backend has its own subordinate backends.
-   *
-   * @param  subSuffixDN  The DN of the sub-suffix for which to make
-   *                      the determination.
-   *
-   * @return  {@code true} if this backend has a subordinate backend
-   *          registered with the provided base DN, or {@code false}
-   *          if it does not.
-   */
-  public final boolean hasSubSuffix(DN subSuffixDN)
-  {
-    for (Backend<?> b : subordinateBackends)
-    {
-      for (DN baseDN : b.getBaseDNs())
-      {
-        if (baseDN.equals(subSuffixDN))
-        {
-          return true;
-        }
-      }
-
-      if (b.hasSubSuffix(subSuffixDN))
-      {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-
-
-  /**
-   * Removes the backend associated with the specified sub-suffix if
-   * it is registered.  This may check recursively if a subordinate
-   * backend has its own subordinate backends.
-   *
-   * @param  subSuffixDN  The DN of the sub-suffix to remove from this
-   *                      backend.
-   * @param  parentDN     The superior DN for the sub-suffix DN that
-   *                      matches one of the subordinate base DNs for
-   *                      this backend.
-   *
-   * @throws  ConfigException  If the sub-suffix exists but it is not
-   *                           possible to remove it for some reason.
-   */
-  public final void removeSubSuffix(DN subSuffixDN, DN parentDN)
-         throws ConfigException
-  {
-    synchronized (this)
-    {
-      boolean matchFound = false;
-      ArrayList<Backend<?>> subBackendList =
-           new ArrayList<Backend<?>>(subordinateBackends.length);
-      for (Backend<?> b : subordinateBackends)
-      {
-        boolean thisMatches = false;
-        DN[] subBaseDNs = b.getBaseDNs();
-        for (DN dn : subBaseDNs)
-        {
-          if (dn.equals(subSuffixDN))
-          {
-            if (subBaseDNs.length > 1)
-            {
-              throw new ConfigException(
-                  ERR_BACKEND_CANNOT_REMOVE_MULTIBASE_SUB_SUFFIX.get(subSuffixDN, parentDN));
-            }
-
-            thisMatches = true;
-            matchFound  = true;
-            break;
-          }
-        }
-
-        if (! thisMatches)
-        {
-          if (b.hasSubSuffix(subSuffixDN))
-          {
-            b.removeSubSuffix(subSuffixDN, parentDN);
-          }
-          else
-          {
-            subBackendList.add(b);
-          }
-        }
-      }
-
-      if (matchFound)
-      {
-        Backend<?>[] newSubordinateBackends =
-             new Backend[subBackendList.size()];
-        subBackendList.toArray(newSubordinateBackends);
-        subordinateBackends = newSubordinateBackends;
-      }
-    }
-  }
-
-
-
   /**
    * Adds the provided backend to the set of subordinate backends for
    * this backend.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperation.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperation.java
index babd137..3dd1810 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperation.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperation.java
@@ -33,7 +33,15 @@
 import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
 import org.forgerock.opendj.ldap.SearchScope;
 import org.opends.server.controls.MatchedValuesControl;
-import org.opends.server.types.*;
+import org.opends.server.types.Control;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.Entry;
+import org.opends.server.types.Operation;
+import org.opends.server.types.RawFilter;
+import org.opends.server.types.SearchFilter;
+import org.opends.server.types.SearchResultEntry;
+import org.opends.server.types.SearchResultReference;
 
 /**
  * This interface defines an operation used to search for entries
@@ -50,7 +58,7 @@
    * @return  The raw, unprocessed base DN as included in the request from the
    *          client.
    */
-  public abstract ByteString getRawBaseDN();
+  ByteString getRawBaseDN();
 
   /**
    * Specifies the raw, unprocessed base DN as included in the request from the
@@ -59,7 +67,7 @@
    * @param  rawBaseDN  The raw, unprocessed base DN as included in the request
    *                    from the client.
    */
-  public abstract void setRawBaseDN(ByteString rawBaseDN);
+  void setRawBaseDN(ByteString rawBaseDN);
 
   /**
    * Retrieves the base DN for this search operation.  This should not be called
@@ -69,7 +77,7 @@
    * @return  The base DN for this search operation, or <CODE>null</CODE> if the
    *          raw base DN has not yet been processed.
    */
-  public abstract DN getBaseDN();
+  DN getBaseDN();
 
   /**
    * Specifies the base DN for this search operation.  This method is only
@@ -77,14 +85,14 @@
    *
    * @param  baseDN  The base DN for this search operation.
    */
-  public abstract void setBaseDN(DN baseDN);
+  void setBaseDN(DN baseDN);
 
   /**
    * Retrieves the scope for this search operation.
    *
    * @return  The scope for this search operation.
    */
-  public abstract SearchScope getScope();
+  SearchScope getScope();
 
   /**
    * Specifies the scope for this search operation.  This should only be called
@@ -92,14 +100,14 @@
    *
    * @param  scope  The scope for this search operation.
    */
-  public abstract void setScope(SearchScope scope);
+  void setScope(SearchScope scope);
 
   /**
    * Retrieves the alias dereferencing policy for this search operation.
    *
    * @return  The alias dereferencing policy for this search operation.
    */
-  public abstract DereferenceAliasesPolicy getDerefPolicy();
+  DereferenceAliasesPolicy getDerefPolicy();
 
   /**
    * Specifies the alias dereferencing policy for this search operation.  This
@@ -108,14 +116,14 @@
    * @param  derefPolicy  The alias dereferencing policy for this search
    *                      operation.
    */
-  public abstract void setDerefPolicy(DereferenceAliasesPolicy derefPolicy);
+  void setDerefPolicy(DereferenceAliasesPolicy derefPolicy);
 
   /**
    * Retrieves the size limit for this search operation.
    *
    * @return  The size limit for this search operation.
    */
-  public abstract int getSizeLimit();
+  int getSizeLimit();
 
   /**
    * Specifies the size limit for this search operation.  This should only be
@@ -123,21 +131,21 @@
    *
    * @param  sizeLimit  The size limit for this search operation.
    */
-  public abstract void setSizeLimit(int sizeLimit);
+  void setSizeLimit(int sizeLimit);
 
   /**
    * Retrieves the time limit for this search operation.
    *
    * @return  The time limit for this search operation.
    */
-  public abstract int getTimeLimit();
+  int getTimeLimit();
 
   /**
    * Get the time after which the search time limit has expired.
    *
    * @return the timeLimitExpiration
    */
-  public abstract long getTimeLimitExpiration();
+  long getTimeLimitExpiration();
 
   /**
    * Specifies the time limit for this search operation.  This should only be
@@ -145,14 +153,14 @@
    *
    * @param  timeLimit  The time limit for this search operation.
    */
-  public abstract void setTimeLimit(int timeLimit);
+  void setTimeLimit(int timeLimit);
 
   /**
    * Retrieves the typesOnly flag for this search operation.
    *
    * @return  The typesOnly flag for this search operation.
    */
-  public abstract boolean getTypesOnly();
+  boolean getTypesOnly();
 
   /**
    * Specifies the typesOnly flag for this search operation.  This should only
@@ -160,7 +168,7 @@
    *
    * @param  typesOnly  The typesOnly flag for this search operation.
    */
-  public abstract void setTypesOnly(boolean typesOnly);
+  void setTypesOnly(boolean typesOnly);
 
   /**
    * Retrieves the raw, unprocessed search filter as included in the request
@@ -171,7 +179,7 @@
    * @return  The raw, unprocessed search filter as included in the request from
    *          the client.
    */
-  public abstract RawFilter getRawFilter();
+  RawFilter getRawFilter();
 
   /**
    * Specifies the raw, unprocessed search filter as included in the request
@@ -180,7 +188,7 @@
    * @param  rawFilter  The raw, unprocessed search filter as included in the
    *                    request from the client.
    */
-  public abstract void setRawFilter(RawFilter rawFilter);
+  void setRawFilter(RawFilter rawFilter);
 
   /**
    * Retrieves the filter for this search operation.  This should not be called
@@ -190,7 +198,7 @@
    * @return  The filter for this search operation, or <CODE>null</CODE> if the
    *          raw filter has not yet been processed.
    */
-  public abstract SearchFilter getFilter();
+  SearchFilter getFilter();
 
   /**
    * Retrieves the set of requested attributes for this search operation.  Its
@@ -198,7 +206,7 @@
    *
    * @return  The set of requested attributes for this search operation.
    */
-  public abstract Set<String> getAttributes();
+  Set<String> getAttributes();
 
   /**
    * Specifies the set of requested attributes for this search operation.  It
@@ -207,7 +215,7 @@
    * @param  attributes  The set of requested attributes for this search
    *                     operation.
    */
-  public abstract void setAttributes(Set<String> attributes);
+  void setAttributes(Set<String> attributes);
 
   /**
    * Retrieves the number of entries sent to the client for this search
@@ -216,7 +224,7 @@
    * @return  The number of entries sent to the client for this search
    *          operation.
    */
-  public abstract int getEntriesSent();
+  int getEntriesSent();
 
   /**
    * Retrieves the number of search references sent to the client for this
@@ -225,7 +233,7 @@
    * @return  The number of search references sent to the client for this search
    *          operation.
    */
-  public abstract int getReferencesSent();
+  int getReferencesSent();
 
   /**
    * Used as a callback for backends to indicate that the provided entry matches
@@ -242,7 +250,7 @@
    *          <CODE>false</CODE> if not for some reason (e.g., the size limit
    *          has been reached or the search has been abandoned).
    */
-  public abstract boolean returnEntry(Entry entry, List<Control> controls);
+  boolean returnEntry(Entry entry, List<Control> controls);
 
   /**
    * Used as a callback for backends to indicate that the provided entry matches
@@ -261,7 +269,7 @@
    *          <CODE>false</CODE> if not for some reason (e.g., the size limit
    *          has been reached or the search has been abandoned).
    */
-  public abstract boolean returnEntry(Entry entry, List<Control> controls,
+  boolean returnEntry(Entry entry, List<Control> controls,
                                       boolean evaluateAci);
 
   /**
@@ -277,7 +285,7 @@
    *          <CODE>false</CODE> if not for some reason (e.g., the size limit
    *          has been reached or the search has been abandoned).
    */
-  public abstract boolean returnReference(DN dn,
+  boolean returnReference(DN dn,
                                           SearchResultReference reference);
 
   /**
@@ -295,7 +303,7 @@
    *          <CODE>false</CODE> if not for some reason (e.g., the size limit
    *          has been reached or the search has been abandoned).
    */
-  public abstract boolean returnReference(DN dn,
+  boolean returnReference(DN dn,
                                           SearchResultReference reference,
                                           boolean evaluateAci);
 
@@ -307,43 +315,43 @@
    * message should have been set for this operation before this method is
    * called.
    */
-  public abstract void sendSearchResultDone();
+  void sendSearchResultDone();
 
   /**
    * Set the time after which the search time limit has expired.
    *
    * @param timeLimitExpiration - Time after which the search has expired
    */
-  public abstract void setTimeLimitExpiration(long timeLimitExpiration);
+  void setTimeLimitExpiration(long timeLimitExpiration);
 
   /**
    * Indicates whether LDAP subentries should be returned or not.
    *
    * @return true if the LDAP subentries should be returned, false otherwise
    */
-  public abstract boolean isReturnSubentriesOnly();
+  boolean isReturnSubentriesOnly();
 
   /**
-   * Set the flag indicating wether the LDAP subentries should be returned.
+   * Set the flag indicating whether the LDAP subentries should be returned.
    *
-   * @param returnLDAPSubentries - Boolean indicating wether the LDAP
+   * @param returnLDAPSubentries - Boolean indicating whether the LDAP
    *                               subentries should be returned or not
    */
-  public abstract void setReturnSubentriesOnly(boolean returnLDAPSubentries);
+  void setReturnSubentriesOnly(boolean returnLDAPSubentries);
 
   /**
    * The matched values control associated with this search operation.
    *
    * @return the match values control
    */
-  public abstract MatchedValuesControl getMatchedValuesControl();
+  MatchedValuesControl getMatchedValuesControl();
 
   /**
    * Set the match values control.
    *
    * @param controls - The matched values control
    */
-  public abstract void setMatchedValuesControl(MatchedValuesControl controls);
+  void setMatchedValuesControl(MatchedValuesControl controls);
 
   /**
    * Indicates whether to include the account usable response control with
@@ -352,7 +360,7 @@
    * @return true if the usable control has to be part of the search result
    *         entry
    */
-  public abstract boolean isIncludeUsableControl();
+  boolean isIncludeUsableControl();
 
   /**
    * Specify whether to include the account usable response control within the
@@ -362,14 +370,14 @@
    *                               has to be included within the search result
    *                               entries, false otherwise
    */
-  public abstract void setIncludeUsableControl(boolean includeUsableControl);
+  void setIncludeUsableControl(boolean includeUsableControl);
 
   /**
    * Indicates whether the client is able to handle referrals.
    *
    * @return true, if the client is able to handle referrals
    */
-  public abstract boolean isClientAcceptsReferrals();
+  boolean isClientAcceptsReferrals();
 
   /**
    * Specify whether the client is able to handle referrals.
@@ -377,51 +385,39 @@
    * @param clientAcceptReferrals - Boolean set to true if the client
    *                                can handle referrals
    */
-  public abstract void setClientAcceptsReferrals(boolean clientAcceptReferrals);
+  void setClientAcceptsReferrals(boolean clientAcceptReferrals);
 
   /**
-   * Increments by 1 the number of entries sent to the client for this search
-   * operation.
-   */
-  public abstract void incrementEntriesSent();
-
-  /**
-   * Increments by 1 the number of search references sent to the client for this
-   * search operation.
-   */
-  public abstract void incrementReferencesSent();
-
-  /**
-   * Indicates wether the search result done message has to be sent
+   * Indicates whether the search result done message has to be sent
    * to the client, or not.
    *
    * @return true if the search result done message is to be sent to the client
    */
-  public abstract boolean isSendResponse();
+  boolean isSendResponse();
 
   /**
-   * Specify wether the search result done message has to be sent
+   * Specify whether the search result done message has to be sent
    * to the client, or not.
    *
-   * @param sendResponse - boolean indicating wether the search result done
+   * @param sendResponse - boolean indicating whether the search result done
    *                       message is to send to the client
    */
-  public abstract void setSendResponse(boolean sendResponse);
+  void setSendResponse(boolean sendResponse);
 
   /**
    * Returns true if only real attributes should be returned.
    *
    * @return true if only real attributes should be returned, false otherwise
    */
-  public abstract boolean isRealAttributesOnly();
+  boolean isRealAttributesOnly();
 
   /**
-   * Specify wether to only return real attributes.
+   * Specify whether to only return real attributes.
    *
    * @param realAttributesOnly - boolean setup to true, if only the real
    *                             attributes should be returned
    */
-  public abstract void setRealAttributesOnly(boolean realAttributesOnly);
+  void setRealAttributesOnly(boolean realAttributesOnly);
 
   /**
    * Returns true if only virtual attributes should be returned.
@@ -429,15 +425,15 @@
    * @return true if only virtual attributes should be returned, false
    *         otherwise
    */
-  public abstract boolean isVirtualAttributesOnly();
+  boolean isVirtualAttributesOnly();
 
   /**
-   * Specify wether to only return virtual attributes.
+   * Specify whether to only return virtual attributes.
    *
    * @param virtualAttributesOnly - boolean setup to true, if only the virtual
    *                                attributes should be returned
    */
-  public abstract void setVirtualAttributesOnly(boolean virtualAttributesOnly);
+  void setVirtualAttributesOnly(boolean virtualAttributesOnly);
 
   /**
    * Sends the provided search result entry to the client.
@@ -449,7 +445,7 @@
    *                              to send the entry to the client and
    *                              the search should be terminated.
    */
-  public abstract void sendSearchEntry(SearchResultEntry entry)
+  void sendSearchEntry(SearchResultEntry entry)
     throws DirectoryException;
 
   /**
@@ -467,7 +463,7 @@
    *                              to send the reference to the client
    *                              and the search should be terminated.
    */
-  public abstract boolean sendSearchReference(SearchResultReference reference)
+  boolean sendSearchReference(SearchResultReference reference)
     throws DirectoryException;
 
   /**
@@ -478,7 +474,7 @@
    *          authorization has been requested, or {@code null} if proxied
    *          authorization has not been requested.
    */
-  public abstract DN getProxiedAuthorizationDN();
+  DN getProxiedAuthorizationDN();
 
   /**
    * Set the proxied authorization DN for this operation if proxied
@@ -489,6 +485,6 @@
    *          authorization has been requested, or {@code null} if proxied
    *          authorization has not been requested.
    */
-  public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN);
+  void setProxiedAuthorizationDN(DN proxiedAuthorizationDN);
 
 }
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java
index 65b8638..f3efb0c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -26,13 +26,21 @@
  */
 package org.opends.server.core;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
+import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
+import org.opends.server.api.AccessControlHandler;
 import org.opends.server.api.AuthenticationPolicyState;
 import org.opends.server.api.ClientConnection;
 import org.opends.server.api.plugin.PluginResult;
@@ -40,8 +48,22 @@
 import org.opends.server.controls.MatchedValuesControl;
 import org.opends.server.core.networkgroups.NetworkGroup;
 import org.opends.server.protocols.ldap.LDAPFilter;
-import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
+import org.opends.server.types.AbstractOperation;
+import org.opends.server.types.Attribute;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.CancelRequest;
+import org.opends.server.types.CancelResult;
+import org.opends.server.types.CanceledOperationException;
+import org.opends.server.types.Control;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
+import org.opends.server.types.Entry;
+import org.opends.server.types.OperationType;
+import org.opends.server.types.RawFilter;
+import org.opends.server.types.SearchFilter;
+import org.opends.server.types.SearchResultEntry;
+import org.opends.server.types.SearchResultReference;
 import org.opends.server.types.operation.PostResponseSearchOperation;
 import org.opends.server.types.operation.PreParseSearchOperation;
 import org.opends.server.types.operation.SearchEntrySearchOperation;
@@ -71,10 +93,10 @@
    * Indicates whether a search result done response has been sent to the
    * client.
    */
-  private AtomicBoolean responseSent;
+  private final AtomicBoolean responseSent = new AtomicBoolean(false);
 
   /** Indicates whether the client is able to handle referrals. */
-  private boolean clientAcceptsReferrals;
+  private boolean clientAcceptsReferrals = true;
 
   /**
    * Indicates whether to include the account usable control with search result
@@ -118,12 +140,12 @@
   private DN proxiedAuthorizationDN;
 
   /** The number of entries that have been sent to the client. */
-  private int entriesSent;
+  private final AtomicInteger entriesSent = new AtomicInteger();
 
   /**
    * The number of search result references that have been sent to the client.
    */
-  private int referencesSent;
+  private final AtomicInteger referencesSent = new AtomicInteger();
 
   /** The size limit for the search operation. */
   private int sizeLimit;
@@ -138,13 +160,7 @@
   private Set<String> attributes;
 
   /** The set of response controls for this search operation. */
-  private List<Control> responseControls;
-
-  /** The time that processing started on this operation. */
-  private long processingStartTime;
-
-  /** The time that processing ended on this operation. */
-  private long processingStopTime;
+  private final List<Control> responseControls = new ArrayList<Control>();
 
   /** The time that the search time limit has expired. */
   private long timeLimitExpiration;
@@ -193,7 +209,6 @@
   {
     super(clientConnection, operationID, messageID, requestControls);
 
-
     this.rawBaseDN   = rawBaseDN;
     this.scope       = scope;
     this.derefPolicy = derefPolicy;
@@ -201,32 +216,10 @@
     this.timeLimit   = timeLimit;
     this.typesOnly   = typesOnly;
     this.rawFilter   = rawFilter;
-
-    if (attributes == null)
-    {
-      this.attributes  = new LinkedHashSet<String>(0);
-    }
-    else
-    {
-      this.attributes  = attributes;
-    }
+    this.attributes  = attributes != null ? attributes : new LinkedHashSet<String>(0);
 
     this.sizeLimit = getSizeLimit(sizeLimit, clientConnection);
     this.timeLimit = getTimeLimit(timeLimit, clientConnection);
-
-    baseDN                 = null;
-    filter                 = null;
-    entriesSent            = 0;
-    referencesSent         = 0;
-    responseControls       = new ArrayList<Control>();
-    cancelRequest          = null;
-    clientAcceptsReferrals = true;
-    includeUsableControl   = false;
-    responseSent           = new AtomicBoolean(false);
-    returnSubentriesOnly   = false;
-    matchedValuesControl   = null;
-    realAttributesOnly     = false;
-    virtualAttributesOnly  = false;
   }
 
   /**
@@ -258,7 +251,6 @@
   {
     super(clientConnection, operationID, messageID, requestControls);
 
-
     this.baseDN      = baseDN;
     this.scope       = scope;
     this.derefPolicy = derefPolicy;
@@ -266,31 +258,13 @@
     this.timeLimit   = timeLimit;
     this.typesOnly   = typesOnly;
     this.filter      = filter;
-
-    if (attributes == null)
-    {
-      this.attributes = new LinkedHashSet<String>(0);
-    }
-    else
-    {
-      this.attributes  = attributes;
-    }
+    this.attributes  = attributes != null ? attributes : new LinkedHashSet<String>(0);
 
     rawBaseDN = ByteString.valueOf(baseDN.toString());
     rawFilter = new LDAPFilter(filter);
 
     this.sizeLimit = getSizeLimit(sizeLimit, clientConnection);
     this.timeLimit = getTimeLimit(timeLimit, clientConnection);
-
-    entriesSent            = 0;
-    referencesSent         = 0;
-    responseControls       = new ArrayList<Control>();
-    cancelRequest          = null;
-    clientAcceptsReferrals = true;
-    includeUsableControl   = false;
-    responseSent           = new AtomicBoolean(false);
-    returnSubentriesOnly   = false;
-    matchedValuesControl   = null;
   }
 
 
@@ -320,21 +294,14 @@
     return Math.min(timeLimit, clientConnection.getTimeLimit());
   }
 
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final ByteString getRawBaseDN()
   {
     return rawBaseDN;
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setRawBaseDN(ByteString rawBaseDN)
   {
@@ -343,10 +310,7 @@
     baseDN = null;
   }
 
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final DN getBaseDN()
   {
@@ -369,118 +333,91 @@
     return baseDN;
   }
 
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setBaseDN(DN baseDN)
   {
     this.baseDN = baseDN;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final SearchScope getScope()
   {
     return scope;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setScope(SearchScope scope)
   {
     this.scope = scope;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final DereferenceAliasesPolicy getDerefPolicy()
   {
     return derefPolicy;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setDerefPolicy(DereferenceAliasesPolicy derefPolicy)
   {
     this.derefPolicy = derefPolicy;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final int getSizeLimit()
   {
     return sizeLimit;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setSizeLimit(int sizeLimit)
   {
     this.sizeLimit = sizeLimit;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final int getTimeLimit()
   {
     return timeLimit;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setTimeLimit(int timeLimit)
   {
     this.timeLimit = timeLimit;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final boolean getTypesOnly()
   {
     return typesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setTypesOnly(boolean typesOnly)
   {
     this.typesOnly = typesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final RawFilter getRawFilter()
   {
     return rawFilter;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setRawFilter(RawFilter rawFilter)
   {
@@ -489,9 +426,7 @@
     filter = null;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final SearchFilter getFilter()
   {
@@ -514,18 +449,14 @@
     return filter;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final Set<String> getAttributes()
   {
     return attributes;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void setAttributes(Set<String> attributes)
   {
@@ -539,36 +470,28 @@
     }
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final int getEntriesSent()
   {
-    return entriesSent;
+    return entriesSent.get();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final int getReferencesSent()
   {
-    return referencesSent;
+    return referencesSent.get();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final boolean returnEntry(Entry entry, List<Control> controls)
   {
     return returnEntry(entry, controls, true);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final boolean returnEntry(Entry entry, List<Control> controls,
                                    boolean evaluateAci)
@@ -577,7 +500,7 @@
 
     // See if the size limit has been exceeded.  If so, then don't send the
     // entry and indicate that the search should end.
-    if ((getSizeLimit() > 0) && (getEntriesSent() >= getSizeLimit()))
+    if (getSizeLimit() > 0 && getEntriesSent() >= getSizeLimit())
     {
       setResultCode(ResultCode.SIZE_LIMIT_EXCEEDED);
       appendErrorMessage(ERR_SEARCH_SIZE_LIMIT_EXCEEDED.get(getSizeLimit()));
@@ -586,8 +509,8 @@
 
     // See if the time limit has expired.  If so, then don't send the entry and
     // indicate that the search should end.
-    if ((getTimeLimit() > 0) && (TimeThread.getTime() >=
-                                                getTimeLimitExpiration()))
+    if (getTimeLimit() > 0
+        && TimeThread.getTime() >= getTimeLimitExpiration())
     {
       setResultCode(ResultCode.TIME_LIMIT_EXCEEDED);
       appendErrorMessage(ERR_SEARCH_TIME_LIMIT_EXCEEDED.get(getTimeLimit()));
@@ -598,26 +521,23 @@
     // should be returned.
     if (entry.isSubentry() || entry.isLDAPSubentry())
     {
-      if (filterNeedsCheckingForSubentries == true)
+      if (filterNeedsCheckingForSubentries)
       {
         filterIncludesSubentries = checkFilterForLDAPSubEntry(filter, 0);
         filterNeedsCheckingForSubentries = false;
       }
 
-      if ((getScope() != SearchScope.BASE_OBJECT)
+      if (getScope() != SearchScope.BASE_OBJECT
           && !filterIncludesSubentries
           && !isReturnSubentriesOnly())
       {
         return true;
       }
     }
-    else
+    else if (isReturnSubentriesOnly())
     {
-      if (isReturnSubentriesOnly())
-      {
-        // Subentries are visible and normal entries are not.
-        return true;
-      }
+      // Subentries are visible and normal entries are not.
+      return true;
     }
 
     // Determine whether to include the account usable control. If so, then
@@ -662,18 +582,15 @@
                 secondsBeforeExpiration));
           }
         }
+        // Another type of authentication policy (e.g. PTA).
+        else if (state.isDisabled())
+        {
+          controls.add(new AccountUsableResponseControl(false, false, false,
+              -1, true, -1));
+        }
         else
         {
-          // Another type of authentication policy (e.g. PTA).
-          if (state.isDisabled())
-          {
-            controls.add(new AccountUsableResponseControl(false, false, false,
-                -1, true, -1));
-          }
-          else
-          {
-            controls.add(new AccountUsableResponseControl(-1));
-          }
+          controls.add(new AccountUsableResponseControl(-1));
         }
       }
       catch (Exception e)
@@ -683,15 +600,10 @@
     }
 
     // Check to see if the entry can be read by the client.
-    SearchResultEntry unfilteredSearchEntry = new SearchResultEntry(entry,
-        controls);
-    if (evaluateAci)
+    SearchResultEntry unfilteredSearchEntry = new SearchResultEntry(entry, controls);
+    if (evaluateAci && !getACIHandler().maySend(this, unfilteredSearchEntry))
     {
-      if (AccessControlConfigManager.getInstance().getAccessControlHandler()
-          .maySend(this, unfilteredSearchEntry) == false)
-      {
-        return true;
-      }
+      return true;
     }
 
     // Make a copy of the entry and pare it down to only include the set
@@ -706,7 +618,7 @@
     // If there is a matched values control, then further pare down the entry
     // based on the filters that it contains.
     MatchedValuesControl matchedValuesControl = getMatchedValuesControl();
-    if ((matchedValuesControl != null) && (! typesOnly))
+    if (matchedValuesControl != null && !typesOnly)
     {
       // First, look at the set of objectclasses.
 
@@ -790,8 +702,7 @@
     // values that the client is not permitted to see.
     if (evaluateAci)
     {
-      AccessControlConfigManager.getInstance().getAccessControlHandler()
-          .filterEntry(this, unfilteredSearchEntry, filteredSearchEntry);
+      getACIHandler().filterEntry(this, unfilteredSearchEntry, filteredSearchEntry);
     }
 
     // Invoke any search entry plugins that may be registered with the server.
@@ -809,7 +720,7 @@
       {
         sendSearchEntry(filteredSearchEntry);
 
-        incrementEntriesSent();
+        entriesSent.incrementAndGet();
       }
       catch (DirectoryException de)
       {
@@ -823,26 +734,27 @@
     return pluginResult.continueProcessing();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  private AccessControlHandler<?> getACIHandler()
+  {
+    return AccessControlConfigManager.getInstance().getAccessControlHandler();
+  }
+
+  /** {@inheritDoc} */
   @Override
   public final boolean returnReference(DN dn, SearchResultReference reference)
   {
     return returnReference(dn, reference, true);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final boolean returnReference(DN dn, SearchResultReference reference,
                                        boolean evaluateAci)
   {
     // See if the time limit has expired.  If so, then don't send the entry and
     // indicate that the search should end.
-    if ((getTimeLimit() > 0) && (TimeThread.getTime() >=
-                                                getTimeLimitExpiration()))
+    if (getTimeLimit() > 0
+        && TimeThread.getTime() >= getTimeLimitExpiration())
     {
       setResultCode(ResultCode.TIME_LIMIT_EXCEEDED);
       appendErrorMessage(ERR_SEARCH_TIME_LIMIT_EXCEEDED.get(getTimeLimit()));
@@ -852,22 +764,14 @@
 
     // See if we know that this client can't handle referrals.  If so, then
     // don't even try to send it.
-    if (! isClientAcceptsReferrals())
+    if (!isClientAcceptsReferrals()
+        // See if the client has permission to read this reference.
+        || (evaluateAci && !getACIHandler().maySend(dn, this, reference)))
     {
       return true;
     }
 
 
-    // See if the client has permission to read this reference.
-    if (evaluateAci)
-    {
-      if (AccessControlConfigManager.getInstance()
-        .getAccessControlHandler().maySend(dn, this, reference) == false) {
-        return true;
-      }
-    }
-
-
     // Invoke any search reference plugins that may be registered with the
     // server.
     PluginResult.IntermediateResponse pluginResult =
@@ -887,7 +791,7 @@
       {
         if (sendSearchReference(reference))
         {
-          incrementReferencesSent();
+          referencesSent.incrementAndGet();
 
           // FIXME -- Should the size limit apply here?
         }
@@ -910,9 +814,7 @@
     return pluginResult.continueProcessing();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void sendSearchResultDone()
   {
@@ -921,21 +823,16 @@
     // multithreaded in the event of a persistent search, so do it safely.
     if (responseSent.compareAndSet(false, true))
     {
-      // Log the search result.
       logSearchResultDone(this);
 
-      // Send the response to the client.
       clientConnection.sendResponse(this);
 
-      // Invoke the post-response search plugins.
       invokePostResponsePlugins();
     }
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public final OperationType getOperationType()
   {
     // Note that no debugging will be done in this method because it is a likely
@@ -943,48 +840,36 @@
     return OperationType.SEARCH;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public DN getProxiedAuthorizationDN()
   {
     return proxiedAuthorizationDN;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public final List<Control> getResponseControls()
   {
     return responseControls;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public final void addResponseControl(Control control)
   {
     responseControls.add(control);
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public final void removeResponseControl(Control control)
   {
     responseControls.remove(control);
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public void abort(CancelRequest cancelRequest)
   {
     if(cancelResult == null && this.cancelRequest == null)
@@ -993,12 +878,8 @@
     }
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override()
+  /** {@inheritDoc} */
+  @Override
   public final void toString(StringBuilder buffer)
   {
     buffer.append("SearchOperation(connID=");
@@ -1014,171 +895,119 @@
     buffer.append(")");
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setTimeLimitExpiration(long timeLimitExpiration)
   {
     this.timeLimitExpiration = timeLimitExpiration;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isReturnSubentriesOnly()
   {
     return returnSubentriesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setReturnSubentriesOnly(boolean returnLDAPSubentries)
   {
     this.returnSubentriesOnly = returnLDAPSubentries;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public MatchedValuesControl getMatchedValuesControl()
   {
     return matchedValuesControl;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setMatchedValuesControl(MatchedValuesControl controls)
   {
     this.matchedValuesControl = controls;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isIncludeUsableControl()
   {
     return includeUsableControl;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setIncludeUsableControl(boolean includeUsableControl)
   {
     this.includeUsableControl = includeUsableControl;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public long getTimeLimitExpiration()
   {
     return timeLimitExpiration;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isClientAcceptsReferrals()
   {
     return clientAcceptsReferrals;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setClientAcceptsReferrals(boolean clientAcceptReferrals)
   {
     this.clientAcceptsReferrals = clientAcceptReferrals;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void incrementEntriesSent()
-  {
-    entriesSent++;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void incrementReferencesSent()
-  {
-    referencesSent++;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isSendResponse()
   {
     return sendResponse;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setSendResponse(boolean sendResponse)
   {
     this.sendResponse = sendResponse;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isRealAttributesOnly()
   {
     return this.realAttributesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isVirtualAttributesOnly()
   {
     return this.virtualAttributesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setRealAttributesOnly(boolean realAttributesOnly)
   {
     this.realAttributesOnly = realAttributesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setVirtualAttributesOnly(boolean virtualAttributesOnly)
   {
     this.virtualAttributesOnly = virtualAttributesOnly;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void sendSearchEntry(SearchResultEntry searchEntry)
       throws DirectoryException
@@ -1186,9 +1015,7 @@
     getClientConnection().sendSearchEntry(this, searchEntry);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean sendSearchReference(SearchResultReference searchReference)
       throws DirectoryException
@@ -1196,18 +1023,14 @@
     return getClientConnection().sendSearchReference(this, searchReference);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN)
   {
     this.proxiedAuthorizationDN = proxiedAuthorizationDN;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public final void run()
   {
@@ -1394,8 +1217,8 @@
         // FIXME : technically this is not correct since the presence
         // of draft oc would trigger rfc oc visibility and visa versa.
         String stringValueLC = toLowerCase(v.toString());
-        if (stringValueLC.equals(OC_LDAP_SUBENTRY_LC) ||
-            stringValueLC.equals(OC_SUBENTRY))
+        if (OC_LDAP_SUBENTRY_LC.equals(stringValueLC) ||
+            OC_SUBENTRY.equals(stringValueLC))
         {
           return true;
         }
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationWrapper.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationWrapper.java
index 5d52749..a0bc3f4 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationWrapper.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/SearchOperationWrapper.java
@@ -54,18 +54,14 @@
     super(search);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean returnEntry(Entry entry, List<Control> controls)
   {
     return getOperation().returnEntry(entry, controls);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean returnEntry(Entry entry, List<Control> controls,
                              boolean evaluateAci)
@@ -73,18 +69,14 @@
     return getOperation().returnEntry(entry, controls, evaluateAci);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean returnReference(DN dn, SearchResultReference reference)
   {
     return getOperation().returnReference(dn, reference);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean returnReference(DN dn, SearchResultReference reference,
                                  boolean evaluateAci)
@@ -92,375 +84,277 @@
     return getOperation().returnReference(dn, reference, evaluateAci);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public String toString()
   {
     return getOperation().toString();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public Set<String> getAttributes()
   {
     return getOperation().getAttributes();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public DN getBaseDN()
   {
     return getOperation().getBaseDN();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public DereferenceAliasesPolicy getDerefPolicy()
   {
     return getOperation().getDerefPolicy();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public int getEntriesSent()
   {
     return getOperation().getEntriesSent();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public SearchFilter getFilter()
   {
     return getOperation().getFilter();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public ByteString getRawBaseDN()
   {
     return getOperation().getRawBaseDN();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public RawFilter getRawFilter()
   {
     return getOperation().getRawFilter();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public int getReferencesSent()
   {
     return getOperation().getReferencesSent();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public SearchScope getScope()
   {
     return getOperation().getScope();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public int getSizeLimit()
   {
     return getOperation().getSizeLimit();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public int getTimeLimit()
   {
     return getOperation().getTimeLimit();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean getTypesOnly()
   {
     return getOperation().getTypesOnly();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void sendSearchResultDone()
   {
     getOperation().sendSearchResultDone();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setAttributes(Set<String> attributes)
   {
     getOperation().setAttributes(attributes);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setBaseDN(DN baseDN)
   {
     getOperation().setBaseDN(baseDN);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setDerefPolicy(DereferenceAliasesPolicy derefPolicy)
   {
     getOperation().setDerefPolicy(derefPolicy);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setRawBaseDN(ByteString rawBaseDN)
   {
     getOperation().setRawBaseDN(rawBaseDN);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setRawFilter(RawFilter rawFilter)
   {
     getOperation().setRawFilter(rawFilter);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setScope(SearchScope scope)
   {
     getOperation().setScope(scope);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setSizeLimit(int sizeLimit)
   {
     getOperation().setSizeLimit(sizeLimit);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setTimeLimit(int timeLimit)
   {
     getOperation().setTimeLimit(timeLimit);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setTypesOnly(boolean typesOnly)
   {
     getOperation().setTypesOnly(typesOnly);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setTimeLimitExpiration(long timeLimitExpiration)
   {
     getOperation().setTimeLimitExpiration(timeLimitExpiration);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isReturnSubentriesOnly()
   {
     return getOperation().isReturnSubentriesOnly();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setReturnSubentriesOnly(boolean returnLDAPSubentries)
   {
     getOperation().setReturnSubentriesOnly(returnLDAPSubentries);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public MatchedValuesControl getMatchedValuesControl()
   {
     return getOperation().getMatchedValuesControl();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setMatchedValuesControl(MatchedValuesControl controls)
   {
     getOperation().setMatchedValuesControl(controls);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isIncludeUsableControl()
   {
     return getOperation().isIncludeUsableControl();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setIncludeUsableControl(boolean includeUsableControl)
   {
     getOperation().setIncludeUsableControl(includeUsableControl);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public long getTimeLimitExpiration()
   {
     return getOperation().getTimeLimitExpiration();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isClientAcceptsReferrals()
   {
     return getOperation().isClientAcceptsReferrals();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setClientAcceptsReferrals(boolean clientAcceptReferrals)
   {
     getOperation().setClientAcceptsReferrals(clientAcceptReferrals);
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void incrementEntriesSent()
-  {
-    getOperation().incrementEntriesSent();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void incrementReferencesSent()
-  {
-    getOperation().incrementReferencesSent();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isSendResponse()
   {
     return getOperation().isSendResponse();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setSendResponse(boolean sendResponse)
   {
     getOperation().setSendResponse(sendResponse);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isRealAttributesOnly(){
     return getOperation().isRealAttributesOnly();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setRealAttributesOnly(boolean realAttributesOnly){
     getOperation().setRealAttributesOnly(realAttributesOnly);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean isVirtualAttributesOnly()
   {
     return getOperation().isVirtualAttributesOnly();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setVirtualAttributesOnly(boolean virtualAttributesOnly){
     getOperation().setVirtualAttributesOnly(virtualAttributesOnly);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void sendSearchEntry(SearchResultEntry entry)
       throws DirectoryException
@@ -468,9 +362,7 @@
     getOperation().sendSearchEntry(entry);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public boolean sendSearchReference(SearchResultReference reference)
       throws DirectoryException
@@ -478,18 +370,14 @@
     return getOperation().sendSearchReference(reference);
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public DN getProxiedAuthorizationDN()
   {
     return getOperation().getProxiedAuthorizationDN();
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN){
     getOperation().setProxiedAuthorizationDN(proxiedAuthorizationDN);
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/WorkflowTopology.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/WorkflowTopology.java
index 19176a7..d985c77 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/WorkflowTopology.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/WorkflowTopology.java
@@ -39,30 +39,10 @@
  * nodes in the workflow topology (WorkflowTopologyNode) and the second
  * one is used to implement the root DSE node (RootDseWorkflowTopology).
  */
-
 public abstract class WorkflowTopology implements Workflow
 {
-  // The workflow implementation containing the task tree (ie. the processing)
-  private WorkflowImpl workflowImpl = null;
-
-
-  /**
-   * Each workflow node may have specific tasks to be executed before
-   * the workflow task tree. The tasks to execute before are stored in
-   * the following array, which is empty at the moment (implementation
-   * will come later on when needed).
-   */
-  // private WorkflowElement[] preWorkflowElements = null;
-
-
-  /**
-   * Each workflow node may have specific tasks to be executed after
-   * the workflow task tree. The tasks to execute after are stored in
-   * the following array, which is empty at the moment (implementation
-   * will come later on when needed).
-   */
-  // private WorkflowElement[] postWorkflowElements = null;
-
+  /** The workflow implementation containing the task tree (ie. the processing). */
+  private WorkflowImpl workflowImpl;
 
   /**
    * Create a new instance of the workflow topology base class.
@@ -96,6 +76,7 @@
    *
    * @return the base DN of the workflow containing the processing.
    */
+  @Override
   public DN getBaseDN()
   {
     return getWorkflowImpl().getBaseDN();
@@ -111,9 +92,7 @@
    * @return the new scope to use for searches on subordinate workflows,
    *         <code>null</code> when current scope is 'base'
    */
-
-  protected SearchScope elaborateScopeForSearchInSubordinates(
-      SearchScope currentScope)
+  protected SearchScope elaborateScopeForSearchInSubordinates(SearchScope currentScope)
   {
     switch (currentScope.asEnum())
     {
@@ -129,4 +108,11 @@
     }
   }
 
+  /** {@inheritDoc} */
+  @Override
+  public String toString()
+  {
+    return getClass().getSimpleName() + " " + workflowImpl;
+  }
+
 }

--
Gitblit v1.10.0