directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1071956 - in /directory: apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/ shared/branches/m1/integ/src/test...
Date Fri, 18 Feb 2011 10:47:14 GMT
Author: elecharny
Date: Fri Feb 18 10:47:13 2011
New Revision: 1071956

URL: http://svn.apache.org/viewvc?rev=1071956&view=rev
Log:
o Renamed the getParent( DN ) to getAncestorOf( Dn )
o Some other minor refactoring

Modified:
    directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.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-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=1071956&r1=1071955&r2=1071956&view=diff
==============================================================================
--- directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Fri Feb 18 10:47:13 2011
@@ -1589,7 +1589,7 @@ public abstract class ServerContext impl
     public Name composeName( Name name, Name prefix ) throws NamingException
     {
         // No prefix reduces to name, or the name relative to this context
-        if ( prefix == null || prefix.size() == 0 )
+        if ( ( prefix == null ) || ( prefix.size() == 0 ) )
         {
             return name;
         }

Modified: directory/apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java?rev=1071956&r1=1071955&r2=1071956&view=diff
==============================================================================
--- directory/apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
(original)
+++ directory/apacheds/branches/m1/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
Fri Feb 18 10:47:13 2011
@@ -20,10 +20,7 @@
 package org.apache.directory.server.operations.extended;
 
 import org.apache.directory.server.core.CoreSession;
-import org.apache.directory.server.core.entry.ClonedServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,14 +38,15 @@ public class DITUtilitiesSP
      * http://kahuna.telstra.net/ietf/all-ids/draft-armijo-ldap-treedelete-02.txt
      * you can do it yourself!
      * 
-     * @param ctx an LDAP context to perform operations on
-     * @param rdn ctx relative name of the entry which is root of
-     *        the subtree to be deleted
+     * @param session The LDAP session
+     * @param dn Starting DN from which we the entries will be deleted
      * @throws LdapException
      */
-    public static void deleteSubtree( CoreSession session, Dn rdn ) throws Exception
+    public static void deleteSubtree( CoreSession session, Dn dn ) throws Exception
     {
-        EntryFilteringCursor results = session.list( rdn, AliasDerefMode.DEREF_ALWAYS, null
);
+        // TODO : This code don't simply work. Fix it.
+        /*
+        EntryFilteringCursor results = session.list( dn, AliasDerefMode.DEREF_ALWAYS, null
);
         
         results.beforeFirst();
         
@@ -56,11 +54,12 @@ public class DITUtilitiesSP
         {
             ClonedServerEntry result = results.get();
             Dn childRdn = result.getDn();
-            childRdn = childRdn.remove( 0 );
+            childRdn = childRdn.getParent();
             deleteSubtree( session, childRdn );
         }
         
-        session.delete( (Dn)rdn );
-        log.info( "Deleted: " + rdn );
+        session.delete( dn );
+        log.info( "Deleted: " + dn );
+        */
     }
 }

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=1071956&r1=1071955&r2=1071956&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
Fri Feb 18 10:47:13 2011
@@ -862,7 +862,7 @@ public class DnTest
     public void testDnGetPrefixPos0() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getParent( "" ) );
+        Dn newDn = ( dn.getAncestorOf( "" ) );
         assertEquals( "a=b, c=d,e = f", newDn.getName() );
     }
 
@@ -874,7 +874,7 @@ public class DnTest
     public void testDnGetPrefixPos1() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getParent( "a=b" ) );
+        Dn newDn = ( dn.getAncestorOf( "a=b" ) );
         assertEquals( " c=d,e = f", newDn.getName() );
     }
 
@@ -886,7 +886,7 @@ public class DnTest
     public void testDnGetPrefixPos2() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getParent( "a=b, c=d" ) );
+        Dn newDn = ( dn.getAncestorOf( "a=b, c=d" ) );
         assertEquals( "e = f", newDn.getName() );
     }
 
@@ -898,7 +898,7 @@ public class DnTest
     public void testDnGetPrefixPos3() throws LdapException
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
-        Dn newDn = ( dn.getParent( "a=b, c=d,e = f" ) );
+        Dn newDn = ( dn.getAncestorOf( "a=b, c=d,e = f" ) );
         assertEquals( "", newDn.getName() );
     }
 
@@ -911,7 +911,7 @@ public class DnTest
     {
         Dn dn = new Dn( "a=b, c=d,e = f" );
 
-        Dn res = dn.getParent( "a=z" );
+        Dn res = dn.getAncestorOf( "a=z" );
     }
 
 
@@ -922,7 +922,7 @@ public class DnTest
     public void testDnGetPrefixEmptyDN() throws LdapInvalidDnException
     {
         Dn dn = new Dn();
-        Dn newDn = ( dn.getParent( "" ) );
+        Dn newDn = ( dn.getAncestorOf( "" ) );
         assertEquals( "", newDn.getName() );
     }
 
