directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r808353 - in /directory: apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ shared/branches/s...
Date Thu, 27 Aug 2009 10:28:39 GMT
Author: elecharny
Date: Thu Aug 27 10:28:38 2009
New Revision: 808353

URL: http://svn.apache.org/viewvc?rev=808353&view=rev
Log:
Compilation errors fixes

Added:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NameOrNumericIdComparator.java
      - copied, changed from r808297, directory/apacheds/branches/apacheds-schema/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdComparator.java
Modified:
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java?rev=808353&r1=808352&r2=808353&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/TestServerEntryUtils.java
Thu Aug 27 10:28:38 2009
@@ -19,16 +19,11 @@
  */
 package org.apache.directory.server.core.entry;
 
-import java.util.Comparator;
-
 import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
-import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
-import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -50,78 +45,14 @@
     /**
      * A local Syntax class for tests
      */
-    static class AT extends AbstractAttributeType
+    static class AT extends AttributeType
     {
         private static final long serialVersionUID = 0L;
-        AttributeType superior;
-        LdapSyntax syntax;
-        MatchingRule equality;
-        MatchingRule ordering;
-        MatchingRule substr;
 
         protected AT( String oid )
         {
             super( oid );
         }
-
-        public AttributeType getSuperior() throws NamingException
-        {
-            return superior;
-        }
-
-
-        public LdapSyntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-
-        public MatchingRule getEquality() throws NamingException
-        {
-            return equality;
-        }
-
-
-        public MatchingRule getOrdering() throws NamingException
-        {
-            return ordering;
-        }
-
-
-        public MatchingRule getSubstr() throws NamingException
-        {
-            return substr;
-        }
-
-
-        public void setSuperior( AttributeType superior )
-        {
-            this.superior = superior;
-        }
-
-
-        public void setSyntax( LdapSyntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setEquality( MatchingRule equality )
-        {
-            this.equality = equality;
-        }
-
-
-        public void setOrdering( MatchingRule ordering )
-        {
-            this.ordering = ordering;
-        }
-
-
-        public void setSubstr( MatchingRule substr )
-        {
-            this.substr = substr;
-        }
     }
 
     public static MatchingRule matchingRuleFactory( String oid )
@@ -133,51 +64,14 @@
     /**
      * A local MatchingRule class for tests
      */
-    static class MR extends AbstractMatchingRule
+    static class MR extends MatchingRule
     {
         private static final long serialVersionUID = 0L;
-        LdapSyntax syntax;
-        LdapComparator<? super Object> ldapComparator;
-        Normalizer normalizer;
 
         protected MR( String oid )
         {
             super( oid );
         }
-
-        public LdapSyntax getSyntax() throws NamingException
-        {
-            return syntax;
-        }
-
-        public LdapComparator<? super Object> getLdapComparator() throws NamingException
-        {
-            return ldapComparator;
-        }
-
-
-        public Normalizer getNormalizer() throws NamingException
-        {
-            return normalizer;
-        }
-
-
-        public void setSyntax( LdapSyntax syntax )
-        {
-            this.syntax = syntax;
-        }
-
-
-        public void setComparator( Comparator<? super Object> comparator )
-        {
-            this.ldapComparator = comparator;
-        }
-
-
-        public void setNormalizer( Normalizer normalizer )
-        {
-            this.normalizer = normalizer;
-        }
     }
 
 
@@ -195,30 +89,22 @@
     static class S extends LdapSyntax
     {
         private static final long serialVersionUID = 0L;
-        SyntaxChecker checker;
 
         public S( String oid, boolean humanReadible )
         {
             super( oid, "", humanReadible );
         }
-
-        public void setSyntaxChecker( SyntaxChecker checker )
-        {
-            this.checker = checker;
-        }
-
-        public SyntaxChecker getSyntaxChecker() throws NamingException
-        {
-            return checker;
-        }
     }
 
     /* no protection*/ static AttributeType getCaseIgnoringAttributeNoNumbersType()
     {
-        S s = new S( "1.1.1.1", true );
+        AttributeType attributeType = new AttributeType( "1.1.3.1" );
+        LdapSyntax syntax = new LdapSyntax( "1.1.1.1", "", true );
 
-        s.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
+        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2.1" )
         {
+            private static final long serialVersionUID = 0L;
+
             public boolean isValidSyntax( Object value )
             {
                 if ( !( value instanceof String ) )
@@ -238,11 +124,15 @@
                 return true;
             }
         } );
+        
+        MatchingRule matchingRule = new MatchingRule( "1.1.2.1" );
+        matchingRule.setSyntax( syntax );
+
 
-        final MR mr = new MR( "1.1.2.1" );
-        mr.syntax = s;
-        mr.ldapComparator = new LdapComparator<String>()
+        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid()
)
         {
+            private static final long serialVersionUID = 0L;
+
             public int compare( String o1, String o2 )
             {
                 return ( o1 == null ? 
@@ -267,12 +157,11 @@
                 
                 throw new IllegalArgumentException( "Not a valid value" );
             }
-        };
+        } );
         
