directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r922935 - in /directory/shared/trunk: ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/ ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/ ldap-schema/src/main/resources/schema/ou=...
Date Sun, 14 Mar 2010 19:53:08 GMT
Author: seelmann
Date: Sun Mar 14 19:53:08 2010
New Revision: 922935

URL: http://svn.apache.org/viewvc?rev=922935&view=rev
Log:
o Fixed some normalizer and comparators assignments for matching rules
o Fixed IntegerOrderingComparator to use BigInteger instead of Long
o Fixed GeneralizedTimeNormalizer
o Added Comparators for generalizedTime and numericString


Added:
    directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/GeneralizedTimeComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
Modified:
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.10.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.21.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.27.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.28.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.8.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.9.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.10.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.14.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.15.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.20.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.21.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.27.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.28.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.8.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.9.ldif
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java

Added: directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java?rev=922935&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager/src/test/java/org/apache/directory/shared/ldap/schema/loader/ldif/MatchingRuleTest.java Sun Mar 14 19:53:08 2010
@@ -0,0 +1,212 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.shared.ldap.schema.loader.ldif;
+
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.GeneralizedTimeComparator;
+import org.apache.directory.shared.ldap.schema.comparators.IntegerOrderingComparator;
+import org.apache.directory.shared.ldap.schema.comparators.NumericStringComparator;
+import org.apache.directory.shared.ldap.schema.comparators.TelephoneNumberComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.GeneralizedTimeNormalizer;
+import org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer;
+import org.apache.directory.shared.ldap.schema.normalizers.TelephoneNumberNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.Schema;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * Tests that matching rules of the schema use correct normalizers and comparators.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MatchingRuleTest
+{
+    // A directory in which the ldif files will be stored
+    private static String workingDirectory;
+
+    // The schema repository
+    private static File schemaRepository;
+
+    // The schema manager
+    private static SchemaManager schemaManager;
+
+
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = MatchingRuleTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        schemaRepository = new File( workingDirectory, "schema" );
+
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy();
+
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+        for ( Schema schema : loader.getAllSchemas() )
+        {
+            schema.enable();
+        }
+        schemaManager.loadAllEnabled();
+    }
+
+
+    @AfterClass
+    public static void cleanup() throws IOException
+    {
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+    }
+
+
+    @Test
+    public void testTelephoneNumberMatch() throws Exception
+    {
+        // matching rule: telephoneNumberMatch
+        MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry( "telephoneNumberMatch" );
+        assertEquals( TelephoneNumberNormalizer.class.getName(), mr1.getNormalizer().getClass().getName() );
+        assertEquals( "+1234567890", mr1.getNormalizer().normalize( " +1 234-567 890 " ) );
+        assertEquals( TelephoneNumberComparator.class.getName(), mr1.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr1.getLdapComparator().compare( " +1 234-567 890 ", "+1234567890" ) );
+
+        // matching rule: telephoneNumberSubstringsMatch
+        MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry( "telephoneNumberSubstringsMatch" );
+        assertEquals( TelephoneNumberNormalizer.class.getName(), mr2.getNormalizer().getClass().getName() );
+        assertEquals( "+1234567890", mr2.getNormalizer().normalize( " +1 234-567 890 " ) );
+        assertEquals( TelephoneNumberComparator.class.getName(), mr2.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr2.getLdapComparator().compare( " +1 234-567 890 ", "+1234567890" ) );
+
+        // test a real attribute: telephoneNumber
+        AttributeType at = schemaManager.lookupAttributeTypeRegistry( "telephoneNumber" );
+        assertNotNull( at.getEquality() );
+        assertEquals( TelephoneNumberNormalizer.class.getName(), at.getEquality().getNormalizer().getClass().getName() );
+        assertEquals( "+1234567890", at.getEquality().getNormalizer().normalize( " +1 234-567 890 " ) );
+        assertEquals( TelephoneNumberComparator.class.getName(), at.getEquality().getLdapComparator().getClass()
+            .getName() );
+        assertEquals( 0, at.getEquality().getLdapComparator().compare( " +1 234-567 890 ", "+1234567890" ) );
+        assertNotNull( at.getSubstring() );
+        assertEquals( TelephoneNumberNormalizer.class.getName(), at.getEquality().getNormalizer().getClass().getName() );
+        assertEquals( "+1234567890", at.getSubstring().getNormalizer().normalize( " +1 234-567 890 " ) );
+        assertNull( at.getOrdering() );
+    }
+
+
+    @Test
+    public void testIntegerMatch() throws Exception
+    {
+        MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry( "integerMatch" );
+        assertEquals( NumericNormalizer.class.getName(), mr1.getNormalizer().getClass().getName() );
+        assertEquals( "1234567890", mr1.getNormalizer().normalize( " 1 234 567 890 " ) );
+        //assertEquals( IntegerOrderingComparator.class.getName(), mr1.getLdapComparator().getClass().getName() );
+        //assertEquals( 0, mr1.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
+
+        MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry( "integerOrderingMatch" );
+        assertEquals( NumericNormalizer.class.getName(), mr2.getNormalizer().getClass().getName() );
+        assertEquals( "1234567890", mr2.getNormalizer().normalize( " 1 234 567 890 " ) );
+        assertEquals( IntegerOrderingComparator.class.getName(), mr2.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr2.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
+        assertTrue( mr2.getLdapComparator().compare( " 1 2 3  ", " 2 3 4" ) < 0 );
+        assertTrue( mr2.getLdapComparator().compare( " 1 2 3 4 ", " 2 3 4" ) > 0 );
+
+        // test a real attribute type: uidNumber
+        AttributeType at = schemaManager.lookupAttributeTypeRegistry( "uidNumber" );
+        assertNotNull( at.getEquality() );
+        assertEquals( NumericNormalizer.class.getName(), at.getEquality().getNormalizer().getClass().getName() );
+        assertEquals( "123", at.getEquality().getNormalizer().normalize( " 1 2 3 " ) );
+        //assertEquals( 0, at.getEquality().getLdapComparator().compare( " 1 2 3 ", "123" ) );
+        assertNull( at.getSubstring() );
+        assertNull( at.getOrdering() );
+    }
+
+
+    @Test
+    public void testNumericStringMatch() throws Exception
+    {
+        MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry( "numericStringMatch" );
+        assertEquals( NumericNormalizer.class.getName(), mr1.getNormalizer().getClass().getName() );
+        assertEquals( "1234567890", mr1.getNormalizer().normalize( " 1 234 567 890 " ) );
+        assertEquals( NumericStringComparator.class.getName(), mr1.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr1.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
+
+        MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry( "numericStringSubstringsMatch" );
+        assertEquals( NumericNormalizer.class.getName(), mr2.getNormalizer().getClass().getName() );
+        assertEquals( "1234567890", mr2.getNormalizer().normalize( " 1 234 567 890 " ) );
+        assertEquals( NumericStringComparator.class.getName(), mr2.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr2.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
+
+        MatchingRule mr3 = schemaManager.lookupMatchingRuleRegistry( "numericStringOrderingMatch" );
+        assertEquals( NumericNormalizer.class.getName(), mr3.getNormalizer().getClass().getName() );
+        assertEquals( "1234567890", mr3.getNormalizer().normalize( " 1 234 567 890 " ) );
+        assertEquals( NumericStringComparator.class.getName(), mr3.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr3.getLdapComparator().compare( " 1 234 567 890 ", "1234567890" ) );
+        assertTrue( mr3.getLdapComparator().compare( " 1 2 3  ", " 2 3 4" ) < 0 );
+        assertTrue( mr3.getLdapComparator().compare( " 1 2 3 4 ", " 2 3 4" ) < 0 );
+    }
+
+
+    @Test
+    public void testGeneralizedTimeStringMatch() throws Exception
+    {
+        MatchingRule mr1 = schemaManager.lookupMatchingRuleRegistry( "generalizedTimeMatch" );
+        assertEquals( GeneralizedTimeNormalizer.class.getName(), mr1.getNormalizer().getClass().getName() );
+        assertEquals( "20100314150000.000Z", mr1.getNormalizer().normalize( "2010031415Z" ) );
+        assertEquals( "20100314133102.003Z", mr1.getNormalizer().normalize( "20100314150102.003+0130" ) );
+        assertEquals( GeneralizedTimeComparator.class.getName(), mr1.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr1.getLdapComparator().compare( "2010031415Z", "20100314150000.000+0000" ) );
+
+        MatchingRule mr2 = schemaManager.lookupMatchingRuleRegistry( "generalizedTimeOrderingMatch" );
+        assertEquals( GeneralizedTimeNormalizer.class.getName(), mr2.getNormalizer().getClass().getName() );
+        assertEquals( "20100314150000.000Z", mr2.getNormalizer().normalize( "2010031415Z" ) );
+        assertEquals( "20100314133102.003Z", mr2.getNormalizer().normalize( "20100314150102.003+0130" ) );
+        assertEquals( GeneralizedTimeComparator.class.getName(), mr2.getLdapComparator().getClass().getName() );
+        assertEquals( 0, mr2.getLdapComparator().compare( "2010031415Z", "20100314150000.000+0000" ) );
+        assertTrue( mr2.getLdapComparator().compare( "2010031415Z", "2010031414Z" ) > 0 );
+        assertTrue( mr2.getLdapComparator().compare( "2010031415Z", "2010031416Z" ) < 0 );
+    }
+
+}

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.10.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.10.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.10.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.10.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.10,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.10
 entrycsn: 20090818052728.244000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.NumericStringComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.21.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.21.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.21.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.21.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,8 @@ dn: m-oid=2.5.13.21,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.21
 entrycsn: 20090818052728.011000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.TelephoneNumberCompa
+ rator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.27.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.27.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.27.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.27.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.27,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.27
 entrycsn: 20090818052728.332000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.GeneralizedTimeComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.28.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.28.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.28.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.28.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.28,ou=comparators,cn=sy
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.28
 entrycsn: 20090818052728.177000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.GeneralizedTimeComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.8.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.8.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.8.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.8.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.8,ou=comparators,cn=sys
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.8
 entrycsn: 20090818052727.999000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.NumericStringComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.9.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dcomparators/m-oid%3D2.5.13.9.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.9.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=comparators/m-oid=2.5.13.9.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.9,ou=comparators,cn=sys
 createtimestamp: 20090818022728Z
 m-oid: 2.5.13.9
 entrycsn: 20090818052728.066000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.comparators.ComparableComparator
- 
+m-fqcn: org.apache.directory.shared.ldap.schema.comparators.NumericStringComparator
 objectclass: metaComparator
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.10.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.10.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.10.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.10.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.10,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.10
 entrycsn: 20090818052727.779000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.14.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.14.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.14.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.14.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.14,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.14
 entrycsn: 20090818052727.769000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.15.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.15.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.15.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.15.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.15,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.15
 entrycsn: 20090818052727.546000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.20.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.20.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.20.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.20.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.20,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.20
 entrycsn: 20090818052727.563000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.TelephoneNumberNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.21.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.21.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.21.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.21.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.21,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.21
 entrycsn: 20090818052727.522000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.TelephoneNumberNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.27.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.27.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.27.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.27.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.27,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.27
 entrycsn: 20090818052727.845000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.CachingDeepTrimNorma
- lizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.GeneralizedTimeNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.28.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.28.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.28.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.28.ldif Sun Mar 14 19:53:08 2010
@@ -3,8 +3,7 @@ dn: m-oid=2.5.13.28,ou=normalizers,cn=sy
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.28
 entrycsn: 20090818052727.668000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.CachingDeepTrimNorma
- lizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.GeneralizedTimeNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.8.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.8.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.8.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.8.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.8,ou=normalizers,cn=sys
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.8
 entrycsn: 20090818052727.517000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.9.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dsystem/ou%3Dnormalizers/m-oid%3D2.5.13.9.ldif?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.9.ldif (original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=system/ou=normalizers/m-oid=2.5.13.9.ldif Sun Mar 14 19:53:08 2010
@@ -3,7 +3,7 @@ dn: m-oid=2.5.13.9,ou=normalizers,cn=sys
 createtimestamp: 20090818022727Z
 m-oid: 2.5.13.9
 entrycsn: 20090818052727.566000Z#000000#000#000000
-m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer
+m-fqcn: org.apache.directory.shared.ldap.schema.normalizers.NumericNormalizer
 objectclass: metaNormalizer
 objectclass: metaTop
 objectclass: top

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/GeneralizedTimeComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/GeneralizedTimeComparator.java?rev=922935&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/GeneralizedTimeComparator.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/GeneralizedTimeComparator.java Sun Mar 14 19:53:08 2010
@@ -0,0 +1,116 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.shared.ldap.schema.comparators;
+
+
+import java.io.IOException;
+import java.text.ParseException;
+
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
+import org.apache.directory.shared.ldap.schema.PrepareString;
+import org.apache.directory.shared.ldap.util.GeneralizedTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A class for the generalizedTimeOrderingMatch matchingRule (RFC 4517, par. 4.2.17)
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437007 $
+ */
+public class GeneralizedTimeComparator extends LdapComparator<String>
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( GeneralizedTimeComparator.class );
+
+    /** The serialVersionUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * The GeneralizedTimeComparator constructor. Its OID is the 
+     * generalizedTimeOrderingMatch matching rule OID.
+     */
+    public GeneralizedTimeComparator( String oid )
+    {
+        super( oid );
+    }
+
+
+    /**
+     * Implementation of the Compare method
+     */
+    public int compare( String backendValue, String assertValue )
+    {
+        LOG.debug( "comparing generalizedTimeOrdering objects '{}' with '{}'", backendValue, assertValue );
+
+        // First, shortcut the process by comparing
+        // references. If they are equals, then o1 and o2
+        // reference the same object
+        if ( backendValue == assertValue )
+        {
+            return 0;
+        }
+
+        // Then, deal with one of o1 or o2 being null
+        // Both can't be null, because then they would 
+        // have been caught by the previous test
+        if ( ( backendValue == null ) || ( assertValue == null ) )
+        {
+            return ( backendValue == null ? -1 : 1 );
+        }
+
+        // Both objects must be stored as String for generalized tim.
+        // But we need to normalize the values first.
+        GeneralizedTime backendTime;
+        try
+        {
+            String prepared = PrepareString.normalize( backendValue, PrepareString.StringType.DIRECTORY_STRING );
+            backendTime = new GeneralizedTime( prepared );
+        }
+        catch ( IOException ioe )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
+        }
+        catch ( ParseException pe )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
+        }
+
+        GeneralizedTime assertTime;
+        try
+        {
+            String prepared = PrepareString.normalize( assertValue, PrepareString.StringType.DIRECTORY_STRING );
+            assertTime = new GeneralizedTime( prepared );
+        }
+        catch ( IOException ioe )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
+        }
+        catch ( ParseException pe )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
+        }
+
+        return backendTime.compareTo( assertTime );
+    }
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/IntegerOrderingComparator.java Sun Mar 14 19:53:08 2010
@@ -20,12 +20,18 @@
 package org.apache.directory.shared.ldap.schema.comparators;
 
 
