Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 19119 invoked from network); 2 Jun 2010 16:41:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 16:41:05 -0000 Received: (qmail 66409 invoked by uid 500); 2 Jun 2010 16:41:04 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 66319 invoked by uid 500); 2 Jun 2010 16:41:04 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 66133 invoked by uid 99); 2 Jun 2010 16:41:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 16:41:03 +0000 X-ASF-Spam-Status: No, hits=-1504.8 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 16:41:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BC9A223889F1; Wed, 2 Jun 2010 16:40:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100602164042.BC9A223889F1@eris.apache.org> 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 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 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; + } + */ } }