directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r953500 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/ core-api/src/main/java/org/apache/directory/server/core/interceptor/ core-api/src/main/java/org/apache/directory/server/core/interceptor/contex...
Date Thu, 10 Jun 2010 23:35:25 GMT
Author: elecharny
Date: Thu Jun 10 23:35:25 2010
New Revision: 953500

URL: http://svn.apache.org/viewvc?rev=953500&view=rev
Log:
o Modified the Move operationContext to store the OriginalEntry and the ModifiedEntry (we
are not anymore using the ClonedServerEntry)
o The entry operational attributes are now updated before calling the backend, in order to
make the move operation atomic
o Removed a useless lookup in referralInterceptor


Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
Thu Jun 10 23:35:25 2010
@@ -647,6 +647,7 @@ public class LdapCoreSessionConnection i
     {
         ModifyDnResponse resp = new ModifyDnResponse();
         resp.setLdapResult( getDefaultResult() );
+        
         try
         {
             session.move( new DN( entryDn ), new DN( newSuperiorDn ) );

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
Thu Jun 10 23:35:25 2010
@@ -593,6 +593,29 @@ public class InterceptorChain
     }
 
 
+    private Entry getOriginalEntry( OperationContext opContext ) throws LdapException
+    {
+        // We have to use the admin session here, otherwise we may have
+        // trouble reading the entry due to insufficient access rights 
+        CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();
+        
+        Entry foundEntry = adminSession.lookup( opContext.getDn(),
+            SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES_ARRAY );
+        
+        if ( foundEntry != null )
+        {
+            return foundEntry;
+        }
+        else
+        {
+            // This is an error : we *must* have an entry if we want to be able to rename.
+            LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256,
opContext.getDn() ) );
+
+            throw ldnfe;
+        }
+    }
+
+    
     public void delete( DeleteOperationContext opContext ) throws LdapException
     {
         Element entry = getStartingEntry();
@@ -788,16 +811,16 @@ public class InterceptorChain
     }
 
 
