directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1084663 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/ apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/serve...
Date Wed, 23 Mar 2011 18:21:08 GMT
Author: elecharny
Date: Wed Mar 23 18:21:07 2011
New Revision: 1084663

URL: http://svn.apache.org/viewvc?rev=1084663&view=rev
Log:
o Removed the getSuffix( int ) method, which is replaced by the getDescendantOf( Dn )

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/DnUtils.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=1084663&r1=1084662&r2=1084663&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
Wed Mar 23 18:21:07 2011
@@ -230,7 +230,7 @@ public class DefaultOperationManager imp
             if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
                 Entry parentEntry = directoryService.getReferralManager().getParentReferral(
dn );
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 // Depending on the Context.REFERRAL property value, we will throw
                 // a different exception.
@@ -318,7 +318,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
@@ -397,7 +397,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
@@ -586,7 +586,7 @@ public class DefaultOperationManager imp
                         referralManager.unlock();
 
                         // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                         LdapReferralException exception = buildReferralException( parentEntry,
childDn );
                         throw exception;
@@ -603,7 +603,7 @@ public class DefaultOperationManager imp
                         referralManager.unlock();
 
                         // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                         LdapPartialResultException exception = buildLdapPartialResultException(
childDn );
                         throw exception;
@@ -614,7 +614,7 @@ public class DefaultOperationManager imp
                         referralManager.unlock();
 
                         // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                         LdapReferralException exception = buildReferralException( parentEntry,
childDn );
                         throw exception;
@@ -669,7 +669,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
@@ -767,7 +767,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
@@ -880,7 +880,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {
@@ -962,7 +962,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current Dn
-                Dn childDn = dn.getSuffix( parentEntry.getDn().size() );
+                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
 
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java?rev=1084663&r1=1084662&r2=1084663&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java
Wed Mar 23 18:21:07 2011
@@ -119,7 +119,7 @@ public class SubtreeEvaluator
         if ( ( subtree.getChopBeforeExclusions().size() != 0 ) || 
              ( subtree.getChopAfterExclusions().size() != 0 ) )
         {
-            Dn entryRelativeDn = entryDn.getSuffix( apDn.size() + subtree.getBase().size()
);
+            Dn entryRelativeDn = entryDn.getDescendantOf( apDn ).getDescendantOf( subtree.getBase()
);
             
             for ( Dn chopBeforeDn : subtree.getChopBeforeExclusions() )
             {

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1084663&r1=1084662&r2=1084663&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
Wed Mar 23 18:21:07 2011
@@ -505,7 +505,7 @@ public class LdifPartition extends Abstr
         StringBuilder filePath = new StringBuilder();
         filePath.append( suffixDirectory ).append( File.separator );
 
-        Dn baseDn = entryDn.getSuffix( suffix.size() );
+        Dn baseDn = entryDn.getDescendantOf( suffix );
 
         for ( int i = 0; i < baseDn.size() - 1; i++ )
         {

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java?rev=1084663&r1=1084662&r2=1084663&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
Wed Mar 23 18:21:07 2011
@@ -926,7 +926,7 @@ public class DnTest
     public void testDnGetSuffixPos0() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getSuffix( 0 ) );
+        Dn newDn = ( dn.getDescendantOf( "" ) );
         assertEquals( "a=b, c=d,e = f", newDn.getName() );
     }
 
@@ -938,7 +938,7 @@ public class DnTest
     public void testDnGetSuffixPos1() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getSuffix( 1 ) );
+        Dn newDn = ( dn.getDescendantOf( "e=f" ) );
         assertEquals( "a=b, c=d", newDn.getName() );
     }
 
@@ -950,7 +950,7 @@ public class DnTest
     public void testDnGetSuffixPos2() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getSuffix( 2 ) );
+        Dn newDn = ( dn.getDescendantOf( "c=d,e=f" ) );
         assertEquals( "a=b", newDn.getName() );
     }
 
@@ -962,7 +962,7 @@ public class DnTest
     public void testDnGetSuffixPos3() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getSuffix( 3 ) );
+        Dn newDn = ( dn.getDescendantOf( "a=b, c=d, e=f" ) );
         assertEquals( "", newDn.getName() );
     }
 
@@ -977,7 +977,7 @@ public class DnTest
 
         try
         {
-            dn.getSuffix( 4 );
+            dn.getDescendantOf( "i=j, a=b, c=d, e=f" );
             // We should not reach this point.
             fail();
         }
