From 59685c84348f8d71dc3bbd3513c5eb10cc738a8e Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 03 Nov 2006 16:39:22 +0000
Subject: [PATCH] Refactor DN and RDN classes and improve their test coverage.

---
 opends/src/server/org/opends/server/core/DirectoryServer.java |   33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 94e6740..caf5bb0 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -31,7 +31,6 @@
 import java.io.FileOutputStream;
 import java.io.PrintStream;
 import java.net.InetAddress;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -1926,7 +1925,7 @@
       throw new InitializationException(msgID, message, e);
     }
 
-    DN[] baseDNs   = { new DN(new RDN[0]) };
+    DN[] baseDNs   = { DN.nullDN() };
     rootDSEBackend = new RootDSEBackend();
     rootDSEBackend.initializeBackend(rootDSEConfigEntry, baseDNs);
   }
@@ -5372,7 +5371,7 @@
 
     while (backend == null)
     {
-      dn = dn.getParent();
+      dn = dn.getParentDNInSuffix();
       if (dn == null)
       {
         break;
@@ -5422,7 +5421,7 @@
       }
 
       boolean found = false;
-      DN parentDN = suffixDN.getParent();
+      DN parentDN = suffixDN.getParentDNInSuffix();
       while (parentDN != null)
       {
         b = directoryServer.suffixes.get(suffixDN);
@@ -5444,7 +5443,7 @@
           }
         }
 
-        parentDN = parentDN.getParent();
+        parentDN = parentDN.getParentDNInSuffix();
       }
 
 
@@ -5513,7 +5512,7 @@
           throw new ConfigException(msgID, message);
         }
 
-        DN parentDN = suffixDN.getParent();
+        DN parentDN = suffixDN.getParentDNInSuffix();
         while (parentDN != null)
         {
           b = directoryServer.suffixes.get(suffixDN);
@@ -5525,7 +5524,7 @@
             throw new ConfigException(msgID, message);
           }
 
-          parentDN = suffixDN.getParent();
+          parentDN = suffixDN.getParentDNInSuffix();
         }
       }
 
@@ -5542,7 +5541,7 @@
         throw new ConfigException(msgID, message);
       }
 
-      DN parentDN = suffixDN.getParent();
+      DN parentDN = suffixDN.getParentDNInSuffix();
       while (parentDN != null)
       {
         b = directoryServer.privateSuffixes.get(suffixDN);
@@ -5563,7 +5562,7 @@
           }
         }
 
-        parentDN = suffixDN.getParent();
+        parentDN = suffixDN.getParentDNInSuffix();
       }
 
 
@@ -5599,7 +5598,7 @@
         return;
       }
 
-      DN parentDN = suffixDN.getParent();
+      DN parentDN = suffixDN.getParentDNInSuffix();
       while (parentDN != null)
       {
         b = directoryServer.suffixes.get(parentDN);
@@ -5625,7 +5624,7 @@
         return;
       }
 
-      DN parentDN = suffixDN.getParent();
+      DN parentDN = suffixDN.getParentDNInSuffix();
       while (parentDN != null)
       {
         b = directoryServer.privateSuffixes.get(parentDN);
@@ -7328,7 +7327,7 @@
       {
         // The config handler hasn't been initialized yet.  Just return the DN
         // of the root DSE.
-        return new DN(new ArrayList<RDN>(0));
+        return DN.nullDN();
       }
 
       return configHandler.getConfigRootEntry().getDN();
@@ -7339,7 +7338,7 @@
 
       // This could theoretically happen if an alert needs to be sent before the
       // configuration is initialized.  In that case, just return an empty DN.
-      return new DN(new ArrayList<RDN>(0));
+      return DN.nullDN();
     }
   }
 
@@ -7782,11 +7781,9 @@
       // Cannot reach this point.
       throw new RuntimeException();
     }
-    RDN[] baseRDNs = monitorRootDN.getRDNComponents();
-    RDN[] rdns = new RDN[baseRDNs.length+1];
-    rdns[0] = new RDN(cnType, new AttributeValue(cnType, monitorName));
-    System.arraycopy(baseRDNs, 0, rdns, 1, baseRDNs.length);
-    return new DN(rdns);
+
+    RDN rdn = RDN.create(cnType, new AttributeValue(cnType, monitorName));
+    return monitorRootDN.concat(rdn);
   }
 }
 

--
Gitblit v1.10.0