From e3ce4910af53462b22a5f98f6719935964ae43ee Mon Sep 17 00:00:00 2001
From: sin <sin@localhost>
Date: Mon, 13 Jul 2009 17:25:15 +0000
Subject: [PATCH] issue# 4113: Collation matching rules aren't displayed correctly while searching

---
 opends/src/server/org/opends/server/api/AbstractMatchingRule.java            |   26 ++++++++++++++++++++++----
 opends/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java |   21 ++++++++-------------
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/opends/src/server/org/opends/server/api/AbstractMatchingRule.java b/opends/src/server/org/opends/server/api/AbstractMatchingRule.java
index fc1d178..9223fbc 100644
--- a/opends/src/server/org/opends/server/api/AbstractMatchingRule.java
+++ b/opends/src/server/org/opends/server/api/AbstractMatchingRule.java
@@ -224,14 +224,32 @@
   {
     buffer.append("( ");
     buffer.append(getOID());
-    buffer.append(" NAME '");
-    buffer.append(getName());
+    buffer.append(" NAME ");
+    Collection<String> names = getAllNames();
+    if(names.size()>1)
+    {
+      buffer.append("(");
+      for(String name: names)
+      {
+        buffer.append(" '");
+        buffer.append(name);
+        buffer.append('\'');
+      }
+     buffer.append(" )");
+    }
+    else
+    {
+      buffer.append('\'');
+      buffer.append(getName());
+      buffer.append('\'');
+    }
 
     String description = getDescription();
     if ((description != null) && (description.length() > 0))
     {
-      buffer.append("' DESC '");
+      buffer.append(" DESC '");
       buffer.append(description);
+      buffer.append('\'');
     }
 
     if (isObsolete())
@@ -240,7 +258,7 @@
     }
     else
     {
-      buffer.append("' SYNTAX ");
+      buffer.append(" SYNTAX ");
     }
 
     buffer.append(getSyntaxOID());
diff --git a/opends/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java b/opends/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
index f0247d3..faaf3ed 100644
--- a/opends/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
+++ b/opends/src/server/org/opends/server/schema/CollationMatchingRuleFactory.java
@@ -530,21 +530,22 @@
     String nOID = mapper.getNumericOID();
 
     MatchingRule matchingRule = getMatchingRule(nOID);
-    Collection<String> names = new HashSet<String>();
+    Collection<String> defaultNames = new HashSet<String>();
     if (matchingRule != null)
     {
       for (String name : matchingRule.getAllNames())
       {
-        names.add(name);
+        defaultNames.add(name);
       }
     }
 
-    names.add(lTag);
+    defaultNames.add(lTag);
     matchingRule =
-        new CollationEqualityMatchingRule(nOID, Collections
-            .<String> emptySet(), locale);
+        new CollationEqualityMatchingRule(nOID,
+                                      defaultNames, locale);
     addMatchingRule(nOID, matchingRule);
 
+    Collection<String> names = new HashSet<String>();
     // Register OID.3 as the equality matching rule.
     String OID = mapper.getNumericOID() + ".3";
     MatchingRule equalityMatchingRule = getMatchingRule(OID);
@@ -772,14 +773,8 @@
     @Override
     public String getName()
     {
-      // Concatenate all the names and return.
-      StringBuilder builder = new StringBuilder();
-      for (String name : getAllNames())
-      {
-        builder.append(name);
-        builder.append("\b");
-      }
-      return builder.toString();
+      //This is called when there is only 1 name.
+      return names.iterator().next();
     }
 
 

--
Gitblit v1.10.0