You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/10/22 01:16:42 UTC

svn commit: rev 55283 - incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap

Author: akarasulu
Date: Thu Oct 21 16:16:41 2004
New Revision: 55283

Added:
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreComparatorProducer.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreNormalizerProducer.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/RegistryNameComponentNormalizer.java
Log:
Commit changes ...

 o added a new dn component normalizer implementation which uses registries
   to resolve the normalizer to use for the value while normalizing a name
   component's attribute value
 o added the set of normalizers for the core schema
 o added the set of comparators for the core schema

Notes ...

 o these normalizers and comparators are really rough estimates for the
   various matching rules and can be tweeked as we go along



Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreComparatorProducer.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreComparatorProducer.java	Thu Oct 21 16:16:41 2004
@@ -0,0 +1,210 @@
+/*
+ *   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.eve.schema.bootstrap;
+
+
+import java.util.Comparator;
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.schema.*;
+
+
+/**
+ * Document this class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CoreComparatorProducer extends AbstractBootstrapProducer
+{
+    public CoreComparatorProducer()
+    {
+        super( ProducerTypeEnum.COMPARATOR_PRODUCER );
+    }
+
+
+    public void produce( BootstrapRegistries registries, ProducerCallback cb )
+            throws NamingException
+    {
+        Comparator comparator;
+
+        /*
+         * Straight out of RFC 2252: Section 8
+         * =======================================
+        ( 2.5.13.0 NAME 'objectIdentifierMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
+         */
+        comparator = new ComparableComparator();
+        cb.schemaObjectProduced( this, "2.5.13.0", comparator );
+
+        /*
+        ( 2.5.13.1 NAME 'distinguishedNameMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
+          */
+         comparator = new DnComparator(
+                 new RegistryNameComponentNormalizer( registries ) );
+         cb.schemaObjectProduced( this, "2.5.13.1", comparator );
+
+         /*
+        ( 2.5.13.2 NAME 'caseIgnoreMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "2.5.13.2", comparator );
+
+         /*
+        ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "2.5.13.3", comparator );
+
+         /*
+        ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
+         SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+         */
+         comparator = new NormalizingComparator(
+                new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
+                new ComparableComparator() );
+         cb.schemaObjectProduced( this, "2.5.13.4", comparator );
+
+        /*
+        ( 2.5.13.8 NAME 'numericStringMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.8", comparator );
+
+         /*
+        ( 2.5.13.10 NAME 'numericStringSubstringsMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.10", comparator );
+
+         /*
+        ( 2.5.13.11 NAME 'caseIgnoreListMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "2.5.13.11", comparator );
+
+         /*
+        ( 2.5.13.14 NAME 'integerMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.14", comparator );
+
+         /*
+        ( 2.5.13.16 NAME 'bitStringMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.16", comparator );
+
+         /*
+        ( 2.5.13.20 NAME 'telephoneNumberMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.20", comparator );
+
+         /*
+        ( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.21", comparator );
+
+         /*
+        ( 2.5.13.22 NAME 'presentationAddressMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.22", comparator );
+
+         /*
+        ( 2.5.13.23 NAME 'uniqueMemberMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "2.5.13.23", comparator );
+
+         /*
+        ( 2.5.13.24 NAME 'protocolInformationMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.24", comparator );
+
+         /*
+        ( 2.5.13.27 NAME 'generalizedTimeMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.27", comparator );
+
+         /*
+        ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.28", comparator );
+
+         /*
+        ( 2.5.13.29 NAME 'integerFirstComponentMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.29", comparator );
+
+         /*
+        ( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
+          */
+         comparator = new ComparableComparator();
+         cb.schemaObjectProduced( this, "2.5.13.30", comparator );
+
+         /*
+        ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", comparator );
+
+         /*
+        ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+          */
+         comparator = new NormalizingComparator(
+                 new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
+                 new ComparableComparator() );
+         cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", comparator );
+
+    }
+}

Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreNormalizerProducer.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/CoreNormalizerProducer.java	Thu Oct 21 16:16:41 2004
@@ -0,0 +1,197 @@
+/*
+ *   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.eve.schema.bootstrap;
+
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.schema.*;
+
+
+/**
+ * A bootstrap producer which creates and announces newly created Normalizers
+ * for various matchingRules in the core schema.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class CoreNormalizerProducer extends AbstractBootstrapProducer
+{
+    public CoreNormalizerProducer()
+    {
+        super( ProducerTypeEnum.NORMALIZER_PRODUCER );
+    }
+
+
+    public void produce( BootstrapRegistries registries, ProducerCallback cb )
+            throws NamingException
+    {
+        Normalizer normalizer;
+
+        /*
+         * Straight out of RFC 2252: Section 8
+         * =======================================
+
+        ( 2.5.13.1 NAME 'distinguishedNameMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
+         */
+        normalizer = new CachingNormalizer( new DnNormalizer(
+                new RegistryNameComponentNormalizer( registries) ) ) ;
+        cb.schemaObjectProduced( this, "2.5.13.1", normalizer );
+
+        /*
+        ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", normalizer );
+
+        /*
+        ( 2.5.13.11 NAME 'caseIgnoreListMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.11", normalizer );
+
+        /*
+        ( 2.5.13.2 NAME 'caseIgnoreMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.2", normalizer );
+
+        /*
+        ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.3", normalizer );
+
+        /*
+        ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimToLowerNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.4", normalizer );
+
+        /*
+        ( 2.5.13.0 NAME 'objectIdentifierMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.0", normalizer );
+
+        /*
+        ( 2.5.13.8 NAME 'numericStringMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.8", normalizer );
+
+        /*
+        ( 2.5.13.10 NAME 'numericStringSubstringsMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.10", normalizer );
+
+        /*
+        ( 2.5.13.14 NAME 'integerMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.14", normalizer );
+
+        /*
+        ( 2.5.13.16 NAME 'bitStringMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.16", normalizer );
+
+        /*
+        ( 2.5.13.20 NAME 'telephoneNumberMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.20", normalizer );
+
+        /*
+        ( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.21", normalizer );
+
+        /*
+        ( 2.5.13.22 NAME 'presentationAddressMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.22", normalizer );
+
+        /*
+        ( 2.5.13.23 NAME 'uniqueMemberMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.23", normalizer );
+
+        /*
+        ( 2.5.13.24 NAME 'protocolInformationMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.24", normalizer );
+
+        /*
+        ( 2.5.13.27 NAME 'generalizedTimeMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.27", normalizer );
+
+        /*
+        ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        cb.schemaObjectProduced( this, "2.5.13.28", normalizer );
+
+        /*
+        ( 2.5.13.29 NAME 'integerFirstComponentMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.29", normalizer );
+
+        /*
+        ( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
+          */
+        normalizer = new NoOpNormalizer();
+        cb.schemaObjectProduced( this, "2.5.13.30", normalizer );
+
+        /*
+        ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
+          SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
+          */
+        normalizer = new CachingNormalizer( new DeepTrimNormalizer() );
+        cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", normalizer );
+
+    }
+}

Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/RegistryNameComponentNormalizer.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/RegistryNameComponentNormalizer.java	Thu Oct 21 16:16:41 2004
@@ -0,0 +1,91 @@
+/*
+ *   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.eve.schema.bootstrap;
+
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.schema.Normalizer;
+import org.apache.ldap.common.schema.AttributeType;
+import org.apache.ldap.common.name.NameComponentNormalizer;
+
+import org.apache.eve.schema.AttributeTypeRegistry;
+
+
+/**
+ * A DN Name component Normalizer which uses the bootstrap registries to find
+ * the appropriate normalizer for the attribute of the name component with which
+ * to normalize the name component value.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RegistryNameComponentNormalizer implements NameComponentNormalizer
+{
+    /** the bootstrap registries used to dynamically resolve Normalizers */
+    private final BootstrapRegistries registries;
+
+
+    /**
+     * Creates a DN Name component Normalizer which uses the bootstrap
+     * registries to find the appropriate normalizer for the attribute of the
+     * name component with which to normalize the name component value.
+     *
+     * @param registries the bootstrap registries to use for resolution
+     */
+    public RegistryNameComponentNormalizer( BootstrapRegistries registries )
+    {
+        this.registries = registries;
+    }
+
+
+    /**
+     * @see NameComponentNormalizer#normalizeByName(String, String)
+     */
+    public String normalizeByName( String name, String value ) throws NamingException
+    {
+        return lookup( name ).normalize( value ).toString();
+    }
+
+
+    /**
+     * @see NameComponentNormalizer#normalizeByOid(String, String)
+     */
+    public String normalizeByOid( String oid, String value ) throws NamingException
+    {
+        return lookup( oid ).normalize( value ).toString();
+    }
+
+
+    /**
+     * Looks up the Normalizer to use for a name component using the attributeId
+     * for the name component.  First the attribute is resolved, then its
+     * equality matching rule is looked up.  The normalizer of that matching
+     * rule is returned.
+     *
+     * @param id the name or oid of the attribute in the name component to
+     * normalize the value of
+     * @return the Normalizer to use for normalizing the value of the attribute
+     * @throws NamingException if there are failures resolving the Normalizer
+     */
+    private Normalizer lookup( String id ) throws NamingException
+    {
+        AttributeTypeRegistry registry = registries.getAttributeTypeRegistry();
+        AttributeType type = registry.lookup( id );
+        return type.getEquality().getNormalizer();
+    }
+}