From fff28547081591b9b506c43b2df646dea3a32405 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 15 Jul 2013 15:24:47 +0000
Subject: [PATCH] Extracted several time the method findAndSetMatchingDN(). We should look at moving this code to a single reusable place.

---
 opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java |   68 +++++++++++++++-------------------
 1 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java b/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
index 2b2d54c..3dc3214 100644
--- a/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
+++ b/opends/src/server/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -115,22 +115,18 @@
    */
   private static final DebugTracer TRACER = getTracer();
 
-
-
-  // The current configuration state.
+  /** The current configuration state. */
   private PasswordModifyExtendedOperationHandlerCfg currentConfig;
 
-  // The DN of the identity mapper.
+  /** The DN of the identity mapper. */
   private DN identityMapperDN;
 
-  // The reference to the identity mapper.
+  /** The reference to the identity mapper. */
   private IdentityMapper<?> identityMapper;
 
-  // The default set of supported control OIDs for this extended
+  /** The default set of supported control OIDs for this extended */
   private Set<String> supportedControlOIDs = new HashSet<String>(0);
 
-
-
   /**
    * Create an instance of this password modify extended operation.  All
    * initialization should be performed in the
@@ -139,12 +135,8 @@
   public PasswordModifyExtendedOperation()
   {
     super();
-
   }
 
-
-
-
   /**
    * Initializes this extended operation handler based on the information in the
    * provided configuration.  It should also register itself with the
@@ -920,7 +912,7 @@
       {
         // Remove all existing encoded values that match the old password.
         Set<AttributeValue> existingValues = pwPolicyState.getPasswordValues();
-        LinkedHashSet<AttributeValue> deleteValues =
+        Set<AttributeValue> deleteValues =
              new LinkedHashSet<AttributeValue>(existingValues.size());
         if (pwPolicyState.getAuthenticationPolicy().isAuthPasswordSyntax())
         {
@@ -1245,35 +1237,12 @@
       if (userEntry == null)
       {
         operation.setResultCode(ResultCode.NO_SUCH_OBJECT);
-
         operation.appendErrorMessage(
                 ERR_EXTOP_PASSMOD_NO_USER_ENTRY_BY_AUTHZID.get(
                         String.valueOf(entryDN)));
 
         // See if one of the entry's ancestors exists.
-        DN parentDN = entryDN.getParentDNInSuffix();
-        while (parentDN != null)
-        {
-          try
-          {
-            if (DirectoryServer.entryExists(parentDN))
-            {
-              operation.setMatchedDN(parentDN);
-              break;
-            }
-          }
-          catch (Exception e)
-          {
-            if (debugEnabled())
-            {
-              TRACER.debugCaught(DebugLogLevel.ERROR, e);
-            }
-            break;
-          }
-
-          parentDN = parentDN.getParentDNInSuffix();
-        }
-
+        findAndSetMatchingDN(operation, entryDN);
         return null;
       }
 
@@ -1295,7 +1264,30 @@
     }
   }
 
+  private void findAndSetMatchingDN(Operation operation, DN entryDN)
+  {
+    try
+    {
+      DN matchedDN = entryDN.getParentDNInSuffix();
+      while (matchedDN != null)
+      {
+        if (DirectoryServer.entryExists(matchedDN))
+        {
+          operation.setMatchedDN(matchedDN);
+          return;
+        }
 
+        matchedDN = matchedDN.getParentDNInSuffix();
+      }
+    }
+    catch (Exception e)
+    {
+      if (debugEnabled())
+      {
+        TRACER.debugCaught(DebugLogLevel.ERROR, e);
+      }
+    }
+  }
 
   /**
    * {@inheritDoc}
@@ -1386,7 +1378,7 @@
   {
     ResultCode        resultCode          = ResultCode.SUCCESS;
     boolean           adminActionRequired = false;
-    ArrayList<Message> messages            = new ArrayList<Message>();
+    List<Message>     messages            = new ArrayList<Message>();
 
 
     // Make sure that the specified identity mapper is OK.

--
Gitblit v1.10.0