@@ -990,7 +990,7 @@ public class DnTest
 
     /**
      * Get the suffix of an empty LdapName
-     */
+     *
     @Test
     public void testDnGetSuffixEmptyDN()
     {
@@ -1593,11 +1593,11 @@ public class DnTest
     public void testGetXSuffix() throws Exception
     {
         Dn name = new Dn( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-        assertEquals( "", name.getSuffix( 4 ).toString() );
-        assertEquals( "cn=HomeDir", name.getSuffix( 3 ).toString() );
-        assertEquals( "cn=HomeDir,cn=John", name.getSuffix( 2 ).toString() );
-        assertEquals( "cn=HomeDir,cn=John,ou=Marketing", name.getSuffix( 1 ).toString() );
-        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getSuffix( 0 ).toString()
);
+        assertEquals( "", name.getDescendantOf( "cn=HomeDir,cn=John,ou=Marketing,ou=East"
).toString() );
+        assertEquals( "cn=HomeDir", name.getDescendantOf( "cn=John,ou=Marketing,ou=East"
).toString() );
+        assertEquals( "cn=HomeDir,cn=John", name.getDescendantOf( "ou=Marketing,ou=East"
).toString() );
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing", name.getDescendantOf( "ou=East"
).toString() );
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getDescendantOf( ""
).toString() );
     }
 
 
@@ -2127,11 +2127,11 @@ public class DnTest
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
         Dn aName = new Dn( "cn=four,cn=three,cn=two,cn=one" );
 
-        assertEquals( jName.getSuffix( 0 ).toString(), aName.getSuffix( 0 ).toString() );
-        assertEquals( jName.getSuffix( 1 ).toString(), aName.getSuffix( 1 ).toString() );
-        assertEquals( jName.getSuffix( 2 ).toString(), aName.getSuffix( 2 ).toString() );
-        assertEquals( jName.getSuffix( 3 ).toString(), aName.getSuffix( 3 ).toString() );
-        assertEquals( jName.getSuffix( 4 ).toString(), aName.getSuffix( 4 ).toString() );
+        assertEquals( jName.getSuffix( 0 ).toString(), aName.getDescendantOf( "" ).toString()
);
+        assertEquals( jName.getSuffix( 1 ).toString(), aName.getDescendantOf( "cn=one" ).toString()
);
+        assertEquals( jName.getSuffix( 2 ).toString(), aName.getDescendantOf( "cn=two,cn=one"
).toString() );
+        assertEquals( jName.getSuffix( 3 ).toString(), aName.getDescendantOf( "cn=three,cn=two,cn=one"
).toString() );
+        assertEquals( jName.getSuffix( 4 ).toString(), aName.getDescendantOf( "cn=four,cn=three,cn=two,cn=one"
).toString() );
     }
 
 

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=1084663&r1=1084662&r2=1084663&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 Mar 23 18:21:07 2011
@@ -1041,46 +1041,6 @@ public class Dn implements Iterable<Rdn>
 
 
     /**
-     * {@inheritDoc}
-     */
-    public Dn getSuffix( int posn )
-    {
-        if ( rdns.size() == 0 )
-        {
-            return EMPTY_DN;
-        }
-
-        if ( ( posn < 0 ) || ( posn > rdns.size() ) )
-        {
-            String message = I18n.err( I18n.ERR_04206, posn, rdns.size() );
-            LOG.error( message );
-            throw new ArrayIndexOutOfBoundsException( message );
-        }
-
-        Dn newDn = new Dn();
-
-        for ( int i = 0; i < size() - posn; i++ )
-        {
-            // Don't forget to clone the rdns !
-            newDn.rdns.add( rdns.get( i ).clone() );
-        }
-
-        try
-        {
-            newDn.normalize( schemaManager );
-        }
-        catch ( LdapInvalidDnException lide )
-        {
-            // Do nothing
-        }
-        
-        newDn.upName = getUpNameSuffix( posn );
-
-        return newDn;
-    }
-
-
-    /**
      * Adds the components of a name -- in order -- at a specified position
      * within this name. Components of this name at or after the index of the
      * first new component are shifted up (away from 0) to accommodate the new

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/DnUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/DnUtils.java?rev=1084663&r1=1084662&r2=1084663&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/DnUtils.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/DnUtils.java
Wed Mar 23 18:21:07 2011
@@ -22,6 +22,7 @@ package org.apache.directory.studio.conn
 
 import javax.naming.InvalidNameException;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 
@@ -41,7 +42,7 @@ public class DnUtils
      * 
      * @return the prefix
      */
-    public static Dn getPrefixName( Dn dn, Dn suffix )
+    public static Dn getPrefixName( Dn dn, Dn suffix ) 
     {
         if ( suffix.size() < 1 )
         {
@@ -49,8 +50,16 @@ public class DnUtils
         }
         else
         {
-            Dn prefix = (Dn) dn.getSuffix( suffix.size() );
-            return prefix;
+            try
+            {
+                Dn prefix = dn.getDescendantOf( suffix );
+                
+                return prefix;
+            }
+            catch ( LdapInvalidDnException lide )
+            {
+                return null;
+            }
         }
     }
 



Mime
View raw message