directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r451847 - in /directory/branches/apacheds/1.0: core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ core/src/main/java/org/apache/directory/server/core/schema/ server-unit/src/test/java/org/apache/directory/server/
Date Mon, 02 Oct 2006 00:44:22 GMT
Author: akarasulu
Date: Sun Oct  1 17:44:22 2006
New Revision: 451847

URL: http://svn.apache.org/viewvc?view=rev&rev=451847
Log:
fix for DIRSERVER-752

Modified:
    directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
    directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/AddITest.java

Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?view=diff&rev=451847&r1=451846&r2=451847
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
(original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Sun Oct  1 17:44:22 2006
@@ -642,7 +642,7 @@
         oneAliasIdx.drop( ancestorId, targetId );
         subAliasIdx.drop( ancestorId, targetId );
 
-        while ( !ancestorDn.equals( upSuffix ) )
+        while ( !ancestorDn.equals( normSuffix ) )
         {
             ancestorDn = ( LdapDN ) ancestorDn.getPrefix( 1 );
             ancestorId = getEntryId( ancestorDn.toString() );
@@ -751,7 +751,7 @@
         // Add the alias to the simple alias index
         // TODO should we be adding aliasTarget which is not normalized or 
         //      should we be adding targetDn.toNormName()
-        aliasIdx.add( aliasTarget, aliasId );
+        aliasIdx.add( normalizedAliasTargetDn.getNormName(), aliasId );
 
         /*
          * Handle One Level Scope Alias Index
@@ -786,7 +786,7 @@
                 subAliasIdx.add( ancestorId, targetId );
             }
 
-            ancestorDn = ( LdapDN ) ancestorDn.remove( ancestorDn.size() - 1 );
+            ancestorDn.remove( ancestorDn.size() - 1 );
             ancestorId = getEntryId( ancestorDn.toNormName() );
         }
     }

Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java?view=diff&rev=451847&r1=451846&r2=451847
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
(original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/DnNormalizer.java
Sun Oct  1 17:44:22 2006
@@ -62,6 +62,6 @@
         }
         
         dn.normalize( attrRegistry.getNormalizerMapping() );
-        return dn;
+        return dn.getNormName();
     }
 }

Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/AddITest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/AddITest.java?view=diff&rev=451847&r1=451846&r2=451847
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/AddITest.java
(original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/AddITest.java
Sun Oct  1 17:44:22 2006
@@ -21,6 +21,8 @@
 
 
 import javax.naming.directory.*;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
 import netscape.ldap.LDAPAttribute;
@@ -355,5 +357,122 @@
         {
             
         }
+    }
+
+
+    /**
+     * Try to add entry and an alias to it. Afterwards, remove it.
+     */
+    public void testAddAlias() throws NamingException
+    {
+
+        // Create entry
+        Attributes entry = new BasicAttributes();
+        Attribute entryOcls = new BasicAttribute( "objectclass" );
+        entryOcls.add( "top" );
+        entryOcls.add( "organizationalUnit" );
+        entry.put( entryOcls );
+        entry.put( "ou", "favorite" );
+        String entryRdn = "ou=favorite";
+        ctx.createSubcontext( entryRdn, entry );
+
+        // Create Alias
+        String aliasedObjectName = entryRdn + "," + ctx.getNameInNamespace();
+        Attributes alias = new BasicAttributes();
+        Attribute aliasOcls = new BasicAttribute( "objectclass" );
+        aliasOcls.add( "top" );
+        aliasOcls.add( "alias" );
+        alias.put( aliasOcls );
+        alias.put( "ou", "bestFruit" );
+        alias.put( "aliasedObjectName", aliasedObjectName );
+        String rdnAlias = "ou=bestFruit";
+        ctx.createSubcontext( rdnAlias, alias );
+
+        // Remove alias and entry
+        ctx.destroySubcontext( rdnAlias );
+        ctx.destroySubcontext( entryRdn );
+    }
+
+
+    /**
+     * Try to add entry and an alias to it. Afterwards, remove it. This version
+     * cretes a container entry before the operations.
+     */
+    public void testAddAliasInContainer() throws NamingException
+    {
+
+        // Create container
+        Attributes container = new BasicAttributes();
+        Attribute containerOcls = new BasicAttribute( "objectclass" );
+        containerOcls.add( "top" );
+        containerOcls.add( "organizationalUnit" );
+        container.put( containerOcls );
+        container.put( "ou", "Fruits" );
+        String containerRdn = "ou=Fruits";
+        DirContext containerCtx = ctx.createSubcontext( containerRdn, container );
+
+        // Create entry
+        Attributes entry = new BasicAttributes();
+        Attribute entryOcls = new BasicAttribute( "objectclass" );
+        entryOcls.add( "top" );
+        entryOcls.add( "organizationalUnit" );
+        entry.put( entryOcls );
+        entry.put( "ou", "favorite" );
+        String entryRdn = "ou=favorite";
+        containerCtx.createSubcontext( entryRdn, entry );
+
+        // Create alias ou=bestFruit,ou=Fruits to entry ou=favorite,ou=Fruits
+        String aliasedObjectName = entryRdn + "," + containerCtx.getNameInNamespace();
+        Attributes alias = new BasicAttributes();
+        Attribute aliasOcls = new BasicAttribute( "objectclass" );
+        aliasOcls.add( "top" );
+        aliasOcls.add( "alias" );
+        alias.put( aliasOcls );
+        alias.put( "ou", "bestFruit" );
+        alias.put( "aliasedObjectName", aliasedObjectName );
+        String rdnAlias = "ou=bestFruit";
+        containerCtx.createSubcontext( rdnAlias, alias );
+
+        // search one level scope for alias 
+        SearchControls controls = new SearchControls();
+        controls.setDerefLinkFlag( true );
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "never" );
+        NamingEnumeration ne = containerCtx.search( "", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        SearchResult sr = ( SearchResult ) ne.next();
+        assertEquals( "ou=favorite", sr.getName() );
+        assertTrue( ne.hasMore() );
+        sr = ( SearchResult ) ne.next();
+        assertEquals( "ou=bestFruit", sr.getName() );
+        
+        // search one level with dereferencing turned on
+        controls = new SearchControls();
+        controls.setDerefLinkFlag( true );
+        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
+        ne = containerCtx.search( "", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        sr = ( SearchResult ) ne.next();
+        assertEquals( "ou=favorite", sr.getName() );
+        assertFalse( ne.hasMore() );
+        
+        // search with base set to alias and dereferencing turned on
+        controls = new SearchControls();
+        controls.setDerefLinkFlag( false );
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+        containerCtx.addToEnvironment( "java.naming.ldap.derefAliases", "always" );
+        ne = containerCtx.search( "ou=bestFruit", "(objectClass=*)", controls );
+        assertTrue( ne.hasMore() );
+        sr = ( SearchResult ) ne.next();
+        assertEquals( "ldap://localhost:1024/ou=favorite,ou=Fruits,ou=system", sr.getName()
);
+        assertFalse( ne.hasMore() );
+        
+        // Remove alias and entry
+        containerCtx.destroySubcontext( rdnAlias );
+        containerCtx.destroySubcontext( entryRdn );
+
+        // Remove container
+        ctx.destroySubcontext( containerRdn );
     }
 }



Mime
View raw message