directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1071604 - in /directory: apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/ shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/ shared/branches/m1/ldap-model/src/main/java/org/apache/directo...
Date Thu, 17 Feb 2011 13:22:19 GMT
Author: elecharny
Date: Thu Feb 17 13:22:18 2011
New Revision: 1071604

URL: http://svn.apache.org/viewvc?rev=1071604&view=rev
Log:
o Added a new constructor that takes a RDN and a DN
o Removed a thrown exception in the Dn.addAll() method
o Added a test

Modified:
    directory/apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
    directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java

Modified: directory/apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=1071604&r1=1071603&r2=1071604&view=diff
==============================================================================
--- directory/apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
(original)
+++ directory/apacheds/branches/m1/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
Thu Feb 17 13:22:18 2011
@@ -48,7 +48,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.exception.LdapAffectMultipleDsaException;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapOperationErrorException;
 import org.apache.directory.shared.ldap.model.exception.LdapPartialResultException;
 import org.apache.directory.shared.ldap.model.exception.LdapReferralException;
@@ -100,22 +99,18 @@ public class DefaultOperationManager imp
             {
                 // we have to replace the parent by the referral
                 LdapURL ldapUrl = new LdapURL( url.getString() );
-
+    
                 // We have a problem with the Dn : we can't use the UpName,
                 // as we may have some spaces around the ',' and '+'.
                 // So we have to take the Rdn one by one, and create a
                 // new Dn with the type and value UP form
-
+    
                 Dn urlDn = ldapUrl.getDn().addAll( childDn );
-
+    
                 ldapUrl.setDn( urlDn );
                 urls.add( ldapUrl.toString() );
             }
         }
-        catch ( LdapInvalidDnException lide )
-        {
-            throw new LdapOperationErrorException( lide.getMessage() );
-        }
         catch ( LdapURLEncodingException luee )
         {
             throw new LdapOperationErrorException( luee.getMessage() );

Modified: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java?rev=1071604&r1=1071603&r2=1071604&view=diff
==============================================================================
--- directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
Thu Feb 17 13:22:18 2011
@@ -3598,4 +3598,16 @@ public class DnTest
 
         assertEquals( dnStr, dn.toString() );
     }
+    
+    
+    @Test
+    public void testCreateDnFromRdnParent() throws Exception
+    {
+        String rdn = "cn=test";
+        String parentDn = "ou=apache,ou=org";
+        
+        Dn dn = new Dn( rdn, parentDn );
+        
+        assertEquals( "cn=test,ou=apache,ou=org", dn.getName() );
+    }
 }

Modified: directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1071604&r1=1071603&r2=1071604&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Thu Feb 17 13:22:18 2011
@@ -365,7 +365,6 @@ public final class Dn implements Iterabl
         for ( Rdn rdn : rdns)
         {
             this.rdns.add( rdn.clone() );
-            
         }
 
         normalizeInternal();
@@ -375,6 +374,45 @@ public final class Dn implements Iterabl
 
 
     /**
+     * Creates a Dn concatenating a Rdn and a Dn.
+     *
+     * @param rdns the list of Rdns to be used for the Dn
+     */
+    public Dn( Rdn rdn, Dn dn ) throws LdapInvalidDnException
+    {
+        if ( ( dn == null ) || ( rdn == null ) )
+        {
+            throw new IllegalArgumentException( "Either the dn or the rdn is null" );
+        }
+        
+        for ( Rdn rdnParent : dn )
+        {
+            rdns.add( rdnParent );
+        }
+        
+        rdns.add( rdn );
+        
+        normalized = new AtomicBoolean();
+        schemaManager = dn.schemaManager;
+
+        if ( schemaManager != null )
+        {
+            normalize( schemaManager.getNormalizerMapping() );
+        }
+        else
+        {
+            normalized.set( false );
+
+            // Stores the representations of a Dn : internal (as a string and as a
+            // byte[]) and external.
+            normalizeInternal();
+        }
+
+        toUpName();
+    }
+
+
+    /**
      * Creates a Schema aware Dn from a list of Rdns.
      *
      *  @param schemaManager The SchemaManager to use
@@ -1136,9 +1174,20 @@ public final class Dn implements Iterabl
     /**
      * {@inheritDoc}
      */
-    public Dn addAll( Dn suffix ) throws LdapInvalidDnException
+    public Dn addAll( Dn suffix )
     {
-        return addAll( rdns.size(), suffix );
+        Dn result = null;
+        
+        try
+        {
+            result = addAll( rdns.size(), suffix );
+        }
+        catch ( LdapInvalidDnException lie )
+        {
+            // Do nothing, 
+        }
+
+        return result;
     }
 
 



Mime
View raw message