directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r950633 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operations/search/ core/src/main/java/org/apache/directory/server/core/schema/ xdbm-search/src/main/java/org/apache/directory/server/xdbm/sear...
Date Wed, 02 Jun 2010 16:40:42 GMT
Author: elecharny
Date: Wed Jun  2 16:40:42 2010
New Revision: 950633

URL: http://svn.apache.org/viewvc?rev=950633&view=rev
Log:
o Added an (ignored) test for DIRSERVER-1389
o Prepared the SubstringEvaluator for when we will be ready to do SUBSTR filters on binary
values

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchBinaryIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchBinaryIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchBinaryIT.java?rev=950633&r1=950632&r2=950633&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchBinaryIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchBinaryIT.java
Wed Jun  2 16:40:42 2010
@@ -34,6 +34,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -70,6 +71,26 @@ import org.junit.runner.RunWith;
         enableChangeLog = false )
 @ApplyLdifs(
     {
+        "dn: m-oid=2.2.0, ou=attributeTypes, cn=apachemeta, ou=schema",
+        "objectclass: metaAttributeType",
+        "objectclass: metaTop",
+        "objectclass: top",
+        "m-oid: 2.2.0",
+        "m-name: binaryAttribute",
+        "m-description: an attribute storing binary values",
+        "m-equality: octetStringMatch",
+        "m-ordering: octetStringOrderingMatch",
+        "m-substr: octetStringSubstringsMatch",
+        "m-syntax: 1.3.6.1.4.1.1466.115.121.1.40",
+        "m-length: 0",
+        "",
+        "dn: ou=testingBin,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "objectClass: extensibleObject",
+        "ou: testingBin",
+        "binaryAttribute:: AQIDBA==",
+        "",
         "dn: cn=testing00,ou=system",
         "objectClass: top",
         "objectClass: person", 
@@ -109,7 +130,7 @@ import org.junit.runner.RunWith;
 public class SearchBinaryIT extends AbstractLdapTestUnit
 {
     /**
-     * Test an add operation performance
+     * Test search on a binary attribute
      */
     @Test
     public void testSearchWithIndexBinaryAttribute() throws Exception
@@ -181,4 +202,30 @@ public class SearchBinaryIT extends Abst
         assertEquals( 0, i );
         connection.close();
     }
+
+    /**
+     * Test search on a binary attribute
+     */
+    @Test
+    @Ignore // This test fails atm. Cf DIRSERVER-1389
+    public void testSearchSubstrOnBinaryAttribute() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( service );
+
+        // Check that searching for an entry using a valid SUBSTR filter works
+        Cursor<SearchResponse> responses = connection.search( "ou=system", "(binaryAttribute=\\01\\02*)",
SearchScope.SUBTREE, "*" );
+
+        int i = 0;
+
+        while ( responses.next() )
+        {
+            responses.get();
+            ++i;
+        }
+
+        responses.close();
+
+        assertEquals( 1, i );
+        connection.close();
+    }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=950633&r1=950632&r2=950633&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Wed Jun  2 16:40:42 2010
@@ -578,18 +578,10 @@ public class SchemaInterceptor extends B
                     node.setValue( newValue );
                 }
             }
-            else if ( filter instanceof SubstringNode )
-            {
-                SubstringNode node = ( ( SubstringNode ) filter );
-
-                if ( !schemaManager.lookupAttributeTypeRegistry( node.getAttribute() ).getSyntax().isHumanReadable()
)
-                {
-                    String message = I18n.err( I18n.ERR_50 );
-                    LOG.error( message );
-                    throw new LdapException( message );
-                }
-            }
-            else if ( filter instanceof PresenceNode )
+            else if ( ( filter instanceof SubstringNode ) || 
+                      ( filter instanceof PresenceNode ) || 
+                      ( filter instanceof AssertionNode ) || 
+                      ( filter instanceof ScopeNode ) )
             {
                 // Nothing to do
             }
@@ -641,16 +633,6 @@ public class SchemaInterceptor extends B
                     node.setValue( newValue );
                 }
             }
-            else if ( filter instanceof AssertionNode )
-            {
-                // Nothing to do
-                return;
-            }
-            else if ( filter instanceof ScopeNode )
-            {
-                // Nothing to do
-                return;
-            }
         }
         else
         {

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=950633&r1=950632&r2=950633&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
Wed Jun  2 16:40:42 2010
@@ -29,8 +29,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -103,7 +103,15 @@ public class SubstringEvaluator<ID exten
         }
 
         // compile the regular expression to search for a matching attribute
-        regex = node.getRegex( normalizer );
+        // if the attributeType is humanReadable
+        if ( type.getSyntax().isHumanReadable() )
+        {
+            regex = node.getRegex( normalizer );
+        }
+        else
+        {
+            regex = null;
+        }
 
         if ( db.hasIndexOn( node.getAttribute() ) )
         {
@@ -350,17 +358,41 @@ public class SubstringEvaluator<ID exten
              * The test uses the comparator obtained from the appropriate
              * substring matching rule.
              */
-            for ( Value<?> value : attr )
+            if ( attr.isHR() )
             {
-                value.normalize( normalizer );
-                String strValue = ( String ) value.getNormalizedValue();
-
-                // Once match is found cleanup and return true
-                if ( regex.matcher( strValue ).matches() )
+                for ( Value<?> value : attr )
                 {
-                    // before returning we set the normalized value
-                    indexEntry.setValue( strValue );
-                    return true;
+                    value.normalize( normalizer );
+                    String strValue = ( String ) value.getNormalizedValue();
+    
+                    // Once match is found cleanup and return true
+                    if ( regex.matcher( strValue ).matches() )
+                    {
+                        // before returning we set the normalized value
+                        indexEntry.setValue( strValue );
+                        return true;
+                    }
+                }
+            }
+            else
+            {
+                // Slightly more complex. We won't be able to use a regex to check
+                // the value.
+                for ( Value<?> value : attr )
+                {
+                    value.normalize( normalizer );
+                    byte[] byteValue = (byte[])value.getNormalizedValue();
+    
+                    // Once match is found cleanup and return true
+                    // @TODO : implement this check.
+                    /*
+                    if ( check( byteValue ) )
+                    {
+                        // before returning we set the normalized value
+                        indexEntry.setValue( byteValue );
+                        return true;
+                    }
+                    */
                 }
             }
 



Mime
View raw message