From 18de8b9ed9f6ba9780d3292d2828f67de08b7483 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 24 Jul 2009 09:46:24 +0000
Subject: [PATCH] Refactor the code of dsreplication and extract some of its commodity methods and move them to the classes they apply to.

---
 opends/src/ads/org/opends/admin/ads/ADSContext.java |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/ADSContext.java b/opends/src/ads/org/opends/admin/ads/ADSContext.java
index a0c3214..fdab5be 100644
--- a/opends/src/ads/org/opends/admin/ads/ADSContext.java
+++ b/opends/src/ads/org/opends/admin/ads/ADSContext.java
@@ -688,16 +688,15 @@
 
   /**
    * Returns whether a given administrator is already registered or not.
-   * @param adminProperties the administrator properties.
+   * @param uid the administrator UID.
    * @return <CODE>true</CODE> if the administrator was registered and
    * <CODE>false</CODE> otherwise.
    * @throws ADSContextException if something went wrong.
    */
-  public boolean isAdministratorAlreadyRegistered(
-      Map<AdministratorProperty, Object> adminProperties)
+  public boolean isAdministratorAlreadyRegistered(String uid)
   throws ADSContextException
   {
-    LdapName dn = makeDNFromAdministratorProperties(adminProperties);
+    LdapName dn = makeDNFromAdministratorProperties(uid);
     return isExistingEntry(dn);
   }
 
@@ -1505,7 +1504,20 @@
   throws ADSContextException
   {
     String adminUid = getAdministratorUID(adminProperties);
+    return makeDNFromAdministratorProperties(adminUid);
+  }
 
+  /**
+   * This method returns the DN of the entry that corresponds to the given
+   * administrator properties.
+   * @param adminUid the administrator uid.
+   * @return the DN of the entry that corresponds to the given administrator
+   * properties.
+   * @throws ADSContextException if something goes wrong.
+   */
+  private static LdapName makeDNFromAdministratorProperties(String adminUid)
+  throws ADSContextException
+  {
     String dnCentralAdmin = getAdministratorDN(adminUid);
 
     return nameFromDN(dnCentralAdmin);
@@ -2463,9 +2475,9 @@
     SortedSet<String> notDefinedAdmins = new TreeSet<String>();
     for (Map<AdministratorProperty, Object> admin2 : admins2)
     {
-      if (!isAdministratorAlreadyRegistered(admin2))
+      String uid = (String)admin2.get(AdministratorProperty.UID);
+      if (!isAdministratorAlreadyRegistered(uid))
       {
-        String uid = (String)admin2.get(AdministratorProperty.UID);
         notDefinedAdmins.add(uid);
       }
     }

--
Gitblit v1.10.0