-        mr.normalizer = new Normalizer( "1.1.1" )
+        Normalizer normalizer = new Normalizer( "1.1.1" )
         {
-            // The serial UID
-            private static final long serialVersionUID = 1L;
+            private static final long serialVersionUID = 0L;
 
             public Value<?> normalize( Value<?> value ) throws NamingException
             {
@@ -291,66 +180,76 @@
             }
         };
         
-        AttributeType at = new AttributeType( "1.1.3.1" );
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
+        matchingRule.setNormalizer( normalizer );
+        
+        attributeType.setEquality( matchingRule );
+        attributeType.setSyntax( syntax );
+        
+        return attributeType;
     }
 
 
     /* no protection*/ static AttributeType getIA5StringAttributeType()
     {
-        AT at = new AT( "1.1" );
+        AttributeType attributeType = new AttributeType( "1.1" );
+        LdapSyntax syntax = new LdapSyntax( "1.1.1", "", true );
 
-        S s = new S( "1.1.1", true );
-
-        s.setSyntaxChecker( new SyntaxChecker( "1.1.2" )
+        syntax.setSyntaxChecker( new SyntaxChecker( "1.1.2" )
         {
+            private static final long serialVersionUID = 0L;
+
             public boolean isValidSyntax( Object value )
             {
                 return ((String)value == null) || (((String)value).length() < 7) ;
             }
         } );
+        
+        MatchingRule matchingRule = new MatchingRule( "1.1.2" );
+        matchingRule.setSyntax( syntax );
 
-        final MR mr = new MR( "1.1.2" );
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
+
+        matchingRule.setLdapComparator( new LdapComparator<String>( matchingRule.getOid()
)
         {
+            private static final long serialVersionUID = 0L;
+
             public int compare( String o1, String o2 )
             {
                 return ( ( o1 == null ) ? 
                     ( o2 == null ? 0 : -1 ) :
                     ( o2 == null ? 1 : o1.compareTo( o2 ) ) );
             }
-        };
+        } );
+        
+        matchingRule.setNormalizer( new DeepTrimToLowerNormalizer( matchingRule.getOid()
) );
         
-        mr.normalizer = new DeepTrimToLowerNormalizer( mr.getOid());
+        attributeType.setEquality( matchingRule );
+        attributeType.setSyntax( syntax );
         
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
+        return attributeType;
     }
 
 
     /* No protection */ static AttributeType getBytesAttributeType()
     {
-        AT at = new AT( "1.2" );
-
-        S s = new S( "1.2.1", true );
+        AttributeType attributeType = new AttributeType( "1.2" );
+        LdapSyntax syntax = new LdapSyntax( "1.2.1", "", true );
 
-        s.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
+        syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
         {
+            private static final long serialVersionUID = 0L;
+
             public boolean isValidSyntax( Object value )
             {
                 return ( value == null ) || ( ((byte[])value).length < 5 );
             }
         } );
 