+import java.io.IOException;
+import java.math.BigInteger;
+
+import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
+import org.apache.directory.shared.ldap.schema.PrepareString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
- * A class for the IntegerOrderingComparator matchingRule (RFC 4517, par. 4.2.20)
+ * A class for the integerOrderingMatch matchingRule (RFC 4517, par. 4.2.20)
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 437007 $
@@ -38,6 +44,7 @@ public class IntegerOrderingComparator e
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
 
+
     /**
      * The IntegerOrderingComparator constructor. Its OID is the IntegerOrderingMatch matching
      * rule OID.
@@ -47,11 +54,11 @@ public class IntegerOrderingComparator e
         super( oid );
     }
 
-    
+
     /**
      * Implementation of the Compare method
      */
-    public int compare( String backendValue, String assertValue ) 
+    public int compare( String backendValue, String assertValue )
     {
         LOG.debug( "comparing IntegerOrdering objects '{}' with '{}'", backendValue, assertValue );
 
@@ -62,7 +69,7 @@ public class IntegerOrderingComparator e
         {
             return 0;
         }
-        
+
         // Then, deal with one of o1 or o2 being null
         // Both can't be null, because then they would 
         // have been caught by the previous test
@@ -71,22 +78,27 @@ public class IntegerOrderingComparator e
             return ( backendValue == null ? -1 : 1 );
         }
 
