directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r472175 - in /directory/trunks/apacheds: core/src/main/java/org/apache/directory/server/core/partition/impl/btree/ mitosis/src/main/java/org/apache/directory/mitosis/operation/ mitosis/src/main/java/org/apache/directory/mitosis/service/ mit...
Date Tue, 07 Nov 2006 17:30:31 GMT
Author: akarasulu
Date: Tue Nov  7 09:30:30 2006
New Revision: 472175

URL: http://svn.apache.org/viewvc?view=rev&rev=472175
Log:
fixing adds of deleted entries which may have delete marked entries as children: doing a recursive
delete on dead branches; this btw fixes DIRSERVER-774

Modified:
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
    directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Tue Nov  7 09:30:30 2006
@@ -386,10 +386,11 @@
     public abstract void modify( LdapDN dn, ModificationItem[] mods ) throws NamingException;
 
 
+    private static final String[] ENTRY_DELETED_ATTRS = new String[] { "entrydeleted" };
     public NamingEnumeration list( LdapDN base ) throws NamingException
     {
         SearchResultEnumeration list;
-        list = new BTreeSearchResultEnumeration( ArrayUtils.EMPTY_STRING_ARRAY, list( getEntryId(
base.toString() ) ),
+        list = new BTreeSearchResultEnumeration( ENTRY_DELETED_ATTRS, list( getEntryId( base.toString()
) ),
             this, attributeTypeRegistry );
         return list;
     }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddEntryOperation.java
Tue Nov  7 09:30:30 2006
@@ -20,13 +20,16 @@
 package org.apache.directory.mitosis.operation;
 
 
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchResult;
 
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
 import org.apache.directory.mitosis.store.ReplicationStore;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 
@@ -67,7 +70,8 @@
     }
 
 
-    protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
+    protected void execute0( PartitionNexus nexus, ReplicationStore store, AttributeTypeRegistry
registry )
+        throws NamingException
     {
         if ( !EntryUtil.isEntryUpdatable( nexus, normalizedName, getCSN() ) )
         {
@@ -79,7 +83,7 @@
         Attributes oldEntry = nexus.lookup( normalizedName );
         if ( oldEntry != null )
         {
-            nexus.delete( normalizedName );
+            recursiveDelete( nexus, normalizedName, registry );
         }
 
         String rdn = normalizedName.get( normalizedName.size() - 1 );
@@ -89,5 +93,28 @@
         entry.remove( NamespaceTools.getRdnAttribute( rdn ) );
         entry.put( NamespaceTools.getRdnAttribute( rdn ), NamespaceTools.getRdnValue( rdn
) );
         nexus.add( normalizedName, entry );
+    }
+
+
+    @SuppressWarnings("unchecked")
+    private void recursiveDelete( PartitionNexus nexus, LdapDN normalizedName, AttributeTypeRegistry
registry )
+        throws NamingException
+    {
+        NamingEnumeration<SearchResult> ne = nexus.list( normalizedName );
+        if ( !ne.hasMore() )
+        {
+            nexus.delete( normalizedName );
+            return;
+        }
+
+        while ( ne.hasMore() )
+        {
+            SearchResult sr = ne.next();
+            LdapDN dn = new LdapDN( sr.getName() );
+            dn.normalize( registry.getNormalizerMapping() );
+            recursiveDelete( nexus, dn, registry );
+        }
+        
+        nexus.delete( normalizedName );
     }
 }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/AttributeOperation.java
Tue Nov  7 09:30:30 2006
@@ -24,6 +24,7 @@
 import javax.naming.directory.Attribute;
 
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.operation.support.EntryUtil;
@@ -77,7 +78,8 @@
     }
 
 
