directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r807899 - in /directory/apacheds/branches/apacheds-schema/core-entry/src: main/java/org/apache/directory/server/core/entry/ test/java/org/apache/directory/server/core/entry/
Date Wed, 26 Aug 2009 07:24:46 GMT
Author: elecharny
Date: Wed Aug 26 07:24:43 2009
New Revision: 807899

URL: http://svn.apache.org/viewvc?rev=807899&view=rev
Log:
Fixed many compilation errors by using the correct methods

Modified:
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
    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/ServerBinaryValueTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
Wed Aug 26 07:24:43 2009
@@ -109,15 +109,7 @@
         else
         {
             
-            try
-            {
-                isHR = attributeType.getSyntax().isHumanReadable();
-            }
-            catch ( NamingException ne )
-            {
-                // Do nothing : the syntax should always exist ...
-            }
-            
+            isHR = attributeType.getSyntax().isHumanReadable();
 
             // Copy all the values
             for ( Value<?> clientValue:attribute )
@@ -429,94 +421,86 @@
         
         for ( Value<?> val:vals )
         {
-            try
+            if ( attributeType.getSyntax().isHumanReadable() )
             {
-                if ( attributeType.getSyntax().isHumanReadable() )
+                if ( ( val == null ) || val.isNull() )
                 {
-                    if ( ( val == null ) || val.isNull() )
+                    Value<String> nullSV = new ServerStringValue( attributeType, (String)null
);
+                    
+                    if ( !values.contains( nullSV ) )
                     {
-                        Value<String> nullSV = new ServerStringValue( attributeType,
(String)null );
-                        
-                        if ( !values.contains( nullSV ) )
-                        {
-                            values.add( nullSV );
-                            nbAdded++;
-                        }
+                        values.add( nullSV );
+                        nbAdded++;
                     }
-                    else if ( val instanceof ServerStringValue )
+                }
+                else if ( val instanceof ServerStringValue )
+                {
+                    if ( !values.contains( val ) )
                     {
-                        if ( !values.contains( val ) )
+                        if ( values.add( val ) )
                         {
-                            if ( values.add( val ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else if ( val instanceof ClientStringValue )
+                }
+                else if ( val instanceof ClientStringValue )
+                {
+                    // If we get a Client value, convert it to a Server value first 
+                    Value<String> serverStringValue = new ServerStringValue( attributeType,
val.getString() ); 
+                    
+                    if ( !values.contains( serverStringValue ) )
                     {
-                        // If we get a Client value, convert it to a Server value first 
-                        Value<String> serverStringValue = new ServerStringValue( attributeType,
val.getString() ); 
-                        
-                        if ( !values.contains( serverStringValue ) )
+                        if ( values.add( serverStringValue ) )
                         {
-                            if ( values.add( serverStringValue ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else
-                    {
-                        String message = "The value must be a String, as its AttributeType
is H/R";
-                        LOG.error( message );
-                    }
                 }
                 else
                 {
-                    if ( val == null )
+                    String message = "The value must be a String, as its AttributeType is
H/R";
+                    LOG.error( message );
+                }
+            }
+            else
+            {
+                if ( val == null )
+                {
+                    Value<byte[]> nullSV = new ServerBinaryValue( attributeType, (byte[])null
);
+                    
+                    if ( !values.contains( nullSV ) )
                     {
-                        Value<byte[]> nullSV = new ServerBinaryValue( attributeType,
(byte[])null );
-                        
-                        if ( !values.contains( nullSV ) )
-                        {
-                            values.add( nullSV );
-                            nbAdded++;
-                        }
+                        values.add( nullSV );
+                        nbAdded++;
                     }
-                    else if ( ( val instanceof ClientBinaryValue ) )
+                }
+                else if ( ( val instanceof ClientBinaryValue ) )
+                {
+                    Value<byte[]> serverBinaryValue = new ServerBinaryValue( attributeType,
val.getBytes() ); 
+                    
+                    if ( !values.contains( serverBinaryValue ) )
                     {
-                        Value<byte[]> serverBinaryValue = new ServerBinaryValue( attributeType,
val.getBytes() ); 
-                        
-                        if ( !values.contains( serverBinaryValue ) )
+                        if ( values.add( serverBinaryValue ) )
                         {
-                            if ( values.add( serverBinaryValue ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else if ( val instanceof ServerBinaryValue )
+                }
+                else if ( val instanceof ServerBinaryValue )
+                {
+                    if ( !values.contains( val ) )
                     {
-                        if ( !values.contains( val ) )
+                        if ( values.add( val ) )
                         {
-                            if ( values.add( val ) )
-                            {
-                                nbAdded++;
-                            }
+                            nbAdded++;
                         }
                     }
-                    else
-                    {
-                        String message = "The value must be a byte[], as its AttributeType
is not H/R";
-                        LOG.error( message );
-                    }
                 }
-            }
-            catch ( NamingException ne )
-            {
-                String message = "Error while adding value '" + val.toString() +"' : " +
ne.getMessage();
-                LOG.error( message );
+                else
+                {
+                    String message = "The value must be a byte[], as its AttributeType is
not H/R";
+                    LOG.error( message );
+                }
             }
         }
         
@@ -722,7 +706,7 @@
         
         String normId = StringTools.lowerCaseAscii( trimmedId );
         
-        for ( String name:attributeType.getNamesRef() )
+        for ( String name:attributeType.getNames() )
         {
             if ( normId.equalsIgnoreCase( name ) )
             {
@@ -893,21 +877,12 @@
         this.attributeType = attributeType;
         setUpId( null, attributeType );
         
-        try
+        if ( attributeType.getSyntax().isHumanReadable() )
         {
-            if ( attributeType.getSyntax().isHumanReadable() )
-            {
-                isHR = true;
-            }
-            else
-            {
-                isHR = false;
-            }
+            isHR = true;
         }
-        catch ( NamingException ne )
+        else
         {
-            // If we have an exception while trying to get the Syntax for this attribute
-            // just set it as Binary
             isHR = false;
         }
     }
@@ -965,7 +940,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normId = StringTools.lowerCaseAscii( StringTools.trim( id ) );
                 
-                for ( String atName:attributeType.getNamesRef() )
+                for ( String atName:attributeType.getNames() )
                 {
                     if ( atName.equalsIgnoreCase( normId ) )
                     {
@@ -1034,7 +1009,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normUpId = StringTools.lowerCaseAscii( StringTools.trim( upId ) );
                 
-                for ( String atId:attributeType.getNamesRef() )
+                for ( String atId:attributeType.getNames() )
                 {
                     if ( atId.equalsIgnoreCase( normUpId ) )
                     {
@@ -1112,7 +1087,7 @@
                 // In this case, it must be equals to the attributeType OID.
                 String normUpId = StringTools.lowerCaseAscii( StringTools.trim( upId ) );
                 
-                for ( String atId:attributeType.getNamesRef() )
+                for ( String atId:attributeType.getNames() )
                 {
                     if ( atId.equalsIgnoreCase( normUpId ) )
                     {

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
Wed Aug 26 07:24:43 2009
@@ -30,7 +30,6 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.AbstractEntry;
@@ -42,6 +41,7 @@
 import org.apache.directory.shared.ldap.name.LdapDNSerializer;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+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;

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
Wed Aug 26 07:24:43 2009
@@ -32,6 +32,7 @@
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.comparators.ByteArrayComparator;
@@ -84,24 +85,17 @@
      */
     protected String checkAttributeType( AttributeType attributeType )
     {
-        try
+        if ( attributeType == null )
         {
-            if ( attributeType == null )
-            {
-                return "The AttributeType parameter should not be null";
-            }
-            
-            if ( attributeType.getSyntax() == null )
-            {
-                return "There is no Syntax associated with this attributeType";
-            }
-
-            return null;
+            return "The AttributeType parameter should not be null";
         }
-        catch ( NamingException ne )
+        
+        if ( attributeType.getSyntax() == null )
         {
-            return "This AttributeType is incorrect";
+            return "There is no Syntax associated with this attributeType";
         }
+
+        return null;
     }
 
     
@@ -122,21 +116,14 @@
             throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
 
-        try
+        if ( attributeType.getSyntax() == null )
         {
-            if ( attributeType.getSyntax() == null )
-            {
-                throw new IllegalArgumentException( "There is no Syntax associated with this
attributeType" );
-            }
-
-            if ( attributeType.getSyntax().isHumanReadable() )
-            {
-                LOG.warn( "Treating a value of a human readible attribute {} as binary: ",
attributeType.getName() );
-            }
+            throw new IllegalArgumentException( "There is no Syntax associated with this
attributeType" );
         }
-        catch( NamingException e )
+
+        if ( attributeType.getSyntax().isHumanReadable() )
         {
-            LOG.error( "Failed to resolve syntax for attributeType {}", attributeType, e
);
+            LOG.warn( "Treating a value of a human readible attribute {} as binary: ", attributeType.getName()
);
         }
 
         this.attributeType = attributeType;
@@ -215,7 +202,7 @@
 
     
     /**
-     * Gets the normalized (cannonical) representation for the wrapped string.
+     * Gets the normalized (canonical) representation for the wrapped string.
      * If the wrapped String is null, null is returned, otherwise the normalized
      * form is returned.  If no the normalizedValue is null, then this method
      * will attempt to generate it from the wrapped value: repeated calls to
@@ -390,11 +377,11 @@
 
             try
             {
-                Comparator<? super Value<byte[]>> comparator = getComparator();
+                Comparator<? super byte[]> comparator = getLdapComparator();
                 
-                if ( comparator != null )
+                if ( comparator == null )
                 {
-                    return getComparator().compare( getNormalizedValueReference(), binaryValue.getNormalizedValueReference()
);
+                    return comparator.compare( getNormalizedValueReference(), binaryValue.getNormalizedValueReference()
);
                 }
                 else
                 {
@@ -512,7 +499,7 @@
         {
             try
             {
-                Comparator<byte[]> comparator = getComparator();
+                LdapComparator<? super byte[]> comparator = getLdapComparator();
 
                 // Compare normalized values
                 if ( comparator == null )
@@ -589,7 +576,7 @@
      * @return a comparator associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */
-    private Comparator getComparator() throws NamingException
+    private LdapComparator<? super Object> getLdapComparator() throws NamingException
     {
         MatchingRule mr = getMatchingRule();
 
@@ -598,7 +585,7 @@
             return null;
         }
 
-        return mr.getComparator();
+        return mr.getLdapComparator();
     }
     
     

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntrySerializer.java
Wed Aug 26 07:24:43 2009
@@ -25,7 +25,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
Wed Aug 26 07:24:43 2009
@@ -35,7 +35,6 @@
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchResult;
 
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -45,6 +44,7 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.EmptyEnumeration;
 import org.apache.directory.shared.ldap.util.StringTools;
 
@@ -463,7 +463,7 @@
                 // TODO - after removing JNDI we need to make the server handle 
                 // this in the codec
                 
-                if ( ! atRegistry.hasAttributeType( id ) 
+                if ( ! atRegistry.contains( id ) 
                      && modification.getAttribute().size() == 0 
                      && modification.getOperation() == ModificationOperation.REPLACE_ATTRIBUTE
)
                 {
@@ -510,7 +510,7 @@
                 // TODO - after removing JNDI we need to make the server handle 
                 // this in the codec
                 
-                if ( ! atRegistry.hasAttributeType( id ) 
+                if ( ! atRegistry.contains( id ) 
                      && modification.getAttribute().size() == 0 
                      && modification.getModificationOp() == DirContext.REPLACE_ATTRIBUTE
)
                 {

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
Wed Aug 26 07:24:43 2009
@@ -26,13 +26,13 @@
 import javax.naming.NamingException;
 //import javax.naming.directory.DirContext;
 
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
Wed Aug 26 07:24:43 2009
@@ -23,7 +23,6 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.util.Comparator;
 
 import javax.naming.NamingException;
 
@@ -31,6 +30,7 @@
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.slf4j.Logger;
@@ -77,24 +77,17 @@
      */
     protected String checkAttributeType( AttributeType attributeType )
     {
-        try
+        if ( attributeType == null )
         {
-            if ( attributeType == null )
-            {
-                return "The AttributeType parameter should not be null";
-            }
-            
-            if ( attributeType.getSyntax() == null )
-            {
-                return "There is no Syntax associated with this attributeType";
-            }
-
-            return null;
+            return "The AttributeType parameter should not be null";
         }
-        catch ( NamingException ne )
+        
+        if ( attributeType.getSyntax() == null )
         {
-            return "This AttributeType is incorrect";
+            return "There is no Syntax associated with this attributeType";
         }
+
+        return null;
     }
 
     
@@ -115,22 +108,15 @@
             throw new IllegalArgumentException( "The AttributeType parameter should not be
null" );
         }
 
-        try
+        if ( attributeType.getSyntax() == null )
         {
-            if ( attributeType.getSyntax() == null )
-            {
-                throw new IllegalArgumentException( "There is no Syntax associated with this
attributeType" );
-            }
-
-            if ( ! attributeType.getSyntax().isHumanReadable() )
-            {
-                LOG.warn( "Treating a value of a binary attribute {} as a String: " +
-                        "\nthis could cause data corruption!", attributeType.getName() );
-            }
+            throw new IllegalArgumentException( "There is no Syntax associated with this
attributeType" );
         }
-        catch( NamingException e )
+
+        if ( ! attributeType.getSyntax().isHumanReadable() )
         {
-            LOG.error( "Failed to resolve syntax for attributeType {}", attributeType, e
);
+            LOG.warn( "Treating a value of a binary attribute {} as a String: " +
+                    "\nthis could cause data corruption!", attributeType.getName() );
         }
 
         this.attributeType = attributeType;
@@ -336,7 +322,7 @@
             try
             {
                 //noinspection unchecked
-                return getComparator().compare( getNormalizedValue(), stringValue.getNormalizedValue()
);
+                return getLdapComparator().compare( getNormalizedValue(), stringValue.getNormalizedValue()
);
             }
             catch ( NamingException e )
             {
@@ -436,7 +422,7 @@
         {
             try
             {
-                Comparator<String> comparator = getComparator();
+                LdapComparator<? super Object> comparator = getLdapComparator();
 
                 // Compare normalized values
                 if ( comparator == null )
@@ -549,7 +535,7 @@
      * @return a comparator associated with the attributeType or null if one cannot be found
      * @throws NamingException if resolution of schema entities fail
      */
-    private Comparator getComparator() throws NamingException
+    private LdapComparator<? super Object> getLdapComparator() throws NamingException
     {
         MatchingRule mr = getMatchingRule();
 
@@ -558,7 +544,7 @@
             return null;
         }
 
-        return mr.getComparator();
+        return mr.getLdapComparator();
     }
     
     

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=807899&r1=807898&r2=807899&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
Wed Aug 26 07:24:43 2009
@@ -30,6 +30,7 @@
 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;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
@@ -123,6 +124,12 @@
         }
     }
 
+    public static MatchingRule matchingRuleFactory( String oid )
+    {
+        MatchingRule matchingRule = new MatchingRule( oid );
+        
+        return matchingRule;
+    }
     /**
      * A local MatchingRule class for tests
      */
@@ -130,7 +137,7 @@
     {
         private static final long serialVersionUID = 0L;
         LdapSyntax syntax;
-        Comparator comparator;
+        LdapComparator<? super Object> ldapComparator;
         Normalizer normalizer;
 
         protected MR( String oid )
@@ -143,9 +150,9 @@
             return syntax;
         }
 
-        public Comparator getComparator() throws NamingException
+        public LdapComparator<? super Object> getLdapComparator() throws NamingException
         {
-            return comparator;
+            return ldapComparator;
         }
 
 
@@ -161,9 +168,9 @@
         }
 
 
-        public void setComparator( Comparator<?> comparator )
+        public void setComparator( Comparator<? super Object> comparator )
         {
-            this.comparator = comparator;
+            this.ldapComparator = comparator;
         }
 
 
@@ -177,6 +184,14 @@
     /**
      * A local Syntax class used for the tests
      */
+    public static LdapSyntax syntaxFactory( String oid, boolean humanReadable )
+    {
+        LdapSyntax ldapSyntax = new LdapSyntax( oid );
+        
+        ldapSyntax.setHumanReadable( humanReadable );
+        
+        return ldapSyntax;
+    }
     static class S extends LdapSyntax
     {
         private static final long serialVersionUID = 0L;
@@ -226,7 +241,7 @@
 
         final MR mr = new MR( "1.1.2.1" );
         mr.syntax = s;
-        mr.comparator = new Comparator<String>()
+        mr.ldapComparator = new LdapComparator<String>()
         {
             public int compare( String o1, String o2 )
             {
@@ -276,7 +291,7 @@
             }
         };
         
-        AT at = new AT( "1.1.3.1" );
+        AttributeType at = new AttributeType( "1.1.3.1" );
         at.setEquality( mr );
         at.setSyntax( s );
         return at;
@@ -333,15 +348,7 @@
 
         final MR mr = new MR( "1.2.2" );
         mr.syntax = s;
-        mr.comparator = new Comparator<byte[]>()
-        {
-            public int compare( byte[] o1, byte[] o2 )
-            {
-                return ( ( o1 == null ) ? 
-                    ( o2 == null ? 0 : -1 ) :
-                    ( o2 == null ? 1 : ByteArrayComparator.INSTANCE.compare( o1, o2 ) ) );
-            }
-        };
+        mr.setComparator( new ByteArrayComparator() );
         
         mr.normalizer = new Normalizer( "1.1.1" )
         {

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=807899&r1=807898&r2=807899&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
Wed Aug 26 07:24:43 2009
@@ -52,8 +52,6 @@
 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.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientAttribute;
@@ -61,6 +59,8 @@
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import org.junit.BeforeClass;

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=807899&r1=807898&r2=807899&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
Wed Aug 26 07:24:43 2009
@@ -42,8 +42,6 @@
 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.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -55,6 +53,8 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import static org.junit.Assert.assertEquals;

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerBinaryValueTest.java
Wed Aug 26 07:24:43 2009
@@ -32,6 +32,8 @@
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapSyntax;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.comparators.ByteArrayComparator;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.AcceptAllSyntaxChecker;
@@ -63,9 +65,9 @@
  */
 public class ServerBinaryValueTest
 {
-    private TestServerEntryUtils.S s;
-    private TestServerEntryUtils.AT at;
-    private TestServerEntryUtils.MR mr;
+    private LdapSyntax s;
+    private AttributeType at;
+    private MatchingRule mr;
     
     private static final byte[] BYTES1 = new byte[]{0x01, 0x02, 0x03, 0x04};
     private static final byte[] BYTES2 = new byte[]{(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84};
@@ -76,12 +78,13 @@
      */
     @Before public void initAT()
     {
-        s = new TestServerEntryUtils.S( "1.1.1.1", false );
+        s = TestServerEntryUtils.syntaxFactory( "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 ByteArrayComparator();
-        mr.normalizer = new Normalizer( "1.1.1" )
+        mr = TestServerEntryUtils.matchingRuleFactory( "1.1.2.1" );
+        mr.setSyntax( s );
+        
+        mr.setLdapComparator( new ByteArrayComparator() );
+        mr.setNormalizer( new Normalizer( "1.1.1" )
         {
             private static final long serialVersionUID = 1L;
             
@@ -110,8 +113,9 @@
             {
                 throw new IllegalStateException( "expected byte[] to normalize" );
             }
-        };
-        at = new TestServerEntryUtils.AT( "1.1.3.1" );
+        });
+        
+        at = new AttributeType( "1.1.3.1" );
         at.setEquality( mr );
         at.setOrdering( mr );
         at.setSubstr( mr );
@@ -210,7 +214,7 @@
         }
         
         // create a AT without any syntax
-        AttributeType attribute = new TestServerEntryUtils.AT( "1.1.3.1" );
+        AttributeType attribute = new AttributeType( "1.1.3.1" );
         
         try
         {

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
Wed Aug 26 07:24:43 2009
@@ -35,13 +35,13 @@
 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.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.StringTools;
 
 import static org.junit.Assert.assertEquals;

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java?rev=807899&r1=807898&r2=807899&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
Wed Aug 26 07:24:43 2009
@@ -39,8 +39,6 @@
 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.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
@@ -48,6 +46,8 @@
 import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;

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=807899&r1=807898&r2=807899&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
Wed Aug 26 07:24:43 2009
@@ -654,7 +654,7 @@
 
                 try
                 {
-                    return mr.getComparator().compare( n1, n2 );
+                    return mr.getLdapComparator().compare( n1, n2 );
                 }
                 catch ( NamingException ne )
                 {



Mime
View raw message