-        // Both object must be stored as String for boolean
-        // values. If this is not the case, we have a pb...
-        // However, the method will then throw a ClassCastException
-        long b1 = Long.parseLong( backendValue );
-        long b2 = Long.parseLong( assertValue );
-        
-        if ( b1 == b2 )
+        // Both objects must be stored as String for numeric.
+        // But we need to normalize the values first.
+        try
         {
-            return 0;
+            backendValue = PrepareString.normalize( backendValue, PrepareString.StringType.NUMERIC_STRING );
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
+        }
+        try
+        {
+            assertValue = PrepareString.normalize( assertValue, PrepareString.StringType.NUMERIC_STRING );
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
         }
 
-        // The boolean should have been stored as 'TRUE' or 'FALSE'
-        // into the server, and the compare method will be called
-        // with normalized booleans, so no need to uppercase them.
-        // We don't need to check the assertion value, because we
-        // are dealing with booleans.
-        return ( b1 > b2 ? 1 : -1 );
+        BigInteger b1 = new BigInteger( backendValue );
+        BigInteger b2 = new BigInteger( assertValue );
+        return b1.compareTo( b2 );
     }
 }

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java?rev=922935&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NumericStringComparator.java Sun Mar 14 19:53:08 2010
@@ -0,0 +1,101 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.shared.ldap.schema.comparators;
+
+
+import java.io.IOException;
+
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
+import org.apache.directory.shared.ldap.schema.PrepareString;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A class for the numericStringOrderingMatch matchingRule (RFC 4517, par. 4.2.23)
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 437007 $
+ */
+public class NumericStringComparator extends LdapComparator<String>
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( NumericStringComparator.class );
+
+    /** The serialVersionUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * The IntegerOrderingComparator constructor. Its OID is the numericStringOrderingMatch matching
+     * rule OID.
+     */
+    public NumericStringComparator( String oid )
+    {
+        super( oid );
+    }
+
+
+    /**
+     * Implementation of the Compare method
+     */
+    public int compare( String backendValue, String assertValue )
+    {
+        LOG.debug( "comparing numericStringOrdering objects '{}' with '{}'", backendValue, assertValue );
+
+        // First, shortcut the process by comparing
+        // references. If they are equals, then o1 and o2
+        // reference the same object
+        if ( backendValue == assertValue )
+        {
+            return 0;
+        }
+
+        // Then, deal with one of o1 or o2 being null
+        // Both can't be null, because then they would 
+        // have been caught by the previous test
+        if ( ( backendValue == null ) || ( assertValue == null ) )
+        {
+            return ( backendValue == null ? -1 : 1 );
+        }
+
+        // Both objects must be stored as String for numeric.
+        // But we need to normalize the values first.
+        try
+        {
+            backendValue = PrepareString.normalize( backendValue, PrepareString.StringType.NUMERIC_STRING );
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
+        }
+        try
+        {
+            assertValue = PrepareString.normalize( assertValue, PrepareString.StringType.NUMERIC_STRING );
+        }
+        catch ( IOException e )
+        {
+            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
+        }
+
+        return backendValue.compareTo( assertValue );
+    }
+}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/GeneralizedTimeNormalizer.java Sun Mar 14 19:53:08 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
 
 
 import java.io.IOException;
