directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1085042 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/ shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/ shared/trunk/ldap/model/src/main/java/org/apache/directory/s...
Date Thu, 24 Mar 2011 17:20:07 GMT
Author: elecharny
Date: Thu Mar 24 17:20:06 2011
New Revision: 1085042

URL: http://svn.apache.org/viewvc?rev=1085042&view=rev
Log:
o Removed the Dn.addAl( int, Dn ) method 
o Fixed some tests and code accordingly

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.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/aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java

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=1085042&r1=1085041&r2=1085042&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
Thu Mar 24 17:20:06 2011
@@ -80,6 +80,8 @@ public class SubtreeEvaluator
         Dn subentryBaseDn = apDn;
         subentryBaseDn = subentryBaseDn.addAll( subtree.getBase() );
         
+        String s = subentryBaseDn.toString();
+        
         if ( !entryDn.isDescendantOf( subentryBaseDn ) )
         {
             // The entry Dn is not part of the subtree specification, get out

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=1085042&r1=1085041&r2=1085042&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
Thu Mar 24 17:20:06 2011
@@ -220,8 +220,8 @@ public class DnTest
         Dn dn = new Dn( "cn=Kate Bush+sn=Bush,ou=system" );
         Dn target = new Dn();
 
-        assertTrue( Dn.isValid("cn=Kate Bush+sn=Bush,ou=system") );
-        target = target.addAll( target.size(), dn );
+        assertTrue( Dn.isValid( "cn=Kate Bush+sn=Bush,ou=system" ) );
+        target = target.addAll( dn );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getName() );
     }
@@ -779,7 +779,7 @@ public class DnTest
     {
         Dn dn = new Dn( "a = b" );
         Dn dn2 = new Dn( "c = d" );
-        dn = dn.addAll( 0, dn2 );
+        dn = dn2.addAll( dn );
         assertEquals( "a = b,c = d", dn.getName() );
     }
 
