From 98a5df3565beaa1999020a16fcb5338d13d5b50f Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 26 Aug 2014 08:11:29 +0000
Subject: [PATCH] Removed useless getChangeNumber() and setChangeNumber methods from *Operation interfaces. These methods are useless because setChangeNumber() is never set inside production code, so changeNumber is always equal to -1 for all the update operations. In addition it is very unlikely the ChangeNumberIndexer could have computed the changeNumber before a results are sent to a persistent search.

---
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java |  103 +++++++++++++++++----------------------------------
 1 files changed, 35 insertions(+), 68 deletions(-)

diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
index 6cf49d0..d8b715a 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendDeleteOperation.java
@@ -22,16 +22,10 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2013 ForgeRock AS
+ *      Portions Copyright 2011-2014 ForgeRock AS
  */
 package org.opends.server.workflowelement.localbackend;
 
-import static org.opends.messages.CoreMessages.*;
-import static org.opends.server.loggers.ErrorLogger.*;
-import static org.opends.server.loggers.debug.DebugLogger.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
 import java.util.List;
 import java.util.concurrent.locks.Lock;
 
@@ -53,6 +47,12 @@
 import org.opends.server.types.operation.PostSynchronizationDeleteOperation;
 import org.opends.server.types.operation.PreOperationDeleteOperation;
 
+import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.loggers.ErrorLogger.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
 /**
  * This class defines an operation used to delete an entry in a local backend
  * of the Directory Server.
@@ -63,36 +63,22 @@
                   PostResponseDeleteOperation,
                   PostSynchronizationDeleteOperation
 {
-  /**
-   * The tracer object for the debug logger.
-   */
+  /** The tracer object for the debug logger. */
   private static final DebugTracer TRACER = getTracer();
 
+  /** The backend in which the operation is to be processed. */
+  private Backend<?> backend;
 
-
-  /**
-   * The backend in which the operation is to be processed.
-   */
-  private Backend backend;
-
-  /**
-   * Indicates whether the LDAP no-op control has been requested.
-   */
+  /** Indicates whether the LDAP no-op control has been requested. */
   private boolean noOp;
 
-  /**
-   * The client connection on which this operation was requested.
-   */
+  /** The client connection on which this operation was requested. */
   private ClientConnection clientConnection;
 
-  /**
-   * The DN of the entry to be deleted.
-   */
+  /** The DN of the entry to be deleted. */
   private DN entryDN;
 
-  /**
-   * The entry to be deleted.
-   */
+  /** The entry to be deleted. */
   private Entry entry;
 
   /** The pre-read request control included in the request, if applicable. */
@@ -193,7 +179,7 @@
           // Notify persistent searches.
           for (PersistentSearch psearch : wfe.getPersistentSearches())
           {
-            psearch.processDelete(entry, getChangeNumber());
+            psearch.processDelete(entry);
           }
 
           // Notify change listeners.
@@ -202,8 +188,7 @@
           {
             try
             {
-              changeListener.handleDeleteOperation(
-                  LocalBackendDeleteOperation.this, entry);
+              changeListener.handleDeleteOperation(LocalBackendDeleteOperation.this, entry);
             }
             catch (Exception e)
             {
@@ -212,10 +197,8 @@
                 TRACER.debugCaught(DebugLogLevel.ERROR, e);
               }
 
-              Message message =
-                  ERR_DELETE_ERROR_NOTIFYING_CHANGE_LISTENER
-                      .get(getExceptionMessage(e));
-              logError(message);
+              logError(ERR_DELETE_ERROR_NOTIFYING_CHANGE_LISTENER
+                  .get(getExceptionMessage(e)));
             }
           }
         }
@@ -334,8 +317,7 @@
       // handling a subtree delete). But we will need to check if there are
       // any subordinate backends that should stop us from attempting the
       // delete.
-      Backend[] subBackends = backend.getSubordinateBackends();
-      for (Backend b : subBackends)
+      for (Backend<?> b : backend.getSubordinateBackends())
       {
         for (DN dn : b.getBaseDNs())
         {
@@ -450,7 +432,7 @@
       for (Control c : requestControls)
       {
         final String oid = c.getOID();
-        if (oid.equals(OID_LDAP_ASSERTION))
+        if (OID_LDAP_ASSERTION.equals(oid))
         {
           LDAPAssertionRequestControl assertControl =
                 getRequestControl(LDAPAssertionRequestControl.DECODER);
@@ -509,16 +491,16 @@
                                 de.getMessageObject()));
           }
         }
-        else if (oid.equals(OID_LDAP_NOOP_OPENLDAP_ASSIGNED))
+        else if (OID_LDAP_NOOP_OPENLDAP_ASSIGNED.equals(oid))
         {
           noOp = true;
         }
-        else if (oid.equals(OID_LDAP_READENTRY_PREREAD))
+        else if (OID_LDAP_READENTRY_PREREAD.equals(oid))
         {
           preReadRequest =
                 getRequestControl(LDAPPreReadRequestControl.DECODER);
         }
-        else if (oid.equals(OID_PROXIED_AUTH_V1))
+        else if (OID_PROXIED_AUTH_V1.equals(oid))
         {
           // Log usage of legacy proxy authz V1 control.
           addAdditionalLogItem(AdditionalLogItem.keyOnly(getClass(),
@@ -537,16 +519,9 @@
 
           Entry authorizationEntry = proxyControl.getAuthorizationEntry();
           setAuthorizationEntry(authorizationEntry);
-          if (authorizationEntry == null)
-          {
-            setProxiedAuthorizationDN(DN.nullDN());
-          }
-          else
-          {
-            setProxiedAuthorizationDN(authorizationEntry.getDN());
-          }
+          setProxiedAuthorizationDN(getDN(authorizationEntry));
         }
-        else if (oid.equals(OID_PROXIED_AUTH_V2))
+        else if (OID_PROXIED_AUTH_V2.equals(oid))
         {
           // The requester must have the PROXIED_AUTH privilege in order to
           // be able to use this control.
@@ -561,32 +536,24 @@
 
           Entry authorizationEntry = proxyControl.getAuthorizationEntry();
           setAuthorizationEntry(authorizationEntry);
-          if (authorizationEntry == null)
-          {
-            setProxiedAuthorizationDN(DN.nullDN());
-          }
-          else
-          {
-            setProxiedAuthorizationDN(authorizationEntry.getDN());
-          }
+          setProxiedAuthorizationDN(getDN(authorizationEntry));
         }
-
         // NYI -- Add support for additional controls.
-
-        else if (c.isCritical())
+        else if (c.isCritical()
+            && (backend == null || !backend.supportsControl(oid)))
         {
-          if ((backend == null) || (! backend.supportsControl(oid)))
-          {
-            throw newDirectoryException(entry,
-                           ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
-                           ERR_DELETE_UNSUPPORTED_CRITICAL_CONTROL.get(
-                                String.valueOf(entryDN), oid));
-          }
+          throw newDirectoryException(entry,
+              ResultCode.UNAVAILABLE_CRITICAL_EXTENSION,
+              ERR_DELETE_UNSUPPORTED_CRITICAL_CONTROL.get(String.valueOf(entryDN), oid));
         }
       }
     }
   }
 
+  private DN getDN(Entry e)
+  {
+    return e != null ? e.getDN() : DN.nullDN();
+  }
 
   /**
    * Handle conflict resolution.

--
Gitblit v1.10.0