@@ -1923,11 +1923,11 @@ public class DnTest
     {
         Dn name = new Dn( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getParent( "" ).toString()
);
-        assertEquals( "cn=John,ou=Marketing,ou=East", name.getParent( "cn=HomeDir" ).toString()
);
-        assertEquals( "ou=Marketing,ou=East", name.getParent( "cn=HomeDir,cn=John" ).toString()
);
-        assertEquals( "ou=East", name.getParent( "cn=HomeDir,cn=John,ou=Marketing" ).toString()
);
-        assertEquals( "", name.getParent( "cn=HomeDir,cn=John,ou=Marketing,ou=East" ).toString()
);
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getAncestorOf( "" ).toString()
);
+        assertEquals( "cn=John,ou=Marketing,ou=East", name.getAncestorOf( "cn=HomeDir" ).toString()
);
+        assertEquals( "ou=Marketing,ou=East", name.getAncestorOf( "cn=HomeDir,cn=John" ).toString()
);
+        assertEquals( "ou=East", name.getAncestorOf( "cn=HomeDir,cn=John,ou=Marketing" ).toString()
);
+        assertEquals( "", name.getAncestorOf( "cn=HomeDir,cn=John,ou=Marketing,ou=East" ).toString()
);
     }
 
 
@@ -2456,11 +2456,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.getPrefix( 0 ).toString(), aName.getParent( "cn=four,cn=three,cn=two,cn=one"
).toString() );
-        assertEquals( jName.getPrefix( 1 ).toString(), aName.getParent( "cn=four,cn=three,cn=two"
).toString() );
-        assertEquals( jName.getPrefix( 2 ).toString(), aName.getParent( "cn=four,cn=three"
).toString() );
-        assertEquals( jName.getPrefix( 3 ).toString(), aName.getParent( "cn=four" ).toString()
);
-        assertEquals( jName.getPrefix( 4 ).toString(), aName.getParent( "" ).toString() );
+        assertEquals( jName.getPrefix( 0 ).toString(), aName.getAncestorOf( "cn=four,cn=three,cn=two,cn=one"
).toString() );
+        assertEquals( jName.getPrefix( 1 ).toString(), aName.getAncestorOf( "cn=four,cn=three,cn=two"
).toString() );
+        assertEquals( jName.getPrefix( 2 ).toString(), aName.getAncestorOf( "cn=four,cn=three"
).toString() );
+        assertEquals( jName.getPrefix( 3 ).toString(), aName.getAncestorOf( "cn=four" ).toString()
);
+        assertEquals( jName.getPrefix( 4 ).toString(), aName.getAncestorOf( "" ).toString()
);
     }
 
 

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=1071956&r1=1071955&r2=1071956&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
Fri Feb 18 10:47:13 2011
@@ -1081,18 +1081,40 @@ public final class Dn implements Iterabl
 
 
     /**
-     * {@inheritDoc}
+     * Get the ancestor of a given DN, using the descendant DN. Assuming that
+     * a DN has two parts :<br/>
+     * DN = [descendant DN][ancestor DN]<br/>
+     * To get back the ancestor from the full DN, you just pass the descendant DN
+     * as a parameter. Here is a working example :
+     * <pre>
+     * Dn dn = new Dn( "cn=test, dc=server, dc=directory, dc=apache, dc=org" );
+     * 
+     * Dn ancestor = dn.getAncestorOf( "cn=test, dc=server, dc=directory" );
+     * 
+     * // At this point, the ancestor contains "dc=apache, dc=org"
+     * </pre> 
      */
-    public Dn getParent( String descendant ) throws LdapInvalidDnException
+    public Dn getAncestorOf( String descendant ) throws LdapInvalidDnException
     {
-        return getParent( new Dn( schemaManager, descendant ) );
+        return getAncestorOf( new Dn( schemaManager, descendant ) );
     }
     
 
     /**
-     * {@inheritDoc}
+     * Get the ancestor of a given DN, using the descendant DN. Assuming that
+     * a DN has two parts :<br/>
+     * DN = [descendant DN][ancestor DN]<br/>
+     * To get back the ancestor from the full DN, you just pass the descendant DN
+     * as a parameter. Here is a working example :
+     * <pre>
+     * Dn dn = new Dn( "cn=test, dc=server, dc=directory, dc=apache, dc=org" );
+     * 
+     * Dn ancestor = dn.getAncestorOf( new Dn( "cn=test, dc=server, dc=directory" ) );
+     * 
+     * // At this point, the ancestor contains "dc=apache, dc=org"
+     * </pre> 
      */
-    public Dn getParent( Dn descendant ) throws LdapInvalidDnException
+    public Dn getAncestorOf( Dn descendant ) throws LdapInvalidDnException
     {
         if ( ( descendant == null ) || ( descendant.size() == 0 ) )
         {



Mime
View raw message