commits@directory.apache.org
[Top] [All Lists]

svn commit: r413368 - in /directory/branches/apacheds/optimization/core/

Subject: svn commit: r413368 - in /directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core: exception/ operational/ partition/ partition/impl/btree/jdbm/
From:
Date: Sat, 10 Jun 2006 22:07:22 -0000
Author: akarasulu
Date: Sat Jun 10 15:07:21 2006
New Revision: 413368

URL: http://svn.apache.org/viewvc?rev=413368&view=rev
Log:
fixed several integration tests by fixing bugs in normalization

Modified:
    
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
    
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java
    
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
    
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java

Modified: 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
URL: 
http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java?rev=413368&r1=413367&r2=413368&view=diff
==============================================================================
--- 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
 (original)
+++ 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
 Sat Jun 10 15:07:21 2006
@@ -86,24 +86,22 @@
             throw ne;
         }
 
-        LdapDN parentDn = ( LdapDN ) normName.getPrefix( 1 );
-
-        // check if we don't have the parent to add to
-        assertHasEntry( nextInterceptor, "Attempt to add under non-existant 
parent: ", parentDn );
+        LdapDN parentDn = ( LdapDN ) normName.clone();
+        parentDn.remove( normName.size() - 1 );
 
         // check if we're trying to add to a parent that is an alias
-        Attributes attrs = nextInterceptor.lookup( ( LdapDN ) 
normName.getPrefix( 1 ) );
+        Attributes attrs = nextInterceptor.lookup( parentDn );
         Attribute objectClass = attrs.get( "objectClass" );
         if ( objectClass.contains( "alias" ) )
         {
             String msg = "Attempt to add entry to alias '" + 
normName.toUpName() + "' not allowed.";
             ResultCodeEnum rc = ResultCodeEnum.ALIASPROBLEM;
             NamingException e = new LdapNamingException( msg, rc );
-            e.setResolvedName( parentDn );
+            e.setResolvedName( new LdapDN( parentDn.toUpName() ) );
             throw e;
         }
 
-        nextInterceptor.add(normName, entry );
+        nextInterceptor.add( normName, entry );
     }
 
 
@@ -257,12 +255,15 @@
         assertHasEntry( nextInterceptor, msg, dn );
 
         // check to see if target entry exists
-        LdapDN target = ( LdapDN ) dn.getPrefix( 1 ).add( newRn );
-        if ( nextInterceptor.hasEntry( target ) )
+        LdapDN newDn = ( LdapDN ) dn.clone();
+        newDn.remove( dn.size() - 1 );
+        newDn.add( newRn );
+        newDn.normalize();
+        if ( nextInterceptor.hasEntry( newDn ) )
         {
             LdapNameAlreadyBoundException e;
-            e = new LdapNameAlreadyBoundException( "target entry " + target + 
" already exists!" );
-            e.setResolvedName( target );
+            e = new LdapNameAlreadyBoundException( "target entry " + 
newDn.toUpName() + " already exists!" );
+            e.setResolvedName( new LdapDN( newDn.toUpName() ) );
             throw e;
         }
 

Modified: 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java
URL: 
http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java?rev=413368&r1=413367&r2=413368&view=diff
==============================================================================
--- 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java
 (original)
+++ 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java
 Sat Jun 10 15:07:21 2006
@@ -177,7 +177,10 @@
         attribute.add( DateUtils.getGeneralizedTime() );
         attributes.put( attribute );
 
-        LdapDN newDn = ( LdapDN ) name.getPrefix( 1 ).add( newRn );
+        LdapDN newDn = ( LdapDN ) name.clone();
+        newDn.remove( name.size() - 1 );
+        newDn.add( newRn );
+        newDn.normalize();
         nexus.modify( newDn, DirContext.REPLACE_ATTRIBUTE, attributes );
     }
 

Modified: 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
URL: 
http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java?rev=413368&r1=413367&r2=413368&view=diff
==============================================================================
--- 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
 (original)
+++ 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
 Sat Jun 10 15:07:21 2006
@@ -579,10 +579,10 @@
      *
      * @see 
DirectoryPartition#add(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.Attributes)
      */
-    public void add(LdapDN dn, Attributes an_entry) throws NamingException
+    public void add( LdapDN dn, Attributes entry ) throws NamingException
     {
         DirectoryPartition backend = getBackend( dn );
-        backend.add(dn, an_entry );
+        backend.add( dn, entry );
     }
 
 

Modified: 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java
URL: 
http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java?rev=413368&r1=413367&r2=413368&view=diff
==============================================================================
--- 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java
 (original)
+++ 
directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDirectoryPartition.java
 Sat Jun 10 15:07:21 2006
@@ -59,7 +59,6 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
 import org.slf4j.Logger;