-        final MR mr = new MR( "1.2.2" );
-        mr.syntax = s;
-        mr.setComparator( new ByteArrayComparator() );
+        MatchingRule matchingRule = new MatchingRule( "1.2.2" );
+        matchingRule.setSyntax( syntax );
+
+        matchingRule.setLdapComparator( new ByteArrayComparator() );
         
-        mr.normalizer = new Normalizer( "1.1.1" )
+        matchingRule.setNormalizer( new Normalizer( "1.1.1" )
         {
             // The serial UID
             private static final long serialVersionUID = 1L;
@@ -381,10 +280,11 @@
             {
                 throw new IllegalStateException( "expected byte[] to normalize" );
             }
-        };
+        } );
         
-        at.setEquality( mr );
-        at.setSyntax( s );
-        return at;
+        attributeType.setEquality( matchingRule );
+        attributeType.setSyntax( syntax );
+
+        return attributeType;
     }
 }

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java?rev=808353&r1=808352&r2=808353&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
Thu Aug 27 10:28:38 2009
@@ -50,7 +50,6 @@
 import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
@@ -112,7 +111,7 @@
     public static void setup() throws Exception
     {
         loader = new BootstrapSchemaLoader();
-        oidRegistry = new DefaultOidRegistry();
+        oidRegistry = new OidRegistry();
         registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
         
         // load essential bootstrap schemas 

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=808353&r1=808352&r2=808353&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
Thu Aug 27 10:28:38 2009
@@ -40,7 +40,6 @@
 import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Entry;
@@ -105,7 +104,7 @@
     public static void setup() throws Exception
     {
         loader = new BootstrapSchemaLoader();
-        oidRegistry = new DefaultOidRegistry();
+        oidRegistry = new OidRegistry();
         registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
         
         // load essential bootstrap schemas 

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=808353&r1=808352&r2=808353&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
Thu Aug 27 10:28:38 2009
@@ -32,11 +32,12 @@
 import java.util.List;
 
 import javax.naming.NamingException;
-import javax.naming.directory.InvalidAttributeValueException;
 
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+import org.apache.directory.shared.ldap.schema.comparators.StringComparator;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.normalizers.NoOpNormalizer;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.AcceptAllSyntaxChecker;
@@ -51,8 +52,6 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import jdbm.helper.StringComparator;
-
 
 /**
  * Tests that the ServerStringValue class works properly as expected.
@@ -83,9 +82,9 @@
         s = new TestServerEntryUtils.S( "1.1.1.1", false );
         s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
         mr = new TestServerEntryUtils.MR( "1.1.2.1" );
-        mr.syntax = s;
-        mr.comparator = new StringComparator();
-        mr.normalizer = new DeepTrimToLowerNormalizer( "1.1.2.1" );
+        mr.setSyntax( s );
+        mr.setLdapComparator( new StringComparator() );
+        mr.setNormalizer( new DeepTrimToLowerNormalizer( "1.1.2.1" ) );
         at = new TestServerEntryUtils.AT( "1.1.3.1" );
         at.setEquality( mr );
         at.setOrdering( mr );
@@ -444,6 +443,8 @@
     @Test public void testConstrainedString()
     {
         s.setSyntaxChecker( new SyntaxChecker( "1.1.1.1" ) {
+            private static final long serialVersionUID = 0L;
+
             public boolean isValidSyntax( Object value )
             {
                 if ( value instanceof String )
@@ -455,9 +456,11 @@
             }
         });
 
-        mr.syntax = s;
-        mr.comparator = new Comparator<String>()
+        mr.setSyntax( s );
+        mr.setLdapComparator( new LdapComparator<String>( mr.getOid() )
         {
+            private static final long serialVersionUID = 0L;
+
             public int compare( String o1, String o2 )
             {
                 if ( o1 == null )
@@ -493,8 +496,9 @@
                 if ( val.equals( "HIGH" ) ) { return 2; }
                 throw new IllegalArgumentException( "Not a valid value" );
             }
-        };
-        mr.normalizer = new NoOpNormalizer( mr.getOid() );
+        } );
+        
+        mr.setNormalizer( new NoOpNormalizer( mr.getOid() ) );
         at.setEquality( mr );
         at.setSyntax( s );
 

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=808353&r1=808352&r2=808353&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Thu Aug 27 10:28:38 2009
@@ -82,13 +82,13 @@
     private static final long serialVersionUID = 1L;
 
     /** The associated Comparator */
-    private LdapComparator<? super Object> ldapComparator;
+    protected LdapComparator<? super Object> ldapComparator;
 
     /** The associated Normalizer */
-    private Normalizer normalizer;
+    protected Normalizer normalizer;
 
     /** The associated LdapSyntax */
-    private LdapSyntax ldapSyntax;
+    protected LdapSyntax ldapSyntax;
     
     /** The associated LdapSyntax OID */
     private String ldapSyntaxOid;
@@ -198,7 +198,7 @@
      *
      * @param oid The LdapComparator
      */
-    public void setLdapComparator( LdapComparator<? > ldapComparator )
+    public void setLdapComparator( LdapComparator<?> ldapComparator )
     {
         if ( !isReadOnly )
         {

Copied: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NameOrNumericIdComparator.java
(from r808297, directory/apacheds/branches/apacheds-schema/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdComparator.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NameOrNumericIdComparator.java?p2=directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NameOrNumericIdComparator.java&p1=directory/apacheds/branches/apacheds-schema/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdComparator.java&r1=808297&r2=808353&rev=808353&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/NameOrNumericIdComparator.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/comparators/NameOrNumericIdComparator.java
Thu Aug 27 10:28:38 2009
@@ -17,17 +17,15 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.server.schema.bootstrap;
+package org.apache.directory.shared.ldap.schema.comparators;
 
 
-import java.io.Serializable;
-import java.util.Comparator;
-
-import javax.naming.NamingException;
-
-import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,27 +36,33 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class NameOrNumericIdComparator implements Comparator, Serializable
+public class NameOrNumericIdComparator extends LdapComparator<String>
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( NameOrNumericIdComparator.class
);
+
+    /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
-    private transient OidRegistry registry;
+
+    /** A reference to the global registries */ 
+    private transient Registries registries;
 
     
-    public NameOrNumericIdComparator( OidRegistry registry )
-    {
-        this.registry = registry;
-    }
-    
-    
-    public NameOrNumericIdComparator()
+    /**
+     * The IntegerOrderingComparator constructor. Its OID is the IntegerOrderingMatch matching
+     * rule OID.
+     */
+    public NameOrNumericIdComparator( Registries registries )
     {
+        super( SchemaConstants.NAME_OR_NUMERIC_ID_MATCH_OID );
+        this.registries = registries;
     }
     
     
-    /* (non-Javadoc)
-     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+    /**
+     * Implementation of the Compare method
      */
-    public int compare( Object o1, Object o2 )
+    public int compare( String o1, String o2 )
     {
         String s1 = getNumericIdString( o1 );
         String s2 = getNumericIdString( o2 );
@@ -84,7 +88,7 @@
     
     public void setRegistries( Registries registries )
     {
-        registry = registries.getOidRegistry();
+        this.registries = registries;
     }
     
     
@@ -115,18 +119,15 @@
             return "";
         }
 
-        if ( registry.hasOid( strValue ) )
+        String oid = registries.getOid( strValue );
+        
+        if ( oid != null )
         {
-            try
-            {
-                return registry.getOid( strValue );
-            }
-            catch ( NamingException e )
-            {
-                throw new RuntimeException( "Failed to lookup OID for " + strValue, e );
-            }
+            return oid;
         }
         
-        return strValue;
+        String msg =  "Failed to lookup OID for " + strValue;
+        LOG.warn( msg );
+        throw new RuntimeException( msg );
     }
 }



Mime
View raw message