Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 10128 invoked from network); 3 Aug 2010 13:33:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Aug 2010 13:33:49 -0000 Received: (qmail 79728 invoked by uid 500); 3 Aug 2010 13:33:48 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 79674 invoked by uid 500); 3 Aug 2010 13:33:48 -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 79667 invoked by uid 99); 3 Aug 2010 13:33:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 13:33:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Tue, 03 Aug 2010 13:33:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C62DD23889BF; Tue, 3 Aug 2010 13:32:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r981868 - /directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java Date: Tue, 03 Aug 2010 13:32:30 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100803133230.C62DD23889BF@eris.apache.org> Author: kayyagari Date: Tue Aug 3 13:32:30 2010 New Revision: 981868 URL: http://svn.apache.org/viewvc?rev=981868&view=rev Log: o replaced 'normalized' flag with AtomicBoolean o synchronized the normalize method o added a new normalize() method which takes schema manager Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=981868&r1=981867&r2=981868&view=diff ============================================================================== --- directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java (original) +++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java Tue Aug 3 13:32:30 2010 @@ -1156,7 +1156,7 @@ public class DN implements Cloneable, Se clonedDn.rdns.add( clonedDn.size() - posn, rdn ); } - clonedDn.normalizeInternal(); + clonedDn.normalize( schemaManager ); clonedDn.toUpName(); return clonedDn; @@ -1190,7 +1190,7 @@ public class DN implements Cloneable, Se } else { - clonedDn.normalizeInternal(); + clonedDn.normalize( schemaManager ); clonedDn.toUpName(); } @@ -1214,7 +1214,7 @@ public class DN implements Cloneable, Se clonedDn.rdns.add( 0, newRdn ); - clonedDn.normalizeInternal(); + clonedDn.normalize( schemaManager ); clonedDn.toUpName(); return clonedDn; @@ -1233,7 +1233,17 @@ public class DN implements Cloneable, Se clonedDn.rdns.add( 0, newRdn ); - clonedDn.normalizeInternal(); + // FIXME this try-catch block shouldn't be here + // instead this method should throw the LdapInvalidDnException + try + { + clonedDn.normalize( schemaManager ); + } + catch( LdapInvalidDnException e ) + { + LOG.error( e.getMessage(), e ); + } + clonedDn.toUpName(); return clonedDn; @@ -1253,7 +1263,17 @@ public class DN implements Cloneable, Se clonedDn.rdns.add( newRdn ); - clonedDn.normalizeInternal(); + // FIXME this try-catch block shouldn't be here + // instead this method should throw the LdapInvalidDnException + try + { + clonedDn.normalize( schemaManager ); + } + catch( LdapInvalidDnException e ) + { + LOG.error( e.getMessage(), e ); + } + clonedDn.toUpName(); return clonedDn; @@ -1313,7 +1333,7 @@ public class DN implements Cloneable, Se int realPos = clonedDn.size() - posn; clonedDn.rdns.add( realPos, newRdn ); - clonedDn.normalizeInternal(); + clonedDn.normalize( schemaManager ); clonedDn.toUpName(); return clonedDn; @@ -1617,10 +1637,18 @@ public class DN implements Cloneable, Se return this; } + /* having the below check improves perf but + * there are many places where a non-normalized RDN gets + * added to a normalized DN and when normalized is called on the new DN + * this check is preventing it from being normalized + * cause the cloned DN (right before adding new RDN(s) ) retains the + * original DN's 'normalized' status + if( normalized.get() ) { return this; } + */ synchronized ( this ) { @@ -1648,6 +1676,33 @@ public class DN implements Cloneable, Se } } + + /** + * normalizes the DN @see {@link #normalize(Map)} however + * if the schema manager of the DN is null then sets the given schema manager + * as the DN's schema manager. + * + * If both, the given schema manager and that of the DN are null then the + * {@link #normalizeInternal()} will be called. + * + */ + public DN normalize( SchemaManager schemaManager ) throws LdapInvalidDnException + { + if( this.schemaManager == null ) + { + this.schemaManager = schemaManager; + } + + if( this.schemaManager != null ) + { + return normalize( schemaManager.getNormalizerMapping() ); + } + + normalizeInternal(); + + return this; + } + /** * Check if a DistinguishedName is syntactically valid. @@ -1761,7 +1816,7 @@ public class DN implements Cloneable, Se } // A serialized DN is always normalized. - normalized.set( true ); + normalized = new AtomicBoolean( true ); // Should we read the byte[] ??? bytes = StringTools.getBytesUtf8( upName );