@@ -642,15 +641,14 @@
      */
     private void addAliasIndices( BigInteger aliasId, LdapDN aliasDn, String 
aliasTarget ) throws NamingException
     {
-        LdapDN targetDn = null; // Name value of aliasedObjectName
+        LdapDN normalizedAliasTargetDn = null; // Name value of 
aliasedObjectName
         BigInteger targetId = null; // Id of the aliasedObjectName
-        Normalizer normalizer = null; // Temporary handle for Dn's
         LdapDN ancestorDn = null; // Name of an alias entry relative
         BigInteger ancestorId = null; // Id of an alias entry relative
 
         // Access aliasedObjectName, normalize it and generate the Name 
-        normalizer = oneAliasIdx.getAttribute().getEquality().getNormalizer();
-        targetDn = new LdapDN( ( String ) normalizer.normalize( aliasTarget ) 
);
+        normalizedAliasTargetDn = new LdapDN( aliasTarget );
+        normalizedAliasTargetDn.normalize();
 
         /*
          * Check For Cycles
@@ -662,9 +660,9 @@
          * entry Dn starts with the target Dn.  If it does then we know the 
          * aliased target is a relative and we have a perspecitive cycle.
          */
-        if ( aliasDn.startsWith( targetDn ) )
+        if ( aliasDn.startsWith( normalizedAliasTargetDn ) )
         {
-            if ( aliasDn.equals( targetDn ) )
+            if ( aliasDn.equals( normalizedAliasTargetDn ) )
             {
                 throw new NamingException( "[36] aliasDereferencingProblem - " 
+ "attempt to create alias to itself." );
             }
@@ -682,7 +680,7 @@
          * need to point it out to the user instead of saying the target
          * does not exist when it potentially could outside of this upSuffix.
          */
-        if ( !targetDn.startsWith( upSuffix ) )
+        if ( !normalizedAliasTargetDn.startsWith( normSuffix ) )
         {
             // Complain specifically about aliases to outside naming contexts
             throw new NamingException( "[36] aliasDereferencingProblem -"
@@ -691,7 +689,7 @@
         }
 
         // L O O K U P   T A R G E T   I D
-        targetId = ndnIdx.forwardLookup( targetDn.toNormName() );
+        targetId = ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() 
);
 
         /*
          * Check For Target Existance
@@ -725,6 +723,8 @@
         }
 
         // 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 );
 
         /*
@@ -734,10 +734,11 @@
          * index.  If the target is not a sibling of the alias then we add the
          * index entry maping the parent's id to the aliased target id.
          */
-        ancestorDn = ( LdapDN ) aliasDn.getPrefix( 1 );
-        ancestorId = getEntryId( ancestorDn.toString() );
+        ancestorDn = ( LdapDN ) aliasDn.clone();
+        ancestorDn.remove( aliasDn.size() - 1 );
+        ancestorId = getEntryId( ancestorDn.toNormName() );
 
-        if ( !NamespaceTools.isSibling( targetDn, aliasDn ) )
+        if ( !NamespaceTools.isSibling( normalizedAliasTargetDn, aliasDn ) )
         {
             oneAliasIdx.add( ancestorId, targetId );
         }
@@ -752,15 +753,15 @@
          * ignored since everything is under its scope.  The first loop 
          * iteration shall handle the parents.
          */
-        while ( !ancestorDn.equals( upSuffix ) && null != ancestorId )
+        while ( !ancestorDn.equals( normSuffix ) && null != ancestorId )
         {
-            if ( !NamespaceTools.isDescendant( ancestorDn, targetDn ) )
+            if ( !NamespaceTools.isDescendant( ancestorDn, 
normalizedAliasTargetDn ) )
             {
                 subAliasIdx.add( ancestorId, targetId );
             }
 
-            ancestorDn = ( LdapDN ) ancestorDn.getPrefix( 1 );
-            ancestorId = getEntryId( ancestorDn.toString() );
+            ancestorDn = ( LdapDN ) ancestorDn.remove( ancestorDn.size() - 1 );
+            ancestorId = getEntryId( ancestorDn.toNormName() );
         }
     }
 
@@ -1408,10 +1409,12 @@
 
         // Now we can handle the appropriate name indices for all cases
         ndnIdx.drop( id );
-        ndnIdx.add( ndnIdx.getNormalized( updn.toString() ), id );
+        
+        LdapDN normalizedDn = LdapDN.normalize( updn );
+        ndnIdx.add( ndnIdx.getNormalized( normalizedDn.toNormName() ), id );
 
         updnIdx.drop( id );
-        updnIdx.add( updn.toString(), id );
+        updnIdx.add( updn.toUpName(), id );
 
         /* 
          * Read Alias Index Tuples


<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: r413368 - in /directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core: exception/ operational/ partition/ partition/impl/btree/jdbm/, akarasulu <=