+import java.text.ParseException;
 
 import javax.naming.NamingException;
 
@@ -30,15 +31,21 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.PrepareString;
+import org.apache.directory.shared.ldap.util.GeneralizedTime;
+import org.apache.directory.shared.ldap.util.GeneralizedTime.Format;
+import org.apache.directory.shared.ldap.util.GeneralizedTime.FractionDelimiter;
+import org.apache.directory.shared.ldap.util.GeneralizedTime.TimeZoneFormat;
 
 
 /**
  * Normalizer which normalize a time following those rules :
- * - if minutes are ommited, then they are replaced by 00
- * - if seconds are ommited, then they are replaced by 00
- * - if fraction is 0, it is removed
- * - the time is supposed to be expressed in Zulu (GMT), so 
- * increment is applied to hours/days/yeah, and a Z is added at the end.
+ * </ul>
+ * <li>if minutes are ommited, then they are replaced by 00</li>
+ * <li>if seconds are ommited, then they are replaced by 00</li>
+ * <li>if fraction is 0 or omitted, it is replaced by 000</li>
+ * <li>the time is supposed to be expressed in Zulu (GMT), so 
+ * increment is applied to hours/days/yeah, and a Z is added at the end</li>
+ * </ul>
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 491034 $
@@ -48,6 +55,7 @@ public class GeneralizedTimeNormalizer e
     /** The serial UID */
     public static final long serialVersionUID = 1L;
 