-    public void rename( RenameOperationContext opContext ) throws LdapException
+    public void rename( RenameOperationContext renameContext ) throws LdapException
     {
         Element entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
-        eagerlyPopulateFields( opContext );
-
+        eagerlyPopulateFields( renameContext );
+        
         try
         {
-            head.rename( next, opContext );
+            head.rename( next, renameContext );
         }
         catch ( LdapException le )
         {
@@ -810,16 +833,18 @@ public class InterceptorChain
     }
 
 
-    public void move( MoveOperationContext opContext ) throws LdapException
+    public void move( MoveOperationContext moveContext ) throws LdapException
     {
         Element entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
-        eagerlyPopulateFields( opContext );
+        Entry originalEntry = getOriginalEntry( moveContext );
+        
+        moveContext.setOriginalEntry( originalEntry );
 
         try
         {
-            head.move( next, opContext );
+            head.move( next, moveContext );
         }
         catch ( LdapException le )
         {

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
Thu Jun 10 23:35:25 2010
@@ -40,6 +40,9 @@ public abstract class AbstractChangeOper
     /** The flag used to tell the server to store the changes into the changeLog */
     protected LogChange logChange;
     
+    /** The original Entry */
+    protected Entry originalEntry;
+
     /** The modified Entry as it will be stored into the backend */
     protected Entry modifiedEntry;
 
@@ -69,6 +72,24 @@ public abstract class AbstractChangeOper
 
     
     /**
+     * @return the originalEntry
+     */
+    public Entry getOriginalEntry()
+    {
+        return originalEntry;
+    }
+
+
+    /**
+     * @param originalEntry the originalEntry to set
+     */
+    public void setOriginalEntry( Entry originalEntry )
+    {
+        this.originalEntry = originalEntry;
+    }
+
+
+    /**
      * @return the modifiedEntry
      */
     public Entry getModifiedEntry()

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -914,7 +914,7 @@ public class AciAuthorizationInterceptor
         DN oriChildName = moveContext.getDn();
 
         // Access the principal requesting the operation, and bypass checks if it is the
admin
-        Entry entry = moveContext.getEntry();
+        Entry entry = moveContext.getOriginalEntry();
 
         DN newDn = moveContext.getNewDn();
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -271,7 +271,7 @@ public class EventInterceptor extends Ba
      */
     public void move( NextInterceptor next, MoveOperationContext moveContext ) throws LdapException
     {
-        Entry oriEntry = moveContext.getEntry();
+        Entry oriEntry = moveContext.getOriginalEntry();
         List<RegistrationEntry> selecting = getSelectingRegistrations( moveContext.getDn(),
oriEntry );
 
         next.move( moveContext );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -332,20 +332,13 @@ public class OperationalAttributeInterce
      */
     public void move( NextInterceptor nextInterceptor, MoveOperationContext moveContext )
throws LdapException
     {
+        Entry modifiedEntry = moveContext.getOriginalEntry().clone();
+        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        modifiedEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
+        modifiedEntry.setDn( moveContext.getNewDn() );
+        moveContext.setModifiedEntry( modifiedEntry );
+        
         nextInterceptor.move( moveContext );
-
-        // add operational attributes after call in case the operation fails
-        Entry serverEntry = new DefaultEntry( schemaManager, moveContext.getDn() );
-        serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
-        serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
-
-        List<Modification> items = ModifyOperationContext.createModItems( serverEntry,
-            ModificationOperation.REPLACE_ATTRIBUTE );
-
-        ModifyOperationContext newModify = new ModifyOperationContext( moveContext.getSession(),
moveContext.getNewSuperior(),
-            items );
-
-        service.getPartitionNexus().modify( newModify );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -294,21 +294,17 @@ public class ReferralInterceptor extends
         DN newDn = moveContext.getNewDn();
 
         // Check if the entry is a referral itself
-        boolean isReferral = isReferral( moveContext.getEntry() );
+        boolean isReferral = isReferral( moveContext.getOriginalEntry() );
 
         next.move( moveContext );
 
         if ( isReferral )
         {
             // Update the referralManager
-            LookupOperationContext lookupContext = new LookupOperationContext( moveContext.getSession(),
newDn );
-
-            Entry newEntry = nexus.lookup( lookupContext );
-
             referralManager.lockWrite();
 
-            referralManager.addReferral( newEntry );
-            referralManager.removeReferral( moveContext.getEntry() );
+            referralManager.addReferral( moveContext.getModifiedEntry() );
+            referralManager.removeReferral( moveContext.getOriginalEntry() );
 
             referralManager.unlock();
         }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -969,7 +969,7 @@ public class SubentryInterceptor extends
         DN oriChildName = moveContext.getDn();
         DN newParentName = moveContext.getNewSuperior();
 
-        Entry entry = moveContext.getEntry();
+        Entry entry = moveContext.getOriginalEntry();
 
         EntryAttribute objectClasses = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
Thu Jun 10 23:35:25 2010
@@ -499,7 +499,7 @@ public class TriggerInterceptor extends 
         DN newSuperior = moveContext.getNewSuperior();
 
         // Gather supplementary data.        
-        Entry movedEntry = moveContext.getEntry();
+        Entry movedEntry = moveContext.getOriginalEntry();
 
         //RDN newRDN = dn.getRdn();
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java?rev=953500&r1=953499&r2=953500&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
Thu Jun 10 23:35:25 2010
@@ -366,8 +366,9 @@ public abstract class AbstractXdbmPartit
             DN oldDn = moveContext.getDn();
             DN newSuperior = moveContext.getNewSuperior();
             DN newDn = moveContext.getNewDn();
+            Entry modifiedEntry = moveContext.getModifiedEntry();
             
-            store.move( oldDn, newSuperior, newDn );
+            store.move( oldDn, newSuperior, newDn, modifiedEntry );
         }
         catch ( Exception e )
         {



Mime
View raw message