-    protected final void execute0( PartitionNexus nexus, ReplicationStore store ) throws
NamingException
+    protected final void execute0( PartitionNexus nexus, ReplicationStore store, AttributeTypeRegistry
registry ) 
+        throws NamingException
     {
         if ( !EntryUtil.isEntryUpdatable( nexus, name, getCSN() ) )
         {

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/CompositeOperation.java
Tue Nov  7 09:30:30 2006
@@ -30,6 +30,7 @@
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.common.CSNVector;
 import org.apache.directory.mitosis.common.ReplicaId;
@@ -161,13 +162,14 @@
     }
 
 
-    protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
+    protected void execute0( PartitionNexus nexus, ReplicationStore store, AttributeTypeRegistry
registry ) 
+        throws NamingException
     {
         Iterator<Operation> i = children.iterator();
         while ( i.hasNext() )
         {
             Operation op = i.next();
-            op.execute( nexus, DUMMY_STORE );
+            op.execute( nexus, DUMMY_STORE, registry );
         }
     }
 

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java
Tue Nov  7 09:30:30 2006
@@ -26,6 +26,7 @@
 import javax.naming.OperationNotSupportedException;
 
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.mitosis.common.CSN;
 import org.apache.directory.mitosis.store.ReplicationStore;
 
@@ -84,17 +85,19 @@
     /**
      * Exeutes this operation on the specified nexus.
      */
-    public final void execute( PartitionNexus nexus, ReplicationStore store ) throws NamingException
+    public final void execute( PartitionNexus nexus, ReplicationStore store, AttributeTypeRegistry
registry ) 
+        throws NamingException
     {
         synchronized ( nexus )
         {
-            execute0( nexus, store );
+            execute0( nexus, store, registry );
             store.putLog( this );
         }
     }
 
 
-    protected void execute0( PartitionNexus nexus, ReplicationStore store ) throws NamingException
+    protected void execute0( PartitionNexus nexus, ReplicationStore store, AttributeTypeRegistry
registry ) 
+        throws NamingException
     {
         throw new OperationNotSupportedException( nexus.getSuffix().toString() );
     }

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/ReplicationService.java
Tue Nov  7 09:30:30 2006
@@ -288,28 +288,28 @@
     public void add( NextInterceptor nextInterceptor, LdapDN normalizedName, Attributes entry
) throws NamingException
     {
         Operation op = operationFactory.newAdd( normalizedName, entry );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
     public void delete( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
     {
         Operation op = operationFactory.newDelete( name );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
     public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes attrs )
throws NamingException
     {
         Operation op = operationFactory.newModify( name, modOp, attrs );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
     public void modify( NextInterceptor next, LdapDN name, ModificationItem[] items ) throws
NamingException
     {
         Operation op = operationFactory.newModify( name, items );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
@@ -317,7 +317,7 @@
         throws NamingException
     {
         Operation op = operationFactory.newModifyRn( oldName, newRDN, deleteOldRDN );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
@@ -325,14 +325,14 @@
         throws NamingException
     {
         Operation op = operationFactory.newMove( oldName, newParentName, newRDN, deleteOldRDN
);
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 
     public void move( NextInterceptor next, LdapDN oldName, LdapDN newParentName ) throws
NamingException
     {
         Operation op = operationFactory.newMove( oldName, newParentName );
-        op.execute( nexus, store );
+        op.execute( nexus, store, attrRegistry );
     }
 
 

Modified: directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java?view=diff&rev=472175&r1=472174&r2=472175
==============================================================================
--- directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
(original)
+++ directory/trunks/apacheds/mitosis/src/main/java/org/apache/directory/mitosis/service/protocol/handler/ReplicationServerContextHandler.java
Tue Nov  7 09:30:30 2006
@@ -188,7 +188,9 @@
         LogEntryAckMessage ack = null;
         try
         {
-            op.execute( ctx.getServiceConfiguration().getPartitionNexus(), ctx.getConfiguration().getStore()
);
+            op.execute( ctx.getServiceConfiguration().getPartitionNexus(), 
+                ctx.getConfiguration().getStore(),
+                ctx.getServiceConfiguration().getGlobalRegistries().getAttributeTypeRegistry()
);
             ack = new LogEntryAckMessage( message.getSequence(), Constants.OK );
         }
         catch ( Exception e )



Mime
View raw message