+
     /**
      * Creates a new instance of GeneralizedTimeNormalizer.
      */
@@ -57,40 +65,46 @@ public class GeneralizedTimeNormalizer e
     }
 
 
-   /**
-    * {@inheritDoc}
-    */
-   public Value<?> normalize( Value<?> value ) throws NamingException
-   {
-       try
-       {
-           String normalized = PrepareString.normalize( value.getString(), 
-               PrepareString.StringType.DIRECTORY_STRING );
-           
-           return new ClientStringValue( normalized );
-       }
-       catch ( IOException ioe )
-       {
-           throw new NamingException( I18n.err( I18n.ERR_04224, value ) );
-       }
-   }
-
-   
-   /**
-    * {@inheritDoc}
-    */
-   public String normalize( String value ) throws NamingException
-   {
-       try
-       {
-           String normalized = PrepareString.normalize( value, 
-               PrepareString.StringType.DIRECTORY_STRING );
-           
-           return normalized;
-       }
-       catch ( IOException ioe )
-       {
-           throw new NamingException( I18n.err( I18n.ERR_04224, value ) );
-       }
-   }
+    /**
+     * {@inheritDoc}
+     */
+    public Value<?> normalize( Value<?> value ) throws NamingException
+    {
+        try
+        {
+            String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING );
+
+            return new ClientStringValue( normalized );
+        }
+        catch ( IOException ioe )
+        {
+            throw new NamingException( I18n.err( I18n.ERR_04224, value ) );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String normalize( String value ) throws NamingException
+    {
+        try
+        {
+            String prepared = PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING );
+
+            GeneralizedTime time = new GeneralizedTime( prepared );
+            String normalized = time.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION,
+                FractionDelimiter.DOT, 3, TimeZoneFormat.Z );
+
+            return normalized;
+        }
+        catch ( IOException ioe )
+        {
+            throw new NamingException( I18n.err( I18n.ERR_04224, value ) );
+        }
+        catch ( ParseException pe )
+        {
+            throw new NamingException( I18n.err( I18n.ERR_04224, value ) );
+        }
+    }
 }
