directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1058216 - in /directory/apacheds/branches/apacheds-AP: core-integ/src/test/java/org/apache/directory/server/core/subtree/ core/src/main/java/org/apache/directory/server/core/admin/ core/src/main/java/org/apache/directory/server/core/subtree/
Date Wed, 12 Jan 2011 16:12:55 GMT
Author: elecharny
Date: Wed Jan 12 16:12:54 2011
New Revision: 1058216

URL: http://svn.apache.org/viewvc?rev=1058216&view=rev
Log:
o Added the handling of SAP rename
o Removed the rename operation from the AdministrativePointInterceptor

Modified:
    directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java

Modified: directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java?rev=1058216&r1=1058215&r2=1058216&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryRenameOperationIT.java
Wed Jan 12 16:12:54 2011
@@ -39,6 +39,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.util.tree.DnNode;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -72,6 +73,49 @@ public class SubentryRenameOperationIT e
     // -------------------------------------------------------------------
     // Success expected
     // -------------------------------------------------------------------
+    /**
+     * 
+     */
+    @Test
+    public void testRenameSAP() throws Exception
+    {
+        DN sapDn = service.getDNFactory().create( "ou=SAP,ou=system" );
+        DN sapDnNew = service.getDNFactory().create( "ou=SAPnew,ou=system" );
+        
+        // First add an SAP
+        createCaSAP( "ou=SAP,ou=system" ); 
+        
+        // Add a subentry
+        createCaSubentry( "cn=test,ou=SAP,ou=system", "{}" );
+        
+        // Add an entry
+        Entry e1 = LdifUtils.createEntry( 
+            "ou=e1,ou=SAP,ou=system", 
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit", 
+            "ou: e1" );
+        
+        createEntryAdmin( e1 );
+
+        long sapCaSeqNumber = getCaSeqNumber( "ou=SAP,ou=system" );
+
+        // Now, try to rename the SAP
+        ModifyDnResponse response = adminConnection.rename( "ou=SAP,ou=system", "ou=SAPnew"
);
+        
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        
+        // Check that the seqNumber has not changed
+        assertNull( adminConnection.lookup( sapDn, "CollectiveAttributeSeqNumber" ) );
+        assertEquals( sapCaSeqNumber, getCaSeqNumber( "ou=SAPnew,ou=system" ) );
+        
+        // Check that the cache have been updated
+        DnNode<AdministrativePoint> caCache = service.getCollectiveAttributeAPCache();
+        
+        assertNull( caCache.getElement( sapDn ) );
+        assertNotNull( caCache.getElement( sapDnNew ) );
+    }
+    
+    
     
     
     // ===================================================================

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java?rev=1058216&r1=1058215&r2=1058216&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
Wed Jan 12 16:12:54 2011
@@ -846,31 +846,4 @@ public class AdministrativePointIntercep
         LOG.error( message );
         throw new LdapUnwillingToPerformException( message );
     }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws
LdapException
-    {
-        Entry entry = renameContext.getEntry();
-
-        // Check if we are renaming an Administrative Point
-        EntryAttribute adminPoint = entry.get( ADMINISTRATIVE_ROLE_AT );
-
-        if ( adminPoint == null )
-        {
-            // Nope, go on.
-            next.rename( renameContext );
-
-            LOG.debug( "Exit from Administrative Interceptor" );
-
-            return;
-        }
-
-        // Else throw an UnwillingToPerform exception ATM
-        String message = "Cannot rename an Administrative Point in the current version";
-        LOG.error( message );
-        throw new LdapUnwillingToPerformException( message );
-    }
 }

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1058216&r1=1058215&r2=1058216&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Wed Jan 12 16:12:54 2011
@@ -2791,7 +2791,8 @@ public class SubentryInterceptor extends
         if ( adminPointAT != null )
         {
             // This is an AP. If it's a SAP, we have nothing to do, as a rename does not
modify 
-            // the subtree evaluations, nor does it impact any underlying entries.
+            // the subtree evaluations, nor does it impact any underlying entries. We just
have to 
+            // update the AP caches.
             // If the AP is an IAP, then as the underlying entries will be modified, then
             // we have to update the IAP seqNumber : the underlying entries might be impacted
             // as the parent's AP for the renamed IAP may have a base or some chopBefore/chopAfter
@@ -2802,6 +2803,34 @@ public class SubentryInterceptor extends
             else
             {
                 next.rename( renameContext );
+                
+                List<AdministrativePoint> adminpoints = getAdministrativePoints( oldDn
);
+                
+                for ( AdministrativePoint adminPoint : adminpoints )
+                {
+                    switch ( adminPoint.getRole() )
+                    {
+                        case AccessControlSpecificArea :
+                            directoryService.getAccessControlAPCache().remove( oldDn );
+                            directoryService.getAccessControlAPCache().add( newDn, adminPoint
);
+                            break;
+                            
+                        case CollectiveAttributeSpecificArea :
+                            directoryService.getCollectiveAttributeAPCache().remove( oldDn
);
+                            directoryService.getCollectiveAttributeAPCache().add( newDn,
adminPoint );
+                            break;
+                            
+                        case SubSchemaSpecificArea :
+                            directoryService.getSubschemaAPCache().remove( oldDn );
+                            directoryService.getSubschemaAPCache().add( newDn, adminPoint
);
+                            break;
+                            
+                        case TriggerExecutionSpecificArea :
+                            directoryService.getTriggerExecutionAPCache().remove( oldDn );
+                            directoryService.getTriggerExecutionAPCache().add( newDn, adminPoint
);
+                            break;
+                    }
+                }
             }
         }
         else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.SUBENTRY_OC ) )



Mime
View raw message