directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r687163 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/interceptor/ core/src/main/java/org/apache/directory/server/core/operational/ protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/...
Date Tue, 19 Aug 2008 21:34:40 GMT
Author: akarasulu
Date: Tue Aug 19 14:34:39 2008
New Revision: 687163

URL: http://svn.apache.org/viewvc?rev=687163&view=rev
Log:
fixing persistent search

Added:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
      - copied, changed from r687130, directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchTest.java
Removed:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchTest.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/PersistentSearchListener.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=687163&r1=687162&r2=687163&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
Tue Aug 19 14:34:39 2008
@@ -431,6 +431,7 @@
         return entry.getName();
     }
 
+    
     private void register0( Interceptor interceptor, Entry nextEntry ) throws Exception
     {
         String name = interceptor.getName();
@@ -687,13 +688,41 @@
         }
     }
 
+    
+    /**
+     * Eagerly populates fields of operation contexts so multiple Interceptors 
+     * in the processing pathway can reuse this value without performing a 
+     * redundant lookup operation.
+     *
+     * @param opContext the operation context to populate with cached fields
+     */
+    private void eagerlyPopulateFields( OperationContext opContext )
+    {
+        // If the entry field is not set for ops other than add for example 
+        // then we set the entry but don't freak if we fail to do so since it
+        // may not exist in the first place
+        
+        if ( opContext.getEntry() == null )
+        {
+            try
+            {
+                opContext.setEntry( opContext.getSession().lookup( opContext.getDn() ) );
+            }
+            catch ( Exception e )
+            {
+                // might not exist
+            }
+        }
+    }
+    
 
     public void delete( DeleteOperationContext opContext ) throws Exception
     {
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
-
+        eagerlyPopulateFields( opContext );
+        
         try
         {
             head.delete( next, opContext );
@@ -735,6 +764,7 @@
         Entry node = getStartingEntry();
         Interceptor head = node.interceptor;
         NextInterceptor next = node.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -777,6 +807,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -798,6 +829,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -821,6 +853,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -887,6 +920,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -908,6 +942,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {
@@ -929,6 +964,7 @@
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
         NextInterceptor next = entry.nextInterceptor;
+        eagerlyPopulateFields( opContext );
 
         try
         {

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=687163&r1=687162&r2=687163&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 Aug 19 14:34:39 2008
@@ -49,10 +49,8 @@
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
-import org.apache.directory.server.core.schema.SchemaInterceptor;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -68,9 +66,6 @@
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import javax.naming.InsufficientResourcesException;
-import javax.naming.directory.SearchControls;
  
 
 /**
@@ -337,7 +332,6 @@
     public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext
opContext ) throws Exception
     {
         EntryFilteringCursor cursor = nextInterceptor.search( opContext );
-        SearchControls searchCtls = opContext.getSearchControls();
         
         if ( opContext.isAllOperationalAttributes() || 
              ( opContext.getReturningAttributes() != null && ! opContext.getReturningAttributes().isEmpty()
) )

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/PersistentSearchListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/PersistentSearchListener.java?rev=687163&r1=687162&r2=687163&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/PersistentSearchListener.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/PersistentSearchListener.java
Tue Aug 19 14:34:39 2008
@@ -119,6 +119,11 @@
             {
                 ecControl.setChangeNumber( opContext.getChangeLogEvent().getRevision() );
             }
+         
+            if ( opContext instanceof RenameOperationContext || opContext instanceof MoveOperationContext
)
+            {
+                ecControl.setPreviousDn( opContext.getDn() ); 
+            }
             
             response.add( ecControl );
         }
@@ -136,6 +141,7 @@
         respEntry.setObjectName( opContext.getDn() );
         respEntry.setAttributes( ServerEntryUtils.toAttributesImpl( opContext.getEntry()
) );
         setECResponseControl( respEntry, opContext, ChangeType.ADD );
+        session.getIoSession().write( respEntry );
     }
 
 
@@ -150,6 +156,7 @@
         respEntry.setObjectName( opContext.getDn() );
         respEntry.setAttributes( ServerEntryUtils.toAttributesImpl( opContext.getEntry()
) );
         setECResponseControl( respEntry, opContext, ChangeType.DELETE );
+        session.getIoSession().write( respEntry );
     }
 
 
@@ -164,6 +171,7 @@
         respEntry.setObjectName( opContext.getDn() );
         respEntry.setAttributes( ServerEntryUtils.toAttributesImpl( opContext.getEntry()
) );
         setECResponseControl( respEntry, opContext, ChangeType.MODIFY );
+        session.getIoSession().write( respEntry );
     }
 
 
@@ -178,6 +186,7 @@
         respEntry.setObjectName( opContext.getDn() );
         respEntry.setAttributes( ServerEntryUtils.toAttributesImpl( opContext.getEntry()
) );
         setECResponseControl( respEntry, opContext, ChangeType.MODDN );
+        session.getIoSession().write( respEntry );
     }
 
 
@@ -198,5 +207,6 @@
         respEntry.setObjectName( opContext.getAlteredEntry().getDn() );
         respEntry.setAttributes( ServerEntryUtils.toAttributesImpl( opContext.getAlteredEntry()
) );
         setECResponseControl( respEntry, opContext, ChangeType.MODDN );
+        session.getIoSession().write( respEntry );
     }
 }
\ No newline at end of file

Copied: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
(from r687130, directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchTest.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java?p2=directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java&p1=directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchTest.java&r1=687130&r2=687163&rev=687163&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchTest.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
Tue Aug 19 14:34:39 2008
@@ -61,7 +61,6 @@
 
 
 /**
- * TODO - enable me - not executed (not in suite yet)
  * Test case which tests the correct operation of the persistent search control.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -79,7 +78,7 @@
     "sn: Amos\n\n"
     }
 )
-public class PersistentSearchTest
+public class PersistentSearchIT
 {
     private static final String BASE = "ou=system";
     private static final String PERSON_DESCRIPTION = "an American singer-songwriter";
@@ -620,6 +619,7 @@
         //assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
     }*/
 
+    
     class JndiNotificationListener implements NamespaceChangeListener, ObjectChangeListener
     {
         boolean hasError = false;
@@ -658,6 +658,7 @@
         }
     }
 
+    
     class PSearchListener implements Runnable
     {
         boolean isReady = false;
@@ -739,6 +740,7 @@
         }
     }
 
+    
     class PSearchNotification extends SearchResult
     {
         private static final long serialVersionUID = 1L;

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java?rev=687163&r1=687162&r2=687163&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/suites/StockServerISuite.java
Tue Aug 19 14:34:39 2008
@@ -41,6 +41,7 @@
 import org.apache.directory.server.operations.modifydn.ModifyRdnIT;
 import org.apache.directory.server.operations.modifydn.MoveIT;
 import org.apache.directory.server.operations.search.NegationSearchIT;
+import org.apache.directory.server.operations.search.PersistentSearchIT;
 import org.apache.directory.server.operations.search.ReferralSearchIT;
 import org.apache.directory.server.operations.search.SchemaSearchIT;
 import org.apache.directory.server.operations.search.SearchIT;
@@ -76,7 +77,8 @@
         SchemaSearchIT.class,
         ReferralSearchIT.class,
         StartTlsIT.class,
-        ModifyDnReferralIT.class
+        ModifyDnReferralIT.class,
+        PersistentSearchIT.class
         } )
 @CleanupLevel ( Level.SUITE )
 @Mode ( SetupMode.ROLLBACK )



Mime
View raw message