directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1073718 - in /directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model: name/Dn.java name/Rdn.java schema/comparators/DnComparator.java schema/comparators/UniqueMemberComparator.java
Date Wed, 23 Feb 2011 12:20:33 GMT
Author: elecharny
Date: Wed Feb 23 12:20:33 2011
New Revision: 1073718

URL: http://svn.apache.org/viewvc?rev=1073718&view=rev
Log:
o Made de Rdn class final
o Removed the Dn.normalize( Dn, Map ) and Dn.normalize( Map ) methods

Modified:
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
    directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1073718&r1=1073717&r2=1073718&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Wed Feb 23 12:20:33 2011
@@ -316,7 +316,7 @@ public final class Dn implements Iterabl
         if ( schemaManager != null )
         {
             this.schemaManager = schemaManager;
-            normalize( schemaManager.getNormalizerMapping() );
+            normalize( schemaManager );
         }
         else
         {
@@ -390,7 +390,7 @@ public final class Dn implements Iterabl
 
         if ( schemaManager != null )
         {
-            normalize( schemaManager.getNormalizerMapping() );
+            normalize( schemaManager );
         }
         else
         {
@@ -427,7 +427,7 @@ public final class Dn implements Iterabl
 
         if ( schemaManager != null )
         {
-            normalize( schemaManager.getNormalizerMapping() );
+            normalize( schemaManager );
         }
         else
         {
@@ -466,7 +466,7 @@ public final class Dn implements Iterabl
             
             if ( this.schemaManager != null )
             {
-                normalize( schemaManager.getNormalizerMapping() );
+                normalize( schemaManager );
             }
 
             normalizeInternal();
@@ -1310,7 +1310,7 @@ public final class Dn implements Iterabl
         {
             if ( schemaManager != null )
             {
-                clonedDn.normalize( schemaManager.getNormalizerMapping() );
+                clonedDn.normalize( schemaManager );
 
                 normalizeInternal();
             }
@@ -1346,7 +1346,7 @@ public final class Dn implements Iterabl
 
         if ( schemaManager != null )
         {
-            clonedDn.normalize( schemaManager.getNormalizerMapping() );
+            clonedDn.normalize( schemaManager );
         }
         else
         {
@@ -1386,7 +1386,7 @@ public final class Dn implements Iterabl
             {
                 if ( schemaManager != null )
                 {
-                    clonedDn.normalize( schemaManager.getNormalizerMapping() );
+                    clonedDn.normalize( schemaManager );
                 }
                 else
                 {
@@ -1612,95 +1612,6 @@ public final class Dn implements Iterabl
 
 
     /**
-     * Change the internal Dn, using the OID instead of the first name or other
-     * aliases. As we still have the UP name of each Rdn, we will be able to
-     * provide both representation of the Dn. example : dn: 2.5.4.3=People,
-     * dc=example, domainComponent=com will be transformed to : 2.5.4.3=People,
-     * 0.9.2342.19200300.100.1.25=example, 0.9.2342.19200300.100.1.25=com
-     * because 2.5.4.3 is the OID for cn and dc is the first
-     * alias of the couple of aliases (dc, domaincomponent), which OID is
-     * 0.9.2342.19200300.100.1.25.
-     * This is really important do have such a representation, as 'cn' and
-     * 'commonname' share the same OID.
-     *
-     * @param dn The Dn to transform.
-     * @param oidsMap The mapping between names and oids.
-     * @return A normalized form of the Dn.
-     * @throws LdapInvalidDnException If something went wrong.
-     */
-    public static Dn normalize( Dn dn, Map<String, OidNormalizer> oidsMap ) throws
LdapInvalidDnException
-    {
-        if ( ( dn == null ) || ( dn.size() == 0 ) || ( oidsMap == null ) || ( oidsMap.size()
== 0 ) )
-        {
-            return dn;
-        }
-
-        for ( Rdn rdn : dn.rdns )
-        {
-            String upName = rdn.getName();
-            rdnOidToName( rdn, oidsMap );
-            rdn.normalize();
-            rdn.setUpName( upName );
-        }
-
-        dn.normalizeInternal();
-
-        dn.normalized.set( true );
-        return dn;
-    }
-
-
-    /**
-     * Change the internal Dn, using the OID instead of the first name or other
-     * aliases. As we still have the UP name of each Rdn, we will be able to
-     * provide both representation of the Dn. example : dn: 2.5.4.3=People,
-     * dc=example, domainComponent=com will be transformed to : 2.5.4.3=People,
-     * 0.9.2342.19200300.100.1.25=example, 0.9.2342.19200300.100.1.25=com
-     * because 2.5.4.3 is the OID for cn and dc is the first
-     * alias of the couple of aliases (dc, domaincomponent), which OID is
-     * 0.9.2342.19200300.100.1.25.
-     * This is really important do have such a representation, as 'cn' and
-     * 'commonname' share the same OID.
-     *
-     * @param oidsMap The mapping between names and oids.
-     * @throws LdapInvalidDnException If something went wrong.
-     * @return The normalized Dn
-     */
-    private Dn normalize( Map<String, OidNormalizer> oidsMap ) throws LdapInvalidDnException
-    {
-        if ( ( oidsMap == null ) || ( oidsMap.isEmpty() ) )
-        {
-            return this;
-        }
-
-        if ( normalized.get() )
-        {
-            return this;
-        }
-
-        synchronized ( this )
-        {
-            if ( size() == 0 )
-            {
-                normalized.set( true );
-                return this;
-            }
-
-            for ( Rdn rdn : rdns )
-            {
-                rdn.normalize( oidsMap );
-            }
-
-            normalizeInternal();
-
-            normalized.set( true );
-
-            return this;
-        }
-    }
-
-
-    /**
      * 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.
@@ -1718,7 +1629,30 @@ public final class Dn implements Iterabl
 
         if ( this.schemaManager != null )
         {
-            return normalize( schemaManager.getNormalizerMapping() );
+            if ( normalized.get() )
+            {
+                return this;
+            }
+
+            synchronized ( this )
+            {
+                if ( size() == 0 )
+                {
+                    normalized.set( true );
+                    return this;
+                }
+
+                for ( Rdn rdn : rdns )
+                {
+                    rdn.normalize( schemaManager );
+                }
+
+                normalizeInternal();
+
+                normalized.set( true );
+
+                return this;
+            }
         }
 
         normalizeInternal();

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1073718&r1=1073717&r2=1073718&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
Wed Feb 23 12:20:33 2011
@@ -115,7 +115,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class Rdn implements Cloneable, Externalizable, Iterable<Ava>
+public final class Rdn implements Cloneable, Externalizable, Iterable<Ava>
 {
     /** The LoggerFactory used by this class */
     protected static final Logger LOG = LoggerFactory.getLogger( Rdn.class );
@@ -485,13 +485,27 @@ public class Rdn implements Cloneable, E
      * Transform a Rdn by changing the value to its OID counterpart and
      * normalizing the value accordingly to its type.
      *
-     * @param sm the SchemaManager
+     * @param schemaManager the SchemaManager
      * @return this Rdn, normalized
      * @throws org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException if
the Rdn is invalid
      */
-    public Rdn normalize( SchemaManager sm ) throws LdapInvalidDnException
+    public Rdn normalize( SchemaManager schemaManager ) throws LdapInvalidDnException
     {
-        return normalize( sm.getNormalizerMapping() );
+        if ( normalized.get() )
+        {
+            return this;
+        }
+
+        synchronized ( this )
+        {
+            String savedUpName = getName();
+            Dn.rdnOidToName( this, schemaManager.getNormalizerMapping() );
+            normalize();
+            this.upName = savedUpName;
+            normalized.set( true );
+    
+            return this;
+        }
     }
 
 

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java?rev=1073718&r1=1073717&r2=1073718&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/DnComparator.java
Wed Feb 23 12:20:33 2011
@@ -83,7 +83,7 @@ public class DnComparator extends LdapCo
         {
             dn = (Dn)obj;
             
-            dn = ( dn.isNormalized() ? dn : Dn.normalize(dn, schemaManager.getNormalizerMapping())
);
+            dn = ( dn.isNormalized() ? dn : dn.normalize( schemaManager ) );
         }
         else if ( obj instanceof String )
         {

Modified: directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java?rev=1073718&r1=1073717&r2=1073718&view=diff
==============================================================================
--- directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java
(original)
+++ directory/shared/trunk/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/schema/comparators/UniqueMemberComparator.java
Wed Feb 23 12:20:33 2011
@@ -173,7 +173,7 @@ public class UniqueMemberComparator exte
         {
             dn = (Dn) obj;
 
-            dn = ( dn.isNormalized() ? dn : Dn.normalize(dn, schemaManager.getNormalizerMapping())
);
+            dn = ( dn.isNormalized() ? dn : dn.normalize( schemaManager ) );
         }
         else if ( obj instanceof String )
         {



Mime
View raw message