\ No newline at end of file

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/GeneralizedTime.java Sun Mar 14 19:53:08 2010
@@ -591,6 +591,12 @@ public class GeneralizedTime implements 
     public String toGeneralizedTime( Format format, FractionDelimiter fractionDelimiter, int fractionLength,
         TimeZoneFormat timeZoneFormat )
     {
+        Calendar calendar = ( Calendar ) this.calendar.clone();
+        if ( timeZoneFormat == TimeZoneFormat.Z )
+        {
+            calendar.setTimeZone( GMT );
+        }
+
         NumberFormat twoDigits = new DecimalFormat( "00" );
         NumberFormat fourDigits = new DecimalFormat( "00" );
         String fractionFormat = "";

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java?rev=922935&r1=922934&r2=922935&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/util/GeneralizedTimeTest.java Sun Mar 14 19:53:08 2010
@@ -500,6 +500,22 @@ public class GeneralizedTimeTest
             TimeZoneFormat.DIFF_HOUR_MINUTE );
         assertEquals( "2008010212+0000", result );
     }
+    
+    
+    /**
+     * Test adjustment of time while formatting. 
+     */
+    @Test
+    public void testAdjustWhileFormatting() throws ParseException
+    {
+        String gt = "20080102121314+0130";
+        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
+        String result = generalizedTime.toGeneralizedTime();
+        assertEquals( gt, result );
+        
+        result = generalizedTime.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC, null, 0, TimeZoneFormat.Z );
+        assertEquals( "20080102104314Z", result );
+    }
 
 
     /**



Mime
View raw message