@@ -794,27 +794,12 @@ public class DnTest
     {
         Dn dn = new Dn( "a = b" );
         Dn dn2 = new Dn( "c = d" );
-        dn = dn.addAll( 1, dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "c = d,a = b", dn.getName() );
     }
 
 
     /**
-     * Test AddAll at the middle
-     *
-     * @throws LdapException
-     */
-    @Test
-    public void testDnAtTheMiddleAddAll() throws LdapException
-    {
-        Dn dn = new Dn( "a = b, c = d" );
-        Dn dn2 = new Dn( "e = f" );
-        dn = dn.addAll( 1, dn2 );
-        assertEquals( "a = b,e = f, c = d", dn.getName() );
-    }
-
-
-    /**
      * Test AddAll with an empty added name at position 0
      *
      * @throws LdapException
@@ -824,7 +809,7 @@ public class DnTest
     {
         Dn dn = new Dn( "a = b" );
         Dn dn2 = new Dn();
-        dn = dn.addAll( 0, dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a=b", dn.getNormName() );
         assertEquals( "a = b", dn.getName() );
     }
@@ -840,7 +825,7 @@ public class DnTest
     {
         Dn dn = new Dn();
         Dn dn2 = new Dn( "a = b" );
-        dn = dn.addAll( 0, dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a = b", dn.getName() );
     }
 
@@ -1748,40 +1733,7 @@ public class DnTest
 
         name = name.addAll( name0 );
         assertTrue( name0.equals( name ) );
-        assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
-    }
-
-
-    /**
-     * Class to test for Dn addAll(int, Dn)
-     *
-     * @throws Exception
-     *             when something goes wrong
-     */
-    @Test
-    public void testAddAllintName1() throws Exception
-    {
-        Dn name = new Dn();
-        Dn name0 = new Dn( "cn=HomeDir,ou=Marketing,ou=East" );
-        Dn name1 = new Dn( "cn=John" );
-        Dn name2 = new Dn( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-
-        name = name.addAll( name0 );
-        assertTrue( name0.equals( name ) );
-
-        name = name.addAll( 2, name1 );
-        assertTrue( name2.equals( name ) );
-
-        Dn name3 = new Dn( "cn=Airport" );
-        Dn name4 = new Dn( "cn=Airport,cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-
-        name = name.addAll( 4, name3 );
-        assertTrue( name4.equals( name ) );
-
-        Dn name5 = new Dn( "cn=ABC123" );
-        Dn name6 = new Dn( "cn=Airport,cn=HomeDir,cn=ABC123,cn=John,ou=Marketing,ou=East"
);
-
-        assertTrue( name6.equals( name.addAll( 3, name5 ) ) );
+        assertTrue( name2.equals( name.addAll( name1 ) ) );
     }
 
 
@@ -2176,15 +2128,15 @@ public class DnTest
         Dn aName = new Dn( "cn=four,cn=three,cn=two,cn=one" );
 
         assertSame( jName, jName.addAll( 0, new LdapName( "cn=zero,cn=zero.5" ) ) );
-        assertNotSame( aName, aName.addAll( 0, new Dn( "cn=zero,cn=zero.5" ) ) );
+        assertNotSame( aName, aName.addAll( new Dn( "cn=zero,cn=zero.5" ) ) );
         assertNotSame( jName.toString(), aName.toString() );
 
         assertSame( jName, jName.addAll( 2, new LdapName( "cn=zero,cn=zero.5" ) ) );
-        assertNotSame( aName, aName.addAll( 2, new Dn( "cn=zero,cn=zero.5" ) ) );
+        assertNotSame( aName, aName.addAll( new Dn( "cn=zero,cn=zero.5" ) ) );
         assertNotSame( jName.toString(), aName.toString() );
 
         assertSame( jName, jName.addAll( jName.size(), new LdapName( "cn=zero,cn=zero.5"
) ) );
-        assertNotSame( aName, aName.addAll( aName.size(), new Dn( "cn=zero,cn=zero.5" ) )
);
+        assertNotSame( aName, aName.addAll( new Dn( "cn=zero,cn=zero.5" ) ) );
         assertNotSame( jName.toString(), aName.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=1085042&r1=1085041&r2=1085042&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
Thu Mar 24 17:20:06 2011
@@ -343,11 +343,11 @@ public class Dn implements Iterable<Rdn>
         
         for ( Rdn rdnParent : dn )
         {
-            rdns.add( rdnParent );
+            rdns.add( 0, rdnParent );
         }
         
-        rdns.add( rdn );
-        
+        rdns.add( 0, rdn );
+
         applySchemaManager( dn.schemaManager );
         toUpName();
     }
@@ -1088,29 +1088,9 @@ public class Dn implements Iterable<Rdn>
     /**
      * {@inheritDoc}
      */
-    public Dn addAll( Dn suffix )
-    {
-        Dn result = null;
-        
-        try
-        {
-            result = addAll( rdns.size(), suffix );
-        }
-        catch ( LdapInvalidDnException lie )
-        {
-            // Do nothing, 
-        }
-
-        return result;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Dn addAll( int posn, Dn dn ) throws LdapInvalidDnException
+    public Dn addAll( Dn suffix ) throws LdapInvalidDnException
     {
-        if ( ( dn == null ) || ( dn.size() == 0 ) )
+        if ( ( suffix == null ) || ( suffix.size() == 0 ) )
         {
             return this;
         }
@@ -1118,16 +1098,16 @@ public class Dn implements Iterable<Rdn>
         Dn clonedDn = copy();
 
         // Concatenate the rdns
-        clonedDn.rdns.addAll( clonedDn.size() - posn, dn.rdns );
+        clonedDn.rdns.addAll( 0, suffix.rdns );
 
         // Regenerate the normalized name and the original string
-        if ( clonedDn.isSchemaAware() && dn.isSchemaAware() )
+        if ( clonedDn.isSchemaAware() && suffix.isSchemaAware() )
         {
             if ( clonedDn.size() != 0 )
             {
-                clonedDn.normName = dn.getNormName() + "," + normName;
+                clonedDn.normName = suffix.getNormName() + "," + normName;
                 clonedDn.bytes = Strings.getBytesUtf8(normName);
-                clonedDn.upName = dn.getName() + "," + upName;
+                clonedDn.upName = suffix.getName() + "," + upName;
             }
         }
         else

Modified: directory/studio/trunk/plugins/aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java?rev=1085042&r1=1085041&r2=1085042&view=diff
==============================================================================
--- directory/studio/trunk/plugins/aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
(original)
+++ directory/studio/trunk/plugins/aciitemeditor/src/main/java/org/apache/directory/studio/aciitemeditor/valueeditors/SubtreeSpecificationDialog.java
Thu Mar 24 17:20:06 2011
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+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.subtree.BaseSubtreeSpecification;
 import org.apache.directory.shared.ldap.model.subtree.SubtreeSpecification;
@@ -652,17 +653,26 @@ class SubtreeSpecificationDialog extends
     private void addValueExclusionsTable()
     {
         Dn chopBase = subtreeSpecification.getBase();
+        
         if ( useLocalName && ( subentryDn != null ) )
         {
             Dn suffix = subentryDn.getParent();
             
             if ( !Dn.isNullOrEmpty( suffix ) )
             {
-                chopBase = chopBase.addAll( suffix );
+                try
+                { 
+                    chopBase = chopBase.addAll( suffix );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    // Do nothing 
+                }
             }
         }
 
         ExclusionDialog dialog = new ExclusionDialog( getShell(), connection, chopBase, ""
); //$NON-NLS-1$
+        
         if ( dialog.open() == TextDialog.OK && !SubtreeValueEditor.EMPTY.equals(
dialog.getType() )
             && !SubtreeValueEditor.EMPTY.equals( dialog.getDN() ) )
         {
@@ -684,17 +694,27 @@ class SubtreeSpecificationDialog extends
         if ( oldValue != null )
         {
             Dn chopBase = subtreeSpecification.getBase();
+            
             if ( useLocalName && ( subentryDn != null ) )
             {
                 Dn suffix = subentryDn.getParent();
                 
                 if ( !Dn.isNullOrEmpty( suffix ) )
                 {
-                    chopBase = chopBase.addAll( suffix );
+                    try
+                    {
+                        chopBase = chopBase.addAll( suffix );
+                    }
+                    catch ( LdapInvalidDnException lide )
+                    {
+                        // Do nothing 
+                    }
+
                 }
             }
 
             ExclusionDialog dialog = new ExclusionDialog( getShell(), connection, chopBase,
oldValue );
+            
             if ( dialog.open() == TextDialog.OK && !SubtreeValueEditor.EMPTY.equals(
dialog.getType() )
                 && !SubtreeValueEditor.EMPTY.equals( dialog.getDN() ) )
             {

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java?rev=1085042&r1=1085041&r2=1085042&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/search/EntryWidget.java
Thu Mar 24 17:20:06 2011
@@ -201,11 +201,19 @@ public class EntryWidget extends Browser
 
                     // calculate initial Dn
                     Dn initialDn = dn;
+                    
                     if ( useLocalName && suffix != null && suffix.size()
> 0 )
                     {
                         if ( initialDn != null && initialDn.size() > 0 )
                         {
-                            initialDn = initialDn.addAll( suffix );
+                            try
+                            {         
+                                initialDn = initialDn.addAll( suffix );
+                            }
+                            catch ( LdapInvalidDnException lide )
+                            {
+                                // Do nothing 
+                            }
                         }
                     }
 



Mime
View raw message