directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r954953 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Date Tue, 15 Jun 2010 16:35:21 GMT
Author: elecharny
Date: Tue Jun 15 16:35:21 2010
New Revision: 954953

URL: http://svn.apache.org/viewvc?rev=954953&view=rev
Log:
The entry is modified before the call to the backend is made for the MoveAndRename operation,
we don't need a second call : the operation is now atomic.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java

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=954953&r1=954952&r2=954953&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
Tue Jun 15 16:35:21 2010
@@ -345,20 +345,13 @@ public class OperationalAttributeInterce
     public void moveAndRename( NextInterceptor nextInterceptor, MoveAndRenameOperationContext
moveAndRenameContext )
         throws LdapException
     {
-        nextInterceptor.moveAndRename( moveAndRenameContext );
-
-        // add operational attributes after call in case the operation fails
-        Entry serverEntry = new DefaultEntry( schemaManager, moveAndRenameContext.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 );
+        Entry modifiedEntry = moveAndRenameContext.getOriginalEntry().clone();
+        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        modifiedEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
+        modifiedEntry.setDn( moveAndRenameContext.getNewDn() );
+        moveAndRenameContext.setModifiedEntry( modifiedEntry );
 
-        ModifyOperationContext newModify = new ModifyOperationContext( moveAndRenameContext.getSession(),
moveAndRenameContext.getNewSuperiorDn(),
-            items );
-
-        service.getPartitionNexus().modify( newModify );
+        nextInterceptor.moveAndRename( moveAndRenameContext );
     }
 
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=954953&r1=954952&r2=954953&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Tue Jun 15 16:35:21 2010
@@ -1239,8 +1239,8 @@ public abstract class AbstractStore<E, I
             throw ne;
         }
 
-        rename( oldDn, newRdn, deleteOldRdn );
-        moveAndRename( oldDn, oldId, newSuperiorDn, newRdn );
+        rename( oldDn, newRdn, deleteOldRdn, modifiedEntry );
+        moveAndRename( oldDn, oldId, newSuperiorDn, newRdn, modifiedEntry );
 
         if ( isSyncOnWrite )
         {
@@ -1928,7 +1928,7 @@ public abstract class AbstractStore<E, I
      * @param newParentDn the normalized dn of the new parent for the child
      * @throws Exception if something goes wrong
      */
-    protected void moveAndRename( DN oldDn, ID childId, DN newSuperior, RDN newRdn ) throws
Exception
+    protected void moveAndRename( DN oldDn, ID childId, DN newSuperior, RDN newRdn, Entry
modifiedEntry ) throws Exception
     {
         // Get the child and the new parent to be entries and Ids
         ID newParentId = getEntryId( newSuperior );
@@ -1976,6 +1976,16 @@ public abstract class AbstractStore<E, I
         {
             addAliasIndices( childId, buildEntryDn( childId ), aliasTarget );
         }
+
+        // Update the master table with the modified entry
+        // Warning : this test is an hack. As we may call the Store API directly
+        // we may not have a modified entry to update. For instance, if the ModifierName
+        // or ModifyTimeStamp AT are not updated, there is no reason we want to update the
+        // master table.
+        if ( modifiedEntry != null )
+        {
+            master.put( childId, modifiedEntry );
+        }
     }
 
 



Mime
View raw message