directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r414010 - in /directory/branches/apacheds/optimization/core/src/main: java/org/apache/directory/server/core/partition/ java/org/apache/directory/server/core/schema/ java/org/apache/directory/server/core/schema/bootstrap/ schema/
Date Wed, 14 Jun 2006 00:28:49 GMT
Author: akarasulu
Date: Tue Jun 13 17:28:49 2006
New Revision: 414010

URL: http://svn.apache.org/viewvc?rev=414010&view=rev
Log:
fixing normalization for distinguishedNameMatch which had a bug that was breaking the MatchingRuleCompareTest
test case in server-unit

Added:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnComparator.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java
    directory/branches/apacheds/optimization/core/src/main/schema/apache.schema

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java?rev=414010&r1=414009&r2=414010&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
Tue Jun 13 17:28:49 2006
@@ -428,7 +428,7 @@
         partitions.put( partition.getSuffix().toString(), partition );
 
         Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
-        namingContexts.add( partition.getSuffix().toString() );
+        namingContexts.add( partition.getUpSuffix() );
     }
 
 
@@ -442,7 +442,7 @@
         }
 
         Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
-        namingContexts.remove( partition.getSuffix().toString() );
+        namingContexts.remove( partition.getUpSuffix() );
         partitions.remove( key );
 
         partition.sync();

Added: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnComparator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnComparator.java?rev=414010&view=auto
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnComparator.java
(added)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnComparator.java
Tue Jun 13 17:28:49 2006
@@ -0,0 +1,89 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.schema;
+
+
+import java.util.Comparator;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DnComparator implements Comparator
+{
+    // @TODO you'll need this to fix the way normalization is done
+    private final AttributeTypeRegistry attrRegistry;
+    
+    
+    public DnComparator( AttributeTypeRegistry attrRegistry )
+    {
+        this.attrRegistry = attrRegistry;
+    }
+    
+    
+    public int compare( Object obj0, Object obj1 ) 
+    {
+        LdapDN dn0 = null;
+        LdapDN dn1 = null;
+        
+        try 
+        {
+            dn0 = getDn( obj0 );
+            dn1 = getDn( obj1 );
+        }
+        catch ( NamingException e )
+        {
+            // -- what do we do here ?
+        }
+        
+        return dn0.compareTo( dn1 );
+    }
+
+
+    public LdapDN getDn( Object obj ) throws NamingException
+    {
+        LdapDN dn = null;
+        if ( obj instanceof LdapDN )
+        {
+            dn = LdapDN.normalize( ( LdapDN ) obj );
+        }
+        else if ( obj instanceof Name )
+        {
+            dn = new LdapDN( ( Name ) obj );
+            dn.normalize();
+        }
+        else if ( obj instanceof String )
+        {
+            dn = new LdapDN( ( String ) obj );
+            dn.normalize();
+        }
+        else
+        {
+            throw new IllegalStateException( "I do not know how to handle dn comparisons
with objects of class: " 
+                + obj.getClass() );
+        }
+        return dn;
+    }
+}

Added: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java?rev=414010&view=auto
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
(added)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
Tue Jun 13 17:28:49 2006
@@ -0,0 +1,64 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.directory.server.core.schema;
+
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+
+
+/**
+ * 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DnNormalizer implements Normalizer
+{
+    // @TODO use this later for seting up normalization
+    private final AttributeTypeRegistry attrRegistry;
+    
+    
+    public DnNormalizer( AttributeTypeRegistry attrRegistry )
+    {
+        this.attrRegistry = attrRegistry;
+    }
+    
+
+    public Object normalize( Object value ) throws NamingException
+    {
+        LdapDN dn = null;
+        if ( value instanceof LdapDN )
+        {
+            dn = ( LdapDN ) ( ( LdapDN ) value ).clone();
+        }
+        else if ( value instanceof Name )
+        {
+            dn = new LdapDN( ( Name ) value );
+        }
+        else if ( value instanceof String )
+        {
+            dn = new LdapDN( ( String ) value );
+        }
+        
+        dn.normalize();
+        return dn;
+    }
+}

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java?rev=414010&r1=414009&r2=414010&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java
Tue Jun 13 17:28:49 2006
@@ -21,8 +21,7 @@
 
 import javax.naming.NamingException;
 
-import jdbm.helper.StringComparator;
-
+import org.apache.directory.server.core.schema.DnComparator;
 import org.apache.directory.server.core.schema.bootstrap.ProducerTypeEnum;
 import org.apache.directory.shared.ldap.schema.CachingNormalizer;
 import org.apache.directory.shared.ldap.schema.ComparableComparator;
@@ -63,7 +62,7 @@
          ( 2.5.13.1 NAME 'distinguishedNameMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
          */
-        comparator = new StringComparator();
+        comparator = new DnComparator( registries.getAttributeTypeRegistry() );
         cb.schemaObjectProduced( this, "2.5.13.1", comparator );
 
         /*

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java?rev=414010&r1=414009&r2=414010&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java
Tue Jun 13 17:28:49 2006
@@ -19,6 +19,7 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.server.core.schema.DnNormalizer;
 import org.apache.directory.server.core.schema.bootstrap.ProducerTypeEnum;
 import org.apache.directory.shared.ldap.schema.CachingNormalizer;
 import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer;
@@ -54,7 +55,7 @@
          ( 2.5.13.1 NAME 'distinguishedNameMatch'
          SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
          */
-        normalizer = new CachingNormalizer( new NoOpNormalizer() );
+        normalizer = new CachingNormalizer( new DnNormalizer( registries.getAttributeTypeRegistry()
) );
         cb.schemaObjectProduced( this, "2.5.13.1", normalizer );
 
         /*

Modified: directory/branches/apacheds/optimization/core/src/main/schema/apache.schema
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/schema/apache.schema?rev=414010&r1=414009&r2=414010&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/schema/apache.schema (original)
+++ directory/branches/apacheds/optimization/core/src/main/schema/apache.schema Tue Jun 13
17:28:49 2006
@@ -18,8 +18,7 @@
 
 attributetype ( 1.2.6.1.4.1.18060.1.1.1.3.1 NAME 'apacheNdn'
     DESC 'Index attribute DN whose values are normalized based on schema'
-    SUP distinguishedName
-    EQUALITY distinguishedNameMatch
+    EQUALITY exactDnAsStringMatch
     SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
     SINGLE-VALUE
     NO-USER-MODIFICATION



Mime
View raw message